Jump to content
  • Advertisement
Sign in to follow this  
Halsafar

Number of Primitves on a dome

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

Okay, using triangle strips and running a for..for..loop through phi and theta I simply calculate 4 vertices each iteration of the inner theta loop. Well, I thought I was calculating the primitives properly, but it seems as I increase the num primitves used to a DP call DX Debug aint complaining and new rows of triangles are being added to the dome... So how do I determine how many primitives there is going to be?

Share this post


Link to post
Share on other sites
Advertisement
I don't quite understand - you say DX isn't complaining and new triangles are being added - isn't that what you want?

Maybe you mean to ask how many triangles the dome will contain all together?

Screenshots say a 1000 words. (Try http://www.imageshack.us if you don't have a host).

Share this post


Link to post
Share on other sites
Nah Nah, its the DrawPrimitive(TRIANGLE_STRIP, 0, numPrimitives)
Now I use a routine to fill up the vertices for the dome but I gotta formulate a way to count the number of vertices.

See at first I figured for every 4 vertices I'd have 2 primitives... But that is not enough.

See DX Debug mode will complain the second you try and render even 1 primitive past the number of vertices allocated in the buffer.

I just keep increasing the number till it complains, a lot of trial and error and I was able to get the actual number.... but that took almost an hour... There has to be a way to derive the number of TRIANGLE_SRIPS in the dome.

Share this post


Link to post
Share on other sites
Yeah I'd agree with that...but anyway...

So you are using strips not lists (which would be too easy!). The easy way to view a dome is a set of cylinders on top of each other, but distorted so the top of each cylinder is narrower than the bottom. The top of the dome would be a triangle fan though.

If you have a 'cylinder' with N sides then you have 2 circles each with N vertices, and you render N quads. So in total you have 2N triangles, and there are 2N vertices (I assume you are not using index buffers yet?)

If every 'cylinder has the same number of sides then it's easy except at the top of the dome. Here you have 1 point at the top and N forming a circle. So that's N+1 vertices, and you draw N triangles.

So if your dome has M 'layers', plus the vertex at the top, then you have M-1 'cylinders' each with 2N vertices, and one fan with N+1 vertices.

Total vertices = (M-1)*2N + (N+1).

You want to check my math on a simple case - say using N=4 and M=2.

Share this post


Link to post
Share on other sites
Yes well I dummed the calculation of the number of vertices down to:
DWORD dwNumVertices = (int)((360 / dtheta) * (90 / dphi) * 4);

dtheta and dphi are used to increase or decrease tesselation and obviously have to be numbers which divide equally into 360 and 90.


Now, with that said, the number of vertices != the number primitives.

So I am still at a loss.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!