I am trying to understand how I could create and parse my object (which will be turned into a binary format, for this example). I am not entirely sure what this relationship is called, nor what GoF pattern I would use appropriately to build said object (builder, factory, abstract factory..?)
Here is an example of my problem. The critical example is my car analogy.
/*
* class 'Model' would essentially be the main object for my binary format (for our sake, let's refer to this by its pseudoextension: '.gm'
* It is completely dependent on having Geometry, but Collision and Lights are optional.
*
* Essentially, models are dependent on having X objects, and those X objects are completely dependent on having a Model object (needs a parent).
*
* Think of it like a car. You need an engine to have a car. Without an engine, your car is useless. On the other hand, if you have an engine without a car, it is also useless.
* However, this engine can be put in a car to be made useful.
*/
class Model {
const char *name;
Geometry *geometries[16];
Collision *collision;
Light *lights[16];
}
/*
* This class is essentially just a Vertex and Index buffer. On its own, it is useless. It needs to be encapsulated by a 'Model' to have a purpose.
*/
class Geometry {
VertexBuffer *vertexBuffer;
IndexBuffer *indexBuffer;
unsigned int VertexMask;
// ...
}
/*
* Like geometry, it is also useless on its own.
*/
class Collision {
// ...
}
/*
* Like geometry, it is also useless on its own.
*/
class Light {
// ...
}
Thanks.
Aucun commentaire:
Enregistrer un commentaire