mesh - mesh handle |
Flips all the triangles in a mesh. This is useful for a couple of reasons. Firstly though, it is important to understand a little bit of the theory behind 3D graphics. A 3D triangle is represented by three points; only when these points are presented to the viewer in a clockwise-fashion is the triangle visible. So really, triangles only have one side. Normally, for example in the case of a sphere, a model's triangles face the inside of the model, so it doesn't matter that you can't see them. However, what about if you wanted to use the sphere as a huge sky for your world, i.e. so you only needed to see the inside? In this case you would just use dxFlipMesh. Another use for dxFlipMesh is to make objects two-sided, so you can see them from the inside and outside if you can't already. In this case, you can copy the original mesh using dxCopyEntity, specifying the original mesh as the parent, and dxFlip it using dxFlipMesh. You will now have two meshes occupying the same space - this will make it double-sided, but beware, it will also double the polygon count! The above technique is worth trying when an external modelling program has exported a model in such a way that some of the triangles appear to be missing. |
; dxFlipMesh Example ; ---------------- dxGraphics3D 640,480 dxSetBuffer dxBackBuffer() camera=dxCreateCamera() light=dxCreateLight() ; Create sphere sphere=dxCreateSphere() ; Scale sphere dxScaleEntity sphere,100,100,100 ; Texture sphere with sky texture sky_tex=dxLoadTexture("media/sky.bmp") dxEntityTexture sphere,sky_tex ; dxFlip mesh so we can see the inside of it dxFlipMesh sphere dxColor 0,0,0 While Not dxKeyDown( 1 ) dxRenderWorld dxText 0,0,"You are viewing a flipped sphere mesh - makes a great sky!" dxFlip Wend End |