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); }
public ManualObject.ManualObjectSection getSection(uint index) { global::System.IntPtr cPtr = OgrePINVOKE.ManualObject_getSection(swigCPtr, index); ManualObject.ManualObjectSection ret = (cPtr == global::System.IntPtr.Zero) ? null : new ManualObject.ManualObjectSection(cPtr, false); if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
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; }
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); }