|
Dina Vanalten
Registered User
Join date: 24 Dec 2006
Posts: 268
|
07-22-2007 07:24
Hi.
Looking for the clue on how to get from using llGetRot / llGetPos to llSetPos.
I have an object that the av sits on. I have no problems with moving the object up and down and rotating it.
What I want add is moving forwards and backwards based on the direction the av is looking. I know how to use llGetPos and llSetPos to find out where I and and set where I want to go.
What I don't understand is how to use the information from llGetRot to calculate the correct x/y values for llSetPos to move forward or backwards in a straight line.
Does anyone know the math?
Thanks - D
|
|
Marcel Cromulent
Registered User
Join date: 28 Jan 2007
Posts: 10
|
07-22-2007 08:50
From: Dina Vanalten Hi.
Looking for the clue on how to get from using llGetRot / llGetPos to llSetPos.
I have an object that the av sits on. I have no problems with moving the object up and down and rotating it.
What I want add is moving forwards and backwards based on the direction the av is looking. I know how to use llGetPos and llSetPos to find out where I and and set where I want to go.
What I don't understand is how to use the information from llGetRot to calculate the correct x/y values for llSetPos to move forward or backwards in a straight line.
Does anyone know the math?
Thanks - D When you say "The direction the avatar is looking at", this presumably means the "forward direction" of the avatar, not the direction the camera is looking at. If the avatar itself has the zero rotation, the forward direction will be the x-axis, that is the vector <1,0,0>. In general, the forward direction will depend on the rotation of the object, and on the sit-rotation of the avatar. If the object is not rotated in itself, the forward direction will be given by the vector <1,0,0>*SitRotation. The sit-rotation is determined by the llSitTarget() command, which has format llSitTarget(SitVector,SitRotation). If the object is further rotated by Rot, the new forward direction will be Forwardvector = (<1,0,0>*SitRotation)*Rot =<1,0,0> *(SitRotation * Rot) To move the object in this direction multiplied by a float t, you simply do llSetPos(llGetPos()+t*ForwardVector);
|
|
Dina Vanalten
Registered User
Join date: 24 Dec 2006
Posts: 268
|
07-22-2007 09:05
Thanks.
I'll give it a try. In this case the camera and the av are both facing the same direction.
- Dina
|
|
Dina Vanalten
Registered User
Join date: 24 Dec 2006
Posts: 268
|
07-22-2007 09:12
Thanks.
I'll give it a try. In this case the camera and the av are both facing the same direction.
- Dina
|