![]() | ![]() | ![]() |
|
Built-in Behaviours© Justin Couch 1999In order to save you some frustration, Java3D provides you will a collection of simple, but very effective behaviours. The behaviours specify the core types of functionality that may occur within the Java3D environment. There are three fundamental types of behaviours available to the user:
BillboardThe billboard behaviour is used to make sure that an object always faces the viewer. When an object always faces the viewer, that means that the same face is presented to the user regardless of what direction they approach the object. The most common example of this is to use a texture of a tree on a polygon rather than building a proper 3D model of the tree.The billboard has two modes of operation: it can be restricted to rotating about the local Y axis or it can freely rotate about a point. In the first case if you move up and down the Y axis, the object will not rotate. However, as you move sideways along the X axis the object will rotate so that it always faces you. For the second case, as you move along the Y axis the object will continue to rotate so that it always faces you. Defining how an object faces you can be rather tricky. For the simple tree texture case this is relatively easy: make sure that the normal of the plane is faced towards the view position. With a more complex object that involves more than one face, it rotates so that whatever was facing you as you entered the bounding region always faces you. Using billboards can be quite interesting, particularly if the subject object is not centred at the axis of rotation. Combinations of these objects can produce a swing like object that moves to always cover your approach. A football goalkeeper moving to always be between you and the goal would be a familiar example. LODLOD stands for Level Of Detail. What this behaviour provides is the ability to change the geometry of an object based on the distance the user is from it. The principle behind this is that when you are far away from the object, you don’t need much detail but when you are close to it, detail should be high. All of this is in the name of optimisation. The more polygons that you have to render, the more it slows the system down. At distance, most of those polygons are wasted (probably less than one pixel in size) so you eliminate their rendering cost by substituting a lower detail model.Use of the LOD node is very common in complex worlds due to this performance enhancing feature. A typical example is the representation of a building. At a very far distance it might be represented as a coloured box. In the middle distance it is a box but now has a texture that represents the building. Once up close, the detail changes to geometry representing the building.
The basic
There is only one default implementation of the LOD node:
InterpolatorsFor most animation effects, interpolators are your best friend. An interpolator provides a set of key value pairs that is used to determine the output based on arbitrary input. For example, a position interpolator provides a series of defined waypoints along a trail. In between those points we still need to move the camera along a smooth path so the interpolator steps in and calculates all of the intermediate values on an as needed basis (each frame, for example).Interpolators are typically time based, but not always so. Very often you will find them in conjunction with another control such as a user interface device like a slider or knob. As the value of the slider movers, that is fed into the interpolator, and the output is sent to the object being manipulated. We’ll explore the use and structure of interpolators in more detail in the next section. Mouse and Keyboard Behaviours?The one behaviour that you might have noticed is missing from this list is the ability to react to user input. Because Java3D uses various different types ofInputSensors it can be very difficult to provide a
general, all-purpose sensor to deal with these. Although they are not
provided with the standard Java3D APIs, a number of standard behaviours
are provided with the Sun utilities classes and we will also create custom
versions in the next chapter.
|
|