Sign in to follow this  
miyagison

How would you write a DirectX Model Class?

Recommended Posts

Since there have been no replies to this post I will rephrase my question... and insert code into this post.. Is this a decent DirectX model class? Are there any changes you( the reader ) would make to it? // Utility Class -> Float+Matrices -> Position Scale Rotation class uPosScaRot{ public: enum SetValues{ Position, Scale, Rotation, PositionIncrements, RotationIncrements }; uPosScaRot(); ~uPosScaRot(); void UpdateMatrices(); void SetValue( SetValues value, float x, float y, float z ); void SetAutoIncrement( bool value ){ this->AutoIncrementValues = value; } D3DXMATRIX & GetWorldMatrix(); // Update Matrices private: D3DVECTOR vPos, vScale, vRot; // Vector Values for Pos Scale and Rotation D3DVECTOR vAPos, vARot; // Values for auto incrementing Position and scale D3DXMATRIX mPos, mScale; // Position and Scale Matrices D3DXMATRIX mRotX, mRotY, mRotZ; // Rotation Matrices D3DXMATRIX mMulWorld; // PreCalculated World Matrix bool AutoIncrementValues; // Auto Incrementing of Position and Rotation Values for unattended // manipulations }; // Utility -> Model Class derived from the matrix position/rotation/scale class class uModel : public uPosScaRot { public: uModel(cGfx * GfxClass); ~uModel(void); HRESULT LoadMesh( LPCWSTR meshName );// Load Mesh and textures from a file void Render(); private: cGfx* cGfxDev; // Our Graphics Class LPD3DXMESH g_pMesh; // Our mesh object in sysmem D3DMATERIAL9* g_pMeshMaterials; // Materials for our mesh LPDIRECT3DTEXTURE9* g_pMeshTextures; // Textures for our mesh DWORD g_dwNumMaterials; // Number of mesh materials }; [Edited by - miyagison on March 14, 2010 6:47:23 PM]

Share this post


Link to post
Share on other sites
First of all, use 'source' tags for the code.

Regarding the design, it all depends on what you want to do with it. I'd suggest you start with something that works, use it, see what it's missing, and then redesign it.

If you want you can take a look at some open source graphics engines like Ogre, to get an idea how they've designed things.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this