xof 0302txt 0064 Material frontMaterial { 1.0; 1.0; 1.0; 0.0;; // R = 1.0, G = 1.0, B = 1.0 0.0; 0.0; 0.0; 0.0;; 0.0; 0.0; 0.0;; TextureFilename { "front.bmp"; } } Material backMaterial { 1.0; 1.0; 1.0; 0.0;; // R = 1.0, G = 1.0, B = 1.0 0.0; 0.0; 0.0; 0.0;; 0.0; 0.0; 0.0;; TextureFilename { "back.bmp"; } } Material topMaterial { 1.0; 1.0; 1.0; 0.0;; // R = 1.0, G = 1.0, B = 1.0 0.0; 0.0; 0.0; 0.0;; 0.0; 0.0; 0.0;; TextureFilename { "top.bmp"; } } Material bottomMaterial { 1.0; 1.0; 1.0; 0.0;; // R = 1.0, G = 1.0, B = 1.0 0.0; 0.0; 0.0; 0.0;; 0.0; 0.0; 0.0;; TextureFilename { "bottom.bmp"; } } Material rightMaterial { 1.0; 1.0; 1.0; 0.0;; // R = 1.0, G = 1.0, B = 1.0 0.0; 0.0; 0.0; 0.0;; 0.0; 0.0; 0.0;; TextureFilename { "right.bmp"; } } Material leftMaterial { 1.0; 1.0; 1.0; 1.0;; // R = 1.0, G = 1.0, B = 1.0 0.0; 0.0; 0.0; 0.0;; 0.0; 0.0; 0.0;; TextureFilename { "left.bmp"; } } Mesh dice { //VertexBuffer //A dice has 8 vertices. The problem is that each vertex needs 3 texture coordinates, //because any vertex margins 3 textures needing different texture coordinates. //For this reason any vertex has to be defined triply = 24 vertices. //We order the vertices by faces and surround any face clockwise starting at its left upper corner. //Center of the coordinate system = center of the dice = Vector3.Zero. //Left-handed coordinate system = Y-axis upwards = Vector3.Up. 24; -1.0; 1.0; -1.0;, //front 1.0; 1.0; -1.0;, 1.0; -1.0; -1.0;, -1.0; -1.0; -1.0;, 1.0; 1.0; 1.0;, //back -1.0; 1.0; 1.0;, -1.0; -1.0; 1.0;, 1.0; -1.0; 1.0;, -1.0; 1.0; 1.0;, //top 1.0; 1.0; 1.0;, 1.0; 1.0; -1.0;, -1.0; 1.0; -1.0;, -1.0; -1.0; -1.0;, //bottom 1.0; -1.0; -1.0;, 1.0; -1.0; 1.0;, -1.0; -1.0; 1.0;, 1.0; 1.0; -1.0;, //right 1.0; 1.0; 1.0;, 1.0; -1.0; 1.0;, 1.0; -1.0; -1.0;, -1.0; 1.0; 1.0;, //left -1.0; 1.0; -1.0;, -1.0; -1.0; -1.0;, -1.0; -1.0; 1.0;; //IndexBuffer 6; // 6 faces 4; 0, 1, 2, 3;, 4; 4, 5, 6, 7;, 4; 8, 9,10,11;, 4;12,13,14,15;, 4;16,17,18,19;, 4;20,21,22,23;; MeshMaterialList { 6; // No. of materials = no. of faces 6; // A material for each face 0, 1, 2, 3, 4, 5;; {frontMaterial} {backMaterial} {topMaterial} {bottomMaterial} {rightMaterial} {leftMaterial} } MeshTextureCoords { 24; 0.0; 0.0; //front 1.0; 0.0; 1.0; 1.0; 0.0; 1.0; 0.0; 0.0; //back 1.0; 0.0; 1.0; 1.0; 0.0; 1.0; 0.0; 0.0; //top 1.0; 0.0; 1.0; 1.0; 0.0; 1.0; 0.0; 0.0; //bottom 1.0; 0.0; 1.0; 1.0; 0.0; 1.0; 0.0; 0.0; //right 1.0; 0.0; 1.0; 1.0; 0.0; 1.0; 0.0; 0.0; //left 1.0; 0.0; 1.0; 1.0; 0.0; 1.0;; } MeshNormals { 24; //As with the vector of directional light, //normals should be normalized to length = 1.0. //If the the length is > 1.0 the scalar product of light*normal give an augmented cosinus(alpha), //which produces exaggerated local brightness. //Explanation of value 0.577: 1.0 / Sqrt(3.0) = 0.577. //Pythagorean theorem: Length of a 3D-vector = Sqrt(dx*dx + dy*dy + dz*dz). //With dx=dy=dz=0.577 Sqrt(dx*dx + dy*dy + dz*dz) is 1.0. //Any vertex needs a normal. Because the zero-point lies in the mid of the dice, //we have just to replace all coordinates 1.0 by 0.577 and all -1.0 by -0.577. -0.577; 0.577; -0.577;, //front 0.577; 0.577; -0.577;, 0.577; -0.577; -0.577;, -0.577; -0.577; -0.577;, 0.577; 0.577; 0.577;, //back -0.577; 0.577; 0.577;, -0.577; -0.577; 0.577;, 0.577; -0.577; 0.577;, -0.577; 0.577; 0.577;, //top 0.577; 0.577; 0.577;, 0.577; 0.577; -0.577;, -0.577; 0.577; -0.577;, -0.577; -0.577; -0.577;, //bottom 0.577; -0.577; -0.577;, 0.577; -0.577; 0.577;, -0.577; -0.577; 0.577;, 0.577; 0.577; -0.577;, //right 0.577; 0.577; 0.577;, 0.577; -0.577; 0.577;, 0.577; -0.577; -0.577;, -0.577; 0.577; 0.577;, //left -0.577; 0.577; -0.577;, -0.577; -0.577; -0.577;, -0.577; -0.577; 0.577;; 6; 4; 0, 1, 2, 3;, 4; 4, 5, 6, 7;, 4; 8, 9,10,11;, 4;12,13,14,15;, 4;16,17,18,19;, 4;20,21,22,23;; } //end of MeshNormals { } //end of Mesh dice {