Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > crosstalk across branchgroups
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 20th June 06:28
sanbikinoraion
External User
 
Posts: 1
Default crosstalk across branchgroups



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_TRANSFO RM_WRITE);
rotateY.setCapabilityIsFrequent(TransformGroup.ALL OW_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_TRANSFO RM_WRITE);
rotateZ.setCapabilityIsFrequent(TransformGroup.ALL OW_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_TRANSFOR M_WRITE);
radius.setCapabilityIsFrequent(TransformGroup.ALLO W_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_D ETACH);
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;
}
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666