public static ManualObject CreateTetrahedron3(String name, Mogre.Vector3 position, Single scale, String materialName)
        {
            ManualObject manObTetra = new ManualObject(name);

            manObTetra.CastShadows = false;

            // render just before overlays (so all objects behind the transparent tetrahedron are visible)
            manObTetra.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY - 1; // = 99

            Mogre.Vector3[] c = new Mogre.Vector3[4];                                        // corners

            // calculate corners of tetrahedron (with point of origin in middle of volume)
            Single mbot = scale * 0.2f;    // distance middle to bottom
            Single mtop = scale * 0.62f;   // distance middle to top
            Single mf   = scale * 0.289f;  // distance middle to front
            Single mb   = scale * 0.577f;  // distance middle to back
            Single mlr  = scale * 0.5f;    // distance middle to left right

            //               width / height / depth
            c[0] = new Mogre.Vector3(-mlr, -mbot, mf); // left bottom front
            c[1] = new Mogre.Vector3(mlr, -mbot, mf);  // right bottom front
            c[2] = new Mogre.Vector3(0, -mbot, -mb);   // (middle) bottom back
            c[3] = new Mogre.Vector3(0, mtop, 0);      // (middle) top (middle)

            // add position offset for all corners (move tetrahedron)
            for (Int16 i = 0; i <= 3; i++)
            {
                c[i] += position;
            }

            // create bottom
            manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            manObTetra.Position(c[2]);
            manObTetra.Position(c[1]);
            manObTetra.Position(c[0]);
            manObTetra.Triangle(0, 1, 2);
            manObTetra.End();
            // create right back side
            manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            manObTetra.Position(c[1]);
            manObTetra.Position(c[2]);
            manObTetra.Position(c[3]);
            manObTetra.Triangle(0, 1, 2);
            manObTetra.End();
            // create left back side
            manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            manObTetra.Position(c[3]);
            manObTetra.Position(c[2]);
            manObTetra.Position(c[0]);
            manObTetra.Triangle(0, 1, 2);
            manObTetra.End();
            // create front side
            manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            manObTetra.Position(c[0]);
            manObTetra.Position(c[1]);
            manObTetra.Position(c[3]);
            manObTetra.Triangle(0, 1, 2);
            manObTetra.End();
            return(manObTetra);
        } // CreateTetrahedron
Exemplo n.º 2
0
        private void CreateLine(ManualObject mo, Vector3 origin, Vector3 final, int useMaterial, Vector4 color)
        {
            float lineWidth = 0.1f;

            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_FAN;
            switch (useMaterial)
            {
            case 1:
                mo.Begin("SharpMap/Line3D_v1", operation);
                break;

            default:
                MaterialPtr material = MaterialManager.Singleton.CreateOrRetrieve("Test/ColourLines3d",
                                                                                  ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).first;
                material.GetTechnique(0).GetPass(0).VertexColourTracking =
                    (int)TrackVertexColourEnum.TVC_AMBIENT;
                mo.Begin("Test/ColourLines3d", operation);

                break;
            }

            Vector3 delta = final - origin;

            delta = new Vector3(-delta.y, delta.x, delta.z).NormalisedCopy *lineWidth;
            mo.Position(origin);
            mo.Position(final);
            mo.Position(final + delta);
            mo.Position(origin + delta);
            //lines3d.TextureCoord((float)i / (float)pointsList.Count);

            ManualObject.ManualObjectSection section = lines3d.End();
            section.SetCustomParameter(constantColor, color);
        }
Exemplo n.º 3
0
        public void begin(int type)
        {
            string typeName;

            switch (type)
            {
            case GL.GL_LINE_LOOP:
                typeName = "GL_LINE_LOOP";
                break;

            case GL.GL_TRIANGLE_FAN:
                typeName = "GL_TRIANGLE_FAN";
                manualObj.Begin("Test/ColourPolygon", RenderOperation.OperationTypes.OT_TRIANGLE_FAN);
                break;

            case GL.GL_TRIANGLE_STRIP:
                typeName = "GL_TRIANGLE_STRIP";
                manualObj.Begin("Test/ColourPolygon", RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);
                break;

            case GL.GL_TRIANGLES:
                typeName = "GL_TRIANGLES";
                manualObj.Begin("Test/ColourPolygon", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
                break;

            default:
                typeName = "Unknown";
                break;
            }
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod() + "Primitive type = " + typeName);
        }
Exemplo n.º 4
0
            public void begin(int type)
            {
                string typeName;

                switch (type)
                {
                case GL.GL_LINE_LOOP:
                    typeName = "GL_LINE_LOOP";
                    break;

                case GL.GL_TRIANGLE_FAN:
                    typeName = "GL_TRIANGLE_FAN";
                    manualObj.Begin(material, RenderOperation.OperationTypes.OT_TRIANGLE_FAN);
                    break;

                case GL.GL_TRIANGLE_STRIP:
                    typeName = "GL_TRIANGLE_STRIP";
                    manualObj.Begin(material, RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);
                    break;

                case GL.GL_TRIANGLES:
                    typeName = "GL_TRIANGLES";
                    manualObj.Begin(material, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
                    break;

                default:
                    typeName = "Unknown";
                    break;
                }
#if TESSELLATION_TRACE
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod() + "Primitive type = " + typeName);
#endif
            }
Exemplo n.º 5
0
        protected void drawLine(SceneNode p_Node, string lineName, Vector3 p_Point1, Vector3 p_Point2)
        {
            // create material (colour)
            MaterialPtr moMaterial = MaterialManager.Singleton.Create(lineName, "debugger");

            moMaterial.ReceiveShadows = false;
            moMaterial.GetTechnique(0).SetLightingEnabled(true);
            moMaterial.GetTechnique(0).GetPass(0).SetDiffuse(0, 0, 1, 0);
            moMaterial.GetTechnique(0).GetPass(0).SetAmbient(0, 0, 1);
            moMaterial.GetTechnique(0).GetPass(0).SetSelfIllumination(0, 0, 1);
            moMaterial.Dispose();  // dispose pointer, not the material


            // create line object
            ManualObject manOb = mSceneManager.CreateManualObject(lineName);

            manOb.Begin(lineName, RenderOperation.OperationTypes.OT_LINE_LIST);
            manOb.Position(p_Point1.x, p_Point1.y, p_Point1.z);
            manOb.Position(p_Point2.x, p_Point2.y, p_Point2.z);
            // ... maybe more points
            manOb.End();

            // create SceneNode and attach the line
            //            p_Node.Position = Vector3.ZERO;
            p_Node.AttachObject(manOb);
        }
Exemplo n.º 6
0
        private void UpdateCloudPoints(List <Point3D> PointsList, Decimal d_threshold_meters)
        {
            if (manual == null)
            {
                return;
            }
            if (PointsList == null)
            {
                return;
            }

            double threshold = (double)d_threshold_meters * 1000d; // convert to mm

            try
            {
                manual.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_POINT_LIST);

                // Real data
                foreach (Point3D sp in PointsList)
                {
                    ColourValue cv = sp.color;
                    Vector3     v  = new Vector3((float)sp.x, (float)sp.y, (float)sp.z);

                    manual.Position(v);
                    manual.Colour(cv);
                }
                manual.End();
            }
            catch (Exception e)
            {
                MessageBox.Show("Exception when plotting points: " + e.Message);
                // ignore throw e;
            }
        }
Exemplo n.º 7
0
        public MeshPtr LoadStaticBrfMeshIntoOgre(SceneManager sceneManager, MBBrfMesh brfMesh, int frame = 0)
        {
            //Convert Vertex and Faces to Ogre Mesh Format
            if (brfMesh == null)
            {
                return(null);
            }
            if (meshes.ContainsKey(brfMesh.Name))
            {
                return(meshes[brfMesh.Name]);
            }
            ManualObject mo = sceneManager.CreateManualObject(brfMesh.Name + "-" + Guid.NewGuid().ToString());

            mo.Begin(brfMesh.Material);

            int np = 0, nv = 0;

            for (int i = 0; i < brfMesh.Frames[frame].pos.Count; i++)
            {
                mo.Position(
                    brfMesh.Frames[frame].pos[i].x,
                    brfMesh.Frames[frame].pos[i].y,
                    brfMesh.Frames[frame].pos[i].z
                    );
                np++;
            }

            for (int i = 0; i < brfMesh.Frames[frame].norm.Count; i++)
            {
                mo.Normal(
                    -brfMesh.Frames[frame].norm[i].x,
                    brfMesh.Frames[frame].norm[i].y,
                    brfMesh.Frames[frame].norm[i].z
                    );
                mo.TextureCoord(
                    brfMesh.Vertex[i].ta.X,
                    brfMesh.Vertex[i].ta.Y
                    );
                nv++;
            }

            for (int i = 0; i < brfMesh.Faces.Count; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    mo.Triangle(
                        (uint)(brfMesh.Vertex[brfMesh.Faces[i].index[j]].index + 1 + cp),
                        (uint)(brfMesh.Faces[i].index[j] + 1 + cv),
                        (uint)(brfMesh.Faces[i].index[j] + 1 + cv)
                        );
                }
            }

            mo.End();

            cp += np;
            cv += nv;

            return(mo.ConvertToMesh(brfMesh.Name + "-" + Guid.NewGuid().ToString()));
        }
