Base object class

Started by
8 comments, last by Ainokea 19 years, 6 months ago
I am working on a base object class that all my objects in my game inherit from (IE. cars, trees, skybox, etc...). What would go in it? All I have so far is orientation, position, upvector. What else would go in it? [Edited by - Ainokea on September 28, 2004 12:20:00 PM]
______________________________________________________________________________________With the flesh of a cow.
Advertisement
As you've demonstrated yourself a base type called "object" isn't very useful, its ambiguous, the term object means more than one thing depending on the context of use. The only exception i would make is if a type "object" is a root of an instrusive reference counted type hierarchy basically memory management even then i would reconsider to me the type "object" is way to abstract and not a very useful abstraction.
Quote:Original post by snk_kid
As you've demonstrated yourself a base type called "object" isn't very useful, its ambiguous, the term object means more than one thing depending on the context of use. The only exception i would make is if a type "object" is a root of an instrusive reference counted type hierarchy even then i would reconsider to me the type "object" is way to abstract and not a very useful abstraction.

Your probally right.
______________________________________________________________________________________With the flesh of a cow.
I'm going to disagree slightly with snk_kid.

If you have a concise definition of what an "object" is, then it might be useful to implement an Object class (though that is not a great name) and use it as a base class.

If you are thinking of making a base class just to hold variables that are common to several classes, then you are making a big mistake.

In your case, it probably makes sense to have an Object class that represents something that exists in your world and has a position and orientation. Does it make sense to say that an Object class represents something that exists in your world and has a position and orientation and a texture?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
I have to agree with JohnBolton I myself use the class ObjectBase for my base class for all objects in my world.
Ok now my base class also has things such as rotations, and transelations.

EDIT: What might be a better name?
______________________________________________________________________________________With the flesh of a cow.
The emphasis shouldn't be attributes, but rather behaviors. Attributes are a consequence of behaviors.
Keys to success: Ability, ambition and opportunity.
Quote:Original post by JohnBolton
If you have a concise definition of what an "object" is, then it might be useful to implement an Object class (though that is not a great name) and use it as a base class.


Usually there is no concise definition, and the reason why Ainokea started this thread because he's not sure what an "object" is mean't to have. When people say object there are usually refering it to a specific context and there is usually a better terminology.

Quote:Original post by JohnBolton
If you are thinking of making a base class just to hold variables that are common to several classes, then you are making a big mistake.


That is exactly what he's considering to do, and thats what most people tend to do.

Ainokea there is more than one way to model an inheritance relationship, you could consider "state inheritance" for this instead of making this a static relationship as type inheritance implies beside type inhertiance is more about inheriting behaviours, you might wont to read this for better alternative.

[Edited by - snk_kid on September 28, 2004 7:32:43 AM]
What you want to do is probably "Entity", a physically existing object in your coordinate space. It would be more like an interface for entities in your world. If you want it to move often, you may put look/move direction into it, up-direction, and next to them - relative matrix, recomputed every time is is needed. Position, too, of course. It may contain a basic anti-collision system, but that could be too much...

When it comes to #textures, it rather belongs to a render object. An Entity may have a reference(or pointer) to a render object...

Cheers.
/def
I just looked at the OGRE engine and I am going to do what they did. Have a class that takes care of movement only. Thanks for the help.
______________________________________________________________________________________With the flesh of a cow.

This topic is closed to new replies.

Advertisement