Archived

This topic is now archived and is closed to further replies.

SceneManagers & Cameras Question.

This topic is 5042 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I got My Scene Manager fully working. At this time I handle cameras (to make things easy think that I can only have a camera in the game) separately from the scene, I mean, when I have to render the scene I first call pActiveCam->Update() and then I render the scene, everything works fine, but what about if I want to attach the camera to a scene object?. I was thinking about it, and I come to the solution that I would need first of all to calculate the Transformation matrix of the camera, then set it as the view matrix, and render everything, but how is the best way to do it is something that I haven´t figure out. I would like to know how people do this, because I don´t know how to do it efficiently. Note: If you don´t understand something from the post let me know and I will try to expres myself better. Thnaks in advance, HexDump.

Share this post


Link to post
Share on other sites
You could start at the camera, run up the scene tree up to the root recursively, then recurse back while stacking / multiplying transform matrices, and finally inverse the whole.

That, or you could run up the scene tree while inversing matrices and multiplying them recursively, then returning the matrix.

Victor Nicollet, INT13 game programmer

Share this post


Link to post
Share on other sites
It''s not clear why attaching the camera to a scene object changes anything or presents a problem. Either way the camera has a position and orientation.

I''m guessing the problem is that your camera''s position and orientation are now relative to the position and orientation of the scene object that it is attached to. You are trying to figure out how to incorporate that into your camera''s update function.

Here is my suggestion: Don''t actually put the camera in the scene, put an object that represents it instead. Then the code might look something like this:

SceneManager sceneManager;
SceneObject boomObject;
SceneObject cameraObject;
...
sceneManager.Add( &boomObject );
sceneManager.Add( &cameraObject );
boomObject.Attach( &cameraObject ); // Attach the camera to the boom
...
// Set the position and orientation of the camera based on the camera object
Transform t = cameraObject.GetPositionAndOrientation();
pActiveCamera->SetPositionAndOrientation( t );
pActiveCamera->Update();
// Render the scene now
...

Share this post


Link to post
Share on other sites
Well John, this is not the problem. The thing is that every frame I need the Camera updated, in order to do things like don´t update nodes not in the view, etc... And the question is how to get this efficiently. ToohrVyk posted an answer but I think it is a bit rude (sorry dude, I could be wrong), so I´m asking about ways to do this efficiently.

Note: My nodes have the relative transformation matrix from its parent.


Thanks in advance,
HexDump.

Share this post


Link to post
Share on other sites