Jump to content

Which Side of a cube is up?


Villain Baroque
 Share

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

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

Recommended Posts

vector vPosTest;vPosTest = llRot2Up( llGetRot() );if (llFabs( vPosTest.z ) > 0.5){    if (vPosTest.z > 0){        //-- top is up    }else{        //-- bottom is up    }}else{    vPosTest = llRot2Left( llGetRot() );   if (llFabs( vPosTest.z ) > 0.5){        if (vPosTest.z > 0){            //-- left side is up        }else{            //-- right side is up        }    }else{        vPosTest = llRot2Fwd( llGetRot() );       if (vPosTest.z > 0){            //-- front is up        }else{            //-- back is up        }    }}

 

Link to comment
Share on other sites

EDIT: Void beat me while I was doing my tests in-world. Nevermind... It's almost the same thing but in a function.

I retrieved this old thing in my inventory:

 

integer uuRot2Face(rotation rot){    vector vee = llRot2Up(rot);    integer k = llRound(vee.z);    if (k == 1){ return 0; }    else if (k == -1){ return 5; }    vee = llRot2Fwd(rot);    k = llRound(vee.z);    if (k == 1){ return 3; }    else if (k == -1){ return 2; }    vee = llRot2Left(rot);    k = llRound(vee.z);    if (k == 1){ return 1; }    else if (k == -1){ return 4; }    return -1; // So that the compiler doesn't complain.}

 

It works quite well even if the dice isn't exactly straight.

 

Link to comment
Share on other sites

Better late than never, here is a routine I made for a dice back in April 2008
Note that the list gives the connection between pips and sides so it instantly returns the pip number:smileywink:

integer pips_up(){    vector u = llRot2Fwd( llGetRot() );    vector v = llRot2Left( llGetRot() );    vector w = llRot2Up( llGetRot() );    // Vectors associated with dice pip numbers    list pips_list = [ u.z, 1, -u.z, 6, v.z, 2, -v.z, 5, w.z, 3, -w.z, 4 ];    // sort for the one with the biggest Z (vertical up) component,    // the associated pip number is upward    return llList2Integer( llListSort( pips_list, 2, FALSE ), 1 );}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4616 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...