RotationInterpolator Java3d

cs_dafi Messages postés 17 Date d'inscription vendredi 19 décembre 2003 Statut Membre Dernière intervention 19 mai 2004 - 27 avril 2004 à 14:39
cs_dafi Messages postés 17 Date d'inscription vendredi 19 décembre 2003 Statut Membre Dernière intervention 19 mai 2004 - 27 avril 2004 à 14:41
Bonjour,

J'arrive à mettre en rotation un torus sur l'axe Y à un certain endroit dans l'espace mais impossible de le faire tourner sur un autre axe.

qq1 à une idée ?

J'ai consulté plusieurs aides et forums. Toujours le même pb mais peu de solutions vraiment fonctionnelles.

public void addRings (float valX, float valY, float valZ)
{
float ringX = (rand.nextFloat() * 2 * dimBox[0]) - dimBox[0] + valX;
float ringY = (rand.nextFloat() * 2 * dimBox[1]) - dimBox[1] + valY;
float ringZ = (rand.nextFloat() * 2 * dimBox[2]) - dimBox[2] + valZ;
Material blueMaterial = new Material(col.ambientRed, col.blue, col.red, col.specular, 75.0f);
blueMaterial.setLightingEnable(true);
Appearance ringApp = new Appearance();
ringApp.setMaterial(blueMaterial);

PolygonAttributes pa = new PolygonAttributes();
pa.setPolygonMode(pa.POLYGON_LINE);
pa.setCullFace(pa.CULL_NONE);
ringApp.setPolygonAttributes(pa);

Transform3D t3d = new Transform3D();
Vector3f RingPosition = new Vector3f(ringX, ringY, ringZ);
t3d.setTranslation(RingPosition);
TransformGroup trans = new TransformGroup (t3d);

TransformGroup rotZGrp = new TransformGroup ();
rotZGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
rotZGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

Transform3D zAxis = new Transform3D();
//zAxis.rotX(90.0*3.14159/180.0);
zAxis.setRotation(new AxisAngle4f (ringX,ringY, ringZ,(float)Math.toRadians(360)));
Alpha rotationAlpha = new Alpha(-1, speedRing);
RotationInterpolator rotatorZ = new RotationInterpolator (rotationAlpha, rotZGrp, zAxis, 0.0f, (float) Math.PI*2.0f);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 1000.0);
rotatorZ.setSchedulingBounds(bounds);
//rotatorZ.setTransformAxis(t3d);
rotZGrp.addChild(rotatorZ);

Torus torus = new Torus (radiusRing, thicknessRing);
torus.setAppearance(ringApp);

trans.addChild (torus);
rotZGrp.addChild (trans);
BGring.addChild(rotZGrp);
}

1 réponse

cs_dafi Messages postés 17 Date d'inscription vendredi 19 décembre 2003 Statut Membre Dernière intervention 19 mai 2004
27 avril 2004 à 14:41
et ceci en désactivant

zAxis.setRotation(new AxisAngle4f (ringX,ringY, ringZ,(float)Math.toRadians(360)));

et en activant

rotatorZ.setTransformAxis(t3d);
0
Rejoignez-nous