Jump to content
  • Advertisement


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


MultiTexture QuadTree and vertex data

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

Hi, my levels are made of a single .x mesh file wich contains many different textures and materials, and I''m trying to make a quadtree for optimizing my render. I already managed to divide the world into as many nodes as needed, storing their min and max vector coords. I also alreay assign to each leaf of my quadtree an array of the indices of the faces that are associated to it (meaning if i say to render a node, i have the index of each face that i have to render). The indexes are also ordered by attributes index (all the face''s index of the same material or texture, then all for another one, etc.). Now, what I need is the function to render my quadtree. How can i do this? Do i have to rebuild at each frame a vertex buffer for each material and render it, or could i just use my indices array ? for the indices array, i saw that the DrawIndexedPrimitive function must be calle like the following : m_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, pAttribRange.VertexStart, pAttribRange[i].VertexCount, pAttribRange[i].FaceStart*3, pAttribRange[i].FaceCount ); so, as my vertices are not ordered, i don''t think that it could work (i dont''t have vertex start and a vertex count value). What do you suggest me to render ? Any code would be appreciate. Thanks.

Share this post

Link to post
Share on other sites
what I need is the function to render my quadtree

recursive functions tend to provide very neat and clear solutions to quadtree processing/rendering. Start with that if I were you.

As for what to render, you should do it fine with a list of ordered indicies bucket sorted for texture/material.


Start Quadtree Render
Render QT-A
Render all of texture 1
Render all of texture 2
Render QT-B
Render All of texture 3
Render all of texture 5
Render QT-C
Render all of texture 1
Render all of texture 4
Render QT-D
Render all of texture 1

If you don''t know what order your indicies in, your initial code (NOT your render code) is at fault. Where you extract indicies from the original mesh, you need to devise a better algorithm that picks them out in a proper pattern/order (corresponding to the triangle list for example). Shoving those in a set of list<> or vector<>''s would probably be sufficient.


Share this post

Link to post
Share on other sites
Ok, i did this and it''s working quite good:
for each leaf of my node, i have an array of vertexbuffer (array[0] stores the vertex buffer for the vertices that need to be rendered using material and texture 0, etc.).
But i was wondering if it would''nt be faster that at each frame i build a single verte buffer for each material (just by ''fusioning'' each of them in a single one).

Is it possible to quicker do this?
What do you think about this?

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!