|
How to rotate the object in virtual world with mouse |
|
|
The mouse utility behavior package (com.sun.j3d.utils.behaviors.mouse) contains
behavior classes in which the mouse is used as input for interaction with visual
objects. Included are classes for translating (moving in a plane parallel to the
image plate), zooming (moving forward and back), and rotating visual objects in
response to mouse movements.
This program shows how to rotate the object in virtual world by mouse.
public BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
TransformGroup objRotate = new TransformGroup();
objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
objRoot.addChild(objRotate);
objRotate.addChild(new ColorCube(0.4));
MouseRotate myMouseRotate = new MouseRotate();
myMouseRotate.setTransformGroup(objRotate);
myMouseRotate.setSchedulingBounds(new BoundingSphere());
objRoot.addChild(myMouseRotate);
objRoot.compile();
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.