Exemplo n.º 8
0
        public MeshPtr getCube(string cubeName)
        {
            manualObj = mSceneMgr.CreateManualObject("maualObjQuad");
            manualObj.Begin("void", RenderOperation.OperationTypes.OT_TRIANGLE_LIST); // Starts filling the manual object as a triangle list

            // ---- Vertex Buffer ----
            manualObj.Position(new Vector3(-1000, 0, 1000));        // --- Vertex 0 ---
            manualObj.TextureCoord(new Vector2(0, 0));
            manualObj.Position(new Vector3(1000, 0, 1000));         // --- Vertex 1 ---
            manualObj.TextureCoord(new Vector2(1, 0));
            manualObj.Position(new Vector3(1000, 0, -1000));        // --- Vertex 2 ---
            manualObj.TextureCoord(new Vector2(0, 1));
            manualObj.Position(new Vector3(-1000, 0, -1000 0));     // --- Vertex 3 ---
            manualObj.TextureCoord(new Vector2(1, 1));

            // ---- Index Buffer ----
            // --- Triangle 0 ---
            manualObj.Index(0);
            manualObj.Index(1);
            manualObj.Index(2);

            // --- Triangle 1 ---
            manualObj.Index(1);
            manualObj.Index(3);
            manualObj.Index(2);


            manualObj.End();                                    // Closes the manual objet

            return(manualObj.ConvertToMesh("Floor"));           // Prepares the data to be sent to the GPU
        }
Exemplo n.º 9
0
        //
        //ORIGINAL LINE: MeshPtr realizeMesh(const string& name ="")
        public MeshPtr realizeMesh(string name)
        {
            //Mogre.SceneManager smgr = Root.Singleton.GetSceneManagerIterator().Current;
            Mogre.SceneManagerEnumerator.SceneManagerIterator item = Root.Singleton.GetSceneManagerIterator();
            item.MoveNext();
            Mogre.SceneManager smgr = item.Current;
            item.Dispose();
            ManualObject manual = smgr.CreateManualObject(name);

            //for (List<Shape>.Enumerator it = mShapes.GetEnumerator(); it.MoveNext(); ++it)
            foreach (var it in mShapes)
            {
                manual.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_LINE_STRIP);
                it._appendToManualObject(manual);
                manual.End();
            }

            MeshPtr mesh = null;// MeshManager.Singleton.CreateManual(Guid.NewGuid().ToString("N"), "General"); //new MeshPtr();

            if (name == "")
            {
                mesh = manual.ConvertToMesh(Utils.getName("mutishape_procedural_"));
            }
            else
            {
                mesh = manual.ConvertToMesh(name);
            }
            smgr.DestroyManualObject(manual);
            return(mesh);
        }
Exemplo n.º 10
0
        // creates a wireframe octahedron as a dummy model
        public static MovableObject MakeDummy(SceneManager mgr, String name, String materialName, float size)
        {
            ManualObject dummy = mgr.CreateManualObject(name);

            dummy.Begin(materialName, RenderOperation.OperationTypes.OT_LINE_LIST);

            // octahedron wire shape
            Vector3[] points =
            {
                new Vector3(0,     size,      0), new Vector3(0,     0, size),
                new Vector3(0,     size,      0), new Vector3(0,     0, -size),
                new Vector3(0,     size,      0), new Vector3(-size, 0,     0),
                new Vector3(0,     size,      0), new Vector3(size,  0,     0),

                new Vector3(0,     -size,     0), new Vector3(0,     0, size),
                new Vector3(0,     -size,     0), new Vector3(0,     0, -size),
                new Vector3(0,     -size,     0), new Vector3(-size, 0,     0),
                new Vector3(0,     -size,     0), new Vector3(size,  0,     0),

                new Vector3(-size,     0,     0), new Vector3(0,     0, size),
                new Vector3(0,         0, size),  new Vector3(size,  0,     0),
                new Vector3(size,      0,     0), new Vector3(0,     0, -size),
                new Vector3(0,         0, -size), new Vector3(-size, 0,     0),
            };

            foreach (Vector3 v in points)
            {
                dummy.Position(v);
            }

            dummy.End();

            return(dummy);
        }
