void InitBuffer() { if (buffers.Count != shapes.Count) { buffers.Clear(); int index = 0; foreach (List <Vector3d> shape in shapes) { TimeSeriesLineVertexBuffer buffer = new TimeSeriesLineVertexBuffer(shape.Count); TimeSeriesLineVertex[] pointList = (TimeSeriesLineVertex[])buffer.Lock(); // Lock the buffer (which will return our structs) buffers.Add(buffer); bufferCounts.Add(shape.Count); int counter = 0; foreach (Vector3d point in shape) { pointList[counter] = new TimeSeriesLineVertex(); pointList[counter].Position = point; pointList[counter].Tu = (float)dates[index].StartDate; pointList[counter].Tv = (float)dates[index].EndDate; pointList[counter].Color = colors[index]; counter++; } index++; if (buffer != null) { buffer.Unlock(); } } } }
void InitTriangleBuffer() { if (triangleBuffers.Count == 0) { int count = trianglePoints.Count; TimeSeriesLineVertexBuffer triangleBuffer = null; TimeSeriesLineVertex[] triPointList = null; int countLeft = count; int index = 0; int counter = 0; foreach (Vector3d point in trianglePoints) { if (counter >= 90000 || triangleBuffer == null) { if (triangleBuffer != null) { triangleBuffer.Unlock(); } int thisCount = Math.Min(90000, countLeft); countLeft -= thisCount; triangleBuffer = new TimeSeriesLineVertexBuffer(thisCount); triangleBuffers.Add(triangleBuffer); triangleBufferCounts.Add(thisCount); triPointList = (TimeSeriesLineVertex[])triangleBuffer.Lock(); // Lock the buffer (which will return our structs) counter = 0; } triPointList[counter] = new TimeSeriesLineVertex(); triPointList[counter].Position = point; triPointList[counter].Normal = point; int div3 = (int)(index / 3); triPointList[counter].Color = triangleColors[div3]; triPointList[counter].Tu = (float)triangleDates[div3].StartDate; triPointList[counter].Tv = (float)triangleDates[div3].EndDate; index++; counter++; } if (triangleBuffer != null) { triangleBuffer.Unlock(); } triangleColors.Clear(); triangleDates.Clear(); trianglePoints.Clear(); dataToDraw = true; } }
void InitLineBuffer() { if (lineBuffers.Count == 0) { int count = linePoints.Count; TimeSeriesLineVertexBuffer lineBuffer = null; TimeSeriesLineVertex[] linePointList = null; //localCenter = new Vector3d(); //if (DepthBuffered) //{ // // compute the local center.. // foreach (Vector3d point in linePoints) // { // localCenter.Add(point); // } // localCenter.X /= count; // localCenter.Y /= count; // localCenter.Z /= count; //} int countLeft = count; int index = 0; int counter = 0; Vector3d temp; foreach (Vector3d point in linePoints) { if (counter >= 100000 || linePointList == null) { if (lineBuffer != null) { lineBuffer.Unlock(); } int thisCount = Math.Min(100000, countLeft); countLeft -= thisCount; lineBuffer = new TimeSeriesLineVertexBuffer(thisCount); linePointList = (TimeSeriesLineVertex[])lineBuffer.Lock(); // Lock the buffer (which will return our structs) lineBuffers.Add(lineBuffer); lineBufferCounts.Add(thisCount); counter = 0; } int div2 = (int)(index / 2); temp = point; // -localCenter; linePointList[counter] = new TimeSeriesLineVertex(); linePointList[counter].Position = temp; linePointList[counter].Normal = point; linePointList[counter].Tu = (float)lineDates[div2].StartDate; linePointList[counter].Tv = (float)lineDates[div2].EndDate; linePointList[counter].Color = lineColors[div2]; index++; counter++; } if (lineBuffer != null) { lineBuffer.Unlock(); } } }