protected override void UpdateGeometry() { if (Points.Count == 0) { return; } if (pointsChanged) { if (this.IsVisible) { RecreateBuffers(); } pointsChanged = false; } short vertexIndex = 0; short index = 0; if (!thickLines) { Point3D modelPoint; foreach (Point3DColor p in Points) { modelPoint = ModelToWorld.Transform(p.Point3D); vertices[index] = new VertexPositionColor(new Vector3((float)modelPoint.X, (float)modelPoint.Y, (float)modelPoint.Z), Point3DColor.ColorToInt(p.Color)); indices[index] = index; index++; } } else { Point3D start, end; int color; for (int i = 0; i < Points.Count - 1; i += 2) { start = ModelToWorld.Transform(Points[i].Point3D); end = ModelToWorld.Transform(Points[i + 1].Point3D); color = Point3DColor.ColorToInt(Points[i].Color); thickVertices[vertexIndex] = new ThickLinesVertex(new Vector3((float)start.X, (float)start.Y, (float)start.Z), new Vector3((float)end.X, (float)end.Y, (float)end.Z), new Vector2(0, -0.5f), color); thickVertices[vertexIndex + 1] = new ThickLinesVertex(new Vector3((float)start.X, (float)start.Y, (float)start.Z), new Vector3((float)end.X, (float)end.Y, (float)end.Z), new Vector2(1, -0.5f), color); thickVertices[vertexIndex + 2] = new ThickLinesVertex(new Vector3((float)start.X, (float)start.Y, (float)start.Z), new Vector3((float)end.X, (float)end.Y, (float)end.Z), new Vector2(1, 0.5f), color); thickVertices[vertexIndex + 3] = new ThickLinesVertex(new Vector3((float)start.X, (float)start.Y, (float)start.Z), new Vector3((float)end.X, (float)end.Y, (float)end.Z), new Vector2(0, 0.5f), color); indices[index] = vertexIndex; indices[index + 1] = (short)(vertexIndex + 1); indices[index + 2] = (short)(vertexIndex + 2); indices[index + 3] = vertexIndex; indices[index + 4] = (short)(vertexIndex + 2); indices[index + 5] = (short)(vertexIndex + 3); vertexIndex += 4; index += 6; } } if (this.IsVisible) { FillBuffers(); } }
protected override void UpdateGeometry() { if (Points.Count == 0) return; if (pointsChanged) { if (this.IsVisible) RecreateBuffers(); pointsChanged = false; } short vertexIndex = 0; short index = 0; if (!thickLines) { Point3D modelPoint; foreach (Point3DColor p in Points) { modelPoint = ModelToWorld.Transform(p.Point3D); vertices[index] = new VertexPositionColor(new Vector3((float)modelPoint.X, (float)modelPoint.Y, (float)modelPoint.Z), Point3DColor.ColorToInt(p.Color)); indices[index] = index; index++; } } else { Point3D start, end; int color; for (int i = 0; i < Points.Count - 1; i += 2) { start = ModelToWorld.Transform(Points[i].Point3D); end = ModelToWorld.Transform(Points[i + 1].Point3D); color = Point3DColor.ColorToInt(Points[i].Color); thickVertices[vertexIndex] = new ThickLinesVertex(new Vector3((float)start.X, (float)start.Y, (float)start.Z), new Vector3((float)end.X, (float)end.Y, (float)end.Z), new Vector2(0, -0.5f), color); thickVertices[vertexIndex + 1] = new ThickLinesVertex(new Vector3((float)start.X, (float)start.Y, (float)start.Z), new Vector3((float)end.X, (float)end.Y, (float)end.Z), new Vector2(1, -0.5f), color); thickVertices[vertexIndex + 2] = new ThickLinesVertex(new Vector3((float)start.X, (float)start.Y, (float)start.Z), new Vector3((float)end.X, (float)end.Y, (float)end.Z), new Vector2(1, 0.5f), color); thickVertices[vertexIndex + 3] = new ThickLinesVertex(new Vector3((float)start.X, (float)start.Y, (float)start.Z), new Vector3((float)end.X, (float)end.Y, (float)end.Z), new Vector2(0, 0.5f), color); indices[index] = vertexIndex; indices[index + 1] = (short)(vertexIndex + 1); indices[index + 2] = (short)(vertexIndex + 2); indices[index + 3] = vertexIndex; indices[index + 4] = (short)(vertexIndex + 2); indices[index + 5] = (short)(vertexIndex + 3); vertexIndex += 4; index += 6; } } if (this.IsVisible) FillBuffers(); }