Jump to content
  • Advertisement
Sign in to follow this  

Triangle Strip Vertices

This topic is 3895 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 am doing some work with triangle strips and using them to create a billboard. If you look at this page it shows you a sample of how to create them: http://msdn2.microsoft.com/en-us/library/bb206274.aspx You need to specify the vertices for the strip like so: code: CUSTOMVERTEX Vertices[] = { {-2.0, 1.0, 0.0}, {-2.0, -1.0, 0.0}, {2.0, 1.0, 0.0}, {2.0, -1.0, 0.0} }; Anyway I am now sure how these values map to pixels or world space coordinates. For instance if I have a texture that I want to put on my billboard that is 200x100 pixels, what vertex values do I use so that the size is appropriate and the texture that is on the billboard is not squished or stretched out? I am really confused how they relate to each other. :(

Share this post

Link to post
Share on other sites
Well, it sounds like you're trying to make a sprite.

Are you working in 2d or 3d?
It looks like you're working in 2d.

There are already existing sprite classes...

But anyway...

So picture this:

| |
| |
| |

Say that's your rectangle.

The top left corner is whatever the top left vertex is set to - in your case (-2, 1)

Now, you have your vertices in the wrong order, too, by the looks of it.
(clockwise order)

-2.0, 1.0
2.0, 1.0
-2.0, -1.0
2.0, -1.0

That, I believe, is the correct order.

Each vertex represents a point in your quad (a quad is simply 2 triangles making a rectangular shape).

Standard Cartesian coordinates.

Now, how this will map to screen coordinates is up to the rest of your code.

But most likely this won't work for what you have :P

Are you using RHW projection (XYZRHW)?
Or XYZ with an Orthogonal projection?

Also you really should use the existing sprite helper... ID3DXSPRITE

If you give me some more information I can stop poking at straws and help you out easier :)

Share this post

Link to post
Share on other sites
Thanks! What I am really trying to do is dynamically create a texture and render it to a billboard with some text. This is in a 3D environment. I think I am using Orthogonal projection (I'm a noob).

So my problem is that I create a texture dynamically and render some text to it, but I am confused as to how to relate the texture size to the vertex coordinates.

If I create a texture that is 200x100 pixels then just set the vertex points to 2 and 1, then the billboard is waaay too small and the text is scrunched up. If I bump it up to values of 8 and 4 the texts looks good and like it should. I am wondering how I can come up with the billboard (triangle strips) vertex values on the fly without eyeballing it to get it to look right.

Share this post

Link to post
Share on other sites

Step 1 is to create the billboard the size that you want it - this is completely non-related to the texture - just make the billboard the right size for where you're going to put it.

Step 2 is to create the texture - once again, completely non-related to the billboard.

Step 3 is to put the texture on the quad, mapping the corners of the texture tot he corners of the image in the texture. This is the only step that you have to combine the 2 things :)

Also, you said you're working in 3d (not 2d)?
That means you'll be using perspective, not orgotgonal (ortho is for 2d).

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.

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!