本文整理汇总了C++中math::Matrix::Zero方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::Zero方法的具体用法?C++ Matrix::Zero怎么用?C++ Matrix::Zero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math::Matrix
的用法示例。
在下文中一共展示了Matrix::Zero方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnUpdate
void TestApp::OnUpdate()
{
if (mWindow.HandleMessage())
{
mRunning = false;
}
else
{
// Update our time
mTimer.Update();
// Update animation
mAnimationController.Update(mTimer.GetElapsedTime() * 1000.0f);
// Camera movement
const float kMoveSpeed = 10.0f;
const float kTurnSpeed = 5.0f;
if (mKeyStates[VK_UP] || mKeyStates['W'])
{
mCamera.Walk(kMoveSpeed * mTimer.GetElapsedTime());
}
else if (mKeyStates[VK_DOWN] || mKeyStates['S'])
{
mCamera.Walk(-kMoveSpeed * mTimer.GetElapsedTime());
}
else if (mKeyStates[VK_RIGHT] || mKeyStates['D'])
{
mCamera.Strafe(kMoveSpeed * mTimer.GetElapsedTime());
}
else if (mKeyStates[VK_LEFT] || mKeyStates['A'])
{
mCamera.Strafe(-kMoveSpeed * mTimer.GetElapsedTime());
}
else if (mKeyStates['K'])
{
mDrawSkeleton = !mDrawSkeleton;
}
// Render scene
mGraphicsSystem.BeginRender(Color::Black());
mRenderer.SetCamera(mCamera);
if(mDrawSkeleton)
{
DrawSkeleton();
}
// for each mesh
for(u32 i = 0; i < mModel.mMeshes.size(); ++i)
{
const Mesh* mesh = mModel.mMeshes[i];
// copy vertexweights
const VertexWeights& vertexWeights = mesh->GetVertexWeights();
// if vw not empty
if(!vertexWeights.empty())
{
const std::vector<Math::Matrix>& boneTransforms = mAnimationController.BoneTransforms();
// copy vertices
const Mesh::Vertex* vertices = mesh->GetVertices();
// get vertex count
const u32 count = mesh->GetVertexCount();
// create new vertexarray of size vertex count
Mesh::Vertex* newVertices = new Mesh::Vertex[count];
// for each vertex
for(u32 j = 0; j < count; ++j)
{
// create zero transform
Math::Matrix transform;
transform = transform.Zero();
// copy boneweights from this vertexweight
const BoneWeights& boneWeights = vertexWeights[j];
if(i == 1)
{
transform = boneTransforms[22];
}
else
{
// for each boneweight
for(u32 k = 0; k < boneWeights.size(); ++k)
{
const BoneWeight& boneWeight = boneWeights[k];
transform = transform + boneTransforms[i == 1 ? 22 : boneWeight.boneIndex] * boneWeight.weight;
}
}
// insert position into newVertices
newVertices[j].position = Math::TransformCoord(vertices[j].position, transform);
// insert normal into newVertices
newVertices[j].normal = Math::Normalize(Math::TransformNormal(vertices[j].normal, transform));
// insert texcoord into newVertices
newVertices[j].texcoord = vertices[j].texcoord;
}
// update mesh buffer at index with newVertices
mModel.mMeshBuffers[i]->UpdateBuffer(mGraphicsSystem, newVertices, count);
// safedelete newVertices
SafeDeleteArray(newVertices);
//.........这里部分代码省略.........