本文整理汇总了C++中Transformation::GetMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Transformation::GetMatrix方法的具体用法?C++ Transformation::GetMatrix怎么用?C++ Transformation::GetMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transformation
的用法示例。
在下文中一共展示了Transformation::GetMatrix方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDirection
const Vec3 GetDirection() const
{
if (mOverridingCamera){
return mOverridingCamera->GetDirection();
}
return mTransformation.GetMatrix().Column(1);
}
示例2: invalid_argument
void
Custom::AppendTransformation(Transformation const& Trafo)
{
Matrix const& TrafoMatrix = Trafo.GetMatrix();
if (TrafoMatrix.size2() != m_Matrix.size1())
{
throw std::invalid_argument("Matrix bounds do not match.");
}
Matrix Result(m_Matrix.size1(), TrafoMatrix.size2());
boost::numeric::ublas::axpy_prod(m_Matrix, TrafoMatrix, Result, true);
m_Matrix = std::move(Result);
}
示例3: DrawPrimitiveQuad
void DrawPrimitiveQuad(Transformation &QuadTransformation, const EBlendMode &Mode, const ColorRGB &Color)
{
Image::BindNull();
WindowFrame.SetUniform(U_COLOR, Color.Red, Color.Green, Color.Blue, Color.Alpha);
SetBlendingMode(Mode);
Mat4 Mat = QuadTransformation.GetMatrix();
WindowFrame.SetUniform(U_MVP, &(Mat[0][0]));
// Assign position attrib. pointer
SetPrimitiveQuadVBO();
DoQuadDraw();
FinalizeDraw();
Image::ForceRebind();
}
示例4: Update
//----------------------------------------------------------------------------
void Update()
{
if (mOverridingCamera){
mOverridingCamera->Update();
}
// world coordinates (Blender style)
// x: right
// y: forward
// z: up
bool viewChanged = mViewPropertyChanged;
if (mViewPropertyChanged)
{
mViewPropertyChanged = false;
Vec3 right = mTransformation.GetMatrix().Column(0);
Vec3 forward = mTransformation.GetMatrix().Column(1);
Vec3 up = mTransformation.GetMatrix().Column(2);
const Vec3& pos = mTransformation.GetTranslation();
mMatrices[View] = fb::MakeViewMatrix(pos, right, forward, up);
mTransformation.GetHomogeneous(mMatrices[InverseView]);
mFrustum.mOrigin = mTransformation.GetTranslation();
mFrustum.mOrientation = mTransformation.GetRotation();
}
bool projChanged = mProjPropertyChanged;
if (mProjPropertyChanged)
{
mAspectRatio = GetWidth() / (Real)GetHeight();
mProjPropertyChanged = false;
if (!mOrthogonal)
{
mMatrices[ProjBeforeSwap] = mMatrices[Proj] =
MakeProjectionMatrix(mFov, mAspectRatio, mNear, mFar);
}
else
{
mMatrices[ProjBeforeSwap] = mMatrices[Proj] =
MakeOrthogonalMatrix((Real)mOrthogonalData.left, (Real)mOrthogonalData.top,
(Real)mOrthogonalData.right, (Real)mOrthogonalData.bottom,
mNear, mFar);
}
if (mYZSwap)
{
Mat44 swapMat(
1, 0, 0, 0,
0, 0, 1, 0,
0, 1, 0, 0,
0, 0, 0, 1);
mMatrices[Proj] = mMatrices[Proj] * swapMat;
}
mMatrices[InverseProj] = mMatrices[Proj].Inverse();
mFrustum.SetData(mNear, mFar, mFov, mAspectRatio);
}
if (projChanged || viewChanged)
{
mMatrices[ViewProj] = mMatrices[Proj] * mMatrices[View];
mMatrices[InverseViewProj] = mMatrices[ViewProj].Inverse();
UpdateFrustum();
if (viewChanged && !mSelf->mObservers_.empty()){
auto& observers = mSelf->mObservers_[TransformChanged];
for (auto it = observers.begin(); it != observers.end(); /**/){
auto observer = it->lock();
if (!observer){
it = observers.erase(it);
continue;
}
++it;
observer->OnViewMatrixChanged();
}
}
if (projChanged && !mSelf->mObservers_.empty()){
auto& observers = mSelf->mObservers_[TransformChanged];
for (auto it = observers.begin(); it != observers.end(); /**/){
auto observer = it->lock();
if (!observer){
it = observers.erase(it);
continue;
}
++it;
observer->OnProjMatrixChanged();
}
}
mRayCache.clear();
}
}
示例5: matrix
//----------------------------------------------------------------------------
void Sample5::OnIdle()
{
Double time = System::GetTime();
Double elapsedTime = time - mLastTime;
mLastTime = time;
mAngle += static_cast<Float>(elapsedTime);
mAngle = MathF::FMod(mAngle, MathF::TWO_PI * 2);
// scene graph transformations
//
Node* pLitGroup = DynamicCast<Node>(mspRoot->GetChild(0));
WIRE_ASSERT(pLitGroup);
// rotate the 2 cubes
Matrix3F rotate1(Vector3F(0.75F, 0.25F, 0.5F), -mAngle * 0.5F);
Spatial* pCube1 = pLitGroup->GetChild(0);
pCube1->Local.SetRotate(rotate1);
Matrix3F rotate2(Vector3F(-0.75F, -0.25F, -0.5F), -mAngle * 0.5F);
Spatial* pCube2 = pLitGroup->GetChild(1);
pCube2->Local.SetRotate(rotate2);
// move the green light up and down
Float y = MathF::FMod(static_cast<Float>(time), MathF::TWO_PI);
Vector3F lightPos1(0, MathF::Sin(y*2) * 1.5F, 2);
Node* pLightNode1 = DynamicCast<Node>(mspRoot->GetChild(1));
WIRE_ASSERT(pLightNode1);
pLightNode1->Local.SetTranslate(lightPos1);
// rotate the red light about the y axis
Node* pLightNode2 = DynamicCast<Node>(mspRoot->GetChild(2));
WIRE_ASSERT(pLightNode2);
Matrix34F rotateLight2(Vector3F::UNIT_Y, -mAngle);
Vector3F lightPos2 = rotateLight2 * Vector3F(5, 0, 0);
pLightNode2->Local.SetTranslate(lightPos2);
mspRoot->UpdateGS(time);
mCuller.ComputeVisibleSet(mspRoot);
// manual transformation from local to world space of
// the non-scene graph part
Transformation transformation;
Float angle = MathF::Sin(mAngle*2);
angle = angle * MathF::HALF_PI*0.3F + MathF::PI;
Matrix34F rotateLocalLight3(Vector3F(0, 1, 0), angle);
Matrix34F rotateWorldLight3(Vector3F(1, 0, 0), -0.5F);
transformation.SetTranslate(Vector3F(0.5F, -1.0F, 4+MathF::Sin(y*1.0F)*2));
transformation.SetRotate(rotateWorldLight3 * rotateLocalLight3);
transformation.SetUniformScale(0.15F);
mspSpotLight->Position = transformation.GetTranslate();
mspSpotLight->Direction = transformation.GetMatrix().GetColumn(2);
GetRenderer()->ClearBuffers();
GetRenderer()->PreDraw(mspCamera);
// render the scene graph
GetRenderer()->Draw(mCuller.GetVisibleSets());
// before we start drawing objects in 'manual' mode, release all resources
// cached by the Renderer to return the renderer to its default state.
// This is necessary when identical resources (mspTexture in this case)
// are used by the scene graph and other objects that are being draw
// manually.
GetRenderer()->ReleaseResources();
// render the white cube representing the spot light
GetRenderer()->Draw(mspWhiteCube, transformation);
Matrix34F matrix(Vector3F(1.0F, 0, 0), -1.0F, Vector3F(0, -2.5F, 0));
transformation.SetMatrix(matrix, false);
transformation.SetUniformScale(1);
// render the bottom plane which is being lit by the spot light
GetRenderer()->SetLight(mspSpotLight);
GetRenderer()->EnableLighting(mspSpotLight->Ambient);
GetRenderer()->Draw(mspPlane, transformation);
GetRenderer()->DisableLighting();
GetRenderer()->PostDraw();
GetRenderer()->DisplayBackBuffer();
}