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.




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值