Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


VertexArrays and Octrees (screenshots included)

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

I''m having some issues with my octree coupled with my indexed vertex array. First, I create an indexed vertex array (one implemented with GL_TRIANGLE_STRIP and another with GL_TRIANGLES), and am able to render this easily with glDrawElements(). A screenshot of this is at: http://www.websamba.com/ichor/array_by_itself.jpg However, when I go from the large vertex array to the smaller vertex arrays in an octree, all the triangles are screwed up. A screenshot here: http://www.websamba.com/ichor/array_in_octree.jpg Now, since I''ve done the same steps using GL_TRIANGLE_STRIPS and GL_TRIANGLES, I''ve come to realize that the problem is with the octee (rather than the shared vertices in the STRIPS.) So, without posting all the code (the octree code I created is quite large...), here''s what''s going on when I call createNode()... 1. I set the width, center, minBounds, and maxBounds in the node. 2. If the number of vertices in that node is larger than my set number, I start the major process...first, setting hasChildren to true. (This pretty much only comes into play for my render function.) 3. I go through each vertex in the vertex array, and allocate memory for the 8 smaller arrays that the node is being split into. 4. I have an "if" for each possible (8) nodes to be created; if the node has memory allocated for it, then I create a new node (now a child node.) 5. This is where I _think_ something is getting all screwed up. I cycle through all the vertices again, and depending on the coordinates of the vertex, I assign it to one of the children nodes, and immediately thereafter, I assign the index for that node. Example:
octreeNodes[TOP_LEFT_BACK]->nodeVertArray.verts[tlb] = vertArray.verts[h];
octreeNodes[TOP_LEFT_BACK]->nodeVertArray.indices[tlb] = tlb;
6. After that, I calculate the node, min/maxBounds of the node, and call createNode() again with this new information. Not the nicest of coding, but here''s an example:
octreeNodes[TOP_LEFT_FRONT]->nodeCenter = getNodeCenter(octreeNodes[TOP_LEFT_FRONT]->nodeVertArray);
octreeNodes[TOP_LEFT_FRONT]->maxBounds = getMaxBounds(octreeNodes[TOP_LEFT_FRONT]->nodeVertArray);
octreeNodes[TOP_LEFT_FRONT]->minBounds = getMinBounds(octreeNodes[TOP_LEFT_FRONT]->nodeVertArray); 
And that''s it. And the result doesn''t work. What am I doing wrong? Should I be traversing through my vertices in INDEXED order, rather than 0-n? I''ve been at this a while and can''t figure it out...

Share this post

Link to post
Share on other sites

  • 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!