Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java 3D > PositionPathInt...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 741 of 818
Post > Topic >>

PositionPathInterpolator woes...

by Miss Elaine Eos <Misc@[EMAIL PROTECTED] > Mar 24, 2007 at 10:54 PM

[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.




 1 Posts in Topic:
PositionPathInterpolator woes...
Miss Elaine Eos <Misc@  2007-03-24 22:54:05 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 23:59:09 CDT 2008.