Ejemplo n.º 1
0
        public override void CreateScene()
        {
            ushort points = (ushort)(blockSize + 1);

            for (int i = 0; i < nodesL0.Length; i++)
            {
                nodesL0[i] = base.sceneMgr.RootSceneNode.CreateChildSceneNode("TerrainBlockNodeL0_" + i);
            }

            ManualObject[] manualObjsL0 = new ManualObject[nodesL0.Length];
            for (int i = 0; i < manualObjsL0.Length; i++)
            {
                manualObjsL0[i] = sceneMgr.CreateManualObject("TerrainBlockObjectL0_" + i);
            }

            objSect[0] = BuildTerrainBlock(manualObjsL0[0], points, points, new Vector4(-blockSize, 0, 1, 1), greenBlock);
            objSect[1] = BuildTerrainBlock(manualObjsL0[1], points, points, new Vector4(0, 0, 1, 1), redBlock);
            objSect[2] = BuildTerrainBlock(manualObjsL0[2], points, points, new Vector4(-blockSize, -blockSize, 1, 1), redBlock);
            objSect[3] = BuildTerrainBlock(manualObjsL0[3], points, points, new Vector4(0, -blockSize, 1, 1), greenBlock);

            for (int i = 0; i < nodesL0.Length; i++)
            {
                nodesL0[i].AttachObject(manualObjsL0[i]);
            }
        }
Ejemplo n.º 2
0
        public SceneNode point3d(string name, int id, float x, float y, float z, SceneNode node, SceneManager sceneMgr)
        {
            Entity ent;

            if (node == null)//point of reference 0,0,0
            {
                ManualObject aux = sceneMgr.CreateManualObject();
                //ent = sceneMgr.CreateEntity(name + id, this.getNameEntities());
                node = sceneMgr.RootSceneNode.CreateChildSceneNode(name + id + "Node", new Vector3(y, z, x));
                node.AttachObject(aux);
                return(node);
            }
            else//create new point
            {
                float xAux = x;
                float yAux = y;

                SceneNode nodeAux;

                ent     = sceneMgr.CreateEntity(name + id, getNameEntities());
                nodeAux = node.CreateChildSceneNode(name + "Node_" + id, new Vector3(yAux, z, xAux));

                nodeAux.AttachObject(ent);
                return(nodeAux);
            }
        }
        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
Ejemplo n.º 4
0
        public override void CreateScene()
        {
            TexturePtr mTexture = TextureManager.Singleton.CreateManual("RenderArea",
                                      ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D,
                                      512, 512, 0, PixelFormat.PF_R8G8B8, (int)TextureUsage.TU_RENDERTARGET);
            rttTex = mTexture.GetBuffer().GetRenderTarget();
            rttTex.IsAutoUpdated = false;
            {
                // Create the camera
                Camera camera2 = sceneMgr.CreateCamera("PlayerCam2");

                camera2.Position = new Vector3(0, 0, 3);
                camera2.LookAt(new Vector3(0.0f, 0.0f, 0.0f));
                camera2.NearClipDistance = 1;

                Viewport v = rttTex.AddViewport(camera2);

                MaterialPtr mat = MaterialManager.Singleton.GetByName("CgTutorials/RenderToTexture_Material");
                mat.GetTechnique(0).GetPass(0).GetTextureUnitState(0).SetTextureName("RenderArea");
                v.BackgroundColour = new ColourValue(0.0f, 0.3f, 0.2f, 0.0f);
                //v.SetClearEveryFrame(false);
                //v.OverlaysEnabled = false;
                rttTex.PreRenderTargetUpdate += new RenderTargetListener.PreRenderTargetUpdateHandler(RenderArea_PreRenderTargetUpdate);
                rttTex.PostRenderTargetUpdate += new RenderTargetListener.PostRenderTargetUpdateHandler(RenderArea_PostRenderTargetUpdate);
            }

            node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("TutorialRender2TexNode1");
            node2 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("TutorialRender2TexNode2");

            manualObj1 = sceneMgr.CreateManualObject("TutorialRender2TexObject1");
            manualObj2 = sceneMgr.CreateManualObject("TutorialRender2TexObject2");

            node1.AttachObject(DrawTriangle1(manualObj1));
            node2.AttachObject(DrawTriangle2(manualObj2));
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo 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
        }
Ejemplo 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);
        }
