当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix::Zero方法代码示例

本文整理汇总了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);
//.........这里部分代码省略.........
开发者ID:bretthuff22,项目名称:Animation,代码行数:101,代码来源:TestApp.cpp


注:本文中的math::Matrix::Zero方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。