Exemple #1
0
        /// <summary>
        /// Prepares mesh to be "cell fit":
        /// 1) uniform scale the mesh to fit to SIZE_OF_MESH x SIZE_OF_MESH on XZ plane;
        /// 2) translates mesh to align its bounding box to center of coordiantes (0,0,0);
        /// </summary>
        void fitMesh(Mesh mesh)
        {
            MeshManipulator s = m_device.SceneManager.MeshManipulator;

            float f = Math.Max(mesh.BoundingBox.Extent.X, mesh.BoundingBox.Extent.Z);

            s.Scale(mesh, new Vector3Df(SIZE_OF_MESH / f));
            s.Transform(mesh, new Matrix(mesh.BoundingBox.MinEdge * -1));
            s.RecalculateNormals(mesh);
        }
Exemple #2
0
        void loadCellMesh()
        {
            MeshManipulator s = m_device.SceneManager.MeshManipulator;
            VideoDriver     d = m_device.VideoDriver;

            m_meshCell = m_device.SceneManager.GetMesh("cell.obj");
            s.FlipSurfaces(m_meshCell);             // i don't know why, but somehow this one OBJ exported by Blender has flipped faces when opened by Irrlicht
            fitMesh(m_meshCell);

            s.SetVertexColors(m_meshCell, Color.SolidWhite);
            s.MakePlanarTextureMapping(m_meshCell, 0.10f);

            Material m = new Material();

            m.Type = MaterialType.Reflection2Layer;
            m.SetTexture(0, d.GetTexture("TEXTURE-unk.jpg"));
            m.SetTexture(1, d.GetTexture("TEXTURE-ref.jpg"));
            m_meshCell.MeshBuffers[0].SetMaterial(m);

            s.Transform(m_meshCell, new Matrix(new Vector3Df(0), new Vector3Df(0, -90, 180)));
            s.RecalculateNormals(m_meshCell);
        }