Jump to content

Object Rotation Orientation


revochen Mayne
 Share

You are about to reply to a thread that has been inactive for 3625 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello!

I need some help with setting an objects forward and up rotation based on its current rotation set. I tried using llRot2Up but wasnt able to figure out how to use it proper. The wiki wasnt a help with as its providing very least informations about.

I tried

...

vector currentRot = llGetRot();
vector rotToUp = llRot2Up(currentRot);

llSetRot(currentRot*llEuler2Rot(rotToUp));

...

 but it doesnt seems to do what i need.

 

Anyone may point me to the right direction please? 

Link to comment
Share on other sites

First of all, llGetRot() returns a rotation and not a vector

Then when you know your forward direction by a vector: currentRot and know what it shall be: rotToUp

Wanted rotation is: rotation wantrotation = llRotBetween( currentRot, rotToUp);

You set your new rotation like this: llSetRot( llGetRot()*wantrotation);

You can get vector currentRot like this: vector currentRot = llRot2Fwd( llGetRot());

:smileysurprised::):smileyvery-happy:

 

Link to comment
Share on other sites

Hi Doro =)

Yes, you are right. It was supposed to be a rotation type but the code doesnt solves my problem anyway. I  even wonder why its using a llRot2Fwd function when i want to get its up direction?

Thats the code im using in a test pyramide prim and just want it to rotate up based on its current rotation.

default{    touch_start(integer total_number)    {        rotation rot = llGetRot();        vector currentRot = llRot2Fwd(rot);        vector rotToUp = llRot2Up(rot);        rotation setRot = llRotBetween(currentRot,rotToUp);                llSetRot(rot*setRot);    }}

 

I'm messing with it for a few days now and start to pull out my missing hair soon. óò

Link to comment
Share on other sites

You need to clarify what it is that you want, what have you got and what do you want.
I am kind of lost.
You talk about: "setting an objects forward and up rotation based on its current rotation set".
I don't understand that.

A prim has a forward, a left and an up vector,
but they don't say anything about the prim rotation unless you know their coordinates.
A prim also has a rotation.
It always has a global rotation and in a link set it has a local rotation as well

Again:

  1. What have you got?
  2. What do you want?

:smileysurprised::):smileyvery-happy:

 

Link to comment
Share on other sites

Ok sorry, the thing i'm searching for seems to be the objects upwards direction. Imagine a roly-poly doll, which always stands up by its own to achieve its up direction. So when the doll gets bumped and changing its x + y angle, how do i get it to stand up again as a non physical object?

Link to comment
Share on other sites

This would be one way to do it, I think:

vector size;default{    state_entry()    {     size = llList2Vector(llGetPrimitiveParams([PRIM_SIZE]),0);         }    touch_start(integer total_number)    {      vector pos =llGetPos();      llLookAt(<pos.x,pos.y, pos.z +size.z>,1.0,0.1);    }}

 

 That works for both physical and non-physical objects.   

How does bumping the doll move it in the first place, though, unless it's a physical object?

Link to comment
Share on other sites

Hello and thank you for your reply but this also doesnt seems to resolve my problem. llLookAt will point the X axis towards a target vector but all i want is the the Z axis going straight up.



Innula Zenovka wrote:

How does bumping the doll move it in the first place, though, unless it's a physical object?

The doll was just an example although its a baby im working on. The baby is changing its positions to either stand,  sit, crawl or lay and for thats what i need the proper orientation for based on its current rotation. I dont want to hard-code it and thought there is a function in LSL to rely on. I believe its about the llRot2Up and llRot2Fwd but i tried anything back and forth without success but more confusions about.

Link to comment
Share on other sites

And i just figured the objects local forward axis is the Y, left/right is X and up axis is Z. So i guess i rather have to use llRot2Left instead of llRot2Fwd... but how?! óò

It's so frustrating search way to long for a solution on and the wiki wasnt much of a help about. It even left more questions than it could answer. Also messing with quaternions is a pain. When running a few test i got values like <-0,0,1> which was totally new for me that there is a negative zero (-0) existing! Oô

So to bother you with my complains but i just had to, not feeling better tho. *sighs*

Link to comment
Share on other sites

Had to figure on the first test thats its not reliable for my purpose.

I had the baby in crawling position and want it to change into stand or sit which is just a 90 degree spin on its local X axis. When applying llLookAt it also turned on its Z axis and thats just what i want to avoid.

Link to comment
Share on other sites

If you simply want to move it 90 degrees on its local X axis, try this

rotation x90;default{    state_entry()    {       x90 = llEuler2Rot(<90.0,0.0,0.0>*DEG_TO_RAD);    }    touch_start(integer total_number)    {        llSetRot(x90*llGetRot());        x90= ZERO_ROTATION/x90; //invert the rotation for next time    }}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3625 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...