Ejemplo n.º 10
0
        public override void CreateScene()
        {
            const uint constantColor = 123;

            SceneNode node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Tutorial03Node1");
            SceneNode node2 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Tutorial03Node2");

            ManualObject manualObj1 = sceneMgr.CreateManualObject("Tutorial03Object1");
            ManualObject manualObj2 = sceneMgr.CreateManualObject("Tutorial03Object2");


            /*                                  star    outer   inner  */
            /*                     x      y     Points  radius  radius */
            /*                  =====  =====  ======  ======  ====== */
            ManualObject.ManualObjectSection objSection;
            objSection = DrawStar(manualObj1, -10.0f, -10.0f, 5, 50.0f, 20.0f);
            objSection.SetCustomParameter(constantColor, new Vector4(0.0f, 1.0f, 0.0f, 1.0f));// Green

            objSection = DrawStar(manualObj2, 94.0f, 10.0f, 5, 50.0f, 20.0f);
            objSection.SetCustomParameter(constantColor, new Vector4(1.0f, 0.0f, 0.0f, 1.0f)); // Red

            node1.AttachObject(manualObj1);
            node2.AttachObject(manualObj2);

            MovableText text1 = new MovableText("text1", this.sceneMgr, node1, new Size(128, 32));

            text1.SetText("Node 1!", new System.Drawing.Font(FontFamily.GenericSansSerif, 16, FontStyle.Regular, GraphicsUnit.Pixel), Color.Green);
            text1.Offset = new Vector3(-10.0f + 25f, -10.0f + 25f, 5.0f);

            MovableText text2 = new MovableText("text2", this.sceneMgr, node2, new Size(128, 32));

            text2.SetText("Node 2!", new System.Drawing.Font(FontFamily.GenericSerif, 16, FontStyle.Regular, GraphicsUnit.Pixel), Color.Red);
            text2.Offset = new Vector3(94.0f + 25f, 10.0f + 25f, 5.0f);
        }
Ejemplo n.º 11
0
        public override void CreateScene()
        {
            SceneNode node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Tutorial01Node");

            theObj = CreateNode("Tutorial01Object", base.sceneMgr, false);
            node1.AttachObject(theObj);
        }
        protected override void link()
        {
            SceneNodeElement sceneNode = Owner.getElement(nodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Could not find node {0}.", nodeName);
            }
            entity = sceneNode.getNodeObject(entityName) as ManualObject;
            if (entity == null)
            {
                blacklist("No entity specified or entity is not found.");
            }
            if (subEntityIndex >= entity.getNumSections())
            {
                blacklist("Entity {0} only has {1} SubEntities. Index {2} is invalid.", entity.getName(), entity.getNumSections(), subEntityIndex);
            }
            subEntity        = entity.getSection(subEntityIndex);
            baseMaterialName = subEntity.getMaterialName();
            MaterialManager materialManager   = MaterialManager.getInstance();
            String          alphaMaterialName = baseMaterialName + alphaSuffix;

            if (materialManager.resourceExists(alphaMaterialName))
            {
                finalAlphaMaterialName = alphaMaterialName;
            }
            else
            {
                blacklist("Cannot find automatic alpha material {0}.  Please ensure one exists or define a custom alpha behavior.", alphaMaterialName);
            }
        }
Ejemplo n.º 13
0
        public void Create()
        {
            // create the solid object
            this.solidObject = Engine.Graphics.SceneManager.CreateManualObject();
            this.solidObject.VisibilityFlags = ViewportController.VF_PERSPECTIVE;
            this.solidObject.UserObject      = this;

            DrawSolid(false);

            // create the wireframe version
            float r = Mogre.Math.RangeRandom(0.5f, 1.0f);
            float g = Mogre.Math.RangeRandom(0.5f, 1.0f);
            float b = Mogre.Math.RangeRandom(0.5f, 1.0f);

            this.colour = new ColourValue(r, g, b);

            this.wireObject = Engine.Graphics.SceneManager.CreateManualObject();
            this.wireObject.VisibilityFlags = ViewportController.VF_ORTHOGRAPHIC;
            this.wireObject.UserObject      = this;

            DrawWire(false);

            SceneNode sceneNode = Engine.Graphics.SceneManager.RootSceneNode.CreateChildSceneNode();

            sceneNode.AttachObject(solidObject);
            sceneNode.AttachObject(wireObject);
        }
