computer controlled observer camera
by Ian Omroth Hardingham · in Torque Game Engine · 03/03/2002 (6:24 am) · 2 replies
Hi.
Say I place the camera at a certain map coordinate facing in a certain direction. Then I want it to move smoothly to another coordinate. Or I want it to pan smoothly to look in another direction.
Can anyone give me some helpful hints in how to do this?
Cheers.
Say I place the camera at a certain map coordinate facing in a certain direction. Then I want it to move smoothly to another coordinate. Or I want it to pan smoothly to look in another direction.
Can anyone give me some helpful hints in how to do this?
Cheers.
#2
03/12/2002 (3:21 am)
Maybe you should have a look at this thread: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2304, it describes how to render different views (e.g. a rear view mirror) and also how to assign views to different objects (e.g. a security camera) - a look into this code should answer all your questions...
Torque 3D Owner Joel Baxter
For example, let's say that you wanted the camera, when in this mode, to move to its next destination point at a given speed while maintaining the same orientation.
In Camera::initPersistFields, you could add a field for the current destination point, so that the scripting can set that. Camera speed (mMovementSpeed) is already exported to the scripting, as the global variable $Camera::movementSpeed. (However it might be better to make it a per-camera member field rather than a global variable.)
In Camera::processTick, the first thing you would do is check to see if the camera is in this new mode of yours, and if so, calculate what its next position should be after another game tick has gone by, using the values for its current position and speed and its destination point. Set delta.pos to the new position, and delta.posVec to the old position minus the new position. If the camera is already at the destination point, you could use Con::executef to call out to a script function that can either set a new destination point or put the camera into a different "just stay here" mode.
That's all very general I know, but it's kind of a general question. :-) Doing this will require getting familiar with a few different aspects of the engine code and the script/engine interaction, but at first glance it doesn't seem like there's anything intrinsically tricky about it.