内容:
初始化
//建立Root
Root * root = new Root();
//配置窗口
if(!root->restoreConfig())
if(root->showConfigDialog())
{...};
//建立窗口
root->initialise(true, "My Render Window");
RenderWindow * window =root->getAutoCreatedWindow ();
//摄像机
Camera * cam = sceneMgr ->createCamera("MainCamera");
//视口
Viewport * vp = window->addViewport(camera);
渲染循环
//帧监测
class MyFrameListener : public FrameListener{
public:
bool frameStarted (const FrameEvent &evt);
bool frameEnded (const FrameEvent &evt ){return true;};
};
bool MyFrameListener::frameStarted (const FrameEvent &evt){
//在每一帧画面渲染前,调用这里你写好的代码
return true;
}
//添加Listener 并开始渲染循环
Root * root = new Root();
MyFrameListener myListener;
root->addFrameListener(myListener);
root->startRendering();
场景管理器
SceneManager* sceneMgr = root->createSceneManager(ST_GENERIC, "MySceneManager");
ST_GENERIC:最简单的场景管理器
ST_INTERIOR:优化了室内近距离的渲染
ST_EXTERIOR_CLOSE:优化了室外场景里面的中近距离可视体
ST_EXTERIOR_REAL_FAR:适合那种需要动态加载的地形或者场景
摄像机
camera->setPosition(200, 10, 200);
camera->move(10, 0, 0);
camera->moveRelative(0, 0, 10); //参照摄像机的方向进行移动
roll(angle),yaw(angle),以及pitch(angle)
环绕Z轴(Roll:滚动)、Y轴(Yaw:偏移)或者X轴(Pitch:倾斜)的旋转
lookAt(Real x, Real y, Real z)
朝向一个位置
setDirection(x,y,z);
设置方向
rotate(const Vector3& axis, Real degrees)
绕着给定的轴向旋转
setFixedYawAxis (bool useFixed, const Vector3 &fixedAxis=Vector3::UNIT_Y)
锁定某一个轴向的自由度
setAutoTracking(bool enabled,SceneNode *target=0,const Vector3 &offset=Vector3::ZERO)
让摄像机总是盯着某一个节点
offset 着眼点偏离中心的向量
得到摄像机当前的方向的信息
const Quaternion& getDerivedOrientation(void) const;
const Vector3& getDerivedPosition(void) const;
Vector3 getDerivedDirection(void) const;
Vector3 getDerivedUp(void) const;
Vector3 getDerivedRight(void) const;
const Quaternion& getRealOrientation(void) const;
const Vector3& getRealPosition(void) const;
Vector3 getRealDirection(void) const;
Vector3 getRealUp(void) const;
Vector3 getRealRight(void) const;
其中有“Real”关键字的方法返回的是世界空间的坐标,而拥有“Derived”关键字的方法的返回值是在“轴绑定”的本地坐标系中(也就是说这个坐标系原点是摄像机所在的点,而它的轴向和世界坐标系相同)。
沿摄像机方向的射线
Ray getCameraToViewportRay(Real x, Real y) const;
ogre初始化
最新推荐文章于 2022-03-30 14:49:18 发布