• Advertisement

Archived

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

Base class for camera and objects?

This topic is 5060 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

Since the process of rotating a camera is basically the same as rotating any 3D object, is it usually best to make a base class that can handle rotations (using whetever method you choose) and derive the camera and your 3D objects from the same class?

Share this post


Link to post
Share on other sites
Advertisement
I would do exactly that. If your base class has all the main properties that other objects do (such as x, y and z floats) its easier to derive them from one class.

Worship the holy trinity that is Blitz, Babes and Beers!

Share this post


Link to post
Share on other sites
Yes, it''s not a bad approach. Something you may want to consider, if you''re dealing with a fair old number of 3D objects, is using a ''scene graph'' - in this case, a tree of objects. Transformations applied to a node in the tree get ''carried down'' to nodes lower in the tree - and they put their own transformations on top.

Say you want to set the camera to ''see through the eyes'' of a character in your scene. You could set the camera as a child object of that character in the tree, and then whenever you rotate the character around, the camera goes with it. Further on, it applies to things like animation - having fingers as child objects of a hand means that the fingers will rotate with the hand as it moves, but they can also be rotated and moved on their own (skeletal animation).

Share this post


Link to post
Share on other sites
I hadn''t really thought about the scene graph approach, but it makes sense.

If you want to apply the same rotation to several related objects it would simplify the process and it would also be more efficient. You could compute the matrix once and then pass it to all of the objects that are farther down the tree.

Share this post


Link to post
Share on other sites

  • Advertisement