Ejemplo n.º 14
0
 public ManualObjectSectionShadowRenderable(ManualObject parent, HardwareIndexBufferPtr indexBuffer, VertexData vertexData, bool createSeparateLightCap) : this(OgrePINVOKE.new_ManualObject_ManualObjectSectionShadowRenderable__SWIG_1(ManualObject.getCPtr(parent), HardwareIndexBufferPtr.getCPtr(indexBuffer), VertexData.getCPtr(vertexData), createSeparateLightCap), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
 public ManualObjectSection(ManualObject parent, string materialName, RenderOperation.OperationType opType, string groupName) : this(OgrePINVOKE.new_ManualObject_ManualObjectSection__SWIG_0(ManualObject.getCPtr(parent), materialName, (int)opType, groupName), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 17
0
 public ManualObjectSection(ManualObject parent, MaterialPtr mat, RenderOperation.OperationType opType) : this(OgrePINVOKE.new_ManualObject_ManualObjectSection__SWIG_2(ManualObject.getCPtr(parent), MaterialPtr.getCPtr(mat), (int)opType), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 18
0
        /* Apply an inefficient but simple-to-implement subdivision scheme for a triangle. */
        static void TriangleDivide(ManualObject obj, int depth,
            float[] a, float[] b, float[] c,
            float[] ca, float[] cb, float[] cc)
        {
            if (depth == 0)
            {
                obj.Position(c[0], c[1], 0);
                obj.Colour(cc[0], cc[1], cc[2]);
                obj.Position(b[0], b[1], 0);
                obj.Colour(cb[0], cb[1], cb[2]);
                obj.Position(a[0], a[1], 0);
                obj.Colour(ca[0], ca[1], ca[2]);
            }
            else
            {
                float[] d = new float[2] { (a[0] + b[0]) / 2, (a[1] + b[1]) / 2 };
                float[] e = new float[2] { (b[0] + c[0]) / 2, (b[1] + c[1]) / 2 };
                float[] f = new float[2] { (c[0] + a[0]) / 2, (c[1] + a[1]) / 2 };
                float[] cd = new float[3] { (ca[0] + cb[0]) / 2, (ca[1] + cb[1]) / 2, (ca[2] + cb[2]) / 2 };
                float[] ce = new float[3] { (cb[0] + cc[0]) / 2, (cb[1] + cc[1]) / 2, (cb[2] + cc[2]) / 2 };
                float[] cf = new float[3] { (cc[0] + ca[0]) / 2, (cc[1] + ca[1]) / 2, (cc[2] + ca[2]) / 2 };

                depth -= 1;
                TriangleDivide(obj, depth, a, d, f, ca, cd, cf);
                TriangleDivide(obj, depth, d, b, e, cd, cb, ce);
                TriangleDivide(obj, depth, f, e, c, cf, ce, cc);
                TriangleDivide(obj, depth, d, e, f, cd, ce, cf);
            }
        }
Ejemplo n.º 19
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
        }
Ejemplo n.º 20
0
        protected override void link()
        {
            var node = Owner.getElement(NodeName) as SceneNodeElement;

            if (node == null)
            {
                blacklist($"Cannot find SceneNodeElement {NodeName}");
            }

            manualObject = node.getNodeObject(ManualObjectName) as ManualObject;
            if (manualObject == null)
            {
                blacklist($"Cannot find ManualObject {ManualObjectName} on SceneNodeElement {NodeName}");
            }

            drawTile();

            rigidBody = Owner.getElement(RigidBodyName) as ReshapeableRigidBody;
            if (rigidBody != null)
            {
                rigidBody.beginUpdates();
                var section = rigidBody.createSection("Tile", Vector3.Zero, Quaternion.Identity, Vector3.ScaleIdentity);
                rigidBody.finishUpdates();
                rigidBody.setLocalScaling(Dimensions * TileSize);
            }

            base.link();
        }
Ejemplo n.º 21
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()));
        }
Ejemplo n.º 22
0
        public override void CreateScene()
        {
            ushort points = (ushort)(blockSize + 1);

            for (int i = 0; i < nodesL0.Length; i++)
            {
                nodesL0[i] = base.sceneMgr.RootSceneNode.CreateChildSceneNode("TerrainBlockNodeL0_" + i);
            }

            ManualObject[] manualObjsL0 = new ManualObject[nodesL0.Length];
            for (int i = 0; i < manualObjsL0.Length; i++)
            {
                manualObjsL0[i] = sceneMgr.CreateManualObject("TerrainBlockObjectL0_" + i);
            }

            objSect[0] = BuildTerrainBlock(manualObjsL0[0], points, points, new Vector4(-blockSize, 0, 1, 1), greenBlock);
            objSect[1] = BuildTerrainBlock(manualObjsL0[1], points, points, new Vector4(0, 0, 1, 1), redBlock);
            objSect[2] = BuildTerrainBlock(manualObjsL0[2], points, points, new Vector4(-blockSize, -blockSize, 1, 1), redBlock);
            objSect[3] = BuildTerrainBlock(manualObjsL0[3], points, points, new Vector4(0, -blockSize, 1, 1), greenBlock);

            for (int i = 0; i < nodesL0.Length; i++)
            {
                nodesL0[i].AttachObject(manualObjsL0[i]);
            }
        }
