Villain Baroque Posted October 28, 2011 Share Posted October 28, 2011 I am looking for an easy way to determine which face of a cube points up on the z-plane. I want to script a dice. After some arbitrary rotations on all planes one side (face) is pointing up but which one?Thanks for your help. Link to comment Share on other sites More sharing options...
Jacki Silverfall Posted October 28, 2011 Share Posted October 28, 2011 I think it is your choice. Link to comment Share on other sites More sharing options...
Void Singer Posted October 28, 2011 Share Posted October 28, 2011 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 More sharing options...
Kaluura Boa Posted October 28, 2011 Share Posted October 28, 2011 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 More sharing options...
Void Singer Posted October 28, 2011 Share Posted October 28, 2011 there's a way to do it quicker, but I can't remember it... I think it used additions of <1,1,0> and <1,0, 1> multiplied by the rotation Link to comment Share on other sites More sharing options...
Dora Gustafson Posted October 29, 2011 Share Posted October 29, 2011 Better late than never, here is a routine I made for a dice back in April 2008Note 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 More sharing options...
Villain Baroque Posted October 29, 2011 Author Share Posted October 29, 2011 Thanks to all of you for your prompt help. I guess without your help I would have spent hours with trial and error. :matte-motes-smile: Link to comment Share on other sites More sharing options...
Recommended Posts
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