Homeaux Charisma
Registered User
Join date: 12 Jan 2009
Posts: 3
|
01-15-2010 15:40
It's a bit more complicated than the title, but... http://pastebin.com/m1625afa3That pastebin link has some code to drop in a default cube prim, which will set up a mockup of what I need my final object to do. There's some blanks that need to be filled, and that's where I'm at a loss. Ideally, the object needs to work as either a HUD or a rezzed object and the rezzed object needs to be able to be rotated and still present the chosen face toward either the face it was clicked from (preferable, possibly by using llDetectedTouchNormal?) or just in a consistent direction around the local X axis (by offset from whatever the current face is, perhaps? If the last selected face face is A, and C is clicked, rotate 180° around the LOCAL X axis, regardless of actual in-world rotation). Figured it out, see my post below.
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
01-15-2010 16:25
You are not telling if you want it for all prim types. If you want it for a box and you want to show one of 4 faces it is relatively simple IF you rotate it around the Z axis. In that case all textures will be upside up. Use llRot2Fwd(llGetRot()) to find the normal vector for the forward face, -llRot2Fwd(llGetRot()) to find it for the backward face, llRot2Left(llGetRot()) for the left face, -llRot2Left(llGetRot()) for the right face. Once you have the vector you can turn the cube in your direction with: llSetRot(llRotBetween(faceVector, yourDirection)); I leave it up to you to figure out the face numbering http://lslwiki.net/lslwiki/wakka.php?wakka=sideIf you rotate around the X axis or the Y axis some of the textures will be upside down.
_____________________
From Studio Dora
|
Homeaux Charisma
Registered User
Join date: 12 Jan 2009
Posts: 3
|
01-15-2010 16:31
I'm guessing you didn't use the test script, which illustrates exactly what is needed. I even mentioned that yes, I need this to work for a box.
I know the differences between the X and Z axis, and all the textures I'm using are set up appropriately. I need to use the X axis in this case.
Also, face numbering isn't very cryptic, provided the prim stays the same. All I have to do is select face and Ctrl+Alt+Shift+T to get the number.
|
Homeaux Charisma
Registered User
Join date: 12 Jan 2009
Posts: 3
|
01-15-2010 22:28
Nevermind! Poked at it for a few hours after dinner and solved it.
http://pastebin.com/m69153b43
Works like a charm, can rotate the hell out of the prim at random, either attached or rezzed, and clicking it always rotates the correct face towards the already-lit face.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-16-2010 03:38
if you aren't concerned with what rotation the face has around it's own axis (which shouldn't be an issue with 4 faces around the z axis) you could simply used rot between and fed it vectors for the face to replace, and the chosen face, then applied that as a local rotation. or even simpler since you're going around z touch_end( integer vIntNull ){ integer vIntFaceNow = llDetectedTouchFace( 0 ); if (0 > faceTouched && faceTouched > 5){ //-- default cube around z faces vector vVecTarget = llDetectedTouchST( 0 );
vVecTarget.y = ((1 | -(vVecTarget.y > 0.5)) + vIntFaceNow) & 3; //-- adds or subtracts a face number for left or right, use you own calculation if you want more or different, but it needs to equal the target face number.
rotation vRotLocal = llEuler2Rot( <0.0, 0.0, 90.0> * DEG_TO_RAD ); do{ //-- rot 90deg until we get the right face. llSetRot( vRotLocal * llGetRot() ); ++vIntFaceNow; vIntFaceNow %= 4; }while (vIntFaceNow != vVecTarget.y); } }
untested but the idea is there... you can accumulate the number of needed turns, or even reverse the direction as needed before applying
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|