Al Bravo
Retired
Join date: 29 Jun 2004
Posts: 373
|
07-27-2004 04:56
OK, I'm feeling pretty dumb for asking this one, but.... What is the easiest way to determine the value of a physics die when it is rolled? I know it a question of final rotation. And I have the script to determine the rotation after it stops. But how do I turn that rotational value into "which side is up"?
|
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
|
07-27-2004 06:20
Dont use physics. Anyone can llPushObject your die and mess with the result, or send it offworld.
|
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
|
07-27-2004 06:21
Actually, you could use physics more safely as a graphical effect, if you pregenerate the random value. This would tamper-proof the result, but people could still orbit your die to the other side of the world, regardless of permissions.
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
07-27-2004 07:11
Yup, Eggy's right. As to the maths... the easiest is AxisAngle2Rot, which is way more predictable and intuitive than Euler and also faster because Rots are almost axis/angle. The way you could do this is: - face 1 is zero rot: <0,0,0,1> - faces 2 to 5 are: rotate around z-axis from 0 to 3 times then tilt to one side: rot rFinalRot = ZERO_ROTATION; for( int i = 0; i < iFace - 1; i++ ) { rFinalRot = llAxisAngle2Rot( <0,0,1>, 90 ) * rFinalRot; }
rFinalRot = llAxisAngle2Rot( <0,1,0>,90) * rFinalRot;
(note: cant remember if you need to pre or postmultiply rots in SL, just swap the multiplications around if its wrong; ditto with degrees vs radians; just convert to radians if SL expects radians) And then the last face is simple roatation about x or y axis by 180: rFinalRot = llAxisAngle2Rot( <0,1,0>, 180 ); Azelda
|