Ejemplo n.º 23
0
        public override void CreateScene()
        {
            SceneNode node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Tutorial02Node");

            ManualObject manualObj1 = sceneMgr.CreateManualObject("Tutorial02Object1");
            ManualObject manualObj2 = sceneMgr.CreateManualObject("Tutorial02Object2");
            ManualObject manualObj3 = sceneMgr.CreateManualObject("Tutorial02Object3");
            ManualObject manualObj4 = sceneMgr.CreateManualObject("Tutorial02Object4");
            ManualObject manualObj5 = sceneMgr.CreateManualObject("Tutorial02Object5");
            ManualObject manualObj6 = sceneMgr.CreateManualObject("Tutorial02Object6");

            /*                                  star    outer   inner  */
            /*                     x      y     Points  radius  radius */
            /*                  =====  =====  ======  ======  ====== */
            DrawStar(manualObj1, -0.1f, 0.0f, 5, 0.5f, 0.2f);
            DrawStar(manualObj2, -0.84f, 0.1f, 5, 0.3f, 0.12f);
            DrawStar(manualObj3, 0.92f, -0.5f, 5, 0.25f, 0.11f);
            DrawStar(manualObj4, 0.3f, 0.97f, 5, 0.3f, 0.1f);
            DrawStar(manualObj5, 0.94f, 0.3f, 5, 0.5f, 0.2f);
            DrawStar(manualObj6, -0.97f, -0.8f, 5, 0.6f, 0.2f);

            node1.AttachObject(manualObj1);
            node1.AttachObject(manualObj2);
            node1.AttachObject(manualObj3);
            node1.AttachObject(manualObj4);
            node1.AttachObject(manualObj5);
            node1.AttachObject(manualObj6);
        }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
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();
        }
Ejemplo n.º 26
0
        public override void CreateScene()
        {
            SceneNode node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Tutorial04Node1");

            ManualObject manualObj1 = sceneMgr.CreateManualObject("Tutorial04Object1");

            node1.AttachObject(DrawTriangle(manualObj1));
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Calculate the normal data
        /// </summary>
        /// <param name="worldMapTerrain">Manual Object</param>
        /// <param name="worldMap">World Map</param>
        private void calculateNormal(ManualObject worldMapTerrain, MBWorldMap worldMap)
        {
            worldMap.fcn = new List <float[]>();
            worldMap.vtn = new List <float[]>();
            worldMap.cfa = new List <float>();

            List <List <int> > vtxi = new List <List <int> >();

            for (int i = 0; i < worldMap.Vertics.Count; i++)
            {
                vtxi.Add(new List <int>());
            }
            for (int i = 0; i < worldMap.Faces.Count; i++)
            {
                worldMap.vtn.Add(new float[] { 0, 0, 0 });
            }

            for (int i = 0; i < worldMap.Faces.Count; i++)
            {
                int vta = worldMap.Faces[i].indexFirst;
                int vtb = worldMap.Faces[i].indexSecond;
                int vtc = worldMap.Faces[i].indexThird;

                vtxi[vta].Add(i);
                vtxi[vtb].Add(i);
                vtxi[vtc].Add(i);

                Vector3 normalData = computeNorm(new int[]
                {
                    worldMap.Faces[i].indexFirst,
                    worldMap.Faces[i].indexSecond,
                    worldMap.Faces[i].indexThird
                }, worldMap.Vertics);
                worldMap.fcn.Add(new float[] { normalData.x, normalData.y, normalData.z });

                worldMap.cfa.Add(computeArea(new int[]
                {
                    worldMap.Faces[i].indexFirst,
                    worldMap.Faces[i].indexSecond,
                    worldMap.Faces[i].indexThird
                }, worldMap.Vertics));
            }

            for (int i = 0; i < vtxi.Count; i++)
            {
                if (vtxi[i] != null && vtxi[i].Count > 0)
                {
                    Vector3 triangle = new Vector3(0, 0, 0);
                    for (int u = 0; u < vtxi[i].Count; u++)
                    {
                        var currentface = vtxi[i][u];
                        triangle = triangle + new Vector3(worldMap.Faces[currentface].indexFirst, worldMap.Faces[currentface].indexSecond, worldMap.Faces[currentface].indexThird) * worldMap.cfa[currentface];
                    }
                    var normalizedVector = (triangle / vtxi[i].Count).NormalisedCopy;
                    worldMap.vtn[i] = (new float[] { normalizedVector.x, normalizedVector.y, normalizedVector.z });
                }
            }
        }
Ejemplo n.º 28
0
        public void Create(AxisAlignedBox box)
        {
            this.wireBox = this.CreateViewportManualObject(vfFlag);

            SetupBox(box);
            Draw(false);

            Engine.Graphics.SceneManager.RootSceneNode.AttachObject(this.wireBox);
        }
Ejemplo n.º 29
0
        public override void frameHook(float interpolation)//called every video frame before render
        {
            if (!ready && OgreWindow.Instance.SceneReady)
            {
                ready = true;

                ManualObject asdf = OgreWindow.Instance.mSceneMgr.CreateManualObject();
            }
        }
Ejemplo n.º 30
0
        private ManualObject CreateViewportManualObject(uint vfFlag)
        {
            ManualObject manualObject = Engine.Graphics.SceneManager.CreateManualObject();

            manualObject.Dynamic         = true;
            manualObject.QueryFlags      = 0;
            manualObject.VisibilityFlags = vfFlag;
            return(manualObject);
        }
Ejemplo n.º 31
0
        public void Create(AxisAlignedBox box)
        {
            this.wireBox = this.CreateViewportManualObject(vfFlag);

            SetupBox(box);
            Draw(false);

            Engine.Graphics.SceneManager.RootSceneNode.AttachObject(this.wireBox);
        }
Ejemplo n.º 32
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;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Wczorok¹t w view. Klasa pomocnicza
        /// <author>Adam Witczak</author>
        /// </summary>
        /// <param name="name"></param>
        public Quadrangle3D(SceneManager sceneMgr, String name)
        {
            if (sceneMgr.HasManualObject(name))
            {
                sceneMgr.DestroyManualObject(name);
            }
            manualObject = sceneMgr.CreateManualObject(name);

            this.sceneMgr = sceneMgr;
            this.name     = name;
        }
Ejemplo n.º 34
0
 public void EndBlock()
 {
     Console.WriteLine("EndBlock");
     if (node1 == null)
     {
         node1 = sceneManager.RootSceneNode.CreateChildSceneNode("Lines3DNode_1");
     }
     ManualObject.ManualObjectSection section = rendererObj.End();
     node1.AttachObject(rendererObj);
     rendererObj = null;
 }
Ejemplo n.º 35
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;
        }
