Hi I am trying to rotate A Cylinder(plate) over a box (base)
 
I use RotationInterpolator
I made a translation of the cylinder to the top of the box
the Interpolator target is the cylinder
 
but when I add the rotator to the base the cynlinder will loose its translation and is drawn to the center of the box.
 
base.addChild(rotator) will cancel plate.setTransform(platetrans)
 
How can I come over this problem
 
_--------------------------------------------- A bit of my code ---------------------------
 
public BranchGroup createSceneGraph() {
 
  Background bg = new Background(new Color3f(1.0f, 1.0f, 1.0f));
 
// Create the root of the branch graph
  BranchGroup objRoot = new BranchGroup();
 
// Create a TransformGroup to scale the scene down by 3.5x
// TODO: move view platform instead of scene using orbit behavior
  TransformGroup objScale = new TransformGroup();
  Transform3D scaleTrans = new Transform3D();
  scaleTrans.set(1.0f); // scale down by 3.5x
  objScale.setTransform(scaleTrans);
  objRoot.addChild(objScale);
 
// Create a TransformGroup and initialize it to the
// identity.  Enable the TRANSFORM_WRITE capability so that
// the mouse behaviors code can modify it at runtime.  Add it to the
// root of the subgraph.
  TransformGroup objTrans = new TransformGroup();
  objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
  objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
  objScale.addChild(objTrans);
 
// Add the primitives to the scene
  createIndextab();     // the table
 
  objTrans.addChild(base);
 
  AxisAngle4f faxisOfRot = new AxisAngle4f(0.0f,1.0f,0.0f,(float)Math.PI/2.0f);
  Transform3D faxisT3D = new Transform3D();
  faxisT3D.set(faxisOfRot);
 
  Transform3D Tabletrans = new Transform3D();
  Tabletrans.set(new Vector3f(0.0f, 0.122f, 0.0f));
 
  rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);
 
  rotator = new RotationInterpolator(rotationAlpha, table_body, faxisT3D, 0.0f, (float)Math.PI/2);
  rotator.setSchedulingBounds(bounds);
 

  base.addChild(table_body);
 
  base.addChild(rotator);
 

  //objTrans.addChild(table_body);
 

bg.setApplicationBounds(bounds);
objTrans.addChild(bg);
 
//rotationAlpha.setLoopCount(1);
rotationAlpha.pause();
table_body.setTransform(Tabletrans);
 
// set up the mouse rotation behavior
MouseRotate mr = new MouseRotate();
mr.setTransformGroup(objTrans);
mr.setSchedulingBounds(bounds);
mr.setFactor(0.007);
objTrans.addChild(mr);
 
// Set up the ambient light
Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
AmbientLight ambientLightNode = new AmbientLight(ambientColor);
ambientLightNode.setInfluencingBounds(bounds);
objRoot.addChild(ambientLightNode);
 
// Set up the directional lights
Color3f light1Color = new Color3f(1.0f, 1.0f, 1.0f);
Vector3f light1Direction  = new Vector3f(0.0f, -0.2f, -1.0f);
 
DirectionalLight light1
   = new DirectionalLight(light1Color, light1Direction);
light1.setInfluencingBounds(bounds);
objRoot.addChild(light1);
 

return objRoot;
 
 }


--------------------------------------
Ghislain DZOU
CCNA
--------------------------------------
FONTYS Professional University
Eindhoven - The Nederlands
Tel +31 613 970 354


Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
Cr�ez votre Yahoo! Mail

Dialoguez en direct avec vos amis gr�ce � Yahoo! Messenger ! =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to