public void Build() { if (Initialized == false) { throw new Exception("You forgot to call 'Initialise(...)'"); } m_manualObject.BeginUpdate(0); if (lineVertices.Count > 0 && isEnabled) { m_manualObject.EstimateVertexCount(System.Convert.ToUInt32(lineVertices.Count)); m_manualObject.EstimateIndexCount(System.Convert.ToUInt32(lineIndices.Count)); LinkedList <KeyValuePair <Vector3, ColourValue> > .Enumerator i = lineVertices.GetEnumerator(); while (i.MoveNext()) { m_manualObject.Position(i.Current.Key); m_manualObject.Colour(i.Current.Value); } LinkedList <int> .Enumerator i2 = lineIndices.GetEnumerator(); while (i2.MoveNext()) { m_manualObject.Index(System.Convert.ToUInt16(i2.Current)); } } m_manualObject.End(); m_manualObject.BeginUpdate(1); if (triangleVertices.Count > 0 && isEnabled) { m_manualObject.EstimateVertexCount(System.Convert.ToUInt16((triangleVertices.Count))); m_manualObject.EstimateIndexCount(System.Convert.ToUInt16(triangleIndices.Count)); LinkedList <KeyValuePair <Vector3, ColourValue> > .Enumerator i = triangleVertices.GetEnumerator(); while (i.MoveNext()) { m_manualObject.Position(i.Current.Key); m_manualObject.Colour(i.Current.Value.r, i.Current.Value.g, i.Current.Value.b, fillAlpha); } LinkedList <int> .Enumerator i2 = triangleIndices.GetEnumerator(); while (i2.MoveNext()) { m_manualObject.Index(System.Convert.ToUInt16(i2.Current)); } } m_manualObject.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 }
1, 2, 3 }; // back face /* * static public void CreateBoidMesh(string name, string color) * { * Vector3[] colors = baseColors; * if (color.Equals("green")) * { * colors[0] = colors[1] = colors[2] = new Vector3(0.0f, 1.0f, 0.0f); * } * else if (color.Equals("red")) * { * colors[0] = colors[1] = colors[2] = new Vector3(1.0f, 0.0f, 0.0f); * } * * // Return now if already exists * if (MeshManager.Singleton.ResourceExists(name)) * return; * * MeshBuilderHelper mbh = new MeshBuilderHelper(name, "Flocking", false, 0, (uint)pts.Length); * * UInt32 offPos = mbh.AddElement(VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_POSITION).Offset; * UInt32 offDiff = mbh.AddElement(VertexElementType.VET_FLOAT3, VertexElementSemantic.VES_DIFFUSE).Offset; * * mbh.CreateVertexBuffer(HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY); * for (int count = 0; count < pts.Length; count++) * { * mbh.SetVertFloat((uint)count, offPos, pts[count].x, pts[count].y, pts[count].z); //position * mbh.SetVertFloat((uint)count, offDiff, colors[count].x, colors[count].y, colors[count].z); //color * } * * mbh.CreateIndexBuffer((uint)(indices.Length / 3), HardwareIndexBuffer.IndexType.IT_16BIT, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY); * for (uint index = 0; index < indices.Length / 3; index++) * { * mbh.SetIndex16bit(index, (UInt16)(indices[index * 3]), * (UInt16)(indices[index * 3 + 1]), * (UInt16)(indices[index * 3 + 2])); * } * * MaterialPtr material = MaterialManager.Singleton.CreateOrRetrieve("Test/ColourTest", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).first; * material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT; * MeshPtr m = mbh.Load("Test/ColourTest"); * m._setBounds(new AxisAlignedBox(-1.0f, -1.0f, -1.0f, * 1.0f, 1.0f, 1.0f), false); * m._setBoundingSphereRadius((float)System.Math.Sqrt(1.0f * 1.0f + 1.0f * 1.0f)); * } */ public static ManualObject CreateBoidObject(string name, SceneManager sceneMgr, string color) { Vector3[] colors = baseColors; if (color.Equals("green")) { colors[0] = colors[1] = colors[2] = new Vector3(0.0f, 1.0f, 0.0f); } else if (color.Equals("red")) { colors[0] = colors[1] = colors[2] = new Vector3(1.0f, 0.0f, 0.0f); } // Return now if already exists if (MeshManager.Singleton.ResourceExists(name)) { return(null); } ManualObject boidObj = sceneMgr.CreateManualObject(name); RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_LIST; MaterialPtr material = MaterialManager.Singleton.CreateOrRetrieve("Test/Boid", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).first; material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT; boidObj.Begin("Test/Boid", operation); for (int count = 0; count < pts.Length; count++) { boidObj.Position(pts[count]); //position boidObj.Colour(colors[count].x, colors[count].y, colors[count].z); //color } for (uint index = 0; index < indices.Length / 3; index++) { boidObj.Index((ushort)(indices[index * 3])); boidObj.Index((ushort)(indices[index * 3 + 1])); boidObj.Index((ushort)(indices[index * 3 + 2])); } boidObj.End(); return(boidObj); }
// create a 2D hud element: pos = [-1;1] & size = (pixels) public static MovableObject MakeHud(SceneManager mgr, Viewport vp, String materialName, Vector2 pos, Vector2 size) { // Create a manual object for 2D ManualObject manual = mgr.CreateManualObject(); // Use identity view/projection matrices manual.UseIdentityProjection = true; manual.UseIdentityView = true; // convert from pixels to screen coords float s = size.x / vp.ActualWidth; float t = size.y / vp.ActualHeight; manual.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_STRIP); manual.Position(pos.x - s, pos.y - t, 0.0f); manual.TextureCoord(0, 1); manual.Position(pos.x + s, pos.y - t, 0.0f); manual.TextureCoord(1, 1); manual.Position(pos.x + s, pos.y + t, 0.0f); manual.TextureCoord(1, 0); manual.Position(pos.x - s, pos.y + t, 0.0f); manual.TextureCoord(0, 0); manual.Index(0); manual.Index(1); manual.Index(2); manual.Index(3); manual.Index(0); manual.End(); // Use infinite AAB to always stay visible AxisAlignedBox aabInf = new AxisAlignedBox(); aabInf.SetInfinite(); manual.BoundingBox = aabInf; // Render just before overlays manual.RenderQueueGroup = (byte)(RenderQueueGroupID.RENDER_QUEUE_OVERLAY - 1); manual.CastShadows = false; // Attach to scene mgr.RootSceneNode.CreateChildSceneNode().AttachObject(manual); return(manual); }
/// <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 }
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 }
private void createSphere(string strName, float r, SceneManager sceneMgr, int nRings = 16, int nSegments = 16) { ManualObject manual = sceneMgr.CreateManualObject(strName); manual.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_TRIANGLE_LIST); float fDeltaRingAngle = (Mogre.Math.PI / nRings); float fDeltaSegAngle = (2 * Mogre.Math.PI / nSegments); ushort wVerticeIndex = 0; // Generate the group of rings for the sphere for (int ring = 0; ring <= nRings; ring++) { float r0 = r * Mogre.Math.Sin(ring * fDeltaRingAngle); float y0 = r * Mogre.Math.Cos(ring * fDeltaRingAngle); // Generate the group of segments for the current ring for (int seg = 0; seg <= nSegments; seg++) { float x0 = r0 * Mogre.Math.Sin(seg * fDeltaSegAngle); float z0 = r0 * Mogre.Math.Cos(seg * fDeltaSegAngle); // Add one vertex to the strip which makes up the sphere manual.Position(x0, y0, z0); manual.Normal(new Mogre.Vector3(x0, y0, z0).NormalisedCopy); manual.TextureCoord((float)seg / (float)nSegments, (float)ring / (float)nRings); if (ring != nRings) { // each vertex (except the last) has six indicies pointing to it manual.Index((uint)(wVerticeIndex + nSegments + 1)); manual.Index(wVerticeIndex); manual.Index((uint)(wVerticeIndex + nSegments)); manual.Index((uint)(wVerticeIndex + nSegments + 1)); manual.Index((uint)(wVerticeIndex + 1)); manual.Index(wVerticeIndex); wVerticeIndex++; } } ; // end for seg } // end for ring manual.End(); MeshPtr mesh = manual.ConvertToMesh(strName); mesh._setBounds(new AxisAlignedBox(new Mogre.Vector3(-r, -r, -r), new Mogre.Vector3(r, r, r)), false); mesh._setBoundingSphereRadius(r); ushort src, dest; if (!mesh.SuggestTangentVectorBuildParams(VertexElementSemantic.VES_TANGENT, out src, out dest)) { mesh.BuildTangentVectors(VertexElementSemantic.VES_TANGENT, src, dest); } }
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); }
public MeshPtr getCube(string cubeName, string materialName, float width, float height, float depth) { cube = mSceneMgr.CreateManualObject(cubeName + "_ManObj"); cube.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST); // --- Fills the Vertex buffer and define the texture coordinates for each vertex --- //--- Vertex 0 --- cube.Position(new Vector3(.5f * width, .5f * height, .5f * depth)); cube.TextureCoord(new Vector2(0, 0)); //--- Vertex 1 --- cube.Position(new Vector3(.5f * width, -.5f * height, .5f * depth)); cube.TextureCoord(new Vector2(1, 0)); //--- Vertex 2 --- cube.Position(new Vector3(.5f * width, .5f * height, -.5f * depth)); cube.TextureCoord(new Vector2(0, 1)); //--- Vertex 3 --- cube.Position(new Vector3(.5f * width, -.5f * height, -.5f * depth)); cube.TextureCoord(new Vector2(1, 1)); //--- Vertex 4 --- cube.Position(new Vector3(-.5f * width, .5f * height, .5f * depth)); cube.TextureCoord(new Vector2(0, 0)); //--- Vertex 5 --- cube.Position(new Vector3(-.5f * width, -.5f * height, .5f * depth)); cube.TextureCoord(new Vector2(1, 0)); //--- Vertex 6 --- cube.Position(new Vector3(-.5f * width, .5f * height, -.5f * depth)); cube.TextureCoord(new Vector2(0, 1)); //--- Vertex 7 --- cube.Position(new Vector3(-.5f * width, -.5f * height, -.5f * depth)); cube.TextureCoord(new Vector2(1, 1)); // --- Fills the Index Buffer --- //--------Face 1---------- cube.Index(0); cube.Index(1); cube.Index(2); cube.Index(2); cube.Index(1); cube.Index(3); //--------Face 2---------- cube.Index(4); cube.Index(6); cube.Index(5); cube.Index(6); cube.Index(7); cube.Index(5); //--------Face 3---------- cube.Index(0); cube.Index(4); cube.Index(1); cube.Index(1); cube.Index(4); cube.Index(5); //--------Face 4---------- cube.Index(0); cube.Index(6); cube.Index(4); cube.Index(0); cube.Index(2); cube.Index(6); //--------Face 5---------- cube.Index(6); cube.Index(2); cube.Index(3); cube.Index(6); cube.Index(3); cube.Index(7); //--------Face 5---------- cube.Index(3); cube.Index(1); cube.Index(7); cube.Index(1); cube.Index(5); cube.Index(7); cube.End(); return(cube.ConvertToMesh(cubeName)); }
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; }
/// <summary> /// This method contructs the mesh for the cube /// </summary> /// <param name="cubeName"></param> /// <returns>cubeMesh object</returns> public MeshPtr getCube(string cubeName) { // Console.Write("getCube: "+count); manualObj = mSceneMgr.CreateManualObject("manualObjQuad" + count); manualObj.Begin("void", RenderOperation.OperationTypes.OT_TRIANGLE_LIST); // Starts filling the manual object as a triangle list // ---- Vertex Buffer ---- manualObj.Position(new Vector3(30, 30, 0)); // --- Vertex 0 --- manualObj.TextureCoord(new Vector2(0, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, 30, 0)); // --- Vertex 1 --- manualObj.TextureCoord(new Vector2(1, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(30, -30, 0)); // --- Vertex 2 --- manualObj.TextureCoord(new Vector2(0, 1)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, -30, 0)); // --- Vertex 3 --- manualObj.TextureCoord(new Vector2(1, 1)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(30, 30, -60)); // --- Vertex 4 --- manualObj.TextureCoord(new Vector2(0, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(30, -30, -60)); // --- Vertex 5 --- manualObj.TextureCoord(new Vector2(1, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, 30, -60)); // --- Vertex 6 --- manualObj.TextureCoord(new Vector2(0, 1)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, -30, -60)); // --- Vertex 7 --- manualObj.TextureCoord(new Vector2(1, 1)); manualObj.Normal(1, 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); // --- Triangle 8 --- manualObj.Index(4); manualObj.Index(5); manualObj.Index(6); // --- Triangle 9 --- manualObj.Index(5); manualObj.Index(7); manualObj.Index(6); manualObj.Position(new Vector3(30, 30, -60)); // --- Vertex 8 --- manualObj.TextureCoord(new Vector2(1, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(30, 30, 0)); // --- Vertex 9 --- manualObj.TextureCoord(new Vector2(0, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(30, -30, -60)); // --- Vertex 10 --- manualObj.TextureCoord(new Vector2(1, 1)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(30, -30, 0)); // --- Vertex 11 --- manualObj.TextureCoord(new Vector2(0, 1)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, 30, 0)); // --- Vertex 12 --- manualObj.TextureCoord(new Vector2(0, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, 30, -60)); // --- Vertex 13 --- manualObj.TextureCoord(new Vector2(0, 1)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, -30, 0)); // ---Vertex 14 --- manualObj.TextureCoord(new Vector2(1, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, -30, -60)); // ---Vertex 15 --- manualObj.TextureCoord(new Vector2(1, 1)); manualObj.Normal(1, 1, 1); // ---Triangle 12-- - manualObj.Index(8); manualObj.Index(9); manualObj.Index(10); // ---Triangle 13-- - manualObj.Index(9); manualObj.Index(11); manualObj.Index(10); // ---Triangle 14-- - manualObj.Index(12); manualObj.Index(13); manualObj.Index(14); // ---Triangle 15-- - manualObj.Index(13); manualObj.Index(15); manualObj.Index(14); manualObj.Position(new Vector3(30, 30, -60)); // --- Vertex 16 --- manualObj.TextureCoord(new Vector2(1, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, 30, -60)); // --- Vertex 17 --- manualObj.TextureCoord(new Vector2(0, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(30, 30, 0)); // --- Vertex 18 --- manualObj.TextureCoord(new Vector2(1, 1)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, 30, 0)); // --- Vertex 19 --- manualObj.TextureCoord(new Vector2(0, 1)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(30, -30, 0)); // --- Vertex 20 --- manualObj.TextureCoord(new Vector2(0, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, -30, 0)); // --- Vertex 21 --- manualObj.TextureCoord(new Vector2(0, 1)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(30, -30, -60)); // ---Vertex 22 --- manualObj.TextureCoord(new Vector2(1, 0)); manualObj.Normal(1, 1, 1); manualObj.Position(new Vector3(-30, -30, -60)); // ---Vertex 23 --- manualObj.TextureCoord(new Vector2(1, 1)); manualObj.Normal(1, 1, 1); // ---Triangle 12-- - manualObj.Index(16); manualObj.Index(17); manualObj.Index(18); // ---Triangle 13-- - manualObj.Index(17); manualObj.Index(19); manualObj.Index(18); // ---Triangle 14-- - manualObj.Index(20); manualObj.Index(21); manualObj.Index(22); // ---Triangle 15-- - manualObj.Index(21); manualObj.Index(23); manualObj.Index(22); manualObj.End(); // Closes the manual objet return(manualObj.ConvertToMesh(cubeName)); // Prepares the data to be sent to the GPU }
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; }
public MeshPtr getCube(string cubeName, string materialName, float width, float height, float depth) { manual = mSceneMgr.CreateManualObject(cubeName + "_ManObj"); manual.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_LIST); // --- Fills the Vertex buffer and define the texture coordinates for each vertex --- //--- Vertex 0 --- v0 = new Vector3(.5f * width, .5f * height, .5f * depth); manual.Position(v0); //Texture coordinates here! manual.TextureCoord(new Vector2(0, 0)); //--- Vertex 1 --- v1 = new Vector3(.5f * width, -.5f * height, .5f * depth); manual.Position(v1); //Texture coordinates here! manual.TextureCoord(new Vector2(1, 0)); //--- Vertex 2 --- v2 = new Vector3(.5f * width, .5f * height, -.5f * depth); manual.Position(v2); //Texture coordinates here! manual.TextureCoord(new Vector2(0, 1)); //--- Vertex 3 --- v3 = new Vector3(.5f * width, -.5f * height, -.5f * depth); manual.Position(v3); //Texture coordinates here! manual.TextureCoord(new Vector2(1, 1)); //--- Vertex 4 --- v4 = new Vector3(-.5f * width, .5f * height, .5f * depth); manual.Position(v4); //Texture coordinates here! manual.TextureCoord(new Vector2(0, 0)); //--- Vertex 5 --- v5 = new Vector3(-.5f * width, -.5f * height, .5f * depth); manual.Position(v5); //Texture coordinates here! manual.TextureCoord(new Vector2(-1, 0)); //--- Vertex 6 --- v6 = new Vector3(-.5f * width, .5f * height, -.5f * depth); manual.Position(v6); //Texture coordinates here! manual.TextureCoord(new Vector2(0, -1)); //--- Vertex 7 --- v7 = new Vector3(-.5f * width, -.5f * height, -.5f * depth); manual.Position(v7); //Texture coordinates here! manual.TextureCoord(new Vector2(-1, -1)); // --- Fills the Index Buffer --- //--------Face 1---------- manual.Index(2); manual.Index(1); manual.Index(0); manual.Index(3); manual.Index(1); manual.Index(2); //--------Face 2---------- manual.Index(5); manual.Index(6); manual.Index(4); manual.Index(5); manual.Index(7); manual.Index(6); //--------Face 3---------- manual.Index(1); manual.Index(4); manual.Index(0); manual.Index(5); manual.Index(4); manual.Index(1); ////--------Face 4---------- //manual.Index(0); //manual.Index(6); //manual.Index(4); //manual.Index(0); //manual.Index(2); //manual.Index(6); //--------Face 5---------- manual.Index(3); manual.Index(2); manual.Index(6); manual.Index(7); manual.Index(3); manual.Index(6); //--------Face 6---------- //manual.Index(3); //manual.Index(1); //manual.Index(7); //manual.Index(1); //manual.Index(5); //manual.Index(7); manual.End(); return(manual.ConvertToMesh(cubeName)); }
/// <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 }
///private MeshPtr Quad() public MeshPtr Quad() { cube = mSceneMgr.CreateManualObject("fieldQuad"); cube.Begin("void", RenderOperation.OperationTypes.OT_TRIANGLE_LIST); cube.Position(new Vector3(20f, 20f, 20f)); // Vector 0 cube.TextureCoord(new Vector2(0, 0)); cube.Position(new Vector3(20f, -20f, 20f)); // Vector 1 cube.TextureCoord(new Vector2(1, 0)); cube.Position(new Vector3(20f, 20f, -20f)); // Vector 2 cube.TextureCoord(new Vector2(0, 1)); cube.Position(new Vector3(20f, -20f, -20f)); // Vector 3 cube.TextureCoord(new Vector2(1, 1)); cube.Position(new Vector3(-20f, 20f, 20f)); // Vector 4 cube.TextureCoord(new Vector2(0, 0)); cube.Position(new Vector3(-20f, -20f, 20f)); // Vector 5 cube.TextureCoord(new Vector2(0, 1)); cube.Position(new Vector3(-20f, 20f, -20f)); // Vector 6 cube.TextureCoord(new Vector2(1, 0)); cube.Position(new Vector3(-20f, -20f, -20f)); // Vector 7 cube.TextureCoord(new Vector2(1, 1)); // Index Buffer // Triangle 0 cube.Index(0); cube.Index(1); cube.Index(2); // Triangle 1 cube.Index(2); cube.Index(1); cube.Index(3); // Triangle 2 cube.Index(4); cube.Index(6); cube.Index(5); // Triangle 3 cube.Index(6); cube.Index(7); cube.Index(5); // Triangle 4 cube.Index(0); cube.Index(4); cube.Index(1); // Triangle 5 cube.Index(1); cube.Index(4); cube.Index(5); // Triangle 6 cube.Index(0); cube.Index(6); cube.Index(4); // Triangle 7 cube.Index(0); cube.Index(2); cube.Index(6); // Triangle 8 cube.Index(6); cube.Index(2); cube.Index(3); // Triangle 9 cube.Index(6); cube.Index(3); cube.Index(7); // Triangle 9 cube.Index(3); cube.Index(1); cube.Index(7); cube.Index(1); cube.Index(5); cube.Index(7); cube.End(); return(cube.ConvertToMesh("Quad")); }
/// <summary> /// The vertexs for the walls around the edge of the arena are defined, and placed into the buffer to create the walls. /// </summary> private void BoundaryCubes() { manualObj = mSceneMgr.CreateManualObject("a"); manualObj.Begin("void", RenderOperation.OperationTypes.OT_TRIANGLE_LIST); // Starts filling the manual object as a triangle list // ---- Vertex Buffer ---- manualObj.Position(new Vector3(500, 45, -500)); //SW // --- Vertex 0 --- manualObj.Position(new Vector3(-500, 45, -500)); //SE // --- Vertex 1 --- manualObj.Position(new Vector3(500, 0, -500)); //SW // --- Vertex 2 --- manualObj.Position(new Vector3(-500, 0, -500)); //SE // --- Vertex 3 --- manualObj.Position(new Vector3(500, 45, 500)); //NW // --- Vertex 4 --- manualObj.Position(new Vector3(-500, 45, 500)); //NE // --- Vertex 5 --- manualObj.Position(new Vector3(500, 0, 500)); //NW // --- Vertex 6 --- manualObj.Position(new Vector3(-500, 0, 500)); //NE // --- Vertex 7 --- // ---- Index Buffer ---- //south wall // --- Triangle 0 --- manualObj.Index(0); manualObj.Index(1); manualObj.Index(2); // --- Triangle 1 --- manualObj.Index(1); manualObj.Index(3); manualObj.Index(2); //north wall // --- Triangle 2 --- manualObj.Index(6); manualObj.Index(5); manualObj.Index(4); // --- Triangle 3 --- manualObj.Index(6); manualObj.Index(7); manualObj.Index(5); //east wall // --- Triangle 4 --- manualObj.Index(7); manualObj.Index(3); manualObj.Index(5); // --- Triangle 5 --- manualObj.Index(3); manualObj.Index(1); manualObj.Index(5); //west wall // --- Triangle 6 --- manualObj.Index(4); manualObj.Index(2); manualObj.Index(6); // --- Triangle 7 --- manualObj.Index(4); //NWT manualObj.Index(0); //SWT manualObj.Index(2); //SWB manualObj.End(); // Closes the manual objet //return manualObj.ConvertToMesh("Quad"); manualObj.ConvertToMesh("Quad"); boundaryEntity = mSceneMgr.CreateEntity("maualObjQuad", "Quad"); boundaryEntity.SetMaterialName("Ground"); }