Ejemplo n.º 36
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;
        }
Ejemplo n.º 37
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();
        }
Ejemplo n.º 38
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;
        }
Ejemplo n.º 39
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;
        }
Ejemplo n.º 40
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;
        }
Ejemplo n.º 41
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();
        }
Ejemplo n.º 42
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);
        }
Ejemplo n.º 43
0
        public ManualObject CreateNode(string name, SceneManager sceneMgr, bool isClosed, int useMaterial, Vector4 color)
        {
            if (lines3d == null)
            {
                lines3d = sceneMgr.CreateManualObject(name);
                for (int i = 0; i < pointsList.Count - 1; i++)
                {
                    CreateLine(lines3d, pointsList[i], pointsList[i + 1], useMaterial, color);
                }
                if (isClosed && pointsList.Count > 1)
                {
                    CreateLine(lines3d, pointsList[pointsList.Count - 1], pointsList[0], useMaterial, color);
                }

            }
            return lines3d;
        }
Ejemplo n.º 44
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;
        }
Ejemplo n.º 45
0
        private void UpdateWireBox()
        {
            if (this.wireBox == null)
            {
                this.wireBox = Engine.Graphics.SceneManager.CreateManualObject();
                this.wireBox.Dynamic = true;
                this.wireBox.QueryFlags = 0;
                this.wireBox.VisibilityFlags = ViewportController.VF_PERSPECTIVE;

                Engine.Graphics.SceneManager.RootSceneNode.AttachObject(wireBox);
                this.wireBox.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_LINE_LIST);
            }
            else
            {
                this.wireBox.BeginUpdate(0);
            }

            Vector3[] corners = box.GetAllCorners();
            this.wireBox.Position(corners[0]);  // back quad
            this.wireBox.Position(corners[1]);
            this.wireBox.Position(corners[1]);
            this.wireBox.Position(corners[2]);
            this.wireBox.Position(corners[2]);
            this.wireBox.Position(corners[3]);
            this.wireBox.Position(corners[3]);
            this.wireBox.Position(corners[0]);

            this.wireBox.Position(corners[0]);  // back to front lines
            this.wireBox.Position(corners[6]);
            this.wireBox.Position(corners[1]);
            this.wireBox.Position(corners[5]);
            this.wireBox.Position(corners[2]);
            this.wireBox.Position(corners[4]);
            this.wireBox.Position(corners[3]);
            this.wireBox.Position(corners[7]);

            this.wireBox.Position(corners[7]);  // front quad
            this.wireBox.Position(corners[6]);
            this.wireBox.Position(corners[6]);
            this.wireBox.Position(corners[5]);
            this.wireBox.Position(corners[5]);
            this.wireBox.Position(corners[4]);
            this.wireBox.Position(corners[4]);
            this.wireBox.Position(corners[7]);
            this.wireBox.End();
        }
    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
    }
