cockpit camera orientation probs

Blitz3D Forums/Blitz3D Programming/cockpit camera orientation probs

Vorderman(Posted 2007) [#1]
I've been meaning to fix the cockpit cam in SRX for ages, but it's really annoying me now because I just put the loop back in.

Basically the camera is not parented but is positioned at the car's position, then rotated using DELTAPITCH and DELTAYAW to match the vehicle's orientation, but over a few frames to soften the effect and avoid too much juddering.

The problem is that when the vehicle goes around the loop the camera reverses direction by 180 degrees and then pitches around violently to match the new orientation, I assume caused when PITCH crosses the -180 to 180 boundary.

Has anyone got a system of camera tracking and orientation that will allow a camera to correctly and smoothly orient with and follow an entity that can invert and flip by 360 degrees, but is not just rigidly parented to the target?


Matty(Posted 2007) [#2]
Don't know if this is much help but could you use aligntovector for the camera instead? This allows for smooth transitions and I don't think it would have the problem of pitching violently to match the new orientation although I'm not sure if gimbal lock would be a problem.


Damien Sturdy(Posted 2007) [#3]
As Matty said. Use AlignToVector :)

or you could use the "RotaryDir" function from the code archives? This takes a start angle, a target angle, and number of steps to get there.

Can't find it right now but its a common one- I'll email it later if you want.


Vorderman(Posted 2007) [#4]
Thanks, I'll try the aligntovector command, but what vector would I align to? I need to smoothly align on all three axes (pitch, yaw and roll) when the target could be pointing in any direction.

Cygnus : I've already used that function and unfortunately it too produced a sudden swing right around in one direction, but not always, so I've no idea why it sometimes went wrong. Perhaps you have an updated version though?


Damien Sturdy(Posted 2007) [#5]
I'll send you my version- I don't think its updated in any special way. If used correctly you can avoid the problem but you will need to track the rotation manually as to avoid Gimbal Lock....


Stevie G(Posted 2007) [#6]
Vorderman,

Align to vector uses quarternions so no gimbal lock. Something like this should work ..

;align X-axis 
tformvector 1,0,0, CARmesh, 0
aligntovector CAMERA, tformedx(), tformedy(), tformedz(), 1, .25
;align z axis
tformvector 0,0,1, CARmesh, 0
aligntovector CAMERA, tformedx(), tformedy(), tformedz(), 3, .25


You may only need Pitch and Roll axes.

[EDIT] So you've found some motivation at long last!!! Don't I know this feeling.

Stevie


Vorderman(Posted 2007) [#7]
Thanks guys. Stevie, that version looks reasonably easy to test so I'll give it a go.

I've found a bit more motivation because I've finally found a look I'm happy with for the tracks. I've also decided to try out spline-based AI cars rather than physics ones in an attempt to get back to my original idea of having 8 cars on track at once.


Vorderman(Posted 2007) [#8]
Stevie - that works perfectly cheers - for the first time the camera is under control around the loop, makes it much easier to drive.


Stevie G(Posted 2007) [#9]
Give us a demo then?! ;) Even a wee video would be good.