ogre学习笔记-Intermediate Tutorial 1234

Intermediate Tutorial 1          Animation, Walking Between Points, and Basic Quaternions
节点动画和Ogre::Quaternion类,骨骼动画
1、节点动画和Ogre::Quaternion
  mNode->setPosition(mDestination);
  mNode->translate(mDirection * move);
         Ogre::Quaternion quat = src.getRotationTo(mDirection);
         mNode->rotate(quat);
  mNode->yaw(Ogre::Degree(180));
节点的平移和旋转功能的函数。
void IntermediateTutorial1::rotateRobotToDirection( void ) 函数用于计算节点的旋转方向。
这里用到了三维几何的四元数方面的知识。

2、骨骼动画
(1)初始化动画对象,并设置
 // Set idle animation
        mAnimationState = mEntity->getAnimationState("Idle");
        mAnimationState->setLoop(true);
        mAnimationState->setEnabled(true);
(2)在 bool IntermediateTutorial1::frameRenderingQueued(const Ogre::FrameEvent &evt)函数中添加代码:
mAnimationState->addTime(evt.timeSinceLastFrame);
什么函数给动画时间变化,是动画运行起来。


相关参考文章:关于四元数和旋转(待看)
Quaternion and Rotation Primer          A solid introduction to Quaternions and their use in Ogre


Intermediate Tutorial 2          RaySceneQueries and Basic Mouse Usage (Part 1 of 2)
注意:不兼容1.8版本的OGRE

注意:将CEGUI相关的内容都省略了。所以屏幕上面没有鼠标显示。但是会在鼠标的位置进行相应的操作。
射线选取的代码如下:
Ogre::Ray mouseRay = mCamera->getCameraToViewportRay(          mousePos.d_x/float(arg.state.width),          mousePos.d_y/float(arg.state.height));
mRaySceneQuery->setRay(mouseRay);// Execute queryOgre::RaySceneQueryResult&result = mRaySceneQuery->execute(); Ogre::RaySceneQueryResult::iterator itr = result.begin(); // Get results, create a node/entity on the position if(itr != result.end()&& itr->worldFragment)
{ //关于 itr->worldFragment->singleIntersection的处理代码略
}

Intermediate Tutorial 3         Mouse Picking (3D Object Selection) and SceneQuery Masks (Part 2 of 2)
1、鼠标点选就是上面的射线选取。
2、

Query Masks

ent->setQueryFlags(ROBOT_MASK);
mRayScnQuery->setSortByDistance(true);

mRayScnQuery->setQueryMask(bRobotMode ? ROBOT_MASK : NINJA_MASK);

Intermediate Tutorial 4         Volume Selection and Basic Manual Objects


Building CEGUI         Since the Ogre 1.7 version, CEGUI is not an Ogre dependency anymore using its own basic interface for its samples

mVolQuery = mSceneMgr->createPlaneBoundedVolumeQuery(Ogre::PlaneBoundedVolumeList());
float left = first.x, right = second.x,
top = first.y, bottom = second.y;
 
if(left > right)
        swap(left, right);
 
if(top > bottom)
        swap(top, bottom);
if((right - left)*(bottom - top)<0.0001)return;
Ogre::Ray topLeft = mCamera->getCameraToViewportRay(left, top);
Ogre::Ray topRight = mCamera->getCameraToViewportRay(right, top);
Ogre::Ray bottomLeft = mCamera->getCameraToViewportRay(left, bottom);
Ogre::Ray bottomRight = mCamera->getCameraToViewportRay(right, bottom);
Ogre::PlaneBoundedVolumeList volList;
volList.push_back(vol);
 
mVolQuery->setVolumes(volList);
Ogre::SceneQueryResult result = mVolQuery->execute();


deselectObjects();
Ogre::SceneQueryResultMovableList::iterator iter;for(iter = result.movables.begin();
 iter != result.movables.end();++iter)
        selectObject(*iter);
其它:(待看)

Introduction

There are two ways to create your own mesh within Ogre. The first way is to subclass the SimpleRenderable(external link) object and provide it with the vertex and index buffers directly. This is the most direct way to create one, but it's also the most cryptic. The Generating A Mesh code snippet shows an example of this. To make things easier, Ogre provides a much nicer interface called ManualObject, which allows you to use some simple functions to define a mesh instead of writing raw data to the buffer objects. Instead of dropping the position, color, and so on into a buffer, you simply call the "position" and "colour" functions.

In this tutorial we need to create a white rectangle to display when we are dragging the mouse to select objects. There really isn't a class in Ogre we could use to display a 2D rectangle. We will have to come up with a way of doing it on our own. We could use an Overlay and resize it to display the selection rectangle, but the problem with doing it this way is that the image you use for the selection rectangle could get stretched out of shape and look awkward. Instead, we will generate a very simple 2D mesh to act as our selection rectangle.




你可能感兴趣的:(ogre学习笔记-Intermediate Tutorial 1234)