AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

crosstalk across branchgroups

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> 3D Graphics API's for Java
View previous topic :: View next topic  
Author Message
sanbikinoraion
Guest





PostPosted: Mon Oct 30, 2006 3:44 am    Post subject: crosstalk across branchgroups Reply with quote



Hiya, I'm sure I'm just doing something very simple wrong - I'm
teaching myself java3d as I go here. My problem is that this code to
place a spaceship in orbit around a planet causes two spaceships added
by it to end up halfway between their respective destinations. I'm
pretty sure that this is because the rotators in each branchGroup are
adding together instead of applying separately to the individual ships,
but I don't really understand why that is. The "icon" is the box that
represents the spaceship.

Any insights into this problem would be very gratefully received!

Cheers,

sanbikinoraion

-----

public abstract class MovableControllable
extends Behavior
implements SurfacePositionGet, SurfacePositionSet, Attackable
{

...

protected void makeIconGroup (Planetoid orbiting, Vector3f pos)
{
this.position = pos;
this.planet = orbiting;


// create longitude group
TransformGroup rotateY = new TransformGroup();
Transform3D t3dY = new Transform3D();
t3dY.rotY(((pos.x - 90) /360f) * Math.PI * 2 );
rotateY.setTransform(t3dY);
rotateY.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
rotateY.setCapabilityIsFrequent(TransformGroup.ALLOW_TRANSFORM_WRITE);

// create latitude group
TransformGroup rotateZ = new TransformGroup();
Transform3D t3dZ = new Transform3D();
t3dZ.rotZ((pos.y /360f) * Math.PI * 2);
rotateZ.setTransform(t3dZ);
rotateZ.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
rotateZ.setCapabilityIsFrequent(TransformGroup.ALLOW_TRANSFORM_WRITE);
rotateY.addChild(rotateZ);

// create altitude group
TransformGroup radius = new TransformGroup();
Transform3D t3d = new Transform3D();
Vector3f npos = new Vector3f();
npos.set(planet.getBodyRadius() + pos.z + 10, 0, 0);
t3d.setTranslation(npos);
radius.setTransform(t3d);
radius.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
radius.setCapabilityIsFrequent(TransformGroup.ALLOW_TRANSFORM_WRITE);
radius.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
rotateZ.addChild(radius);


// attach the transforms to the planet and the icon.
this.icon = this.makeIcon();
radius.addChild(this.icon);
this.icon_branch = new BranchGroup();
this.icon_branch.addChild(this);
this.icon_branch.setCapability(BranchGroup.ALLOW_DETACH);
this.icon_branch.addChild(rotateY);
planet.getBodyGroup().addChild(icon_branch);


// store these for later use by the moveToTarget function
this.rad = radius;
this.rotY = rotateY;
this.rotZ = rotateZ;
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> 3D Graphics API's for Java All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.