there is the code
string coorlist = “14.607285,16.557086 13.001963,12.353166 11.396641,8.149246 9.791319,3.945327 8.759057,1.242101 4.259501,1.305308 -0.240055,1.368516 -4.739611,1.431724 -9.239167,1.494931 -9.600000,1.500000 -10.350000,1.299038 -10.899038,0.750000 -12.573967,-3.426675 -14.248896,-7.603350 -15.923824,-11.780025 -17.392715,-15.442914 -14.607285,-16.557086 -13.001963,-12.353166 -11.396641,-8.149246 -9.791319,-3.945327 -8.759057,-1.242101 -4.259501,-1.305308 0.240055,-1.368516 4.739611,-1.431724 9.239167,-1.494931 9.600000,-1.500000 10.350000,-1.299038 10.899038,-0.750000 12.573967,3.426675 14.248896,7.603350 15.923824,11.780025 17.392715,15.442914”;
string[] items = coorlist.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
Vector4[] controlPoints = new Vector4[items.Length*2];
//the higher level with z value 5
for (int i = 0; i < items.Length; i++)
{
string[] values = items[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
controlPoints[i] = new Vector4(double.Parse(values[0]), double.Parse(values[1]),5);
}
// z value is 0
for (int i = 0; i < items.Length; i++)
{
controlPoints[i+items.Length] = new Vector4(controlPoints[i].x, controlPoints[i].y, 0);
}
//all point,int two z value, add two polygon to mesh
mesh_Top.ControlPoints.AddRange(controlPoints);
PolygonBuilder builder = new PolygonBuilder(mesh_Top);
builder.Begin();
for (int i = 0; i < controlPoints.Length/2; i++)
{
builder.AddVertex(i);
}
builder.End();
builder = new PolygonBuilder(mesh_Top);
builder.Begin();
for (int i = controlPoints.Length/2; i < controlPoints.Length; i++)
{
builder.AddVertex(i);
}
builder.End();
scene.RootNode.CreateChildNode("top", mesh_Top);
scene.RootNode.Transform.TransformMatrix = new Matrix4(
1, 0, 0, 0,
0, 0, -1, 0,
0, 1, 0, 0,
0, 0, 0, 1
);
the result should be disply right.jpg (17.2 KB)
but the result is display wrong.png (12.7 KB)