示例#1
0
        //
        //ORIGINAL LINE: Ogre::MeshPtr transformToMesh(const string& name, const Ogre::String& group = "General") const
        //
        public MeshPtr transformToMesh(string name, string group)
        {
            //Mogre.SceneManager sceneMgr = Root.Singleton.GetSceneManagerIterator().Current;
            Mogre.SceneManagerEnumerator.SceneManagerIterator item = Root.Singleton.GetSceneManagerIterator();
            item.MoveNext();
            Mogre.SceneManager sceneMgr = item.Current;
            item.Dispose();
            Mogre.ManualObject manual = sceneMgr.CreateManualObject(name);
            manual.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);

            foreach (var it in mVertices)
            {
                manual.Position(it.mPosition);
                manual.TextureCoord(it.mUV);
                manual.Normal(it.mNormal);
            }
            foreach (var it in mIndices)
            {
                manual.Index((ushort)it);
            }
            manual.End();

            Mogre.MeshPtr mesh = manual.ConvertToMesh(name, group);

            sceneMgr.DestroyManualObject(manual);

            return(mesh);
        }
示例#2
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);
        }
        /// 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);
        }
        public MeshPtr buildMesh(string name, string group)
        {
            System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(name));
            if (string.IsNullOrEmpty(name))
            {
                name = Utils.getName("debugrender_procedural");
            }
            //SceneManager sceneMgr = Root.Singleton.GetSceneManagerIterator().Current;
            Mogre.SceneManagerEnumerator.SceneManagerIterator item = Root.Singleton.GetSceneManagerIterator();
            item.MoveNext();
            Mogre.SceneManager sceneMgr = item.Current;
            item.Dispose();
            ManualObject mo   = buildManualObject();
            MeshPtr      mesh = mo.ConvertToMesh(name, group);

            sceneMgr.DestroyManualObject(mo);

            return(mesh);
        }