🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Best way to store 3d objects data?(polys)

Started by
0 comments, last by VECTOR 24 years ago
I have a number of 3d objects, say 30 of them, each average of 100 polygons. So what would be the easiest way to store them? MS Visual C++ by the way. I was thinking an array-> struct Vertex { x y z u v } struct Poly { info about vertex, texture index } Object [30][100]; but to me that seems a waste of space, because some objects will have maybe 75 polys, leaving me with lots of unused memory. if anyone knows of a very simple way to store these I''d really like to know. Remember, a more or less simple way. It would probably involve pointers too.
The object of war is not to die for your country, but to make the other bastard die for his . . -General MacArthur
Advertisement
Well, an option would be a dynamic array suck as

struct vertex
{
float x, y, z, v;
}

struct poly
{
vertex points[3] <- assumming your using triangles only
texture info ect..
}

struct object
{
int numpolys;
poly *polygons;
any other needed data
}


then when you go to setup the number of polys in your object(wether it be loading from file or whatever) just set the number of vertices, and dyamically allocate the polys such as

object *obj;

object -> numpolys = 75;

object->vertices = new poly [obj->numpolys];

assumming your using c++, if not you can always use malloc/calloc

hope this helps

~ chris

This topic is closed to new replies.

Advertisement