Jump to content
  • Advertisement
Sign in to follow this  

Organizing Vertices into multiple objects

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

Hello all, I think I've finally hit the hump. I've gone through the basic tutorials of camera systems, spinning cubes, textured cubes, lighting, and many more. I'm fairly confident with making a class to store an objects data in, but I don't quite know how to extract the right data and keep track of it all. Here's what I'd like to learn: 1.) Make an object class 2.) Store the objects vertices in some array 3.) Extract each vertice into multiple objects and manipulate them. I'm not exactly sure what I should be searching for. Entity system, object management, object structures? If I'm being too vague, I'll try to elaborate. Thanks, Mike

Share this post

Link to post
Share on other sites
Hmm, so this is how I see the basic process, please correct me if I'm wrong.

Here's some pseudo code/my thinking process.

1.) I make a triangle using the GlVertex commands.
2.) I store the vertices used to make the triangle in a vertex array using glDrawArray and then GlDrawElements(to clean up the shared verts)
3.) I store the id of the GlDrawArray(or GLDrawElements) into my object class.
4.) Now, I have an object I can refrence by an ID.
5.) Whenever I want to manipulate the vertices, I can then use some kind of for/next loop to go through every vertices in my GlDrawArray and move it accordingly.

1.)Does this process sound right? 2.) Most importantly though, will this work as a way to manipulate my objects around in my games? 3.) What are disadvantages/advantages to moving all these vertices around.

I'm sorry if I have lots of questions, please let me know if I need to explain more clearly.

Share this post

Link to post
Share on other sites
Aye, it sounds valid... if I may though, the following was how I was taught. I suppose the actual details of it are up to you... I don't actually know which is more efficient.

Let's say we have access to a high level language like Java or C++. In those, you can get quick in-order access to contents of certain data structures (most notably, linked lists).

You can use a linked list to store pointers to vector Objects, and then use a for...next loop to iterate throgh the linked list. Here's a pseudocode example:

Begin DrawnObject_Initialization()
(fill a linked list with Vectors from a file, or hard-coded if you like here)
End DrawnObject_Initialization

Begin Draw()
for each vector in linked list
glVertex3d(vector.x, vector.y, vector.z)
next vector
End Draw

(I'm forgetting the function names itself right now, but you probably get the idea) Anyways, as you can see above, you tell OpenGL to begin drawing triangles, then give it the vertexes in the order that they appear in the linked list, then tell OpenGL to stop accepting vertexes.

Hopefully that helps! I've never done it your way, so I'm not sure which is better... perhaps someone can give a definitive answer to what's more efficient/quick.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!