Confused by vertexes and surfaces
Blitz3D Forums/Blitz3D Programming/Confused by vertexes and surfaces
| ||
Hi Could someone expain how to make a cube and then texture one side in a different colour. What I've tried is: cube=CreateCube() surface=GetSurface(cube,CountSurfaces(cube)) ClearSurface surface PositionEntity cube,0,0,5 side1=CreateSurface(cube) AddVertex (side1,0,1,0) AddVertex (side1,0,1,1) AddVertex (side1,1,1,0) AddVertex (side1,1,1,1) AddTriangle(side1,0,1,2) AddTriangle(side1,1,2,3) PaintSurface side1,colour(1) But all I get it a doublesided triangle not a square face. |
| ||
if im reading your code right, the second addtriangle is drawing the triangle in the wrong order, try:addtriangle(side1,2,1,3) But your clearing the whole surface of the cube so u need to rebuild it. |
| ||
Btw, the plural of vertex is "vertices". But I guess vertexes would confuse fewer people. :-) |
| ||
Thanks guys. Why does the order matter, I mean surely it's the same triangle whatever order the vertices in. |
| ||
It matters because it determines what side the triangle will be visible from (face normal) |
| ||
The order matters because the order, clockwise, or counterclockwise, tells the 3D card which way the front of the triangle is pointing. Normally, only triangles which are facing the camera are drawn. This makes rendering go faster, because triangles which face away from the camera are almost always hidden completely behind triangles which face towards the camera, unless your object has missing polygons. So it's for speed. And it's for other stuff too, but that has to do with a lot of complicated math you don't need to worry about. |