Esempio n. 1
0
		public static void DrawLine(PositionNormalIndexedTriangleBuffers buffers, PenX3D pen, PointD3D p0, PointD3D p1)
		{
			var vertexIndexOffset = buffers.IndexedTriangleBuffer.VertexCount;

			if (null != buffers.PositionNormalIndexedTriangleBuffer)
			{
				var buf = buffers.PositionNormalIndexedTriangleBuffer;
				/*
				if (pen.Color.Name == "Beige")
				{
				*/
				var solid = new SolidStraightLine();
				solid.AddGeometry(
					(position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z),
					(i0, i1, i2, isLeft) => buf.AddTriangleIndices(i0, i1, i2, isLeft),
					ref vertexIndexOffset,
					pen,
					new LineD3D(p0, p1));

				/*
			}
			else
			{
						var polylinePoints = new[] { p0, p1 };
				SolidPolyline.AddWithNormals(
				(position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z),
				(i0, i1, i2) => buf.AddTriangleIndices(i0, i1, i2),
				ref vertexIndexOffset,
				pen,
				polylinePoints);
			}
			*/
			}
			else if (null != buffers.PositionNormalColorIndexedTriangleBuffer)
			{
				var polylinePoints = new[] { p0, p1 };
				var buf = buffers.PositionNormalColorIndexedTriangleBuffer;
				var color = pen.Color.Color;
				var r = color.ScR;
				var g = color.ScG;
				var b = color.ScB;
				var a = color.ScA;

				var solidPolyline = new SolidPolyline();
				solidPolyline.AddWithNormals(
				(position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z, r, g, b, a),
				(i0, i1, i2, isLeftCOS) => buf.AddTriangleIndices(i0, i1, i2, isLeftCOS),
				ref vertexIndexOffset,
				pen,
				polylinePoints);
			}
			else if (null != buffers.PositionNormalUVIndexedTriangleBuffer)
			{
				throw new NotImplementedException("Texture on a line is not supported yet");
			}
			else
			{
				throw new NotImplementedException("Unexpected type of buffer: " + buffers.IndexedTriangleBuffer.GetType().ToString());
			}
		}
Esempio n. 2
0
		public override PositionNormalIndexedTriangleBuffers GetPositionNormalIndexedTriangleBuffer(IMaterial material)
		{
			var result = new PositionNormalIndexedTriangleBuffers();

			if (material.HasTexture)
			{
				result.IndexedTriangleBuffer = result.PositionNormalUVIndexedTriangleBuffer = InternalGetPositionNormalUVIndexedTriangleBuffer(material);
			}
			else if (material.HasColor)
			{
				result.IndexedTriangleBuffer = result.PositionNormalIndexedTriangleBuffer = InternalGetPositionNormalIndexedTriangleBuffer(material);
			}
			else
			{
				result.IndexedTriangleBuffer = result.PositionNormalColorIndexedTriangleBuffer = InternalGetPositionNormalColorIndexedTriangleBuffer(material);
			}
			return result;
		}
Esempio n. 3
0
		public override PositionNormalIndexedTriangleBuffers GetPositionNormalIndexedTriangleBufferWithClipping(IMaterial material, PlaneD3D[] clipPlanes)
		{
			var result = new PositionNormalIndexedTriangleBuffers();

			if (material.HasTexture)
			{
				throw new NotImplementedException();
			}
			else if (material.HasColor)
			{
				throw new NotImplementedException();
			}
			else
			{
				result.IndexedTriangleBuffer = result.PositionNormalColorIndexedTriangleBuffer = InternalGetPositionNormalColorIndexedTriangleBuffer(material, clipPlanes);
			}
			return result;
		}
Esempio n. 4
0
        public static void DrawLine(PositionNormalIndexedTriangleBuffers buffers, PenX3D pen, PointD3D p0, PointD3D p1)
        {
            var vertexIndexOffset = buffers.IndexedTriangleBuffer.VertexCount;

            if (null != buffers.PositionNormalIndexedTriangleBuffer)
            {
                var buf = buffers.PositionNormalIndexedTriangleBuffer;

                /*
                 *                      if (pen.Color.Name == "Beige")
                 *                      {
                 */
                var solid = new SolidStraightLine();
                solid.AddGeometry(
                    (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z),
                    (i0, i1, i2, isLeft) => buf.AddTriangleIndices(i0, i1, i2, isLeft),
                    ref vertexIndexOffset,
                    pen,
                    new LineD3D(p0, p1));

                /*
                 *              }
                 *              else
                 *              {
                 *                                      var polylinePoints = new[] { p0, p1 };
                 *                      SolidPolyline.AddWithNormals(
                 *                      (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z),
                 *                      (i0, i1, i2) => buf.AddTriangleIndices(i0, i1, i2),
                 *                      ref vertexIndexOffset,
                 *                      pen,
                 *                      polylinePoints);
                 *              }
                 */
            }
            else if (null != buffers.PositionNormalColorIndexedTriangleBuffer)
            {
                var polylinePoints = new[] { p0, p1 };
                var buf            = buffers.PositionNormalColorIndexedTriangleBuffer;
                var color          = pen.Color.Color;
                var r = color.ScR;
                var g = color.ScG;
                var b = color.ScB;
                var a = color.ScA;

                var solidPolyline = new SolidPolyline();
                solidPolyline.AddWithNormals(
                    (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z, r, g, b, a),
                    (i0, i1, i2, isLeftCOS) => buf.AddTriangleIndices(i0, i1, i2, isLeftCOS),
                    ref vertexIndexOffset,
                    pen,
                    polylinePoints);
            }
            else if (null != buffers.PositionNormalUVIndexedTriangleBuffer)
            {
                throw new NotImplementedException("Texture on a line is not supported yet");
            }
            else
            {
                throw new NotImplementedException("Unexpected type of buffer: " + buffers.IndexedTriangleBuffer.GetType().ToString());
            }
        }