triangles in directx

Started by
4 comments, last by ItsDoh 17 years, 11 months ago
Direct3d creates triangles to draw render shapes as well as textures. struct Vertex { float x, y, z; float tu, tv; }; Vertex g_Vertices[] = { {-1.0f, 1.0f, 0.0f, 0.0f,0.0f }, { 1.0f, 1.0f, 0.0f, 1.0f,0.0f }, {-1.0f,-1.0f, 0.0f, 0.0f,1.0f } }; q)Why is there 2 sets of coordinated x,y,z and tu,tv as this seems doing things twice. 1 set is in 3d and other is in 2d q) can the tu,tv be in other coordinates apart from 1 to -1, what about a scale of 1-100 q) can you create more than 3,4 vertices at once eg 5 sided figure with however many vertices or do you need to just specifiy a whole lot of ditinct truangles.
Advertisement
Quote:Original post by jagguy
q)Why is there 2 sets of coordinated x,y,z and tu,tv as this seems doing things twice. 1 set is in 3d and other is in 2d


Because texture coordinates can be anything, they do not have to correspond with the X, Y or Z of the vertex.

Quote:Original post by jagguy
q) can the tu,tv be in other coordinates apart from 1 to -1, what about a scale of 1-100


It can be any scale you want as long as your video card supports it. A common example of scaling would be a wall that is very long, but uses short texture. Say you want to draw the wall texture 5 times horizontally, it is cheaper to scale it by setting the Tu coordinates to (0,5) and draw one quad than drawing 5 quads set to (0,1).

Quote:Original post by jagguy
q) can you create more than 3,4 vertices at once eg 5 sided figure with however many vertices or do you need to just specifiy a whole lot of ditinct truangles.


No D3D will not split polygons into triangles for you, although there are other primitive types like TriangleStrip and TriangleFan that you could use for convex polygons. If you want to eliminate shared vertices you may want to use an index buffer.

Note: "Quad" refers to two triangles used to represent a 4 sided shape.
so a pentagon shape would compries of 3 triangles

q) What about a wire frame where some lines are not shown, so you can see a polygon without the lines drawn in between the shape and the color shaded in.
a note:

texture coordinates u and v are usually a number between 0 and 1. If I make a texture for a plane, I might make 1 image that has images of the wing, fuselage, wheels, etc all over the image. Then I map the different polys in a model to the different parts of the image.

The coordiantes will then be between 0 and 1, and by that I don't depend on a particular resolution of the image. It even makes easier to make different versions of the texture, depending on how good the texture need to be, and what details you need.

Recommend a tutorial by "andy pike", he had a good dx 8 tutorial that uncovered these fancy details. And I also recommend learning 3D modeling, so you get a better understanding of the different parts of a model, and how to use them.
learning3d modelling is a good idea for sure. After I can move a few objects around in direct3D then i will do that.

I think the thing i am picking up is that 3d objects on the screen are pre-created (eg mesh). You don't create these objects on the fly in the program.

The UV points are usedto specify an object on a 2d surface and the xyz points are used for a 3d world, is this right?

[Edited by - jagguy on May 21, 2006 9:45:01 PM]
No, the UV points specify the texture coordinates and have nothing do to with the object's position.

This topic is closed to new replies.

Advertisement