hello all java3D programmers and good morning to
you
i encountered a strange problem today, when creating 16
3dboxes and trying to apply mouse rotation to all of them
, the problem is that when running the program all 16 boxes
appeared to have a unifromed mouse rotation behavior, i.e when
trying to rotate a single shape all the shapes rotated as
well.. does any one know the source for the problem ?
im including the source code for the class that creates
the objects and applies the mouse rotation to each one of them, keep in mind
that class is created 16 times to create 16 different boxes..
class BoxShape{
private BranchGroup localRoot; private Appearance app=null; private float sizeX = 0.0f, sizeY = 0.0f, sizeZ = 0.0f; private BoundingSphere bounds = null; private Transform3D t3dLocation = null; public BoxShape(float x,float y,float z,Vector3f location){ localRoot = new BranchGroup(); sizeX = x; sizeY = y; sizeZ = z; bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),100); t3dLocation = new Transform3D(); t3dLocation.setTranslation (location); localRoot=buildBoxScene(); } private BranchGroup buildBoxScene(){ BranchGroup root = new BranchGroup(); root.setCapability (BranchGroup.ALLOW_CHILDREN_READ); TransformGroup scale = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setScale (0.4); scale.setTransform (t3d); root.addChild (scale);
TransformGroup transG = new
TransformGroup();
transG.setTransform (t3dLocation); transG.setCapability (TransformGroup.ALLOW_TRANSFORM_WRITE); transG.setCapability (TransformGroup.ALLOW_TRANSFORM_READ); transG.setCapability (TransformGroup.ALLOW_BOUNDS_WRITE ); scale.setCapability (TransformGroup.ALLOW_BOUNDS_WRITE ); scale.addChild (transG); Material m = new
Material();
app = new Appearance(); app.setMaterial (m); app.setCapability (Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE); app.setCapability (Appearance.ALLOW_TEXTURE_WRITE); TextureAttributes tAtt = new TextureAttributes(); ColoringAttributes cAtt = new ColoringAttributes (new Color3f(1.0f,1.0f,1.0f),ColoringAttributes.NICEST ); app.setColoringAttributes (cAtt); app.setTextureAttributes (tAtt); com.sun.j3d.utils.geometry.Box box =
new
com.sun.j3d.utils.geometry.Box(sizeX, sizeY,sizeZ, Box.GENERATE_TEXTURE_COORDS | Box.GENERATE_NORMALS, app); transG.addChild (box);
// create mouse
activity
// rotate through mouse left click and drag MouseRotate mRotate=new MouseRotate(transG); transG.addChild (mRotate); mRotate.setSchedulingBounds (bounds); root.compile ();
return root; } public BranchGroup getSceneBranch(){ return localRoot; } } |
- Re: [JAVA3D] multiple mouse rotation behaviors Ben Arbel
- Re: [JAVA3D] multiple mouse rotation behaviors Kelvin Chung