# 请教Luna的DX3D游戏开发编程基础里面的顶点的值是如何计算的

www.MyException.Cn  网友分享于：2013-04-25  浏览：4次

Pyramid->Lock(0, 0, (void**)&v, 0);

// front face
v[0] = Vertex(-1.0f, 0.0f, -1.0f, 0.0f, 0.707f, -0.707f);
v[1] = Vertex( 0.0f, 1.0f, 0.0f, 0.0f, 0.707f, -0.707f);
v[2] = Vertex( 1.0f, 0.0f, -1.0f, 0.0f, 0.707f, -0.707f);

// left face
v[3] = Vertex(-1.0f, 0.0f, 1.0f, -0.707f, 0.707f, 0.0f);
v[4] = Vertex( 0.0f, 1.0f, 0.0f, -0.707f, 0.707f, 0.0f);
v[5] = Vertex(-1.0f, 0.0f, -1.0f, -0.707f, 0.707f, 0.0f);

// right face
v[6] = Vertex( 1.0f, 0.0f, -1.0f, 0.707f, 0.707f, 0.0f);
v[7] = Vertex( 0.0f, 1.0f, 0.0f, 0.707f, 0.707f, 0.0f);
v[8] = Vertex( 1.0f, 0.0f, 1.0f, 0.707f, 0.707f, 0.0f);

// back face
v[9] = Vertex( 1.0f, 0.0f, 1.0f, 0.0f, 0.707f, 0.707f);
v[10] = Vertex( 0.0f, 1.0f, 0.0f, 0.0f, 0.707f, 0.707f);
v[11] = Vertex(-1.0f, 0.0f, 1.0f, 0.0f, 0.707f, 0.707f);

Pyramid->Unlock();

struct Vertex
{
Vertex(){}

Vertex(float x, float y, float z, float nx, float ny, float nz)
{
_x = x; _y = y; _z = z;
_nx = nx; _ny = ny; _nz = nz;
}
float _x, _y, _z;
float _nx, _ny, _nz;

static const DWORD FVF;
};

------解决方案--------------------

v[0] = Vertex(-1.0f, 0.0f, -1.0f, 0.0f, 0.707f, -0.707f); 顶点位置（-1，0，-1） 顶点法向量 （0，0.707，-0.707）