|
How to implement LOD Animation by DistanceLOD class |
|
|
Level of Detail (LOD) is a general term for a technique that varies the amount
of detail in a visual object based on some value from the virtual world. The
typical application is to vary the level of detail based on the distance to
the viewer.As the distance to a visual object increases, the fewer details will
appear in the rendering.
The DistanceLOD Class provides LOD behavior based on distance to the viewer.
Here is the usage recipe for DistanceLOD class:
- create a target Switch object(s) with ALLOW_SWITCH_WRITE capability
- create list of distance thresholds array for the DistanceLOD object
- create DistanceLOD object using the distance thresholds array
- set the target switch object for the DistanceLOD object
- supply a scheduling bounds (or bounding leaf) for the DistanceLOD object
- assemble the scene graph, including adding children to target Switch object(s)
public BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
BoundingSphere bounds = new BoundingSphere();
// create target TransformGroup with Capabilities
TransformGroup objMove = new TransformGroup();
// create DistanceLOD target object
Switch targetSwitch = new Switch();
targetSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
// add visual objects to the target switch
targetSwitch.addChild(new Sphere(.40f, 0, 25));
targetSwitch.addChild(new Sphere(.40f, 0, 15));
targetSwitch.addChild(new Sphere(.40f, 0, 10));
targetSwitch.addChild(new Sphere(.40f, 0, 4));
// create DistanceLOD object
float[] distances = { 5.0f, 10.0f, 20.0f};
DistanceLOD dLOD = new DistanceLOD(distances, new Point3f());
dLOD.addSwitch(targetSwitch);
dLOD.setSchedulingBounds(bounds);
// assemble scene graph
objRoot.addChild(objMove);
objMove.addChild(dLOD); // make the bounds move with object
objMove.addChild(targetSwitch); // must add switch to scene graph
return objRoot;
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.