> Date: Thu, 20 Feb 2003 03:53:09 -0700
> From: Joost Verschuren <[EMAIL PROTECTED]>
> >
> >It's difficult to suggest a solution without seeing the code.
>
> I have extracted some fragments of the code and included it at the end of
> this message. Some of the code could use some optimization :)
>
> public class J3D_VCETether {
> ...
> public void updateVP(){
> tg_obj.getTransform(t3d_obj);
> t3d_obj.get(trans);
> center.set(trans.x,trans.y,trans.z);
> //Determine the new absolute eye position
> eyeabs.set(eyePoint.x+center.x,
> eyePoint.y+center.y,
> eyePoint.z+center.z);
How is eyePoint computed? Is it a constant relative eyepoint, or can it
vary? If it varies, how is that change propagated to updateVP()? That
could be the source of the jitter.
> //Determine the new absolute eye position
> eyeabs.set(eyePoint.x+center.x,
> eyePoint.y+center.y,
> eyePoint.z+center.z);
>
> congruency.sub(center, eyeabs);
A little odd, you're just negating eyePoint there with the sub()... but
harmless.
> // Normalize vectors, for check on dot product
> congruency.normalize();
> up.normalize();
>
> if (Math.abs(congruency.dot(up)) < 0.995) { //only if non-congruent
> t3d.lookAt(eyeabs, center, up);
> ...
A dot product of two unit vectors will give you the cosine of the angle
between them. In the nominal case, the angle between the view direction
and the up direction is 90 degrees, which has a cosine of 0.0, so the
test for less than 0.995 is a little strange... you probably want to
test for > 0.005. This is harmless unless you actually get coaligned
view and up direction vectors with a dot product >= 0.995.
> t3d.invert();
> tg_vp_rot.setTransform(t3d);
>
> trans.set(0.0,0.0,0.0);
> t3dtrans.setIdentity();
> t3dtrans.setTranslation(trans);
> tg_vp_trans.setTransform(t3dtrans);
> }
> }
> }
The last four lines are equivalent to tg_vp_trans.setIdentity(). Also
note that lookAt() will give you a translation component, so the line
tg_vp_rot.setTransform(t3d) isn't necessarily a rotation matrix as
implied by the name. Could be a potential problem.
When are tg_vp_rot and tg_vp_trans composed to get the view platform
transform? There could be a frame latency introduced there or in the
computation of eyePoint mentioned earlier, especially if they're
computed by separate threads.
-- Mark Hood
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".