本文整理汇总了C++中Mat4x4::BuildRotationX方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4x4::BuildRotationX方法的具体用法?C++ Mat4x4::BuildRotationX怎么用?C++ Mat4x4::BuildRotationX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4x4
的用法示例。
在下文中一共展示了Mat4x4::BuildRotationX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
//
// D3DSkyNode11::VOnRestore - Chapter 16, page 556
//
HRESULT D3DSkyNode11::VOnRestore(Scene *pScene)
{
HRESULT hr;
V_RETURN(SceneNode::VOnRestore(pScene) );
m_camera = pScene->GetCamera();
SAFE_RELEASE(m_pVertexBuffer);
SAFE_RELEASE(m_pIndexBuffer);
V_RETURN (m_VertexShader.OnRestore(pScene) );
V_RETURN (m_PixelShader.OnRestore(pScene) );
m_numVerts = 20;
// Fill the vertex buffer. We are setting the tu and tv texture
// coordinates, which range from 0.0 to 1.0
D3D11Vertex_UnlitTextured *pVertices = GCC_NEW D3D11Vertex_UnlitTextured[m_numVerts];
GCC_ASSERT(pVertices && "Out of memory in D3DSkyNode11::VOnRestore()");
if (!pVertices)
return E_FAIL;
// Loop through the grid squares and calc the values
// of each index. Each grid square has two triangles:
//
// A - B
// | / |
// C - D
D3D11Vertex_UnlitTextured skyVerts[4];
D3DCOLOR skyVertColor = 0xffffffff;
float dim = 50.0f;
skyVerts[0].Pos = Vec3( dim, dim, dim ); skyVerts[0].Uv = Vec2(1.0f, 0.0f);
skyVerts[1].Pos = Vec3(-dim, dim, dim ); skyVerts[1].Uv = Vec2(0.0f, 0.0f);
skyVerts[2].Pos = Vec3( dim,-dim, dim ); skyVerts[2].Uv = Vec2(1.0f, 1.0f);
skyVerts[3].Pos = Vec3(-dim,-dim, dim ); skyVerts[3].Uv = Vec2(0.0f, 1.0f);
Vec3 triangle[3];
triangle[0] = Vec3(0.f,0.f,0.f);
triangle[1] = Vec3(5.f,0.f,0.f);
triangle[2] = Vec3(5.f,5.f,0.f);
Vec3 edge1 = triangle[1]-triangle[0];
Vec3 edge2 = triangle[2]-triangle[0];
Vec3 normal;
normal = edge1.Cross(edge2);
normal.Normalize();
Mat4x4 rotY;
rotY.BuildRotationY(GCC_PI/2.0f);
Mat4x4 rotX;
rotX.BuildRotationX(-GCC_PI/2.0f);
m_sides = 5;
for (DWORD side = 0; side < m_sides; side++)
{
for (DWORD v = 0; v < 4; v++)
{
Vec4 temp;
if (side < m_sides-1)
{
temp = rotY.Xform(Vec3(skyVerts[v].Pos));
}
else
{
skyVerts[0].Uv = Vec2(1.0f, 1.0f);
skyVerts[1].Uv = Vec2(1.0f, 1.0f);
skyVerts[2].Uv = Vec2(1.0f, 1.0f);
skyVerts[3].Uv = Vec2(1.0f, 1.0f);
temp = rotX.Xform(Vec3(skyVerts[v].Pos));
}
skyVerts[v].Pos = Vec3(temp.x, temp.y, temp.z);
}
memcpy(&pVertices[side*4], skyVerts, sizeof(skyVerts));
}
D3D11_BUFFER_DESC bd;
ZeroMemory( &bd, sizeof(bd) );
bd.Usage = D3D11_USAGE_DEFAULT;
bd.ByteWidth = sizeof( D3D11Vertex_UnlitTextured ) * m_numVerts;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
D3D11_SUBRESOURCE_DATA InitData;
ZeroMemory( &InitData, sizeof(InitData) );
InitData.pSysMem = pVertices;
hr = DXUTGetD3D11Device()->CreateBuffer( &bd, &InitData, &m_pVertexBuffer );
SAFE_DELETE(pVertices);
if( FAILED( hr ) )
return hr;
// Loop through the grid squares and calc the values
//.........这里部分代码省略.........
示例2: 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);
}
//.........这里部分代码省略.........