Sign in to follow this  
derek7

many object

Recommended Posts

if I have a skinmesh class,and the class have a mesh data member and other data. I instance many the class,so I have many objects.but I want just a mesh in many object. I mean a class just a mesh. because it is waster for a instance there is a mesh copy. so now I make the mesh data member static .so Are there other way to do?

Share this post


Link to post
Share on other sites
Yes, there are other ways and moreover your suggested way will not work. Making the mesh data static means the data is the same for all meshes. So effectively you will be left with precisely one mesh.

The other way is by separating mesh data from a mesh instance. The mesh data holds the vertices, faces, textures, etc. The mesh instance holds a reference to mesh data and, additionally, a position.

You would get something like this:

class CMeshData
{
protected:

vertices
faces
textures

loadfromfile()
};

class CMeshInstance
{
protected:

position
mesh data

render()
};


This way, several mesh instances can refer to the same data. The data will thus be stored just once per mesh. This scheme should be changed a little to deal with instance-specific mesh data like lightmaps.

Greetz,

Illco

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