Camera pains
Blitz3D Forums/Blitz3D Programming/Camera pains
| ||
One of the hideous side-effects with rotating cameras is the gradual increase in Roll that twists the camera. If you want a camera at a distance from an object to rotate around that object, viewing it from different angles, things can get messy. I've got round this by creating a pivot system. I have two rostrums, one for Pan and one for Tilt, and parent the camera to the tilt rostrum... CreatePivot(rostrum_pan) CreatePivot(rostrum_tile, rostrum_pan) CreateCamera(cam, rostrum_tilt) PositionEntity cam,0,0,300 Using the mouse I read x movement as a turn in rostrum_pan's y axis, and y movement as a turn in rostrum_tilt's x axis... TurnEntity rostrum_pan,0,mouse\speedx / 5.0,0 TurnEntity rostrum_tilt,mouse\speedy / 5.0,0,0 Wonderfully nicely, the camera can be turned around an object, viewing it from different directions while keeping the camera level with the floor. What I want to do now is have the camera turn to face a different object when that object is selected, and here my grand schemes fall down. If I just move the rostrum_pan pivot to the new object, the whole camera structure is translated. What I want is for the camera to stay in place, move the pivots to the target object, and turn the camera to face the object. Then when I turn the camera the camera moves around the object without twistig. Ugh! It's not straightforward. I've tried various experiments but can't get it. As I understand it I need to 1) de-parent the camera 2) move rostrum_pan to the new object's location 3) turn rostrum_pan on the y_axis to be aligned with the camera's horizontal position 4) turn rostrum_pan on it's x_axis to be aligned with the camera's vertical position 5) point the camera to look at rostrum_pan 6) reparent camera to rostrum_tilt The end result is that camera's local coords relative to it's parent are 0,0,camera_distance, and moving the mouse uses TurnEntity rostrum_pan,0,mouse\speedx / 5.0,0 TurnEntity rostrum_tilt,mouse\speedy / 5.0,0,0 to turn the camera about the selected object in the x and y axis without any rolling. I'd have thought there'd be a camera lib for this in the Archives but I haven't found one. Can anyone help get this working? It'd also be really nice to have the movement between selected objects as smooth, so the rostrum_pan moves over to the selected object with the camera following it's movements, but still not rolling around when rotated. |
| ||
Problem solved : Using the Global flag of the turn entity helps! |