本文整理汇总了C++中Matrix4::Multiply方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4::Multiply方法的具体用法?C++ Matrix4::Multiply怎么用?C++ Matrix4::Multiply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4::Multiply方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TransformMesh
void MeshUtil::TransformMesh(const std::shared_ptr<Mesh> &mesh, const Matrix4 &matrix) const
{
unsigned int count = mesh->Positions.Data.size();
if (count == 0) return;
count = count / 3;
bool hasNormal = mesh->Normals.Data.size() > 0;
for (unsigned int i = 0; i < count; i++)
{
unsigned int j = i * 3;
Vector4 pos(mesh->Positions.Data[j], mesh->Positions.Data[j + 1], mesh->Positions.Data[j + 2], 1);
pos = matrix.Multiply(pos);
mesh->Positions.Data[j] = pos.x;
mesh->Positions.Data[j + 1] = pos.y;
mesh->Positions.Data[j + 2] = pos.z;
if (hasNormal)
{
Vector4 normal(mesh->Normals.Data[j], mesh->Normals.Data[j + 1], mesh->Normals.Data[j + 2], 0);
normal = matrix.Multiply(normal).Normalized();
mesh->Normals.Data[j] = normal.x;
mesh->Normals.Data[j + 1] = normal.y;
mesh->Normals.Data[j + 2] = normal.z;
}
}
mesh->Positions.UpdateBuffer(true);
}
示例2: UpdatePlayerShip
void SpaceShooter::UpdatePlayerShip()
{
if ( InputManager::Get().GetKeyState( Key::W ) )
{
mPlayerObject->MoveForward();
playerJetParticles->SetEmitterState( true );
}
else
{
mPlayerObject->StopAcceleration();
playerJetParticles->SetEmitterState( false );
}
if ( InputManager::Get().GetKeyState( Key::A ) )
{
mPlayerObject->RotateLeft();
}
if ( InputManager::Get().GetKeyState( Key::D ) )
{
mPlayerObject->RotateRight();
}
// Update player's particles
Matrix4 jetFuelTranspose = Matrix4::Identity;
Matrix4 jetFuelOffset;
jetFuelOffset.CreateTranslation( Vector3(0.f, 0.f, -5.5f) );
Matrix4 jetFuelRotation;
jetFuelRotation.CreateFromQuaternion( mPlayerObject->GetRotation() );
Matrix4 jetFuelTranslation;
jetFuelTranslation.CreateTranslation( mPlayerObject->GetTranslation() );
jetFuelTranspose.Multiply( jetFuelTranslation );
jetFuelTranspose.Multiply( jetFuelRotation );
jetFuelTranspose.Multiply( jetFuelOffset );
playerJetParticles->SetTranslationMatrix( jetFuelTranspose );
}
示例3:
void Matrix4::ApplyRotation(Matrix4& matrix, float angle, const Vector3& axis) {
matrix = matrix.Multiply(Matrix4::Rotation(angle, axis));
}