954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Java 3D - java3D, bird wings, how to do it simple way?

Hello!
I am new here,
I am posting as I can not find any help on sun.com java forums for my problem!

Here what I posted:
Hello all!
I am intending to do a simple thing: a quick bird like made with 3 boxes: 2 for the wings, one for the body. I want the "wings" to move up and down, but as if they were attached to the body.
I presume its a rotation behavior i have to use.
I did it but it rotate completely, I would only need them to rotate 1/4 of a turn, then restart rotating until 1/4 turn, etc...
I might be making it more difficult than it is, I cant manage to do it!

I tried first a simple translate thing but i can not "bend it"... It seems simplier as I only need the wing boxe to be at two position: up and down, but "constrained" to the body side!
So I chose a Rotate:

HERE IS my code:

//----------------------début de la création de la rotation--------------------------------

TransformGroup WinRSpin=new TransformGroup();

// permet de modifier l'objet pendant l'execution
WinRSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

// on crée un fonction de rotation au cours du temps
Alpha rotationAlphaWinRSpin=new Alpha(-1,4000);

Transform3D rot = new Transform3D();
rot.rotX((float)Math.PI/- 2.0f);
// on crée un comportement qui va appliquer la rotation à l'objet voulu
RotationInterpolator rotatorWinRSpin=new RotationInterpolator(rotationAlphaWinRSpin,WinRSpin, rot, 0.50f,(float)(2.0*Math.PI));

// on définit la zone sur laquelle va s'appliquer la rotation
BoundingSphere boundsWinRSpin=new BoundingSphere();
rotatorWinRSpin.setSchedulingBounds(boundsWinRSpin);
WinRSpin.addChild(rotatorWinRSpin);

//----------------------début de la création de la rotation--------------------------------

Thanks for any suggestions, comments, etc..

I found out that my "camera" has a special position and viewing angle which is:

transform.rotX(-Math.PI / 4.0)

Therefore if I have in the scene like a cube, and I want to rotate it on the X axis only, for 45degres, it will not be a normal rotation on the x axis.
I think they kind of combine together, but i'm not sure!

I still think I have a few complex things to do, but I cant get the logic... :(

I mean it seems to rotate "from a center point inside its own box". I want to rotate as if the "x line" would be the right side of the bird body, as a nornal wing would do!
And then only 2 positions needed, up and down, up and down, up and down....

Anyone can help?

here is my code so far:


Previous bit: This part is only to show I had a bounding sphere to the bird body, and later on I tried to attach it to the wings, so it rotate from it and not from the wing itself bounding sphere. //beginning of Rotation for Bird
TransformGroup Bird=new TransformGroup();

//will allow to modify object while executing
Bird.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

//alpha rotation time related
Alpha rotationAlphaBird=new Alpha(-1,400);
Alpha transAlphaBird=new Alpha(-1,5990);

//transform 3d trans for the interpolatipon
Transform3D transBird=new Transform3D();

//create transform 3d for the Bird
transBird.set(new Vector3f(1.90f,-.45f,0.9f));

//create the child tranform group for the Bird Box
Bird.setTransform(transBird);

//matrix for 2positions
Point3f[] cheminBird=new Point3f[3];
cheminBird[0]=new Point3f(1.95f,0.0f,-6.8f);
cheminBird[1]=new Point3f(1.95f,0.90f,-0.8f);
cheminBird[2]=new Point3f(1.95f,0.0f,5.8f);

//matrix of floats to make the dots match with timeline
float[] timePositionBird={0.00f,0.50f,1.0f};
PositionPathInterpolator interpolBird=new PositionPathInterpolator(transAlphaBird,Bird,transBird,timePosition,cheminBird);
BoundingSphere bounds3Bird=new BoundingSphere();
//BoundingSphere bounds3Bird= new BoundingSphere(new Point3d(0.0, 0.0, -50.0), 0.5);
interpolBird.setSchedulingBounds(bounds3Bird);
Bird.addChild(interpolBird);

//behviour for our rotation
RotationInterpolator rotatorBird= new RotationInterpolator(rotationAlphaBird,Bird);

// area where rotation will be
BoundingSphere boundsBird=new BoundingSphere();
rotatorBird.setSchedulingBounds(boundsBird);
Bird.addChild(rotatorBird);

//end of rotation For Bird



//----------------------début de la création de la rotation--------------------------------

TransformGroup WinRSpin=new TransformGroup();

// permet de modifier l'objet pendant l'execution
WinRSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

// on crée un fonction de rotation au cours du temps
Alpha rotationAlphaWinRSpin=new Alpha(-1,2000);

Transform3D rot = new Transform3D();
// rot.rotX((float)Math.PI/- 2.0f);
//rot.rotX(-45);
//rot.rotX((-Math.PI / 4.0)+30);
rot.rotZ((-Math.PI / 4.0));

//rot.rotX(-Math.PI / 4.0);
//rot.rotY(-Math.PI / 4.0);
// rot.rotZ(-Math.PI / 4.0);
// rot.rotY(00);
//rot.rotZ(45);
// on crée un comportement qui va appliquer la rotation à l'objet voulu
// on définit la zone sur laquelle va s'appliquer la rotation


RotationInterpolator rotatorWinRSpin=new RotationInterpolator(rotationAlphaWinRSpin,WinRSpin, rot, 0.50f,(float)(2.0*Math.PI));

BoundingSphere boundsWinRSpin=new BoundingSphere(new Point3d((Math.PI / 4.0), 0.0, 0.0), 0.5);
// boundsWinRSpin.setCenter(new Point3d((Math.PI / 4.0),0,0));
boundsWinRSpin.setCenter(new Point3d(-10,0,0));
//boundsWinRSpin.setCenter();
//test put a t3d to a boundingsphere??
//Transform3D T3Dbounding = new Transform3D();
// T3Dbounding.set(new Vector3f(5.00f,0.0f,0.00f));
//WinRSpin.setTransform(T3Dbounding);
//end test put a t3d to a boundingsphere, not working

rotatorWinRSpin.setSchedulingBounds(boundsWinRSpin);
// test BoundingSphere of BODY BIRD rotatorWinRSpin.setSchedulingBounds(boundsBird);
WinRSpin.addChild(rotatorWinRSpin);

//----------------------End de la création de la rotation--------------------------------

java3d
Newbie Poster
1 post since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

i have interests in learning java 3d. anyone willing to assist? mastergreg

mastergreg
Newbie Poster
1 post since May 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You