Archived

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

Drawing Verticies

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

using the following verticies I should display a square unfortuntly I get a triangle does any one know what the problem is? Vertex #1: (mm) (281648.5023, 98353.3266, 17430.5600) Vertex #2: (mm) (283402.6170, 98353.3266, 17430.5600) Vertex #3: (mm) (283402.6170, 100272.9238, 17430.5600) Vertex #4: (mm) (281648.5023, 100272.9238, 17430.5600) Vertex #5: (mm) (281648.5023, 98353.3266, 17430.5600) the following is used to draw the square g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, (iNumVert-2) );

Share this post


Link to post
Share on other sites
Your points are as such :


4 --- 3
| |
| |
| |
1&5 --- 2


You will first draw 123. This is in trigonometrical order, which in directX will count as a back face. This triangle will not be visible on this side.

Then, you will draw 234. This face is in trigonometrical order, but the backface order changes with each face in trianglestrip mode, so this triangle will be visible on this side.

Finally, you will draw 345. This face is in trigonometrical order, again, so it's a backface this time. This triangle will not be visible on this side.

Diagnosis : you are rendering 3 triangles (only 2 are needed for a square) out of which only one is visible on this side (the two others are on the other side, where they DO form a square).

Edit : solution : render in the order 2134

ToohrVyk



[edited by - ToohrVyk on July 6, 2003 2:50:55 PM]

Share this post


Link to post
Share on other sites
the problem is I have thousands of these
is there a way I can just give directx the list of verticie and get it to generate the shape for me?

Some shapes have 8 or 9 points

[edited by - Rizo on July 6, 2003 3:07:57 PM]

Share this post


Link to post
Share on other sites
If you want to just generate a shape by giving the vertices in a clockwise order, just list them and use a triangle fan.

EDIT : yay, this was my 400th post!

[edited by - ToohrVyk on July 6, 2003 3:35:44 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The data is a polygon outline. Assuming the polygons are convex, you can hand each of them to OpenGL as a GL_TRIANGLE_FAN. I believe Direct3D can draw triangle fans, too.

You don''t actually need to close the fan with the last vertex, issuing vertices 1, 2, 3 and 4 in order for a triangle fan will draw the square you want.

If you don''t know about winding order, you may wish to disable backface culling.

Share this post


Link to post
Share on other sites
guys this problem is getting more complex I''ve now been given the following shape

Vertex #1: (mm) (278658.8473, 99446.6236, 17430.5600)
Vertex #2: (mm) (277926.5305, 97722.1357, 17430.5600)
Vertex #3: (mm) (280572.3202, 97060.6883, 17430.5600)
Vertex #4: (mm) (280714.0589, 97911.1207, 17430.5600)
Vertex #5: (mm) (279840.0034, 97651.2664, 17430.5600)
Vertex #6: (mm) (280950.2901, 98808.7993, 17430.5600)
Vertex #7: (mm) (280572.3202, 99659.2317, 17430.5600)
Vertex #8: (mm) (279084.0635, 100580.5335, 17430.5600)
Vertex #9: (mm) (279414.7872, 99328.5080, 17430.5600)
Vertex #10: (mm) (278469.8623, 100297.0560, 17430.5600)
Vertex #11: (mm) (278658.8473, 99446.6236, 17430.5600)

what is the best way to handle this shape?

Share this post


Link to post
Share on other sites