|
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
|
04-06-2007 09:47
heyas;
okay, i have a compass direction reading (the z rotation of my camera), and i want to tell an object that is on an attachment to point in that compass direction. i've already done a hud compass where the compass z rotation mimicks the camera z rotation, and that works great. but the hud compass doesn't change it's position. you know what i mean?
or, if im holding a pointer in my hand, it's z zero rotation might be pointing east (the same as the camera z rotation pointing east), but if i turn to the left... east might now be 1/4 pi for it or something. i dont think i want to use global rotation, because i want the thing to rotate on its own axis, no matter which direction it is facing. (it could be tipped sideways, for example, but i still only want to rotate it on its z axis, not the global z axis.)
at any rate... my geography and math skills are horrendous, so i can't figure out how i would go about figuring out what local rotation to plug into an object to get it to face a certain global direction. erm... the difference between its an the camera's rotation, perhaps? gah! i can't do plain rotations, let alone do math with them!!
any ideas? help...? formulas!? :) thanks guys!
|
|
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
|
04-06-2007 16:56
|
|
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
|
04-09-2007 06:41
heyas;
i'm sorry, ed, that just tells me what rotations are. i already know what they are, but it is not clear to me how to use and manipulate them to get where i want to go. is there something in particular in that murky quagmire you wanted to point out? perhaps you could be a bit more explicit.
thanks!
|
|
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
|
Progress!
05-07-2007 07:37
heyas; okay, i revisited this for the asl open scripting get-together. (much to the chagrin of... well, everybody ;D ) that helped... a little. but what REALLY helped was when i sat down and doodled diagrams of cameras, bases, and child prims and which ways they were pointing. and thus, i have come up with a formula for the child prims rotation! the only stickler is, i don't know how to apply it via scripting. formula: ZCAM (the z rotation of the camera) -ZBASE (the z rotation of the base/root prim) ---------- ZCH (the desired z rotation of the child, relative to the base) now... very slowly, as if to a complete mathematical moron... what is the best way to get the z rotations, do the math on the z rotations, and apply the final z rotation to the child prim? i have this (code upcoming), but im not sure if using the vCam.z etc is better than using Rot2Up. or even HOW to use Rot2Up. and im pretty sure you can't add/subtract vectors, you have to multiply and divde? im lost. timer() { //--step 1: get camera's Z rotation rCam = llGetCameraRot(); vector vCam = llRot2Euler(rCam); //--use vCam.z //--step 2: figure out our global rotation away from east (0), via root rotation? rBase = llGetRootRot(); vector vBase = llRot2Euler(rBase);
//--and this is our current local rotation rChild = llGetLocalRot(); vector vChild = llRot2Euler(rCompass); //--step 4-er- 3: calculate & apply object/child local rotation to face same as camera global rotation
vector vChange = vCam - vBase; //--how do you subtract vectors? and should this only be z? vChild.z = vChange.z; llSetLocalRot(llEuler2Rot(vChild)/RR); //--only use RR if a child prim }
_____________________
Why Johnny Can't Rotate: http://forums.secondlife.com/showthread.php?t=94705
|