Jump to content
  • Advertisement
Sign in to follow this  
staticVoid2

storing 3d objects

This topic is 3989 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

how are 3d objects usally stored? I was thinking about creating a polyhedron class that stored each vertice of the polyhedron as a 3d point and stored a face subclass that stored pointers/index values to each vertice of that face so the polyhedron would contain an array of vertices and an array of faces, then each polyhedra could have its own buffer for storing the converted 2d vertices, the index values in the faces array should be parallel to the converted 2d vertice buffer array(if that makes sence). but then I thought you could only store three vertices for each face because any 3d polygon that has more than 3 vertices might not be a face. this is just an abstract idea(probaly stupid) but it is all i can think of when it comes to storing a 3d object. I was reading a lot of tutorials that sort of skipped this stage where they would tell you how to convert vertices, points in 3d space then go straight onto polygon fill techniques and bsp trees. does anyone know of any good tutorials about this subject?

Share this post


Link to post
Share on other sites
Advertisement
Different representations suit different needs (e.g., rendering, collision detection, LOD or general mesh manipulation).

It sounds like you want a representation that's suited for rendering, in which case you should use triangles and not general polygons. The model file will usually just store vertices, indices, materials (textures, lighting parameters, etc.) and possibly animation data. It might also store vertices and triangles in "groups", where a group is a collection of triangles that all use the same material.

If this doesn't answer your question, please try to be more specific.

Share this post


Link to post
Share on other sites
well, say for example i wanted to store a cube, so i have 8 vertices and 12 triangle objects which store the index values of the three vertices(in the polyhedra vertice array) of this triangle. then when i convert this object i store each vertices 2d equivelant in the buffer that way i can use the triangles index values to acces the 2d converted point and these would be the points of the polygon for polygon filling. would this be an efficient way of storing the objects?

Share this post


Link to post
Share on other sites
What do you mean by "convert" and "2D equivalent"? Are you talking about projection?

Also, why do you need to use polygons and polyhedras for anything?

Share this post


Link to post
Share on other sites
yes I was talking about the polyhedra's projected points. How would you normally store map data and objects in a 3d environment? every tutorial ive read goes from projecting 3d points in a 2d plane to how to fill 2d polygons. I want to basically create a 3d environment with different 3d objects.

Share this post


Link to post
Share on other sites
Well like I said, I would store vertices and indices.

When you load this data, you have an array of vertices, and an array of triangles (where a triangle is 3 indices into the vertex list). At run-time, you iterate over the triangles, fetch the 3 vertices for a triangle, project them and draw the projected triangle.

Of course, the above description omits many steps (world/view transformation, clipping, backface culling, lighting, texture mapping, rasterization, ...), but it's the basic process (for a wireframe renderer, anyway).

BTW, I should have asked earlier - are you trying to create a software renderer? Because if not, then the 3D API (OpenGL or Direct3D) will take care of the process for you and will also dictate the storage format (well you can store the model data anyway you want, but you'll have to convert it to a format that the 3D API understands).

I'm not sure if that answers your question because I'm still not really sure what you're asking :)

Share this post


Link to post
Share on other sites
It's more of a learning project than anything. I'm trying to understand how directx, opengl etc work. I don't see the point in using api's like directx and opengl if you don't understand how they work, you end up depending on them to much so if they suddenly dissapear - your screwed, which they probaly won't(but you never know).

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!