|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
01-25-2009 15:26
Bah, rotations continue to elude me! Okay, this time I have a vector, it represents an offset relative to a fixed position, and I want to rotate this offset "up" or "down" (pitch) relative to the fixed position. Now, I can get this to work for basic cases, i.e when the vector offset is "in front of" (i.e in the positive x axis from) the fixed position, but it either does nothing in other positions, or rotates in a cone shape rather than a circle. Here is the code I have so far: rotation rot = llRotBetween(diff, ZERO_VECTOR);
// Remove rotation diff /= rot; // Apply local-rotation if (held & CONTROL_UP) diff *= rotUpDown; else diff /= rotUpDown;
// Re-apply rotation diff *= rot;
In this case "diff" is the offset, and the fixed position is unknown. rotUpDown is a 30ยบ rotation on the Y-axis. How do I got about calculating the correct rotation(s) I need here?
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|
|
arton Rotaru
Registered User
Join date: 27 Aug 2007
Posts: 43
|
01-25-2009 19:38
I don't know if I understand exactly what you want to do, but it sounds to me similar to a simple door script. Applying an offset relative to a current rotation you need to multiply the current rotation to the offset rotation. *llGetRot() (or *llGetLocalRot() for childprims with llSetLocalRot()) A simple door script. integer switch = FALSE; vector Axis = <0.0,1.0,0.0>; float deg = 30.0; rotation rot;
default { touch_start(integer total_number) { if (switch){ rot = llEuler2Rot(Axis * deg * DEG_TO_RAD)*llGetLocalRot(); llSetLocalRot(rot); switch = FALSE; }else{ rot = llEuler2Rot(-Axis * deg * DEG_TO_RAD)*llGetLocalRot(); llSetLocalRot(rot); switch = TRUE; } } }
|