|
BETLOG Hax
Geek
Join date: 22 May 2007
Posts: 91
|
05-05-2008 07:49
QUESTION: I have an anti-aircraft gun. The base which the av sits on rotates in global Z only. The base also increments an "elevation" value via the control event. The separate cannon component tracks the base's pos and rot via a timer. However the cannon needs to not only track the bases global Z rot.. it also needs to rotate itself on its own LOCAL Y axis (according to the elevation value).
Whats the easiest way to combine a global and a local element like this to get the desired result (cannon tracks base's global Z, and elevates on its own local Y)?
Make sense?
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-05-2008 09:45
A little hard to say without knowing more about your system. Are both of these child prims of a vehicle or other object? Are they separate objects? You could possibly start with: rotation calculateCannonRot(rotation baseRot, float elevationAngle) { rotation localYRot = llAxisAngle2Rot(<0.0, -1.0, 0.0>, elevationAngle); return localYRot*baseRot; // order IMPORTANT! Don't switch them. }
|
|
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
|
05-05-2008 09:49
From: BETLOG Hax QUESTION: I have an anti-aircraft gun. The base which the av sits on rotates in global Z only. The base also increments an "elevation" value via the control event. The separate cannon component tracks the base's pos and rot via a timer. However the cannon needs to not only track the bases global Z rot.. it also needs to rotate itself on its own LOCAL Y axis (according to the elevation value).
Whats the easiest way to combine a global and a local element like this to get the desired result (cannon tracks base's global Z, and elevates on its own local Y)?
Make sense? Well if the cannon is one prim, then just as you've said.. have just the cannon prim move on it's local Y, while tracking the main bit to move with it (Or whatever) Honestly, I'm not too sure what your problem or question is =/
_____________________
Tutorials for Sculpties using Blender! Http://www.youtube.com/user/BlenderSL
|
|
BETLOG Hax
Geek
Join date: 22 May 2007
Posts: 91
|
05-05-2008 10:40
From: Hewee Zetkin rotation calculateCannonRot(rotation baseRot, float elevationAngle) { rotation localYRot = llAxisAngle2Rot(<0.0, -1.0, 0.0>, elevationAngle); return localYRot*baseRot; // order IMPORTANT! Don't switch them. }
Perfect. I KNEW it was going to be a one liner that solved it.. i hade the entire system working around it and just couldnt find the right function to use to translate things to a useful format. Many thanks. edit: solution was: (ok so a two liner) rotation localRotGun = llAxisAngle2Rot(<0.0, -1.0, 0.0>, gAdjEuler.y*DEG_TO_RAD); localRotGun = localRotGun * rotPivot; //local
|