I think to rotate about a vector, we could be using the class AxisAngle4f.

E.g: to rotate the object about a vector specified in axisAngle and the
angle
of rotate is also stored in axisAngle.
----------------------------------------------------------------------
        targetTG.getTransform(rotation);
        //angle to rotate
        axisAngle.angle=angle;

        //Translate or rotate the object to origin
        //by multiplying the inverse of the original transform, backT
        rotation.mulInverse(backT);

        temp.set(axisAngle);
        rotation.mul(temp);

        // translate or rotate the object to its intended location
        rotation.mul(backT);

        targetTG.setTransform(rotation);
------------------------------------------------------------------------

where
targetTG,temp,backT and rotation are Transfrom3D
axisAngle is AxisAngle4f


The full code for the above behavior is here
----------------------------------------------------------------
public class MouseRotationBehavior extends Behavior
{

  protected WakeupCriterion[] mouseEvents;
  protected WakeupOr mouseCriterion;
  private TransformGroup targetTG;
  private Transform3D rotation = new Transform3D();
  private Transform3D temp= new Transform3D();
  private float angle = 0.0f;


  private Transform3D backT = new Transform3D();
  private AxisAngle4f axisAngle= null;
  private Quat4f quat=null;


    MouseRotationBehavior(TransformGroup targetTG)
    {
      this.targetTG = targetTG;

      // this is where your object is located in the scene
      backT.rotX(Math.PI/2d);
      backT.setTranslation(new Vector3f(0.0f,-3.0f,-14.0f));

      // this is where you set the rotation vector and angle
      axisAngle= new AxisAngle4f(new Vector3f(0.0f,1.0f,10.0f),0);
      quat=new Quat4f();
      quat.set(axisAngle);

    }

    public void initialize()
   {

      mouseEvents = new WakeupCriterion[1];

      mouseEvents[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED);
      mouseCriterion = new WakeupOr(mouseEvents);
      wakeupOn (mouseCriterion);
    }

     public void processStimulus(Enumeration criteria){

        angle += 0.001f;
        targetTG.getTransform(rotation);
        axisAngle.angle=angle;

        rotation.mulInverse(backT);
        temp.set(axisAngle);
        rotation.mul(temp);
        rotation.mul(backT);

        targetTG.setTransform(rotation);
        this.wakeupOn(mouseCriterion);
     }

}



-----------------------------------------------------------------

----- Original Message -----
From: "W.M.Lau" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 17, 2000 6:31 PM
Subject: Re: [JAVA3D] Robot Arm


> Hi, Long
>
> I am currently working on the similar project.
> My project is also trying to produce a robot arm simulation.
> May be we can team up together and share our ideas.
>
> I have only started learning java3d on my own. I 've found out that the
> question you've asked depends on the pivot point of the rotation. I think
> there is a function to set the pivot point.
>
> Also I think there is another function that allows boolean check to see
> if an object is picked up or not. Roughly If I remember right they both
> should be under Transform3D class.
>
> Sorry, I can't be much help. I am still looking for those two method
> names as well.
>
> It's possible to rotate an object manually using the keynavigator or
> mouse navigator, but I think the pivot point is set as the center ofthe
> object as default, to do this it must need to change a pivot point.
>
> Hope what I talk make sense to you, because it doesn't make much sense to
me.
> Still, if you think we should team up together, feel free to share ideas
> and method with me.
>
> yours sincerely
>
> Raymond Lau
>
> On Tue, 15 Aug 2000, Siau Tan Long wrote:
>
> > I am making a robot arm simulation.
> > I wanted the user to pick each segment of the arm and rotate about the
> > joint(given point) manually.
> > My question are:
> > Which class should I use and how do I know which segment that the user
had
> > picked?
> > How do I rotate about a given point?
> >
> >
> >
> > _________________________________________________________
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> >
===========================================================================
> > 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".
> >
>
>
===========================================================================
> 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".



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

===========================================================================
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".

Reply via email to