relative to global acceleration conversion...
Blitz3D Forums/Blitz3D Programming/relative to global acceleration conversion...
| ||
Hi, I'm stumped and could do with picking your brains if you can help... I've got a weapon that's launched from the camera location, it has acceleration, ie each frame it's x, y and z are updated from xacc, yacc and zacc which are modified by various things in the play area (gravity wells etc). Here's the problem, the above works fine if the camera is looking straight down the z axis, I need the initial accelerations to be converted from camera relative to global accelerations, ie modified by the current angle of the camera - but my maths limit has been reached I think, how can this be accomplished? anyone got a little example code to do the conversion and get me past this barrier? Thanks guys. |
| ||
hmm... You need to transform the vertor 0, 0, 1 into the camera space. Not tested but try something like this. TFormVector 0, 0, 1, camera, 0 xvel# = xvel# - (TFormedX() * speed#) yvel# = yvel# - (TFormedY() * speed#) zvel# = zvel# - (TFormedZ() * speed#) |
| ||
like this:TFormVector RelativeXVel#,RelativeYVel#,RelativeZVel#,camera,0 GlobalXVel# = TFormedX() GlobalYVel# = TFormedY() GlobalZVel# = TFormedZ() oh, and by the way... its velocity that changes position, acceleration changes velocity: xaccel# = 0.0 yaccel# = -10.0 zaccel# = 1.0 xvel# = xvel# + xaccel# yvel# = yvel# + yaccel# zvel# = zvel# + zaccel# xpos# = xpos# + xvel# ypos# = ypos# + yvel# zpos# = zpos# + zvel# catch me on irc if you want more help etc, i know a lot of useless junk like this ;) |
| ||
Doh, well at least you knew what I meant. Thanks guys. :) |