Ejemplo n.º 47
0
        public ManualObject CreateNode(string name, SceneManager sceneMgr, bool isClosed)
        {
            if (lineNode == null)
            {
                lineNode = sceneMgr.CreateManualObject(name);
                MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourPolygon",
                         ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
                material.GetTechnique(0).GetPass(0).VertexColourTracking =
                               (int)TrackVertexColourEnum.TVC_AMBIENT;

                int nSeg = 5; // Number of segments on the cap or join pieces
                BufferParameters param = new BufferParameters(nSeg, BufferParameters.BufferEndCapStyle.CapRound, BufferParameters.BufferJoinStyle.JoinRound, 2);
                IGeometry coordBuffer = line1.Buffer(0.5, param);

                Tesselate(coordBuffer.Coordinates);
            }
            return lineNode;
        }
Ejemplo n.º 48
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;
        }
Ejemplo n.º 49
0
 public MogreTessellationCallbacks(ManualObject mo, Script color, Feature feature)
 {
     manualObj = mo;
     this.feature = feature;
     vec3 = color;
 }
Ejemplo n.º 50
0
        public void Create(string name, SceneManager sceneManager, Vector3 axis)
        {
            this.manualObject = sceneManager.CreateManualObject(Engine.UniqueName(name + "Grid"));
            this.manualObject.QueryFlags = 0; // exlcude from scene queries
            this.manualObject.RenderQueueGroup = (byte)Mogre.RenderQueueGroupID.RENDER_QUEUE_OVERLAY - 1;

            Draw(false);

            this.normal = axis;
            this.sceneNode = sceneManager.RootSceneNode.CreateChildSceneNode();
            this.sceneNode.AttachObject(this.manualObject);
            this.sceneNode.Orientation = Vector3.UNIT_Z.GetRotationTo(axis);
        }
Ejemplo n.º 51
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);
        }
