A question about polygons.
Blitz3D Forums/Blitz3D Beginners Area/A question about polygons.
| ||
We all know that a triangle has three corners and a square, and rectangle both share four corners. So does this mean a triangle shape would use three polygons and a square or rectangle would use four polygons in a video game? Oh, and how does this differiniate from using textures on a triangle or a square? Thanks in advice. Sorry for the amaturish question. You uber elitists. |
| ||
A triangle uses one polygon (a triangular polygon). A square (or rectangle) uses two triangular polygons. A triangle has 3 UV coordinates to define how the texture is mapped, whereas a rectangle has 4 UV coords instead. Hope this helps. |
| ||
A square (or rectangle) uses two triangular polygons. When it is drawn by the GPU, yes, but until that point you can consider a square or rectangle to be a polygon. If you don't, then there's no sense differentiating between "triangle" and "polygon." |
| ||
How much memory does one polygon use? |
| ||
If it has it's own surface: a lot. If it's part of a big mesh: not a lot. There's a Triangle, that's made of 3 Vertices (3*1 Vertex= 3 Vertices, not vertexes). A Quad may be made of Two Triangles. 2 of the 3 Vertices of both Triangles may be shared Vertices, used by both triangles. So the Quad would have 4 Vertices total. But you could also make a Quad with 6 unshared Vertices, 3 for each triangle. However, each Vertex has UV Coordinates. Basicly U and V represent its position on the Texture (0.0 to 1.0 while U is X and V is Y). There is also W (Z) but this is only reserved for future options and has no effect. Values higher than 1.0 will result in tiling of the texture. Using values from 0.0 to 1.0 allows to replace a 256*256 texture by a 512*512 texture. The UVs don't care about the real size of the texture since they're proportional. However you should use textures that have a width and height of power-of-two numbers: 2,4,8,16,32,64,128,256,512,1024. Width and height don't has to be the same. Each Vertex can have a second UV pair that can be used with an additional texture that will be blended with the main texture (usually with a lightmap). |
| ||
*gets confused* |
| ||
"Jono" - if you are doing vertex stuff, you can take a look at this - I never finished it: http://www.blitzbasic.com/logs/userlog.php?user=6822&log=379 It may or may not help - I haven't looked at it for ages - don't think I did texturing examples. ps - you have to read it from bottom to top - not top to bottom (it's the way the Worklogs work). |
| ||
Jono - I am not sure you have a clear understanding of the difference between vertices and polygons given you state: "We all know that a triangle has three corners and a square, and rectangle both share four corners. So does this mean a triangle shape would use three polygons and a square or rectangle would use four polygons in a video game? " Each corner of a triangle and rectangle is called a vertex. Multiple corners are called vertices. The 2d "shape" itself - triangle, square, rectangle, (hexagons, octagons, parallelograms etc) is a polygon. Think of a polygon as a shape which is created by joining a set of 'dots' together with straight lines - like a triangle, or square. The simplest polygon that you can make is a triangle - it uses 3 vertices. A square/rectangle uses 2 polygons - think of joining two triangles together to form a square/rectangle. |
| ||
See if this helps.Graphics3D 640,480,16,2 SetBuffer BackBuffer() Camera=CreateCamera() PositionEntity camera,0,0,-5 ;Create Square with 4 vertices and 2 triangles. Mesh1=CreateMesh() surface=CreateSurface(mesh1) Vertex0=AddVertex(surface,-1,+1,0) Vertex1=AddVertex(surface,+1,+1,0) Vertex2=AddVertex(surface,+1,-1,0) Vertex3=AddVertex(surface,-1,-1,0) AddTriangle surface,vertex0,vertex1,vertex2 AddTriangle surface,vertex0,vertex2,vertex3 EntityColor Mesh1,255,0,0 ;Create Square with 6 vertices and 2 triangles. Mesh2=CreateMesh() surface=CreateSurface(mesh2) Vertex0=AddVertex(surface,-1,+1,0) Vertex1=AddVertex(surface,+1,+1,0) Vertex2=AddVertex(surface,+1,-1,0) Vertex3=AddVertex(surface,-1,+1,0) Vertex4=AddVertex(surface,+1,-1,0) Vertex5=AddVertex(surface,-1,-1,0) AddTriangle surface,vertex0,vertex1,vertex2 AddTriangle surface,vertex3,vertex4,vertex5 EntityColor Mesh2,0,255,0 ;Now move them to left & right so we can see them. PositionEntity Mesh1,-2,0,0 PositionEntity Mesh2,+2,0,0 Repeat If KeyHit(57) wire=1-wire WireFrame wire RenderWorld Text 10,10,"Press SpaceBar to See wire frame outline. Text 10,30,"Press esc to exit" Flip Until KeyHit(1) End To answer your question, 3 vertices per triangle. One square(quad) can uses 4 or 6 vertices ,depending on there use.Most commonly it would be 4.Made up of.... 4 vertices \ 2 triangles \ 1 surface(your texture) |