Original Post
I''ve started a new project where I now have a system where I can do something like:
CMObject Cube;
Cube.setup(data);
The problem is when I create an array of cubes they will all have their own instance of vertex/index data but I think that''s a waste of memmory.
So I thought it would be nice to have something like this:
CMesh *Cube = new Cube[10];
And this 10 cubes would share their vertex/index data but would have their own data like if they are visible, position and all the other data an object would have on its own.
I thougt I could overload the new operator to achieve this but I noticed that if I overloaded the new operator I coulnd''t do something like this:
void *CObject::operator new[](size_t sizeo)
{
Mesh = new CMesh();
position = new CPosition[size]
return 0;
}
I thought I could do it so that all the objects would have an position of their own(the positon array) and share their mesh data but C++ doesn''t allow it to acces non-static data from a overloaded new function.
Is there anything I can do to make this work? Maybe someone has another idea how I could share data between different objects?
Thnx for your help