Ejemplo n.º 52
0
		// Create portals for every door
		public void createPortals( SceneManager scene,
									   ManualObject room,
									   SceneNode roomNode,
									   PCZone zone,
									   short doorFlags,
									   bool isEnclosure )
		{
			string portalName;
			Vector3[] corners = new Vector3[ 4 ];

			if ( isEnclosure )
			{
				if ( ( doorFlags & (short)RoomDoors.DOOR_FRONT ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 8 ];
					corners[ 1 ] = points[ 9 ];
					corners[ 2 ] = points[ 10 ];
					corners[ 3 ] = points[ 11 ];
					// create the portal
					portalName = room.Name + "_FrontDoorPortal";
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_BACK ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 15 ];
					corners[ 1 ] = points[ 14 ];
					corners[ 2 ] = points[ 13 ];
					corners[ 3 ] = points[ 12 ];
					// create the portal
					portalName = room.Name + ( "_BackDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_TOP ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 16 ];
					corners[ 1 ] = points[ 17 ];
					corners[ 2 ] = points[ 18 ];
					corners[ 3 ] = points[ 19 ];
					// create the portal
					portalName = room.Name + ( "_TopDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_BOT ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 23 ];
					corners[ 1 ] = points[ 22 ];
					corners[ 2 ] = points[ 21 ];
					corners[ 3 ] = points[ 20 ];
					// create the portal
					portalName = room.Name + ( "_BottomDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_LEFT ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 27 ];
					corners[ 1 ] = points[ 26 ];
					corners[ 2 ] = points[ 25 ];
					corners[ 3 ] = points[ 24 ];
					// create the portal
					portalName = room.Name + ( "_LeftDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_RIGHT ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 28 ];
					corners[ 1 ] = points[ 29 ];
					corners[ 2 ] = points[ 30 ];
					corners[ 3 ] = points[ 31 ];
					// create the portal
					portalName = room.Name + ( "_RightDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
			}
			else
			{
				if ( ( doorFlags & (short)RoomDoors.DOOR_FRONT ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 11 ];
					corners[ 1 ] = points[ 10 ];
					corners[ 2 ] = points[ 9 ];
					corners[ 3 ] = points[ 8 ];
					// create the portal
					portalName = room.Name + ( "_FrontDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_BACK ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 12 ];
					corners[ 1 ] = points[ 13 ];
					corners[ 2 ] = points[ 14 ];
					corners[ 3 ] = points[ 15 ];
					// create the portal
					portalName = room.Name + ( "_BackDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_TOP ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 19 ];
					corners[ 1 ] = points[ 18 ];
					corners[ 2 ] = points[ 17 ];
					corners[ 3 ] = points[ 16 ];
					// create the portal
					portalName = room.Name + ( "_TopDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_BOT ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 20 ];
					corners[ 1 ] = points[ 21 ];
					corners[ 2 ] = points[ 22 ];
					corners[ 3 ] = points[ 23 ];
					// create the portal
					portalName = room.Name + ( "_BottomDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_LEFT ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 24 ];
					corners[ 1 ] = points[ 25 ];
					corners[ 2 ] = points[ 26 ];
					corners[ 3 ] = points[ 27 ];
					// create the portal
					portalName = room.Name + ( "_LeftDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_RIGHT ) != 0 )
				{
					// set the corners to the front door corners
					corners[ 0 ] = points[ 31 ];
					corners[ 1 ] = points[ 30 ];
					corners[ 2 ] = points[ 29 ];
					corners[ 3 ] = points[ 28 ];
					// create the portal
					portalName = room.Name + ( "_RightDoorPortal" );
					Portal p = ( (PCZSceneManager)scene ).CreatePortal( portalName, PORTAL_TYPE.PORTAL_TYPE_QUAD );
					p.setCorners( corners );
					// associate the portal with the roomnode
					p.setNode( roomNode );
					// add the portal to the zone
					zone.AddPortal( p );
					// update derived values for the portal
					p.updateDerivedValues();
				}
			}
		}
Ejemplo n.º 53
0
		public void createWalls( ManualObject room,
									 short doorFlags,
									 bool isEnclosure )
		{

			if ( isEnclosure )
			{
				if ( ( doorFlags & (short)RoomDoors.DOOR_FRONT ) != 0 )
				{
					// make front wall outward facing with door
					room.Quad( 0, 8, 11, 3 );
					room.Quad( 1, 9, 8, 0 );
					room.Quad( 2, 10, 9, 1 );
					room.Quad( 3, 11, 10, 2 );
				}
				else
				{
					// make front wall outward facing without door
					room.Quad( 0, 1, 2, 3 );
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_BACK ) != 0 )
				{
					// make back wall outward facing with door
					room.Quad( 7, 15, 12, 4 );
					room.Quad( 6, 14, 15, 7 );
					room.Quad( 5, 13, 14, 6 );
					room.Quad( 4, 12, 13, 5 );
				}
				else
				{
					// make back wall outward facing without door
					room.Quad( 7, 6, 5, 4 );
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_TOP ) != 0 )
				{
					// make top wall outward facing with door
					room.Quad( 0, 17, 16, 4 );
					room.Quad( 4, 16, 19, 7 );
					room.Quad( 7, 19, 18, 3 );
					room.Quad( 3, 18, 17, 0 );
				}
				else
				{
					// make top wall outward facing without door
					room.Quad( 0, 3, 7, 4 );
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_BOT ) != 0 )
				{
					// make bottom wall outward facing with door
					room.Quad( 5, 20, 21, 1 );
					room.Quad( 6, 23, 20, 5 );
					room.Quad( 2, 22, 23, 6 );
					room.Quad( 1, 21, 22, 2 );
				}
				else
				{
					// make bottom wall outward facing without door
					room.Quad( 2, 1, 5, 6 );
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_LEFT ) != 0 )
				{
					// make left wall outward facing with door
					room.Quad( 0, 24, 25, 1 );
					room.Quad( 4, 27, 24, 0 );
					room.Quad( 5, 26, 27, 4 );
					room.Quad( 1, 25, 26, 5 );
				}
				else
				{
					// make left side wall outward facing without door
					room.Quad( 1, 0, 4, 5 );
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_RIGHT ) != 0 )
				{
					// make right wall outward facing with door
					room.Quad( 2, 29, 28, 3 );
					room.Quad( 6, 30, 29, 2 );
					room.Quad( 7, 31, 30, 6 );
					room.Quad( 3, 28, 31, 7 );
				}
				else
				{
					// make right side wall outward facing without door
					room.Quad( 3, 2, 6, 7 );
				}
			}
			else
			{
				// front back
				if ( ( doorFlags & (short)RoomDoors.DOOR_FRONT ) != 0 )
				{
					// make front wall inward facing with door
					room.Quad( 3, 11, 8, 0 );
					room.Quad( 0, 8, 9, 1 );
					room.Quad( 1, 9, 10, 2 );
					room.Quad( 2, 10, 11, 3 );
				}
				else
				{
					// make front wall inward facing without door
					room.Quad( 3, 2, 1, 0 );
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_BACK ) != 0 )
				{
					// make back wall inward facing with door
					room.Quad( 4, 12, 15, 7 );
					room.Quad( 7, 15, 14, 6 );
					room.Quad( 6, 14, 13, 5 );
					room.Quad( 5, 13, 12, 4 );
				}
				else
				{
					// make back wall inward facing without door
					room.Quad( 4, 5, 6, 7 );
				}
				// top bottom
				if ( ( doorFlags & (short)RoomDoors.DOOR_TOP ) != 0 )
				{
					// make top wall inward facing with door
					room.Quad( 4, 16, 17, 0 );
					room.Quad( 7, 19, 16, 4 );
					room.Quad( 3, 18, 19, 7 );
					room.Quad( 0, 17, 18, 3 );
				}
				else
				{
					// make top wall inward facing without door
					room.Quad( 4, 7, 3, 0 );
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_BOT ) != 0 )
				{
					// make bottom wall inward facing with door
					room.Quad( 1, 21, 20, 5 );
					room.Quad( 5, 20, 23, 6 );
					room.Quad( 6, 23, 22, 2 );
					room.Quad( 2, 22, 21, 1 );
				}
				else
				{
					// make bottom wall inward facing without door
					room.Quad( 6, 5, 1, 2 );
				}
				// end caps
				if ( ( doorFlags & (short)RoomDoors.DOOR_LEFT ) != 0 )
				{
					// make left wall inward facing with door
					room.Quad( 1, 25, 24, 0 );
					room.Quad( 0, 24, 27, 4 );
					room.Quad( 4, 27, 26, 5 );
					room.Quad( 5, 26, 25, 1 );
				}
				else
				{
					// make left side wall inward facing without door
					room.Quad( 5, 4, 0, 1 );
				}
				if ( ( doorFlags & (short)RoomDoors.DOOR_RIGHT ) != 0 )
				{
					// make right wall inward facing with door
					room.Quad( 3, 28, 29, 2 );
					room.Quad( 2, 29, 30, 6 );
					room.Quad( 6, 30, 31, 7 );
					room.Quad( 7, 31, 28, 3 );
				}
				else
				{
					// make right side wall inward facing without door
					room.Quad( 7, 6, 2, 3 );
				}
			}
		}
Ejemplo n.º 54
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 ( this.mCompositeMapSM == null )
			{
				//dedicated SceneManager

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

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

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

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


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

				RenderTarget rtt = this.mCompositeMapRTT.GetBuffer().GetRenderTarget();
				// don't render all the time, only on demand
				rtt.IsAutoUpdated = false;
				Viewport vp = rtt.AddViewport( this.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 = this.mCompositeMapRTT.GetBuffer().GetRenderTarget();
			Viewport vp2 = rtt2.GetViewport( 0 );
			this.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.
			var box = new BasicBox( (int)rect.Left, (int)rect.Top, (int)rect.Right, (int)rect.Bottom );
			destCompositeMap.GetBuffer().Blit( this.mCompositeMapRTT.GetBuffer(), box, box );
		}
Ejemplo n.º 55
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");
        }
Ejemplo n.º 56
0
        private void DrawLine(ManualObject manualObject, int index0, int index1, ColourValue colour)
        {
            Vector3 p0 = corners[index0];
            Vector3 p1 = corners[index1];
            float length = (p1 - p0).Length;

            manualObject.Position(p0);
            manualObject.Colour(colour);
            manualObject.TextureCoord(0);

            manualObject.Position(p1);
            manualObject.Colour(colour);
            manualObject.TextureCoord(length);
        }
Ejemplo n.º 57
0
 //    *
 //	 * Appends the shape vertices to a manual object being edited
 //	 
 //-----------------------------------------------------------------------
 //
 //ORIGINAL LINE: void _appendToManualObject(ManualObject* manual) const
 public void _appendToManualObject(ManualObject manual) {
     //for (List<Vector2>.Enumerator itPos = mPoints.GetEnumerator(); itPos.MoveNext(); itPos++)
     foreach (var itPos in mPoints) {
         manual.Position(new Vector3(itPos.x, itPos.y, 0.0f));
     }
     if (mClosed) {
         //manual.Position(new Vector3(mPoints.GetEnumerator().x, mPoints.GetEnumerator().y, 0.0f));
         manual.Position(new Vector3(mPoints[0].x, mPoints[0].y, 0f));
     }
 }
Ejemplo n.º 58
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 );
				}
			}
Ejemplo n.º 59
0
        private void Destroy()
        {
            if (isCreated)
            {
                this.box = null;

                foreach (ResizableBox resizableBox in this.resizableBoxes)
                    resizableBox.Destroy();

                if (this.wireBox != null)
                {
                    Engine.Graphics.SceneManager.DestroyManualObject(this.wireBox);
                    this.wireBox = null;
                }

                this.isCreated = false;
            }
        }
Ejemplo n.º 60
0
		public void Dispose()
		{
			if ( this.mProfiles != null )
			{
				this.mProfiles.Clear();
				this.mProfiles = null;
			}
			if ( this.mCompositeMapRTT != null && TextureManager.Instance != null )
			{
				TextureManager.Instance.Remove( this.mCompositeMapRTT );
				this.mCompositeMapRTT = null;
			}
			if ( this.mCompositeMapSM != null && Root.Instance != null )
			{
				// will also delete cam and objects etc
				Root.Instance.DestroySceneManager( this.mCompositeMapSM );
				this.mCompositeMapSM = null;
				this.mCompositeMapCam = null;
				this.mCompositeMapPlane = null;
				this.mCompositeMapLight = null;
			}
		}