本文整理汇总了C++中ogre::Camera::getDerivedOrientation方法的典型用法代码示例。如果您正苦于以下问题:C++ Camera::getDerivedOrientation方法的具体用法?C++ Camera::getDerivedOrientation怎么用?C++ Camera::getDerivedOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Camera
的用法示例。
在下文中一共展示了Camera::getDerivedOrientation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notifyMaterialRender
void CameraBlurListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
if (pass_id == 999)
{
if(mApp->pGame->pause == false)
{
//acquire the texture flipping attribute in the first frame
if(compositorinstance)
{
mRequiresTextureFlipping = compositorinstance->getRenderTarget("previousscene")->requiresTextureFlipping();
compositorinstance=NULL;
}
// this is the camera you're using
#ifndef ROAD_EDITOR
Ogre::Camera *cam = mApp->mSplitMgr->mCameras.front();
#else
Ogre::Camera *cam = mApp->mCamera;
#endif
// get the pass
Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
const Ogre::RenderTarget::FrameStats& stats = mApp->getWindow()->getStatistics();
float m_lastFPS =stats.lastFPS;
Ogre::Matrix4 projectionMatrix = cam->getProjectionMatrix();
if (mRequiresTextureFlipping)
{
// Because we're not using setProjectionMatrix, this needs to be done here
// Invert transformed y
projectionMatrix[1][0] = -projectionMatrix[1][0];
projectionMatrix[1][1] = -projectionMatrix[1][1];
projectionMatrix[1][2] = -projectionMatrix[1][2];
projectionMatrix[1][3] = -projectionMatrix[1][3];
}
Ogre::Matrix4 iVP = (projectionMatrix * cam->getViewMatrix()).inverse();
if (params->_findNamedConstantDefinition("EPF_ViewProjectionInverseMatrix"))
params->setNamedConstant("EPF_ViewProjectionInverseMatrix", iVP);
if (params->_findNamedConstantDefinition("EPF_PreviousViewProjectionMatrix"))
params->setNamedConstant("EPF_PreviousViewProjectionMatrix", prevviewproj);
if (params->_findNamedConstantDefinition("intensity"))
params->setNamedConstant("intensity", mApp->pSet->motionblurintensity);
float interpolationFactor = m_lastFPS * 0.03f ; //* m_timeScale m_timeScale is a multiplier to control motion blur interactively
Ogre::Quaternion current_orientation = cam->getDerivedOrientation();
Ogre::Vector3 current_position = cam->getDerivedPosition();
Ogre::Quaternion estimatedOrientation = Ogre::Quaternion::Slerp(interpolationFactor, current_orientation, (m_pPreviousOrientation));
Ogre::Vector3 estimatedPosition = (1-interpolationFactor) * current_position + interpolationFactor * (m_pPreviousPosition);
Ogre::Matrix4 prev_viewMatrix = Ogre::Math::makeViewMatrix(estimatedPosition, estimatedOrientation);//.inverse().transpose();
// compute final matrix
prevviewproj = projectionMatrix * prev_viewMatrix;
// update position and orientation for next update time
m_pPreviousOrientation = current_orientation;
m_pPreviousPosition = current_position;
}
}
}
示例2: setOrientation
void FacingObject::setOrientation(rviz::DisplayContext* context)
{
rviz::ViewManager* manager = context->getViewManager();
rviz::RenderPanel* panel = manager->getRenderPanel();
Ogre::Camera* camera = panel->getCamera();
Ogre::Quaternion q = camera->getDerivedOrientation();
setOrientation(q);
}
示例3: camera_get_derived_orientation
//Ogre::Camera::getDerivedOrientation() const
void camera_get_derived_orientation(CameraHandle handle, coiQuaternion* orientation)
{
Ogre::Camera* camera = static_cast<Ogre::Camera*>(handle);
const Ogre::Quaternion & getter = camera->getDerivedOrientation();
orientation->w = getter.w;
orientation->x = getter.x;
orientation->y = getter.y;
orientation->z = getter.z;
}
示例4: Update
void EC_OgreMovableTextOverlay::Update()
{
if (!node_ || !visible_ || !placeable_ || renderer_.expired())
return;
if(!node_->isInSceneGraph())
{
overlay_->hide();
return;
}
Ogre::Camera* camera = renderer_.lock()->GetCurrentCamera();
if (!camera)
return;
Ogre::Viewport* viewport = camera->getViewport();
Ogre::Vector3 point = node_->_getDerivedPosition();
// Is the camera facing that point? If not, hide the overlay and return.
Ogre::Plane cameraPlane = Ogre::Plane(Ogre::Vector3(camera->getDerivedOrientation().zAxis()), camera->getDerivedPosition());
if(cameraPlane.getSide(point) != Ogre::Plane::NEGATIVE_SIDE)
{
overlay_->hide();
return;
}
// Hide the overlay if it's too far.
Ogre::Vector3 res = camera->getDerivedPosition() - point;
float distance = sqrt(res.x * res.x + res.y * res.y + res.z * res.z);
if (distance > MAX_VISIBILITY_DISTANCE)
{
overlay_->hide();
return;
}
// Set the alpha channel for the overlay.
if (materialHasAlpha_)
SetAlphaChannelIntensity(distance);
// Derive the 2D screen-space coordinates for node point.
point = camera->getProjectionMatrix() * (camera->getViewMatrix() * point);
// Transform from coordinate space [-1, 1] to [0, 1]
float x = (point.x / 2) + 0.5f;
float y = 1 - ((point.y / 2) + 0.5f);
// Update the position (centering the text)
container_->setPosition(x - (textDim_.x / 2), y);
// Update the dimensions also if the window is resized.
if (windowWidth_ != viewport->getActualWidth() ||
windowHeight_ != viewport->getActualHeight())
{
windowWidth_ = viewport->getActualWidth();
windowHeight_ = viewport->getActualHeight();
textDim_ = GetTextDimensions(text_);
container_->setDimensions(textDim_.x, textDim_.y);
}
///\todo Scale the text and width and height of the container?
// text_element_->setMetricsMode(Ogre::GMM_RELATIVE);
// text_element_->setPosition(textDim_.x, textDim_.y);
// text_element_->setPosition(textDim_.x / 10, 0.01);
// text_element_->setCharHeight(max_x - min_x/*2*0.0175f*///);
overlay_->show();
}