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 

PositionPathInterpolator woes...

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





PostPosted: Sun Mar 25, 2007 3:54 am    Post subject: PositionPathInterpolator woes... Reply with quote



[Boy, I sure hope this will be one of those things that, after being
stuck for several days, once I ask, the answer will be obvious to me
<G>]

I've got my scene all set up, and things are working quite well, but I'm
trying to get some of my objects (which are represented as textured
spheres) to "rise up" from under my terrain. The tool I'm using is the
PositionPathEnterpolator, but I clearly don't understand what the docs
are trying to tell me.

Here's the code that's giving me trouble:

// This says "do this once, over 5 seconds", right?
Alpha alpha = new Alpha (1, 5000);
// 2 positions...
float [] knots = { 0.0f, 1.0f };
// start 1.5 below ground (the TG with which we started)
Point3f start = new Point3f (0, -1.5f, 0);
// End at the TG I passed in
Point3f end = new Point3f (0, 0, 0);
Point3f [] pos = { start, end };
// the xform representing the Y axes, where the
// movement should take place
Transform3D xform = new Transform3D();
xform.set (new Vector3d (0, 1, 0));
PositionPathInterpolator interp =
new PositionPathInterpolator (alpha, tg, xform, knots,
pos);
// Make it nice & big, so I know *THAT* isn't the problem...
interp.setSchedulingBounds (new BoundingSphere
(PigUtils.getPointFromTransGroup (tg), 1000));

tg.addChild (interp);


For background, here's the branch-object constructor that includes the
code from above:

// PigObject extends BranchGroup and is a sphere
// with a pig-face texture on it.
// The TG passed-in is described below.

public PigObject (TransformGroup tg)
{
super();

setName ("pig (BG)");

Sphere sphere = new Sphere ((float) pigSize,
Sphere.GENERATE_NORMALS |
Primitive.GENERATE_TEXTURE_COORDS,
pigAppearance());

setCapability (BranchGroup.ALLOW_DETACH);
setCapability (Group.ALLOW_CHILDREN_WRITE);

tg.addChild (sphere);

// If I set this to "if (true)"... I see no pigs. Ever.
// With the "trouble code" (above) out, all works just fine.
if (false)
{
// Get pigs to "fade in" from below the ground.
// Troublesome code, from above, goes here
}

addChild (tg);
}

Here's an example of how I create a pig object, in the first place --
pretty straightforward stuff:

double pigX = xx * dist;
double pigZ = zz * dist;
double pigY = terrain.getAltitude (pigX, pigZ) +
(PigObject.pigSize * 0.66);

PigObject thePig = new PigObject (PigUtils.createLocationTG
(pigX, pigY, pigZ));
pigGroup.addChild (thePig);

and, lastly, here're my utility routines, used above.

public static TransformGroup createLocationTG (double xx, double
yy, double zz)
{
Transform3D pos = new Transform3D ();
pos.setTranslation (new Vector3d (xx, yy, zz));

TransformGroup trans = new TransformGroup (pos);
trans.setCapability (TransformGroup.ALLOW_TRANSFORM_READ);
trans.setCapability (TransformGroup.ALLOW_TRANSFORM_WRITE);

return (trans);
}


public static Point3d getPointFromTransGroup (TransformGroup
tg)
{
Transform3D xform = new Transform3D();
tg.getTransform (xform);

Vector3f loc = new Vector3f();
xform.get (loc);

return (new Point3d (loc));
}


All of this other code works, if I just don't-include my interpolator,
above -- so I'm pretty sure the problem is with my [mis-]use of the
interpolator.

Any ideas?

Thanks!

--
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.
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.