# Number of Primitves on a dome

This topic is 4962 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 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 on other sites
fogive me if i misunderstand, but... count them as you generate them.

##### 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 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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634131
• Total Posts
3015725
×