MultiTexture QuadTree and vertex data
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.VertexCount, pAttribRange.FaceStart*3, pAttribRange.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. </i>
quote: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.
e.g.
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
-LOOP-
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.
Jack
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?
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement