Sure.
SYM_GEOMETRY is a base class for all renderables, it contains a *Mesh, Position and Rotation vectors, and functions for transformation and setting Mass, Velocity, etc.
SYM_MODEL is derived from the Geometry class, and contains just a Load() function for my proprietary format. Here is the Load():
bool SYM_MODEL::Load(string ModelName, string Filename) { //Load mesh from resource manager Mesh = Engine->ResourceManager.Meshes.Get(Filename); //Check for errors if(!Mesh) return false; //Set name Name = ModelName; //New physics body PhysicsBody = new SYM_PHYSICSBODY; //Create physics body from AABB PhysicsBody->CreateBox(Mesh->AABB.Size); //Set physics geometry PhysicsBody->SetGeometry(dynamic_cast<SYM_GEOMETRY*>(this)); return true; }
SYM_BRUSH is derived from the Geometry class, and contains functions to create default geometry objects using the *Mesh. Here is the constructor:
SYM_BRUSH::SYM_BRUSH(string BrushName, int GeomType, SYM_VECTOR3 Dimentions, SYM_VECTOR3 Pos) { //Create new mesh Mesh = new SYM_MESH; //Create new mesh subset MeshSubset = new SYM_MESHSUBSET; //Switch type switch(GeomType) { case SYM_BOX: //Create a box break; case SYM_PLANE: //Create a plane //Mesh->CreatePlane(Dimentions); //Create geometry CreatePlane(Dimentions); break; case SYM_CYLINDER: //Create a cylinder break; case SYM_SPHERE: //Create a sphere break; default: return; } //Process vertex/face data MeshSubset->Process(); //Add subset to mesh Mesh->Subsets.push_back(*MeshSubset); //Set name Name = BrushName; //New physics body PhysicsBody = new SYM_PHYSICSBODY; //Setup collision body PhysicsBody->CreateCustom(Mesh->Subsets[0].Vertices, Mesh->Subsets[0].Faces); //Set physics geometry PhysicsBody->SetGeometry(dynamic_cast<SYM_GEOMETRY*>(this)); //Set position SetPosition(Pos); }
Those are the only objects that contain a NewtonBody, and both make sure to call SetGeometry().
I've tested the dynamic_cast from Model/Brush to the base class, they work fine. I've also cout-ed a few geometry details in SetGeometry() to make sure the pointer is valid, and it's fine.