Jump to content
  • Advertisement
Sign in to follow this  

Reusable Mesh in DX10

This topic is 2785 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

class Mesh : public INode
ID3D10Device* m_pD3DDevice;

ID3D10Buffer* m_pVertexBuffer;
ID3D10Buffer* m_pIndexBuffer;

D3D10_TECHNIQUE_DESC m_techDesc;

//input layout and mesh
ID3D10InputLayout* m_pVertexLayout;

//effects and techniques
ID3D10Effect* m_pBasicEffect;
ID3D10EffectTechnique* m_pBasicTechnique;

//Shader Resource View Variable
ID3D10ShaderResourceView* m_pTextureSRV;

//effect variable pointers
ID3D10EffectShaderResourceVariable* m_pTexutreEffectSRV;

//Vertex and Index Buffer
std::vector<sCustomVertex> m_Vertices;
std::vector<unsigned int> m_Indices;

//Vertex and Index Count
int m_iVertexCount;
int m_iIndexCount;

//Shader Path
WCHAR* m_pShaderPath;

//Texture Path
WCHAR* m_pTexturePath;
char* m_TechniqueName;

ThreadBufferManager* m_pThreadBufferManager;

//Object Culling
bool m_bIsCulled;

ID3D10EffectMatrixVariable* m_pWorldViewProjectionMatrixEffectVariable;
ID3D10EffectMatrixVariable* m_fxWorldVariable;
ID3D10EffectMatrixVariable* m_fxLightRotation;
ID3D10EffectVariable* m_fxEyePosVar;
ID3D10EffectVariable* m_fxLightVar;
ID3D10EffectScalarVariable* m_fxLightType;

ID3D10Device* GetMeshDevice() { return m_pD3DDevice; }
void SetMeshDevice(ID3D10Device* device) { m_pD3DDevice = device; }
void SetShaderPath(WCHAR *pFilename) { m_pShaderPath = pFilename; }
void SetTexturePath(WCHAR *pFilename) { m_pTexturePath = pFilename; }
void SetTechnique(char* technique) { m_TechniqueName = technique; }
void SetCulling(bool bCull) { m_bIsCulled = bCull; }

virtual void CreateVertexIndexBuffer();
virtual void CreatePhysxShape();
virtual bool Initialize();
virtual void Update(float dt);
virtual bool Render(int a_iExecID);
virtual bool LoadShadersAndCreateInputLayouts();
virtual bool SetTextureForShaders(unsigned int uiIndex);

This is my Mesh Class. The following classes will inherit this class

* MeshCube
* MeshGrid
* MeshCylinder
* MeshSphere

In the Create function(virtual function) i procedurally create shapes. For me, if i instance 100 cubes, 100 spheres, 100 grids, it goes into Create function 100 times and create the vertices and indices 100 times. what should i do if i want to create the Vertices and Indices only once for every object. One way which i thought is to take the variable 'm_Vertices' and 'm_Indices' to every other class and make them static, so it declares only once...

Kindly suggest me if there is any other better method. A better method could really lower my loading time.

Share this post

Link to post
Share on other sites
It would be far clever to split the mesh instance from the mesh geometry.

The mesh instance keep the world matrix, the visibility status, a reference to the geometry and things that really belong to the instance, and the geometry keep the vertices, the material and things that are common to every instance!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!