本文整理汇总了C++中ogre::Matrix4类的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4类的具体用法?C++ Matrix4怎么用?C++ Matrix4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Matrix4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetPosition
//设置位置 (游戏世界坐标)
VOID CEffectObject::SetPosition(const fVector3& vPos)
{
//坐标转换
fVector3 fvGfx;
CRenderSystem::GetMe()->Axis_Trans(CRenderSystem::AX_GAME, vPos, CRenderSystem::AX_GFX, fvGfx);
std::list< std::pair< Fairy::Effect*, Ogre::SceneNode* > >::iterator it;
for(it=m_listEffectImpl.begin(); it!=m_listEffectImpl.end(); it++)
{
it->second->setPosition(Ogre::Vector3(fvGfx.x, fvGfx.y, fvGfx.z));
}
#if 0
Ogre::Matrix4 mxPosition = Ogre::Matrix4::IDENTITY;
mxPosition.makeTrans(fvGfx.x, fvGfx.y, fvGfx.z);
Ogre::MatrixList vMatrix;
vMatrix.push_back(mxPosition);
std::list< Ogre::Effect* >::iterator it;
for(it=m_listEffectImpl.begin(); it!=m_listEffectImpl.end(); it++)
{
(*it)->execute(0, vMatrix);
}
#endif
}
示例2:
//------------------------------------------------------------------------------
void
Background2D::renderQueueEnded( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation )
{
if( cv_show_background2d.GetB() == false )
{
return;
}
if( queueGroupId == Ogre::RENDER_QUEUE_MAIN )
{
m_RenderSystem->_setWorldMatrix( Ogre::Matrix4::IDENTITY );
m_RenderSystem->_setProjectionMatrix( Ogre::Matrix4::IDENTITY );
Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
float width = viewport->getActualWidth();
float height = viewport->getActualHeight();
Ogre::Matrix4 view;
view.makeTrans( Ogre::Vector3( m_PositionReal.x * 2 / width, -m_PositionReal.y * 2 / height, 0 ) );
m_RenderSystem->_setViewMatrix( view );
if( m_AlphaRenderOp.vertexData->vertexCount != 0 )
{
m_SceneManager->_setPass( m_AlphaMaterial->getTechnique( 0 )->getPass( 0 ), true, false );
m_RenderSystem->_render( m_AlphaRenderOp );
}
if( m_AddRenderOp.vertexData->vertexCount != 0 )
{
m_SceneManager->_setPass( m_AddMaterial->getTechnique( 0 )->getPass( 0 ), true, false );
m_RenderSystem->_render( m_AddRenderOp );
}
}
}
示例3:
const Ogre::Vector3 Mesh::getWorldSpacePosition(const Ogre::Vector3& ObjectSpacePosition) const
{
Ogre::Matrix4 mWorldMatrix;
if (mCreated)
{
#if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 7
mWorldMatrix = mEntity->getParentSceneNode()->_getFullTransform();
#else
mEntity->getParentSceneNode()->getWorldTransforms(&mWorldMatrix);
#endif
}
else
{
Ogre::SceneNode *mTmpSN = new Ogre::SceneNode(0);
mTmpSN->setPosition(mHydrax->getPosition());
#if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 7
mWorldMatrix = mTmpSN->_getFullTransform();
#else
mTmpSN->getWorldTransforms(&mWorldMatrix);
#endif
delete mTmpSN;
}
return mWorldMatrix.transformAffine(ObjectSpacePosition);
}
示例4: injectMouseMoved
bool Panel::injectMouseMoved(const Ogre::Ray& ray)
{
Ogre::Matrix4 transform;
transform.makeTransform(mNode->getPosition(), mNode->getScale(), mNode->getOrientation());
Ogre::AxisAlignedBox aabb = mScreenRenderable->getBoundingBox();
aabb.transform(transform);
pair<bool, Ogre::Real> result = Ogre::Math::intersects(ray, aabb);
if (result.first == false)
{
unOverAllElements();
return false;
}
Ogre::Vector3 a,b,c,d;
Ogre::Vector2 halfSize = (mSize/100) * 0.5f;
a = transform * Ogre::Vector3(-halfSize.x,-halfSize.y,0);
b = transform * Ogre::Vector3( halfSize.x,-halfSize.y,0);
c = transform * Ogre::Vector3(-halfSize.x, halfSize.y,0);
d = transform * Ogre::Vector3( halfSize.x, halfSize.y,0);
result = Ogre::Math::intersects(ray, c, b, a);
if (result.first == false)
result = Ogre::Math::intersects(ray, c, d, b);
if (result.first == false)
{
unOverAllElements();
return false;
}
if (result.second > mDistanceFromPanelToInteractWith)
{
unOverAllElements();
return false;
}
Ogre::Vector3 hitPos = (ray.getOrigin() + (ray.getDirection() * result.second));
Ogre::Vector3 localPos = transform.inverse() * hitPos;
localPos.x += halfSize.x;
localPos.y -= halfSize.y;
localPos.x *= 100;
localPos.y *= 100;
// Cursor clip
localPos.x = Ogre::Math::Clamp<Ogre::Real>(localPos.x, 0, mSize.x - 10);
localPos.y = Ogre::Math::Clamp<Ogre::Real>(-localPos.y, 0, mSize.y - 18);
mInternalMousePos = Ogre::Vector2(localPos.x, localPos.y);
mMousePointer->position(mInternalMousePos);
// Let's actualize the "over" for each elements
for (size_t i=0; i < mPanelElements.size(); i++)
mPanelElements[i]->isOver(mInternalMousePos);
return true;
}
示例5:
// ----------------------------------------------------------------
// gets the location of the specified eye
// ----------------------------------------------------------------
Ogre::Matrix4 OgreOpenVR::getHMDMatrixPoseEye(vr::Hmd_Eye nEye)
{
if (!m_pHMD)
return Ogre::Matrix4();
vr::HmdMatrix34_t matEye = m_pHMD->GetEyeToHeadTransform(nEye);
Ogre::Matrix4 eyeTransform = convertSteamVRMatrixToOgreMatrix4(matEye);
return eyeTransform.inverse();
}
示例6: addToVertices
int IcoSphere::addToVertices(std::list<VertexPair> *target, const Ogre::Vector3 &position, const Ogre::ColourValue &colour, float scale)
{
Ogre::Matrix4 transform = Ogre::Matrix4::IDENTITY;
transform.setTrans(position);
transform.setScale(Ogre::Vector3(scale, scale, scale));
for (int i = 0; i < (int)vertices.size(); i++)
target->push_back(VertexPair(transform * vertices[i], colour));
return vertices.size();
}
示例7: check
Button* check(const Ogre::Ray& ray, bool& isOver)
{
isOver = false;
Ogre::Matrix4 transform;
transform.makeTransform(mNode->getPosition(), mNode->getScale(), mNode->getOrientation());
Ogre::AxisAlignedBox aabb = mScreen->getBoundingBox();
aabb.transform(transform);
std::pair<bool, Ogre::Real> result = Ogre::Math::intersects(ray, aabb);
if (result.first == false)
return 0;
Ogre::Vector3 a,b,c,d;
Ogre::Vector2 halfSize = mSize * 0.5f;
a = transform * Ogre::Vector3(-halfSize.x,-halfSize.y,0);
b = transform * Ogre::Vector3( halfSize.x,-halfSize.y,0);
c = transform * Ogre::Vector3(-halfSize.x, halfSize.y,0);
d = transform * Ogre::Vector3( halfSize.x, halfSize.y,0);
result = Ogre::Math::intersects(ray, c, b, a);
if (result.first == false)
result = Ogre::Math::intersects(ray, c, d, b);
if (result.first == false)
return 0;
if (result.second > 6.0f)
return 0;
isOver = true;
Ogre::Vector3 hitPos = ( ray.getOrigin() + (ray.getDirection() * result.second) );
Ogre::Vector3 localPos = transform.inverse() * hitPos;
localPos.x += halfSize.x;
localPos.y -= halfSize.y;
localPos.x *= 100;
localPos.y *= 100;
// Cursor clip
localPos.x = Ogre::Math::Clamp<Ogre::Real>(localPos.x, 0, (mSize.x * 100) - 10);
localPos.y = Ogre::Math::Clamp<Ogre::Real>(-localPos.y, 0, (mSize.y * 100) - 18);
mMousePointer->position(localPos.x, localPos.y);
for (size_t i=0;i < mButtons.size();i++)
{
if (mButtons[i]->isOver(mMousePointer->position()))
return mButtons[i];
}
return 0;
}
示例8: GetBoundingBox
Ogre::AxisAlignedBox AACamera::GetBoundingBox(bool transformed) const
{
Ogre::AxisAlignedBox box = Box;
if (!transformed)
return box;
Ogre::Matrix4 transforms;
//Node->getWorldTransforms(&transforms);
transforms.makeTransform(Node->getPosition(),Node->getScale(),Node->getOrientation());
box.transform(transforms);
return box;
}
示例9:
void
BoxCenterMovable::getBoundingBoxCenter()
{
if(object.lock()->hasProperty("bounding box") && object.lock()->hasProperty("position"))
{
Ogre::AxisAlignedBox aabb = VariantCast<Ogre::AxisAlignedBox>(object.lock()->getProperty("bounding box"));
/*Ogre::Vector3 position = VariantCast<Ogre::Vector3>(object.lock()->getProperty("position"));
Ogre::Matrix4 matTrans;
matTrans.makeTrans( position );
aabb.transformAffine(matTrans);*/
Ogre::Matrix4 transform = Ogre::Matrix4::IDENTITY;
Ogre::Matrix3 rot3x3;
if (object.lock()->hasProperty("orientation"))
{
Ogre::Quaternion orientation = VariantCast<Ogre::Quaternion>(object.lock()->getProperty("orientation"));
orientation.ToRotationMatrix(rot3x3);
}
else
{
rot3x3 = Ogre::Matrix3::IDENTITY;
}
Ogre::Matrix3 scale3x3;
if (object.lock()->hasProperty("scale"))
{
Ogre::Vector3 scale = VariantCast<Ogre::Vector3>(object.lock()->getProperty("scale"));
scale3x3 = Ogre::Matrix3::ZERO;
scale3x3[0][0] = scale.x;
scale3x3[1][1] = scale.y;
scale3x3[2][2] = scale.z;
}
else
{
scale3x3 = Ogre::Matrix3::IDENTITY;
}
transform = rot3x3 * scale3x3;
if (object.lock()->hasProperty("position"))
{
Ogre::Vector3 position = VariantCast<Ogre::Vector3>(object.lock()->getProperty("position"));
transform.setTrans(position);
}
aabb.transformAffine(transform);
mCenterPosWC = aabb.getCenter();
}
}
示例10: onRightButtonPressed
void PlayerCameraOgre::onRightButtonPressed()
{
if (!mRightButtonPressedLastFrame)
mMousePosLastFrame = mMouse->getPosition();
mp::Vector2i diff = mMouse->getPosition() - mMousePosLastFrame;
const mp::Vector3f &playerPos = mPlayer->model()->getPosition();
Ogre::Vector3 pivotPoint(playerPos.getX(), playerPos.getY() + mPivotHeight, playerPos.getZ());
float yaw = (float)diff.getX() * CAMERA_SPEED;
float pitch = (float)-diff.getY() * CAMERA_SPEED;
Ogre::Quaternion yawQuat;
yawQuat.FromAngleAxis(Ogre::Radian(yaw), Ogre::Vector3::UNIT_Y);
Ogre::Matrix3 yawMat;
yawQuat.ToRotationMatrix(yawMat);
Ogre::Vector3 pivotToPos = Ogre::Vector3(mRealPosition.getX(), mRealPosition.getY(), mRealPosition.getZ()) - pivotPoint;
Ogre::Matrix4 pos(1, 0, 0, pivotToPos.x,
0, 1, 0, pivotToPos.y,
0, 0, 1, pivotToPos.z,
0, 0, 0, 1);
Ogre::Vector3 xz(pivotToPos.x, 0, pivotToPos.z);
Ogre::Vector3 norm(-xz.z, 0, xz.x);
Ogre::Quaternion pitchQuat;
pitchQuat.FromAngleAxis(Ogre::Radian(pitch), norm);
Ogre::Matrix3 pitchMat;
pitchQuat.ToRotationMatrix(pitchMat);
Ogre::Matrix4 toPivot(1, 0, 0, pivotPoint.x,
0, 1, 0, pivotPoint.y,
0, 0, 1, pivotPoint.z,
0, 0, 0, 1);
Ogre::Matrix4 newPosMat = pos * pitchMat * yawMat * toPivot;
newPosMat = newPosMat.inverse();
Ogre::Vector3 newPos = newPosMat.getTrans();
mRealPosition.set(-newPos.x, -newPos.y, -newPos.z);
setPosition(mRealPosition);
lookAt(pivotPoint.x, pivotPoint.y, pivotPoint.z);
adjustDistance();
mMousePosLastFrame = mMouse->getPosition();
mRightButtonPressedLastFrame = true;
}
示例11: createSceneDFS
void OgreCollada::MeshWriter::pass1Finish() {
// build scene graph and record transformations for each geometry instantiation
// determine initial transformation
Ogre::Matrix4 xform;
xform.makeTransform(Ogre::Vector3::ZERO, // no translation
Ogre::Vector3(m_ColladaScale.x, m_ColladaScale.y, m_ColladaScale.z),
Ogre::Quaternion(m_ColladaRotation.w, m_ColladaRotation.x, m_ColladaRotation.y, m_ColladaRotation.z));
// recursively find geometry instances and their transforms
for (size_t i = 0; i < m_vsRootNodes.size(); ++i) {
createSceneDFS(m_vsRootNodes[i], xform);
}
// create manualobject for use by pass2 writeGeometry calls
m_manobj = new Ogre::ManualObject(m_vsRootNodes[0]->getName() + "_mobj");
}
示例12: setTransform
void EditorNode::setTransform(Ogre::Matrix4 transform) {
Ogre::Vector3 position, scale;
Ogre::Quaternion orientation;
transform.decomposition(position, scale, orientation);
scene_node->setPosition(position);
scene_node->setScale(scale);
scene_node->setOrientation(orientation);
}
示例13: BuildTransformMatrix
//
// 根据输入的平移, 旋转, 缩放分量创建出位置变换矩阵.
//
void FairyEditorFrame::BuildTransformMatrix(Ogre::Matrix4& Matrix, const Ogre::Vector3& position, const Ogre::Quaternion rotate, const Ogre::Vector3 scale)
{
Ogre::Matrix4 posMatrix;
Ogre::Matrix4 scaleMatrix;
Ogre::Matrix4 rotateMatrix(rotate);
posMatrix = Ogre::Matrix4::IDENTITY;
posMatrix.setTrans(position);
scaleMatrix = Ogre::Matrix4::IDENTITY;
scaleMatrix.setScale(scale);
// 最终的变换矩阵.
Matrix = posMatrix * rotateMatrix * scaleMatrix;
}
示例14:
const Ogre::Vector3 Mesh::getWorldSpacePosition(const Ogre::Vector3& ObjectSpacePosition) const
{
Ogre::Matrix4 mWorldMatrix;
if (mCreated)
{
mWorldMatrix = mEntity->getParentSceneNode()->_getFullTransform();
}
else
{
Ogre::SceneNode *mTmpSN = new Ogre::SceneNode(0);
mTmpSN->setPosition(mHydrax->getPosition());
mWorldMatrix = mTmpSN->_getFullTransform();
delete mTmpSN;
}
return mWorldMatrix.transformAffine(ObjectSpacePosition);
}
示例15: GetPointOnPlane
float3 EC_WaterPlane::GetPointOnPlane(const float3 &point) const
{
if (node_ == 0)
return float3::nan;
Ogre::Quaternion rot = node_->_getDerivedOrientation();
Ogre::Vector3 trans = node_->_getDerivedPosition();
Ogre::Vector3 scale = node_->_getDerivedScale();
Ogre::Matrix4 worldTM;
worldTM.makeTransform(trans, scale, rot);
// In Ogre 1.7.1 we could simply use the following line, but since we're also supporting Ogre 1.6.4 for now, the above
// lines are used instead, which work in both.
// Ogre::Matrix4 worldTM = node_->_getFullTransform(); // local->world.
Ogre::Matrix4 inv = worldTM.inverse(); // world->local
Ogre::Vector4 local = inv * Ogre::Vector4(point.x, point.y, point.z, 1.f);
local.y = 0;
Ogre::Vector4 world = worldTM * local;
return float3(world.x, world.y, world.z);
}