Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working with a group of people from around the world to create a game engine (and hopefully a game with it) within the next upcoming years. My first task is to write a camera class for the engine to use in order to add cameras to the scene, with position and follow points.

The problem I have is with using matrices for transformations in the class, should I keep matrices separate to each class? Such as have the model matrix in the model class, camera matrix in the camera class, or have all matrices placed in one class/chuck? I could see pros and cons for each method, but I wanted to hear some input form a more professional standpoint.

share|improve this question
well camera should have view and projection matrix and something that has a model on it should have world matrix – Kikaimaru Nov 24 '12 at 23:51
I wonder what would be the pros of shoving everything in the same class. – Laurent Couvidou Nov 28 '12 at 16:51

The camera class should contain & maintain the view and projection matrices.

Each entity (as opposed to each model, several entities can share a model) will contain (or more commonly generate) it's own world matrix.

share|improve this answer

Have a matrix class that can be utilized by all the other classes. There's no point in duplicating code. You want to keep that to a minimum.

If you're talking about having the actual initialized matrices stored in a central location, don't do that. Keep the instantiated matrices with the classes that use them. This would get very confusing to have them separate. Try to stick to object oriented design. For example the camera is an object that owns its own data values, like its matrices.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.