|
|
我才学习3d程序,问的问题很粗浅,大家不要笑话阿:
我现在有知道一系列的点构成的线,我要以这条线为轴心生成一条管线,在使用ms directx 的程序的教程5的时候,看到生成了一个圆柱体:代码如下:(相当于2个点的管道)
public void OnCreateVertexBuffer(object sender, EventArgs e)
{
VertexBuffer vb = (VertexBuffer)sender;
// Create a vertex buffer (100 customervertex)
CustomVertex.PositionNormalTextured[] verts = (CustomVertex.PositionNormalTextured[])vb.Lock(0,0); // Lock the buffer (which will return our structs)
for (int i = 0; i < 50; i++)
{
// Fill up our structs
float theta = (float)(2 * Math.PI * i) / 49;
verts[2 * i].Position = new Vector3((float)Math.Sin(theta), -1, (float)Math.Cos(theta));
verts[2 * i].Normal = new Vector3((float)Math.Sin(theta), 0, (float)Math.Cos(theta));
verts[2 * i].Tu = ((float)i) / (50 - 1);
verts[2 * i].Tv = 1.0f;
verts[2 * i + 1].Position = new Vector3((float)Math.Sin(theta), 2, (float)Math.Cos(theta));
verts[2 * i + 1].Normal = new Vector3((float)Math.Sin(theta), 0, (float)Math.Cos(theta));
verts[2 * i + 1].Tu = ((float)i) / (100 - 1);
verts[2 * i + 1].Tv = 0.0f;
//HandException(sTxt);
}
}
// Unlock (and copy) the data
vb.Unlock();
}
然后我想在这些点加上一段(相当于3)个点的管道,就是不知道怎么改了阿?有没有人家教我?
另外我对asp.net比较熟悉,大家可以相互交流。 |
|