Exemplo n.º 11
0
        void CreateGrassMesh()
        {
            const float  width  = 25;
            const float  height = 30;
            Vector3      vec    = new Vector3(width / 2, 0, 0);
            ManualObject obj    = _sceneManager.CreateManualObject("GrassObject");

            Quaternion quat = new Quaternion(new Degree(60), Vector3.UNIT_Y);

            obj.Begin("Examples/GrassBlades", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            for (uint i = 0; i < 3; ++i)
            {
                obj.Position(-vec.x, height, -vec.z);
                obj.TextureCoord(0, 0);
                obj.Position(vec.x, height, vec.z);
                obj.TextureCoord(1, 0);
                obj.Position(-vec.x, 0, -vec.z);
                obj.TextureCoord(0, 1);
                obj.Position(vec.x, 0, vec.z);
                obj.TextureCoord(1, 1);

                uint offset = 4 * i;
                obj.Triangle(offset, offset + 3, offset + 1);
                obj.Triangle(offset, offset + 2, offset + 3);

                vec = quat * vec;
            }

            obj.End();
            obj.ConvertToMesh("grass");
            _sceneManager.DestroyManualObject(obj);
        }
Exemplo n.º 12
0
        public static ManualObject CreateRectangle(SceneManager sceneMgr, Vector3 pos, Vector3 size, string material = ColoredMaterials.BLUE)
        {
            Vector3[,] points = new Vector3[2, 4];
            for (int y = 0; y < 2; y++)
            {
                points[y, 0] = pos + y * Vector3.UNIT_Y * size.y;
                points[y, 1] = pos + new Vector3(1, y, 0) * size;
                points[y, 2] = pos + new Vector3(1, y, 1) * size;
                points[y, 3] = pos + new Vector3(0, y, 1) * size;
            }

            ManualObject manOb = sceneMgr.CreateManualObject();

            manOb.Begin(material, RenderOperation.OperationTypes.OT_LINE_LIST);
            for (int y = 0; y < 2; y++)
            {
                for (int i = 0; i < 4; i++)
                {
                    manOb.Position(points[y, i]);
                    manOb.Position(points[y, (i + 1) % 4]);
                }
            }

            for (int i = 0; i < 4; i++)
            {
                manOb.Position(points[0, i]);
                manOb.Position(points[1, i]);
            }

            manOb.End();
            return(manOb);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Large vertex displacements such as are possible with C3E4v_twist
        /// require a high degree of tessellation.  This routine draws a
        /// triangle recursively subdivided to provide sufficient tessellation. */
        /// </summary>
        static void DrawSubDividedTriangle(ManualObject obj, int subdivisions)
        {
            float[] a = new float[2] {
                -0.8f, 0.8f
            };
            float[] b = new float[2] {
                0.8f, 0.8f
            };
            float[] c = new float[2] {
                0.0f, -0.8f
            };

            float[] ca = new float[3] {
                0, 0, 1
            };
            float[] cb = new float[3] {
                0, 0, 1
            };
            float[] cc = new float[3] {
                0.7f, 0.7f, 1
            };

            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;
            obj.Begin("CgTutorials/C3E4_Material", operation);
            TriangleDivide(obj, subdivisions, a, b, c, ca, cb, cc);
            obj.End();
        }
Exemplo n.º 14
0
        /// <summary>
        /// This private method defines the vertex and index buffers of a quad as a triangle list.
        /// </summary>
        private MeshPtr Quad()
        {
            manualObj = mSceneMgr.CreateManualObject("maualObjQuad");
            manualObj.Begin("void", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);    // Starts filling the manual object as a triangle list

            // ---- Vertex Buffer ----
            manualObj.Position(new Vector3(5, 5, 0));               // --- Vertex 0 ---
            manualObj.Position(new Vector3(-5, 5, 0));              // --- Vertex 1 ---
            manualObj.Position(new Vector3(5, -5, 0));              // --- Vertex 2 ---
            manualObj.Position(new Vector3(-5, -5, 0));             // --- Vertex 3 ---

            // ---- Index Buffer ----
            // --- Triangle 0 ---
            manualObj.Index(0);
            manualObj.Index(1);
            manualObj.Index(2);

            // --- Triangle 1 ---
            manualObj.Index(1);
            manualObj.Index(3);
            manualObj.Index(2);

            manualObj.End();                                        // Closes the manual objet

            return(manualObj.ConvertToMesh("Quad"));                // Prepares the data to be sent to the GPU
        }
Exemplo n.º 15
0
    public void Initialise(SceneManager aSceneManager, float aFillAlpha)
    {
        if (isInitialised)
        {
            // Initialization multiple call guard
            return;
        }

        if (aSceneManager == null)
        {
            return;
        }

        m_sceneManager = aSceneManager;
        fillAlpha      = aFillAlpha;
        m_manualObject = null;
        linesIndex     = 0;
        trianglesIndex = 0;

        m_manualObject             = m_sceneManager.CreateManualObject("debugDrawer_object");
        m_manualObject.CastShadows = false;

        m_sceneManager.RootSceneNode.CreateChildSceneNode("debugDrawer_object").AttachObject(m_manualObject);
        m_manualObject.Dynamic = (true);

        icoSphere.Create(this.DEFAULT_ICOSPHERE_RECURSION_LEVEL);

        m_manualObject.Begin("debug_draw", RenderOperation.OperationTypes.OT_LINE_LIST);
        m_manualObject.Position(Vector3.ZERO);
        m_manualObject.Colour(ColourValue.ZERO);
        m_manualObject.Index(0);
        m_manualObject.End();
        m_manualObject.Begin("debug_draw", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
        m_manualObject.Position(Vector3.ZERO);
        m_manualObject.Colour(ColourValue.ZERO);
        m_manualObject.Index(0);
        m_manualObject.End();

        trianglesIndex = 0;
        linesIndex     = trianglesIndex;

        isInitialised = true;
        // Initialization multiple call guard
    }
Exemplo n.º 16
0
        private void createSphere(string strName, float r, SceneManager sceneMgr, int nRings = 16, int nSegments = 16)
        {
            ManualObject manual = sceneMgr.CreateManualObject(strName);

            manual.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            float  fDeltaRingAngle = (Mogre.Math.PI / nRings);
            float  fDeltaSegAngle  = (2 * Mogre.Math.PI / nSegments);
            ushort wVerticeIndex   = 0;

            // Generate the group of rings for the sphere
            for (int ring = 0; ring <= nRings; ring++)
            {
                float r0 = r * Mogre.Math.Sin(ring * fDeltaRingAngle);
                float y0 = r * Mogre.Math.Cos(ring * fDeltaRingAngle);

                // Generate the group of segments for the current ring
                for (int seg = 0; seg <= nSegments; seg++)
                {
                    float x0 = r0 * Mogre.Math.Sin(seg * fDeltaSegAngle);
                    float z0 = r0 * Mogre.Math.Cos(seg * fDeltaSegAngle);

                    // Add one vertex to the strip which makes up the sphere
                    manual.Position(x0, y0, z0);
                    manual.Normal(new Mogre.Vector3(x0, y0, z0).NormalisedCopy);
                    manual.TextureCoord((float)seg / (float)nSegments, (float)ring / (float)nRings);

                    if (ring != nRings)
                    {
                        // each vertex (except the last) has six indicies pointing to it
                        manual.Index((uint)(wVerticeIndex + nSegments + 1));
                        manual.Index(wVerticeIndex);
                        manual.Index((uint)(wVerticeIndex + nSegments));
                        manual.Index((uint)(wVerticeIndex + nSegments + 1));
                        manual.Index((uint)(wVerticeIndex + 1));
                        manual.Index(wVerticeIndex);
                        wVerticeIndex++;
                    }
                }
                ;  // end for seg
            } // end for ring
            manual.End();
            MeshPtr mesh = manual.ConvertToMesh(strName);

            mesh._setBounds(new AxisAlignedBox(new Mogre.Vector3(-r, -r, -r), new Mogre.Vector3(r, r, r)), false);

            mesh._setBoundingSphereRadius(r);
            ushort src, dest;

            if (!mesh.SuggestTangentVectorBuildParams(VertexElementSemantic.VES_TANGENT, out src, out dest))
            {
                mesh.BuildTangentVectors(VertexElementSemantic.VES_TANGENT, src, dest);
            }
        }
Exemplo n.º 17
0
        public static ManualObject CreateLine(SceneManager sceneMgr, Vector3 p1, Vector3 p2, string material = ColoredMaterials.BLUE)
        {
            ManualObject manOb = sceneMgr.CreateManualObject();

            manOb.Begin(material, RenderOperation.OperationTypes.OT_LINE_LIST);
            manOb.Position(p1);
            manOb.Position(p2);
            manOb.End();

            return(manOb);
        }
Exemplo n.º 18
0
        public VideoTexture(SceneManager scm, float width, float height, string aviFileName)
        {
            AviManager aviMgr = new AviManager(aviFileName, true);

            Stream = aviMgr.GetVideoStream();

            TexturePtr VideoTexture = TextureManager.Singleton.CreateManual(
                "Video",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D, Convert.ToUInt32(Stream.Width), Convert.ToUInt32(Stream.Height), 0, PixelFormat.PF_R8G8B8A8, (int)TextureUsage.TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
            MaterialPtr VideoMat = MaterialManager.Singleton.Create(
                "VideoMat", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            VideoMat.GetTechnique(0).GetPass(0).LightingEnabled = false;
            VideoMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("Video");

            PixelBuffer = VideoTexture.GetBuffer();

            screen         = scm.CreateManualObject("Screen");
            screen.Dynamic = true;
            screen.Begin("VideoMat", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            screen.Position(0, 0, 0);
            screen.TextureCoord(0, 0);

            screen.Position(width, 0, 0);
            screen.TextureCoord(1, 0);

            screen.Position(width, height, 0);
            screen.TextureCoord(1, 1);

            screen.Triangle(0, 1, 2);

            screen.Position(0, 0, 0);
            screen.TextureCoord(0, 0);

            screen.Position(width, height, 0);
            screen.TextureCoord(1, 1);

            screen.Position(0, height, 0);
            screen.TextureCoord(0, 1);

            screen.Triangle(3, 4, 5);

            screen.End();

            SceneNode node = scm.RootSceneNode.CreateChildSceneNode();

            node.Position = new Vector3(0, 0, 0);
            node.AttachObject(screen);

            Stream.GetFrameOpen();
            FrameNum = 0;
        }
Exemplo n.º 19
0
        public MultiBlock(string mat, Island current, World mainWorld, int meshType)
        {
            this.mMaterial = mat;
            this.mName     = this.mMaterial + Guid.NewGuid().ToString();

            this.mIsland = current;
            this.mWorld  = mainWorld;

            block = new ManualObject("MultiBlock-" + this.mName);
            block.Begin(this.mMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            this.meshType = meshType;
        }
Exemplo n.º 20
0
        public void AddPt(Vector3 pt)
        {
            this.ptlist.Add(pt);
            ManualLineObject.Begin(ColorMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_FAN);
            foreach (Vector3 ptt in this.ptlist)
            {
                ManualLineObject.Position(ptt);
                ManualLineObject.TextureCoord(ptt.x / 100, ptt.y / 100);
            }

            ManualLineObject.End();
        }
Exemplo n.º 21
0
        public MultiBlock(string mat, Island current, World mainWorld, int meshType)
        {
            this.mMaterial = mat;
            this.mName = this.mMaterial + Guid.NewGuid().ToString();

            this.mIsland = current;
            this.mWorld = mainWorld;

            block = new ManualObject("MultiBlock-" + this.mName);
            block.Begin(this.mMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            this.meshType = meshType;
        }
Exemplo n.º 22
0
        ManualObject CreateGrid(SceneManager theSceneMng, float theWidth, float theStep, string theName)
        {
            float halfW = theWidth / 2f;

            // create material (colour)
            MaterialPtr moMaterial = MaterialManager.Singleton.Create("line_material", "General");

            moMaterial.ReceiveShadows = false;
            moMaterial.GetTechnique(0).SetLightingEnabled(true);
            moMaterial.GetTechnique(0).GetPass(0).SetDiffuse(0.1f, 0.1f, 0.1f, 0);
            moMaterial.GetTechnique(0).GetPass(0).SetAmbient(0.1f, 0.1f, 0.1f);
            moMaterial.GetTechnique(0).GetPass(0).SetSelfIllumination(0.1f, 0.1f, 0.1f);
            moMaterial.Dispose();  // dispose pointer, not the material

            // create line object
            ManualObject manOb = theSceneMng.CreateManualObject("line_" + theName);

            // X lines
            for (float x = -halfW; x <= halfW; x += theStep)
            {
                // draw line
                manOb.Begin("line_material", RenderOperation.OperationTypes.OT_LINE_LIST);
                manOb.Position(x, 0, -halfW);
                manOb.Position(x, 0, halfW);
                manOb.End();
            }

            // Z lines
            for (float z = -halfW; z <= halfW; z += theStep)
            {
                // draw line
                manOb.Begin("line_material", RenderOperation.OperationTypes.OT_LINE_LIST);
                manOb.Position(-halfW, 0, z);
                manOb.Position(halfW, 0, z);
                manOb.End();
            }

            return(manOb);
        }
Exemplo n.º 23
0
        public BulletDebugDrawer()
        {
            sceneMgr = LKernel.GetG<SceneManager>();

            lines = new ManualObject("physics lines");
            triangles = new ManualObject("physics triangles");
            lines.Dynamic = true;
            triangles.Dynamic = true;

            sceneMgr.RootSceneNode.AttachObject(lines);
            sceneMgr.RootSceneNode.AttachObject(triangles);

            string matName = "BulletDebugDrawerMaterial";
            MaterialPtr mtl = MaterialManager.Singleton.GetDefaultSettings().Clone(matName);
            mtl.ReceiveShadows = false;
            mtl.SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            mtl.SetDepthBias(0.1f, 0);

            TextureUnitState tu = mtl.GetTechnique(0).GetPass(0).CreateTextureUnitState();
            tu.SetColourOperationEx(LayerBlendOperationEx.LBX_SOURCE1, LayerBlendSource.LBS_DIFFUSE);
            mtl.GetTechnique(0).SetLightingEnabled(false);

            lines.Begin(matName, RenderOperation.OperationTypes.OT_LINE_LIST);
            begin = true;
            lines.Position(Vector3.ZERO);
            lines.Colour(ColourValue.Blue);
            lines.Position(Vector3.ZERO);
            lines.Colour(ColourValue.Blue);
            lines.End();

            triangles.Begin(matName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            triangles.Position(Vector3.ZERO);
            triangles.Colour(ColourValue.Blue);
            triangles.Position(Vector3.ZERO);
            triangles.Colour(ColourValue.Blue);
            triangles.Position(Vector3.ZERO);
            triangles.Colour(ColourValue.Blue);
            triangles.End();
            begin = false;

            DebugMode = DebugDrawModes.DrawWireframe | /*DebugDrawModes.DrawAabb |*/ DebugDrawModes.FastWireframe
                | DebugDrawModes.EnableCCD | DebugDrawModes.DrawNormals;

            levelMgr = LKernel.GetG<LevelManager>();
            mainPlayerKartNode = LKernel.GetG<PlayerManager>().MainPlayer.Kart.RootNode;

            PhysicsMain.PreSimulate += PreSimulate;
            PhysicsMain.PostSimulate += PostSimulate;

            LKernel.GetG<PhysicsMain>().World.DebugDrawer = this;
        }
Exemplo n.º 24
0
        public ManualObject CreateNode(string name, SceneManager sceneMgr, bool useScreenPos)
        {
            ManualObject manualObj = sceneMgr.CreateManualObject(name);

            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;

            if (useScreenPos)
            {
                manualObj.Begin("CgTutorials/C2E1v_green_Material", operation);
            }
            else
            {
                manualObj.Begin("CgTutorials/C2E1v_green_Material_2", operation);
            }

            manualObj.Position(-0.5f, 0.0f, 0.0f);
            manualObj.Position(0.5f, 0.0f, 0.0f);
            manualObj.Position(0.0f, 0.5f, 0.0f);

            manualObj.End();

            return(manualObj);
        }
        /// Builds the normals representation as a manual object
        /// \exception Ogre::InvalidStateException The input triangle buffer must not be null
        /// \exception Ogre::InvalidStateException Scene Manager is not set in OGRE root object
        //
        //ORIGINAL LINE: ManualObject* buildManualObject() const
        public ManualObject buildManualObject()
        {
            if (mTriangleBuffer == null)
            {
                OGRE_EXCEPT("Ogre::Exception::ERR_INVALID_STATE", "The input triangle buffer must not be null", "Procedural::ShowNormalsGenerator::buildManualObject()");
            }
            ;
            //SceneManager sceneMgr = Root.Singleton.GetSceneManagerIterator().Current;
            Mogre.SceneManagerEnumerator.SceneManagerIterator item = Root.Singleton.GetSceneManagerIterator();
            item.MoveNext();
            Mogre.SceneManager sceneMgr = item.Current;
            item.Dispose();
            if (sceneMgr == null)
            {
                OGRE_EXCEPT("Ogre::Exception::ERR_INVALID_STATE", "Scene Manager must be set in Root", "Procedural::ShowNormalsGenerator::buildManualObject()");
            }
            ;
            ManualObject manual = sceneMgr.CreateManualObject("debug_procedural_" + Guid.NewGuid().ToString("N"));

            manual.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_LINE_LIST);
            std_vector <TriangleBuffer.Vertex> vertices = mTriangleBuffer.getVertices();

            //for (List<TriangleBuffer.Vertex>.Enumerator it = vertices.GetEnumerator(); it.MoveNext(); ++it)
            foreach (var it in vertices)
            {
                manual.Position(it.mPosition);
                manual.Position(it.mPosition + it.mNormal * mSize);

                if (mVisualStyle == VisualStyle.VS_ARROW)
                {
                    Vector3 axis2 = it.mNormal.Perpendicular;
                    Vector3 axis3 = it.mNormal.CrossProduct(axis2);

                    manual.Position(it.mPosition + it.mNormal * mSize);
                    manual.Position(it.mPosition + (.8f * it.mNormal + .1f * axis2) * mSize);

                    manual.Position(it.mPosition + it.mNormal * mSize);
                    manual.Position(it.mPosition + .8f * (it.mNormal - .1f * axis2) * mSize);

                    manual.Position(it.mPosition + it.mNormal * mSize);
                    manual.Position(it.mPosition + .8f * (it.mNormal + .1f * axis3) * mSize);

                    manual.Position(it.mPosition + it.mNormal * mSize);
                    manual.Position(it.mPosition + .8f * (it.mNormal - .1f * axis3) * mSize);
                }
            }
            manual.End();

            return(manual);
        }
Exemplo n.º 26
0
        // creates a simple box with specified material
        public static MovableObject MakeBox(SceneManager mgr, String materialName, Vector3 dims, Vector2 coord)
        {
            ManualObject mo = mgr.CreateManualObject();

            mo.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            float w = dims.x * 0.5f;
            float h = dims.y * 0.5f;
            float d = dims.z * 0.5f;

            Vector3[] norm =
            {
                new Vector3(1.0f,   0.0f, 0.0f),
                new Vector3(0.0f,   1.0f, 0.0f),
                new Vector3(0.0f,   0.0f, 1.0f),
                new Vector3(-1.0f,  0.0f, 0.0f),
                new Vector3(0.0f,  -1.0f, 0.0f),
                new Vector3(0.0f,   0.0f, -1.0f)
            };

            Vector3[] geom =   // 6 faces x 4 vertexes
            {
                new Vector3(+w, -h, +d), new Vector3(+w, -h, -d), new Vector3(+w, +h, -d), new Vector3(+w, +h, +d),
                new Vector3(+w, +h, +d), new Vector3(+w, +h, -d), new Vector3(-w, +h, -d), new Vector3(-w, +h, +d),
                new Vector3(+w, +h, +d), new Vector3(-w, +h, +d), new Vector3(-w, -h, +d), new Vector3(+w, -h, +d),
                new Vector3(-w, -h, +d), new Vector3(-w, +h, +d), new Vector3(-w, +h, -d), new Vector3(-w, -h, -d),
                new Vector3(-w, -h, +d), new Vector3(-w, -h, -d), new Vector3(+w, -h, -d), new Vector3(+w, -h, +d),
                new Vector3(-w, -h, -d), new Vector3(-w, +h, -d), new Vector3(+w, +h, -d), new Vector3(+w, -h, -d)
            };

            // texcoords
            Vector2[] uvs = { new Vector2(0, 0), new Vector2(0, coord.y), coord, new Vector2(coord.x, 0) };

            for (int i = 0; i < 6; i++) // 6 faces
            {
                uint k = (uint)(i * 4);
                for (int j = 0; j < 4; j++) // 4 verts
                {
                    mo.Position(geom[k + j]);
                    mo.Normal(norm[i]);
                    mo.TextureCoord(uvs[j]);
                }
                mo.Quad(k, k + 1, k + 2, k + 3);
            }

            mo.End();

            return(mo);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Large vertex displacements such as are possible with C3E4v_twist
        /// require a high degree of tessellation.  This routine draws a
        /// triangle recursively subdivided to provide sufficient tessellation. */
        /// </summary>
        static void DrawSubDividedTriangle(ManualObject obj, int subdivisions)
        {
            float[] a = new float[2] { -0.8f, 0.8f };
            float[] b = new float[2] { 0.8f, 0.8f };
            float[] c = new float[2] { 0.0f, -0.8f };

            float[] ca = new float[3] { 0, 0, 1 };
            float[] cb = new float[3] { 0, 0, 1 };
            float[] cc = new float[3] { 0.7f, 0.7f, 1 };

            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;
            obj.Begin("CgTutorials/C3E4_Material", operation);
            TriangleDivide(obj, subdivisions, a, b, c, ca, cb, cc);
            obj.End();
        }
Exemplo n.º 28
0
        // create grid
        public static void CreateGrid(SceneManager mgr, String name, int numcols, int numrows, float unitsize)
        {
            ManualObject grid = mgr.CreateManualObject(name);

            grid.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_LINE_LIST);

            float   width  = (float)numcols * unitsize;
            float   depth  = (float)numrows * unitsize;
            Vector3 center = new Vector3(-width / 2.0f, 0, -depth / 2.0f);

            for (int i = 0; i < numrows; ++i)
            {
                Vector3 s, e;
                s.x = 0.0f;
                s.z = i * unitsize;
                s.y = 0.0f;

                e.x = width;
                e.z = i * unitsize;
                e.y = 0.0f;

                grid.Position(s + center);
                grid.Position(e + center);
            }
            grid.Position(new Vector3(0.0f, 0.0f, numrows * unitsize) + center);
            grid.Position(new Vector3(width, 0.0f, numrows * unitsize) + center);

            for (int i = 0; i < numcols; ++i)
            {
                Vector3 s, e;
                s.x = i * unitsize;
                s.z = depth;
                s.y = 0.0f;

                e.x = i * unitsize;
                e.z = 0.0f;
                e.y = 0.0f;

                grid.Position(s + center);
                grid.Position(e + center);
            }
            grid.Position(new Vector3(numcols * unitsize, 0.0f, 0.0f) + center);
            grid.Position(new Vector3(numcols * unitsize, 0.0f, depth) + center);
            grid.End();

            mgr.RootSceneNode.AttachObject(grid);
        }
Exemplo n.º 29
0
        public void BeginBlock()
        {
            Console.WriteLine("BeginBlock");
            pointsList = new List <Point>();
            if (rendererObj == null)
            {
                rendererObj = sceneManager.CreateManualObject("Element" + count);
                count++;
            }
            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;

            MaterialPtr material = MaterialManager.Singleton.CreateOrRetrieve("Test/ColourLines3d",
                                                                              ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).first;

            material.GetTechnique(0).GetPass(0).VertexColourTracking =
                (int)TrackVertexColourEnum.TVC_AMBIENT;
            rendererObj.Begin("Test/ColourLines3d", operation);
        }
Exemplo n.º 30
0
        static ManualObject DrawTriangle(ManualObject obj)
        {
            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;

            obj.Begin("CgTutorials/C3E2_Material", operation);
            obj.Position(0.0f, -0.8f, 0.0f);
            obj.Colour(0, 0, 1);  /* Blue */

            obj.Position(0.8f, 0.8f, 0.0f);
            obj.Colour(0, 1, 0);  /* Green */

            obj.Position(-0.8f, 0.8f, 0.0f);
            obj.Colour(1, 0, 0);  /* Red */

            obj.End();

            return obj;
        }
Exemplo n.º 31
0
        static ManualObject DrawTriangle(ManualObject obj)
        {
            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;

            obj.Begin("CgTutorials/C3E5_Material", operation);
            obj.Position(0.0f, -0.8f, 0.0f);
            obj.TextureCoord(0, 0);

            obj.Position(0.8f, 0.8f, 0.0f);
            obj.TextureCoord(1, 0);

            obj.Position(-0.8f, 0.8f, 0.0f);
            obj.TextureCoord(0.5f, 1);

            obj.End();

            return obj;
        }
Exemplo n.º 32
0
        static ManualObject DrawTriangle(ManualObject obj)
        {
            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;

            obj.Begin("CgTutorials/C3E5_Material", operation);
            obj.Position(0.0f, -0.8f, 0.0f);
            obj.TextureCoord(0, 0);

            obj.Position(0.8f, 0.8f, 0.0f);
            obj.TextureCoord(1, 0);

            obj.Position(-0.8f, 0.8f, 0.0f);
            obj.TextureCoord(0.5f, 1);

            obj.End();

            return(obj);
        }
Exemplo n.º 33
0
        static ManualObject DrawTriangle(ManualObject obj)
        {
            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;

            obj.Begin("CgTutorials/C3E2_Material", operation);
            obj.Position(0.0f, -0.8f, 0.0f);
            obj.Colour(0, 0, 1);  /* Blue */

            obj.Position(0.8f, 0.8f, 0.0f);
            obj.Colour(0, 1, 0);  /* Green */

            obj.Position(-0.8f, 0.8f, 0.0f);
            obj.Colour(1, 0, 0);  /* Red */

            obj.End();

            return(obj);
        }
Exemplo n.º 34
0
                                 1, 2, 3 }; // back face

/*
 *      static public void CreateBoidMesh(string name, string color)
 *      {
 *          Vector3[] colors = baseColors;
 *          if (color.Equals("green"))
 *          {
 *              colors[0] = colors[1] = colors[2] = new Vector3(0.0f, 1.0f, 0.0f);
 *          }
 *          else if (color.Equals("red"))
 *          {
 *              colors[0] = colors[1] = colors[2] = new Vector3(1.0f, 0.0f, 0.0f);
 *          }
 *
 *          // Return now if already exists
 *          if (MeshManager.Singleton.ResourceExists(name))
 *              return;
 *
 *          MeshBuilderHelper mbh = new MeshBuilderHelper(name, "Flocking", false, 0, (uint)pts.Length);
 *
 *          UInt32 offPos = mbh.AddElement(VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_POSITION).Offset;
 *          UInt32 offDiff = mbh.AddElement(VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_DIFFUSE).Offset;
 *
 *          mbh.CreateVertexBuffer(HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
 *          for (int count = 0; count < pts.Length; count++)
 *          {
 *              mbh.SetVertFloat((uint)count, offPos, pts[count].x, pts[count].y, pts[count].z);           //position
 *              mbh.SetVertFloat((uint)count, offDiff, colors[count].x, colors[count].y, colors[count].z); //color
 *          }
 *
 *          mbh.CreateIndexBuffer((uint)(indices.Length / 3), HardwareIndexBuffer.IndexType.IT_16BIT, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
 *          for (uint index = 0; index < indices.Length / 3; index++)
 *          {
 *              mbh.SetIndex16bit(index, (UInt16)(indices[index * 3]),
 *                                       (UInt16)(indices[index * 3 + 1]),
 *                                       (UInt16)(indices[index * 3 + 2]));
 *          }
 *
 *          MaterialPtr material = MaterialManager.Singleton.CreateOrRetrieve("Test/ColourTest", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).first;
 *          material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT;
 *          MeshPtr m = mbh.Load("Test/ColourTest");
 *          m._setBounds(new AxisAlignedBox(-1.0f, -1.0f, -1.0f,
 *                                           1.0f, 1.0f, 1.0f), false);
 *          m._setBoundingSphereRadius((float)System.Math.Sqrt(1.0f * 1.0f + 1.0f * 1.0f));
 *      }
 */

        public static ManualObject CreateBoidObject(string name, SceneManager sceneMgr, string color)
        {
            Vector3[] colors = baseColors;
            if (color.Equals("green"))
            {
                colors[0] = colors[1] = colors[2] = new Vector3(0.0f, 1.0f, 0.0f);
            }
            else if (color.Equals("red"))
            {
                colors[0] = colors[1] = colors[2] = new Vector3(1.0f, 0.0f, 0.0f);
            }

            // Return now if already exists
            if (MeshManager.Singleton.ResourceExists(name))
            {
                return(null);
            }

            ManualObject boidObj = sceneMgr.CreateManualObject(name);

            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST;
            MaterialPtr material = MaterialManager.Singleton.CreateOrRetrieve("Test/Boid", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).first;

            material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT;

            boidObj.Begin("Test/Boid", operation);

            for (int count = 0; count < pts.Length; count++)
            {
                boidObj.Position(pts[count]);                                      //position
                boidObj.Colour(colors[count].x, colors[count].y, colors[count].z); //color
            }
            for (uint index = 0; index < indices.Length / 3; index++)
            {
                boidObj.Index((ushort)(indices[index * 3]));
                boidObj.Index((ushort)(indices[index * 3 + 1]));
                boidObj.Index((ushort)(indices[index * 3 + 2]));
            }

            boidObj.End();

            return(boidObj);
        }
Exemplo n.º 35
0
        /// <summary>
        /// 创建对象
        /// </summary>
        /// <param name="PtList"></param>
        public DrawLine3DClass(List <Vector3> PtList, string ColorMaterial, string name)
        {
            ogreimage = EsdSceneManager.Singleton.OgreImage;
            esmanager = EsdSceneManager.Singleton;

            this.ColorMaterial = ColorMaterial;
            this.ptlist        = PtList;
            ManualLineObject   = ogreimage.SceneManager.CreateManualObject(name);

            ManualLineObject.Begin(ColorMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_FAN);

            foreach (Vector3 pt in PtList)
            {
                ManualLineObject.Position(pt);
                ManualLineObject.TextureCoord(pt.x / 100, pt.y / 100);
            }

            ManualLineObject.End();
        }
Exemplo n.º 36
0
        public static SceneNode block(Vector3 loc, SceneManager sceneMgr)
        {
            ManualObject block = new ManualObject("block-" + Guid.NewGuid().ToString());

            block.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_LINE_LIST);

            for (int i = 0; i < blockPointCoords.Length; i++) {
                block.Position(loc + blockPointCoords[i]);
                if(i != 0) {
                    block.Position(loc + blockPointCoords[i]);
                }
            }

            block.End();

            SceneNode returnNode = sceneMgr.RootSceneNode.CreateChildSceneNode("cubeBorders", new Vector3(0, 0, 0));

            returnNode.AttachObject(block);
            return returnNode;
        }
Exemplo n.º 37
0
        static void DrawStar(ManualObject obj, float x, float y, int starPoints, float R, float r)
        {
            int i;
            float piOverStarPoints = 3.14159f / starPoints,
                   angle = 0.0f;

            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_FAN;
            obj.Begin("CgTutorials/C2E2_green_Material", operation);
            obj.Position(x, y, 0.0f);  /* Center of star */
            /* Emit exterior vertices for star's points. */
            for (i = 0; i < starPoints; i++)
            {
                obj.Position(x + R * Math.Cos(angle), y + R * Math.Sin(angle), 0.0f);
                angle += piOverStarPoints;
                obj.Position(x + r * Math.Cos(angle), y + r * Math.Sin(angle), 0.0f);
                angle += piOverStarPoints;
            }
            /* End by repeating first exterior vertex of star. */
            angle = 0;
            obj.Position(x + R * Math.Cos(angle), y + R * Math.Sin(angle), 0.0f);
            obj.End();
        }
Exemplo n.º 38
0
        static void DisplayRectangle(Vector3 origin, int height, int width, int depth, SceneNode node)
        {
            ManualObject block = new ManualObject(Guid.NewGuid().ToString());
            block.Begin("cube/Sand", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            Vector2[] textureCoord =
                new Vector2[] {
                    new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0),
                    new Vector2(1, 1), new Vector2(1, 0), new Vector2(0, 0), new Vector2(0, 1),
                    new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0),
                    new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0),
                    new Vector2(1, 1), new Vector2(1, 0), new Vector2(0, 0), new Vector2(0, 1),
                    new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0), new Vector2(0, 0)
                };

            Vector3[] blockPointCoords =
            new Vector3[] {
                new Vector3(0, height, 0),            new Vector3(0, 0, 0),                       new Vector3(width, 0, 0),                new Vector3(width, height, 0),
                new Vector3(0, 0, -depth),            new Vector3(0, height, -depth),             new Vector3(width, height, -depth),      new Vector3(width, 0, -depth),
                new Vector3(width, height, 0),        new Vector3(width, height, -depth),         new Vector3(0, height, -depth),          new Vector3(0, height, 0),
                new Vector3(0, 0, 0),                 new Vector3(0, 0, -depth),                  new Vector3(width, 0, -depth),           new Vector3(width, 0, 0),
                new Vector3(0, 0, 0),                 new Vector3(0, height, 0),                  new Vector3(0, height, -depth),          new Vector3(0, 0, -depth),
                new Vector3(width, 0, 0),             new Vector3(width, 0, -depth),              new Vector3(width, height, -depth),      new Vector3(width, height, 0),
            };
            int a = 0;
            for(int i = 0; i < 6; i++) {
                for(int j = 0; j < 4; j++) {
                    block.Position(origin + blockPointCoords[j * 4 + i]); block.TextureCoord(textureCoord[j * 4 + i]);
                    a++;
                }
                block.Quad((uint)a-4, (uint)a-3, (uint)a-2, (uint)a-1);
            }

            block.End();
            node.AttachObject(block);
        }
Exemplo n.º 39
0
        /// <summary>
        /// Helper method to render a composite map.
        /// </summary>
        /// <param name="size"> The requested composite map size</param>
        /// <param name="rect"> The region of the composite map to update, in image space</param>
        /// <param name="mat">The material to use to render the map</param>
        /// <param name="destCompositeMap"></param>
        public virtual void RenderCompositeMap(int size, Rectangle rect,
            Material mat, Texture destCompositeMap)
        {
            //return;
            if (mCompositeMapSM == null)
            {
                //dedicated SceneManager

                mCompositeMapSM = Root.Instance.CreateSceneManager(SceneType.ExteriorClose, "TerrainMaterialGenerator_SceneManager");
                float camDist = 100;
                float halfCamDist = camDist * 0.5f;
                mCompositeMapCam = mCompositeMapSM.CreateCamera("TerrainMaterialGenerator_Camera");
                mCompositeMapCam.Position = new Vector3(0, 0, camDist);
                //mCompositeMapCam.LookAt(Vector3.Zero);
                mCompositeMapCam.ProjectionType = Projection.Orthographic;
                mCompositeMapCam.Near = 10;
                mCompositeMapCam.Far = 999999* 3;
                //mCompositeMapCam.AspectRatio = camDist / camDist;
                mCompositeMapCam.SetOrthoWindow(camDist, camDist);
                // Just in case material relies on light auto params
                mCompositeMapLight = mCompositeMapSM.CreateLight("TerrainMaterialGenerator_Light");
                mCompositeMapLight.Type = LightType.Directional;

                RenderSystem rSys = Root.Instance.RenderSystem;
                float hOffset = rSys.HorizontalTexelOffset / (float)size;
                float vOffset = rSys.VerticalTexelOffset / (float)size;

                //setup scene
                mCompositeMapPlane = mCompositeMapSM.CreateManualObject("TerrainMaterialGenerator_ManualObject");
                mCompositeMapPlane.Begin(mat.Name, OperationType.TriangleList);
                mCompositeMapPlane.Position(-halfCamDist, halfCamDist, 0);
                mCompositeMapPlane.TextureCoord(0 - hOffset, 0 - vOffset);
                mCompositeMapPlane.Position(-halfCamDist, -halfCamDist, 0);
                mCompositeMapPlane.TextureCoord(0 - hOffset, 1 - vOffset);
                mCompositeMapPlane.Position(halfCamDist, -halfCamDist, 0);
                mCompositeMapPlane.TextureCoord(1 - hOffset, 1 - vOffset);
                mCompositeMapPlane.Position(halfCamDist, halfCamDist, 0);
                mCompositeMapPlane.TextureCoord(1 - hOffset, 0 - vOffset);
                mCompositeMapPlane.Quad(0, 1, 2, 3);
                mCompositeMapPlane.End();
                mCompositeMapSM.RootSceneNode.AttachObject(mCompositeMapPlane);
            }//end if

            // update
            mCompositeMapPlane.SetMaterialName(0, mat.Name);
            mCompositeMapLight.Direction = TerrainGlobalOptions.LightMapDirection;
            mCompositeMapLight.Diffuse = TerrainGlobalOptions.CompositeMapDiffuse;
            mCompositeMapSM.AmbientLight =TerrainGlobalOptions.CompositeMapAmbient;
            

            //check for size change (allow smaller to be reused)
            if (mCompositeMapRTT != null && size != mCompositeMapRTT.Width)
            {
                TextureManager.Instance.Remove(mCompositeMapRTT);
                mCompositeMapRTT = null;
            }
            if (mCompositeMapRTT == null)
            {
                mCompositeMapRTT = TextureManager.Instance.CreateManual(
                    mCompositeMapSM.Name + "/compRTT",
                    ResourceGroupManager.DefaultResourceGroupName,
                    TextureType.TwoD,
                    size,
                    size,
                    0,
                    PixelFormat.BYTE_RGBA,
                    TextureUsage.RenderTarget);

                RenderTarget rtt = mCompositeMapRTT.GetBuffer().GetRenderTarget();
                // don't render all the time, only on demand
                rtt.IsAutoUpdated = false;
                Viewport vp = rtt.AddViewport(mCompositeMapCam);
                // don't render overlays
                vp.ShowOverlays = false;
            }

            // calculate the area we need to update
            float vpleft = (float)rect.Left / (float)size;
            float vptop = (float)rect.Top / (float)size;
            float vpright = (float)rect.Right / (float)size;
            float vpbottom = (float)rect.Bottom / (float)size;
            float vpwidth = (float)rect.Width / (float)size;
            float vpheight = (float)rect.Height / (float)size;

            RenderTarget rtt2 = mCompositeMapRTT.GetBuffer().GetRenderTarget();
            Viewport vp2 = rtt2.GetViewport(0);
            mCompositeMapCam.SetWindow(vpleft, vptop, vpright, vpbottom);
            rtt2.Update();
            vp2.Update();
            // We have an RTT, we want to copy the results into a regular texture
            // That's because in non-update scenarios we don't want to keep an RTT
            // around. We use a single RTT to serve all terrain pages which is more
            // efficient.
            BasicBox box = new BasicBox((int)rect.Left, (int)rect.Top, (int)rect.Right, (int)rect.Bottom);
            destCompositeMap.GetBuffer().Blit(mCompositeMapRTT.GetBuffer(), box, box);
        }
Exemplo n.º 40
0
        static ManualObject.ManualObjectSection BuildTerrainBlock(ManualObject obj, ushort pointsX, ushort pointsY,
            Vector4 translationScale, Vector4 color)
        {
            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_STRIP;

            obj.Begin("Terrain/Terrain_Material", operation);
            /*
             * This function uses one big zigzag triangle strip for the whole grid.
             * And insert degenerated (invisible) triangles to join 2 rows. For instance:
             * 0  1  2  3
             * 4  5  6  7
             * 8  9  10 11
             * 12 13 14 15
             *
             * The index buffer would look like :
             * 0, 4, 1, 5, 2, 6, 3, 7, 7, 7, 11, 6, 10, 5, 9, 4, 8, 8, 8, 12, 9, 13, 10, 14, 11, 15
             */
            for (int y = pointsY - 1; y >= 0; y--)
            {
                for (int x = 0; x <= pointsX - 1; x++)
                {
                    obj.Position(x, y, 0.0f);
                    obj.TextureCoord((float)x / (float)(pointsX), (float)y / (float)(pointsY));
                }
            }
            //Console.Write("\n Index:");
            // We have pointsX -1 lines
            for (ushort y = 0; y < pointsY - 1; y++)
            {
                if (y % 2 == 0)
                {
                    for (int x = 0; x < pointsX; x++)
                    {
                        obj.Index((ushort)(y * pointsX + x));            //(x, y + 1, 0.0f);
                        //Console.Write("," + (y * pointsX + x));
                        obj.Index((ushort)(y * pointsX + x + pointsX));  //(x, y, 0.0f);
                        //Console.Write("," + (y * pointsX + x + pointsX));

                    }

                    if (y != pointsY - 2)
                    {
                        obj.Index((ushort)(y * pointsX + pointsX - 1));         //(0, y+1, 0.0f);
                        //Console.Write("," + (y * pointsX + 2 * pointsX - 1));
                    }
                }
                else
                {
                    for (int x = pointsX - 1; x >= 0; x--)
                    {
                        obj.Index((ushort)(y * pointsX + x));           //(x, y + 1, 0.0f);
                        //Console.Write(", " + (y * pointsX + x));
                        obj.Index((ushort)(y * pointsX + x + pointsX));  //(x, y, 0.0f);
                        //Console.Write(", " + (y * pointsX + x + pointsX));
                    }
                    if (y != pointsY - 2)
                    {
                        obj.Index((ushort)(y * pointsX + pointsX));         //(0, y+1, 0.0f);
                        //Console.Write(", " + (y * pointsX + pointsX));
                    }

                }
            }
            //Console.WriteLine(";");
            ManualObject.ManualObjectSection manualObjSec1 = obj.End();
            obj.BoundingBox = new AxisAlignedBox(translationScale.x,
                                                 translationScale.y, -1,
                                                (pointsX * translationScale.z + translationScale.x),
                                                (pointsY * translationScale.w + translationScale.y), 1);
            manualObjSec1.SetCustomParameter(TransXYscaleXY, translationScale);
            manualObjSec1.SetCustomParameter(ColorAndHeightScale, color);
            return manualObjSec1;
        }
Exemplo n.º 41
0
        private void CreateLine(ManualObject mo, Vector3 origin, Vector3 final, int useMaterial, Vector4 color)
        {
            float lineWidth = 0.1f;

            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_FAN;
            switch (useMaterial)
            {
                case 1:
                    mo.Begin("SharpMap/Line3D_v1", operation);
                    break;
                default:
                    MaterialPtr material = MaterialManager.Singleton.CreateOrRetrieve("Test/ColourLines3d",
                                                                            ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).first;
                    material.GetTechnique(0).GetPass(0).VertexColourTracking =
                                   (int)TrackVertexColourEnum.TVC_AMBIENT;
                    mo.Begin("Test/ColourLines3d", operation);

                    break;
            }

            Vector3 delta = final - origin;
            delta = new Vector3(-delta.y, delta.x, delta.z).NormalisedCopy * lineWidth;
            mo.Position(origin);
            mo.Position(final);
            mo.Position(final + delta);
            mo.Position(origin + delta);
            //lines3d.TextureCoord((float)i / (float)pointsList.Count);

            ManualObject.ManualObjectSection section = lines3d.End();
            section.SetCustomParameter(constantColor, color);
        }
Exemplo n.º 42
0
        public void Initialise() {
            manualObject = sceneManager.CreateManualObject("debug_object");
            sceneManager.RootSceneNode.CreateChildSceneNode("debug_object").AttachObject(manualObject);
            manualObject.Dynamic = true;

            _icoSphere.create(DEFAULT_ICOSPHERE_RECURSION_LEVEL);

            manualObject.Begin("debug_draw", RenderOperation.OperationTypes.OT_LINE_LIST);
            manualObject.Position(Vector3.ZERO);
            manualObject.Colour(ColourValue.ZERO);
            manualObject.Index(0);
            manualObject.End();
            manualObject.Begin("debug_draw", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            manualObject.Position(Vector3.ZERO);
            manualObject.Colour(ColourValue.ZERO);
            manualObject.Index(0);
            manualObject.End();

            trianglesIndex = 0;
            linesIndex = trianglesIndex;
        }
Exemplo n.º 43
0
        /// <summary>
        /// This private method defines the vertex and index buffers of a quad as a triangle list.
        /// </summary>
        private MeshPtr Quad()
        {
            manualObj = mSceneMgr.CreateManualObject("maualObjQuad");
            manualObj.Begin("void", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);    // Starts filling the manual object as a triangle list

            // ---- Vertex Buffer ----
            manualObj.Position(new Vector3(5, 5, 0));               // --- Vertex 0 ---
            manualObj.Position(new Vector3(-5, 5, 0));              // --- Vertex 1 ---
            manualObj.Position(new Vector3(5, -5, 0));              // --- Vertex 2 ---
            manualObj.Position(new Vector3(-5, -5, 0));             // --- Vertex 3 ---

            // ---- Index Buffer ----
            // --- Triangle 0 ---
            manualObj.Index(0);
            manualObj.Index(1);
            manualObj.Index(2);

            // --- Triangle 1 ---
            manualObj.Index(1);
            manualObj.Index(3);
            manualObj.Index(2);

            manualObj.End();                                        // Closes the manual objet

            return manualObj.ConvertToMesh("Quad");                 // Prepares the data to be sent to the GPU
        }
Exemplo n.º 44
0
        public static ManualObject CreateTetrahedron3(String name, Mogre.Vector3 position, Single scale, String materialName)
        {
            ManualObject manObTetra = new ManualObject(name);
            manObTetra.CastShadows = false;

            // render just before overlays (so all objects behind the transparent tetrahedron are visible)
            manObTetra.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY - 1; // = 99

            Mogre.Vector3[] c = new Mogre.Vector3[4]; // corners

            // calculate corners of tetrahedron (with point of origin in middle of volume)
            Single mbot = scale * 0.2f;      // distance middle to bottom
            Single mtop = scale * 0.62f;     // distance middle to top    
            Single mf = scale * 0.289f;    // distance middle to front
            Single mb = scale * 0.577f;    // distance middle to back
            Single mlr = scale * 0.5f;      // distance middle to left right 
            //               width / height / depth
            c[0] = new Mogre.Vector3(-mlr, -mbot, mf);  // left bottom front
            c[1] = new Mogre.Vector3(mlr, -mbot, mf);  // right bottom front
            c[2] = new Mogre.Vector3(0, -mbot, -mb);  // (middle) bottom back
            c[3] = new Mogre.Vector3(0, mtop, 0);  // (middle) top (middle)

            // add position offset for all corners (move tetrahedron)
            for (Int16 i = 0; i <= 3; i++)
                c[i] += position;

            // create bottom
            manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            manObTetra.Position(c[2]);
            manObTetra.Position(c[1]);
            manObTetra.Position(c[0]);
            manObTetra.Triangle(0, 1, 2);
            manObTetra.End();
            // create right back side
            manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            manObTetra.Position(c[1]);
            manObTetra.Position(c[2]);
            manObTetra.Position(c[3]);
            manObTetra.Triangle(0, 1, 2);
            manObTetra.End();
            // create left back side
            manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            manObTetra.Position(c[3]);
            manObTetra.Position(c[2]);
            manObTetra.Position(c[0]);
            manObTetra.Triangle(0, 1, 2);
            manObTetra.End();
            // create front side
            manObTetra.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            manObTetra.Position(c[0]);
            manObTetra.Position(c[1]);
            manObTetra.Position(c[3]);
            manObTetra.Triangle(0, 1, 2);
            manObTetra.End();
            return manObTetra;

        } // CreateTetrahedron
Exemplo n.º 45
0
			public DebugRenderable( Node parent )
			{
				_parent = parent;

				string materialName = "Axiom/Debug/AxesMat";
				_material = (Material)MaterialManager.Instance[ materialName ];
				if ( _material == null )
				{
					_material = (Material)MaterialManager.Instance.Create( materialName, ResourceGroupManager.InternalResourceGroupName );
					Pass p = _material.GetTechnique( 0 ).GetPass( 0 );
					p.LightingEnabled = false;
					//TODO: p.PolygonModeOverrideable = false;
					p.VertexColorTracking = TrackVertexColor.Ambient;
					p.SetSceneBlending( SceneBlendType.TransparentAlpha );
					p.CullingMode = CullingMode.None;
					p.DepthWrite = false;
				}

				string meshName = "Axiom/Debug/AxesMesh";
				_mesh = MeshManager.Instance[ meshName ];
				if ( _mesh == null )
				{
					ManualObject mo = new ManualObject( "tmp" );
					mo.Begin( Material.Name, OperationType.TriangleList );
					/* 3 axes, each made up of 2 of these (base plane = XY)
					 *   .------------|\
					 *   '------------|/
					 */
					mo.EstimateVertexCount( 7 * 2 * 3 );
					mo.EstimateIndexCount( 3 * 2 * 3 );
					Quaternion[] quat = new Quaternion[ 6 ];
					ColorEx[] col = new ColorEx[ 3 ];

					// x-axis
					quat[ 0 ] = Quaternion.Identity;
					quat[ 1 ] = Quaternion.FromAxes( Vector3.UnitX, Vector3.NegativeUnitZ, Vector3.UnitY );
					col[ 0 ] = ColorEx.Red;
					col[ 0 ].a = 0.8f;
					// y-axis
					quat[ 2 ] = Quaternion.FromAxes( Vector3.UnitY, Vector3.NegativeUnitX, Vector3.UnitZ );
					quat[ 3 ] = Quaternion.FromAxes( Vector3.UnitY, Vector3.UnitZ, Vector3.UnitX );
					col[ 1 ] = ColorEx.Green;
					col[ 1 ].a = 0.8f;
					// z-axis
					quat[ 4 ] = Quaternion.FromAxes( Vector3.UnitZ, Vector3.UnitY, Vector3.NegativeUnitX );
					quat[ 5 ] = Quaternion.FromAxes( Vector3.UnitZ, Vector3.UnitX, Vector3.UnitY );
					col[ 2 ] = ColorEx.Blue;
					col[ 2 ].a = 0.8f;

					Vector3[] basepos = new Vector3[ 7 ]  
										{
											// stalk
											new Vector3(0f, 0.05f, 0f), 
											new Vector3(0f, -0.05f, 0f),
											new Vector3(0.7f, -0.05f, 0f),
											new Vector3(0.7f, 0.05f, 0f),
											// head
											new Vector3(0.7f, -0.15f, 0f),
											new Vector3(1f, 0f, 0f),
											new Vector3(0.7f, 0.15f, 0f)
										};


					// vertices
					// 6 arrows
					for ( int i = 0; i < 6; ++i )
					{
						// 7 points
						for ( int p = 0; p < 7; ++p )
						{
							Vector3 pos = quat[ i ] * basepos[ p ];
							mo.Position( pos );
							mo.Color( col[ i / 2 ] );
						}
					}

					// indices
					// 6 arrows
					for ( int i = 0; i < 6; ++i )
					{
						ushort baseIndex = (ushort)( i * 7 );
						mo.Triangle( (ushort)( baseIndex + 0 ), (ushort)( baseIndex + 1 ), (ushort)( baseIndex + 2 ) );
						mo.Triangle( (ushort)( baseIndex + 0 ), (ushort)( baseIndex + 2 ), (ushort)( baseIndex + 3 ) );
						mo.Triangle( (ushort)( baseIndex + 4 ), (ushort)( baseIndex + 5 ), (ushort)( baseIndex + 6 ) );
					}

					mo.End();

					_mesh = mo.ConvertToMesh( meshName, ResourceGroupManager.InternalResourceGroupName );
				}
			}
    public void Initialise(SceneManager aSceneManager, float aFillAlpha)
    {
        if (isInitialised) {
            // Initialization multiple call guard
            return;
        }

        if (aSceneManager == null) {
            return;
        }

        m_sceneManager = aSceneManager;
        fillAlpha = aFillAlpha;
        m_manualObject = null;
        linesIndex = 0;
        trianglesIndex = 0;

        m_manualObject = m_sceneManager.CreateManualObject("debugDrawer_object");
        m_manualObject.CastShadows = false;

        m_sceneManager.RootSceneNode.CreateChildSceneNode("debugDrawer_object").AttachObject(m_manualObject);
        m_manualObject.Dynamic = (true);

        icoSphere.Create(this.DEFAULT_ICOSPHERE_RECURSION_LEVEL);

        m_manualObject.Begin("debug_draw", RenderOperation.OperationTypes.OT_LINE_LIST);
        m_manualObject.Position(Vector3.ZERO);
        m_manualObject.Colour(ColourValue.ZERO);
        m_manualObject.Index(0);
        m_manualObject.End();
        m_manualObject.Begin("debug_draw", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
        m_manualObject.Position(Vector3.ZERO);
        m_manualObject.Colour(ColourValue.ZERO);
        m_manualObject.Index(0);
        m_manualObject.End();

        trianglesIndex = 0;
        linesIndex = trianglesIndex;

        isInitialised = true;
        // Initialization multiple call guard
    }
Exemplo n.º 47
0
        public static void generateFace()
        {
            string defaultMaterial = "Default";

            ManualObject block = new ManualObject("frontFace");
            block.Begin(defaultMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            block.Position(new Vector3(0, 0, 0));                                     block.TextureCoord(1, 1); block.Normal(VanillaMultiBlock.normals[0]);
            block.Position(new Vector3(0, Cst.CUBE_SIDE, 0));                   block.TextureCoord(1, 0); block.Normal(VanillaMultiBlock.normals[0]);
            block.Position(new Vector3(Cst.CUBE_SIDE, Cst.CUBE_SIDE, 0)); block.TextureCoord(0, 0); block.Normal(VanillaMultiBlock.normals[0]);
            block.Position(new Vector3(Cst.CUBE_SIDE, 0, 0)); block.TextureCoord(0, 1); block.Normal(VanillaMultiBlock.normals[0]);

            block.Quad(3, 2, 1, 0);
            block.End();
            block.ConvertToMesh("frontFace");

            block = new ManualObject("underFace");
            block.Begin(defaultMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            block.Position(new Vector3(0, 0, 0));                                      block.TextureCoord(1, 1); block.Normal(VanillaMultiBlock.normals[1]);
            block.Position(new Vector3(0, 0, -Cst.CUBE_SIDE));                   block.TextureCoord(1, 0); block.Normal(VanillaMultiBlock.normals[1]);
            block.Position(new Vector3(Cst.CUBE_SIDE, 0, -Cst.CUBE_SIDE)); block.TextureCoord(0, 0); block.Normal(VanillaMultiBlock.normals[1]);
            block.Position(new Vector3(Cst.CUBE_SIDE, 0, 0));                    block.TextureCoord(0, 1); block.Normal(VanillaMultiBlock.normals[1]);

            block.Quad(0, 1, 2, 3);
            block.End();
            block.ConvertToMesh("underFace");

            block = new ManualObject("rightFace");
            block.Begin(defaultMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            block.Position(new Vector3(Cst.CUBE_SIDE, 0, 0));                                      block.TextureCoord(0, 1); block.Normal(VanillaMultiBlock.normals[2]);
            block.Position(new Vector3(Cst.CUBE_SIDE, 0, -Cst.CUBE_SIDE));                   block.TextureCoord(1, 1); block.Normal(VanillaMultiBlock.normals[2]);
            block.Position(new Vector3(Cst.CUBE_SIDE, Cst.CUBE_SIDE, -Cst.CUBE_SIDE)); block.TextureCoord(1, 0); block.Normal(VanillaMultiBlock.normals[2]);
            block.Position(new Vector3(Cst.CUBE_SIDE, Cst.CUBE_SIDE, 0));                    block.TextureCoord(0, 0); block.Normal(VanillaMultiBlock.normals[2]);

            block.Quad(0, 1, 2, 3);
            block.End();
            block.ConvertToMesh("rightFace");

            block = new ManualObject("upperFace");
            block.Begin(defaultMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            block.Position(new Vector3(Cst.CUBE_SIDE, Cst.CUBE_SIDE, 0));                    block.TextureCoord(1, 1); block.Normal(VanillaMultiBlock.normals[3]);
            block.Position(new Vector3(Cst.CUBE_SIDE, Cst.CUBE_SIDE, -Cst.CUBE_SIDE)); block.TextureCoord(1, 0); block.Normal(VanillaMultiBlock.normals[3]);
            block.Position(new Vector3(0, Cst.CUBE_SIDE, -Cst.CUBE_SIDE));                   block.TextureCoord(0, 0); block.Normal(VanillaMultiBlock.normals[3]);
            block.Position(new Vector3(0, Cst.CUBE_SIDE, 0));                                      block.TextureCoord(0, 1); block.Normal(VanillaMultiBlock.normals[3]);

            block.Quad(0, 1, 2, 3);
            block.End();
            block.ConvertToMesh("upperFace");

            block = new ManualObject("leftFace");
            block.Begin(defaultMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            block.Position(new Vector3(0, 0, 0));                                      block.TextureCoord(1, 1); block.Normal(VanillaMultiBlock.normals[4]);
            block.Position(new Vector3(0, Cst.CUBE_SIDE, 0));                    block.TextureCoord(1, 0); block.Normal(VanillaMultiBlock.normals[4]);
            block.Position(new Vector3(0, Cst.CUBE_SIDE, -Cst.CUBE_SIDE)); block.TextureCoord(0, 0); block.Normal(VanillaMultiBlock.normals[4]);
            block.Position(new Vector3(0, 0, -Cst.CUBE_SIDE));                   block.TextureCoord(0, 1); block.Normal(VanillaMultiBlock.normals[4]);

            block.Quad(0, 1, 2, 3);
            block.End();
            block.ConvertToMesh("leftFace");

            block = new ManualObject("backFace");
            block.Begin(defaultMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            block.Position(new Vector3(0, 0, -Cst.CUBE_SIDE));                                     block.TextureCoord(1, 1); block.Normal(VanillaMultiBlock.normals[5]);
            block.Position(new Vector3(0, Cst.CUBE_SIDE, -Cst.CUBE_SIDE));                   block.TextureCoord(1, 0); block.Normal(VanillaMultiBlock.normals[5]);
            block.Position(new Vector3(Cst.CUBE_SIDE, Cst.CUBE_SIDE, -Cst.CUBE_SIDE)); block.TextureCoord(0, 0); block.Normal(VanillaMultiBlock.normals[5]);
            block.Position(new Vector3(Cst.CUBE_SIDE, 0, -Cst.CUBE_SIDE));                   block.TextureCoord(0, 1); block.Normal(VanillaMultiBlock.normals[5]);

            block.Quad(0, 1, 2, 3);
            block.End();
            block.ConvertToMesh("backFace");
        }