本文整理汇总了C++中Mat4x4::Transform方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4x4::Transform方法的具体用法?C++ Mat4x4::Transform怎么用?C++ Mat4x4::Transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4x4
的用法示例。
在下文中一共展示了Mat4x4::Transform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
HRESULT D3DSkyNode9::OnRestore(Scene* pScene)
{
// call base class restore
SceneNode::OnRestore(pScene);
m_Camera = pScene->GetCamera();
m_NumVerts = 20;
CB_COM_RELEASE(m_pVerts);
if (FAILED(DXUTGetD3D9Device()->CreateVertexBuffer(
m_NumVerts * sizeof(D3D9Vertex_ColoredTextured),
D3DUSAGE_WRITEONLY, D3D9Vertex_ColoredTextured::FVF,
D3DPOOL_MANAGED, &m_pVerts, NULL)))
{
return E_FAIL;
}
// fill the vertex buffer -- we're setting the tu and tv texture coordinates (0.0 - 1.0)
// this binds the m_pVerts d3d buffer to pVertices
D3D9Vertex_ColoredTextured* pVertices;
if (FAILED(m_pVerts->Lock(0, 0, (void**)&pVertices, 0)))
{
return E_FAIL;
}
// loop through the grid squares and calculate the values
// of each index. each grid has two triangles:
//
// A - B
// | / |
// C - D
D3D9Vertex_ColoredTextured skyVerts[4];
D3DCOLOR skyVertColor = 0xffffffff;
float dim = 50.0f;
skyVerts[0].position = Vec3(dim, dim, dim);
skyVerts[0].color = skyVertColor;
skyVerts[0].tu = 1.0f; // top right texture coord
skyVerts[0].tv = 0.0f;
skyVerts[1].position = Vec3(-dim, dim, dim);
skyVerts[1].color = skyVertColor;
skyVerts[1].tu = 0.0f; // top left texture coord
skyVerts[1].tv = 0.0f;
skyVerts[2].position = Vec3(dim, -dim, dim);
skyVerts[2].color = skyVertColor;
skyVerts[2].tu = 1.0f; // bottom right texture coord
skyVerts[2].tv = 1.0f;
skyVerts[3].position = Vec3(-dim, -dim, dim);
skyVerts[3].color = skyVertColor;
skyVerts[3].tu = 0.0f; // bottom left texture coord
skyVerts[3].tv = 1.0f;
// triangle
// 2
// / |
// 0--1
Vec3 triangle[3];
triangle[0] = Vec3(0.0f, 0.0f, 0.0f);
triangle[1] = Vec3(5.0f, 0.0f, 0.0f);
triangle[2] = Vec3(5.0f, 5.0f, 0.0f);
Vec3 edge1 = triangle[1] - triangle[0];
Vec3 edge2 = triangle[2] - triangle[0];
Vec3 normal;
normal = edge1.Cross(edge2);
normal.Normalize();
Mat4x4 rotY;
rotY.BuildRotationY(CB_PI / 2.0f);
Mat4x4 rotX;
rotX.BuildRotationX(-CB_PI / 2.0f);
m_Sides = 5;
// loop through all the sides of a sky box and set the texture coords
for (DWORD side = 0; side < m_Sides; side++)
{
for (DWORD v = 0; v < 4; v++)
{
Vec4 temp;
if (side < m_Sides - 1)
{
temp = rotY.Transform(Vec3(skyVerts[v].position));
}
else
{
skyVerts[0].tu = 1.0f; skyVerts[0].tv = 1.0f;
skyVerts[1].tu = 1.0f; skyVerts[1].tv = 0.0f;
skyVerts[2].tu = 0.0f; skyVerts[2].tv = 1.0f;
skyVerts[3].tu = 0.0f; skyVerts[3].tv = 0.0f;
temp = rotX.Transform(Vec3(skyVerts[v].position));
}
skyVerts[v].position = Vec3(temp.x, temp.y, temp.z);
}
//.........这里部分代码省略.........