rotation help, please
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
10-10-2009 15:54
I'm trying to move a follower so it points in the same direction (sim) as an avatar, but points its top face forwards (in the direction the avatar is facing) so a particle stream comes out the right way. I've got it working, sort of, like this: list temp = llGetObjectDetails(target,[OBJECT_POS,OBJECT_ROT]); vector my_pos = llList2Vector(temp,0); rotation my_rot = llList2Rot(temp,1); vector fwd = < 0.0, 1.0, 0.0 >; llSetPrimitiveParams([PRIM_POSITION,pos,PRIM_ROTATION,my_rot]); llSetRot(llEuler2Rot( fwd*DEG_TO_RAD)*llGetRot());
There must be a better way of doing it, though... please someone help me out. I'm very confused about how to point the follower in the right sim direction and to get it to point its top in the right direction in one call.
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
10-10-2009 16:10
Maybe try something like: llLookAt(llDetectedPos(0),1,1)*VectorOffset 
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
10-10-2009 16:24
Sorry.. how am I calculating VectorOffset here?
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
10-10-2009 16:55
Well, llLookAt(llDetectedPos(0),1,1); will have your follower always pointing towards you. If you have your follower end up parallel to your avatar when you are not moving, then you can offset the llDetectedPos(0) by 90 degrees to get your follower to face forward. If your follower is at a diff position during steady state, you will have to figure the vector (rot) out to have it face forward. It all depends on what your follower is doing. 
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
10-10-2009 20:57
In the end, I gave up, used llRotLookAt to point the follower in the same direction as the avatar, and added an emitter prim to the follower, aligned so its z axis was pointing in the same direction as the root prim's (and the avatar's) sim x axis. I was just wondering how to do that with one prim, and was getting confused about how to do the world rotation and the local one together.. I tried the getRotToPointAxisAt function at http://lslwiki.net/lslwiki/wakka.php?wakka=llLookat but that seemed to want to point the thing's corner rather than face where i wanted it.
|
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
|
10-10-2009 21:38
Rotations make my brain hurt.
Couldn't you just llSetRot to the same direction the avatar is facing? Or maybe that * llEular2Rot (<90, 0,0> * DEG_TO_RAD) to flip the z+ axis forward?
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!! - Go here: https://jira.secondlife.com/browse/SVC-3895- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-11-2009 06:40
are you using a sensor for the follower? if you want the top facing the same direction as your avatar, it should just be
llLookAt(llDetectedPos(0),1,1);
but if you have it offset higher or lower than your hip, it will be pointing down or up to your hip so to make it face forward without pointing up or down you would do something like:
vector pos = llDetectedPos(0); vector mypos = llGetPos(); pos = < pos.x, pos.y, mypos.z >//uses the x and y pos from the detected position, and it's own z position so it faces forward llLookAt(pos,1,1);
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
10-11-2009 07:55
From: Ruthven Willenov are you using a sensor for the follower? if you want the top facing the same direction as your avatar, it should just be
llLookAt(llDetectedPos(0),1,1);
but if you have it offset higher or lower than your hip, it will be pointing down or up to your hip so to make it face forward without pointing up or down you would do something like:
vector pos = llDetectedPos(0); vector mypos = llGetPos(); pos = < pos.x, pos.y, mypos.z >//uses the x and y pos from the detected position, and it's own z position so it faces forward llLookAt(pos,1,1); Thanks, all. Ruthven's solution is what I needed; it was, I now realise, the offset that was confusing me.
|