public BezierCube(ControlCube controlCube, Device device) { var minPoint = controlCube.Vertices[0].Position; var maxPoint = controlCube.Vertices[7].Position; var diff = maxPoint - minPoint; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { bezierPoints[i, j, k] = new BezierCubeVertex(minPoint.X + i / 3.0f * diff.X, minPoint.Y + j / 3.0f * diff.Y, minPoint.Z + k / 3.0f * diff.Z); } } } CreateInnerSprings(diff); CreateControlSprings(controlCube); vertexBuffer = Buffer.Create(device, BindFlags.VertexBuffer, GetAllTriangleVertices()); vertexBinding = new VertexBufferBinding(vertexBuffer, Utilities.SizeOf <Vertex>(), 0); springBuffer = Buffer.Create(device, BindFlags.VertexBuffer, GetBezierVertices()); springBinding = new VertexBufferBinding(springBuffer, Utilities.SizeOf <Vertex>(), 0); triangleIndicesArray = GetIndices(); triangleIndices = Buffer.Create(device, BindFlags.IndexBuffer, triangleIndicesArray); springIndicesArray = GetSpringIndices(); springIndices = Buffer.Create(device, BindFlags.IndexBuffer, springIndicesArray); }
public Spring(BezierCubeVertex vertexA, BezierCubeVertex vertexB, float startingDistance) { VertexA = vertexA; VertexB = vertexB; StartingDistance = startingDistance; }