Best way to store 3d objects data?(polys)
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
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
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
Popular Topics
Advertisement