OGRE Tutorials 1
【Guide to building OGRE】
1、Preparing the build environment
You should now create a build directory for Ogre somewhere outside Ogre's sources. This is the directory where CMake will create the build system for your chosen platform and compiler, and this is also where the Ogre libraries will be compiled. This way, the Ogre source dir stays clean, and you can have multiple build directories all working from the same Ogre source.
创建一个不同于 Ogre 的目录,用于CMake生成工程文件,比如叫 project_1。
2、Getting dependencies
By default ogre will build the essential dependencies automatically when you run cmake the first time.
Ogre will install the dependencies into the subfolder Dependencies in the build dir by default. You can configure it by setting OGRE_DEPENDENCIES_DIR in cmake. For instance to point to a common dependencies folder for all of your projects. Inside this directory you must have the subdirectories bin, lib and include where you place .dll, .lib and header files of the dependencies, respectively.
CMake会自动构建基础依赖,将依赖的 dll、libs、header files 放置在 project_1/Dependencies/ 目录下。可以通过 OGRE_DEPENDENCIES_DIR 来更改 Dependencies 目录。
如果是 linux 系统,还需安装一些额外的依赖。
3、Running CMake
1) Now start the program cmake-gui
2) In the field Where is the source code enter the path to the Ogre source directory (the directory which contains this file).
3) In the field Where to build the binaries enter the path to the build directory you created.
4) Hit Configure. A dialogue will appear asking you to select a generator.
Click Finish. CMake will now gather some information about your build environment and try to locate the dependencies. It will then show a list of build options. You can adjust the settings to your liking; for example unchecking any of the OGRE_BUILD_XXX options will disable that particular component from being built. Once you are satisfied, hit Configure again and then click on Generate. CMake will then create the build system for you.
4、Building
Go to your chosen build directory. CMake has generated a build system for you which you will now use to build Ogre.
If you are using Visual Studio, you should find the file OGRE.sln. Open it and compile the target BUILD_ALL.
打开 project_1中的 OGRE.sln,构建 BUILD_ALL。
5、Installing
In Visual Studio, just select and build the target INSTALL. On Windows this will create the folder sdk inside your build directory and copy all the required libraries there. You can change the install location by changing the variable CMAKE_INSTALL_PREFIX in CMake.
构建 INSTALL 工程,即会在 project_1 下生成 sdk 目录,包含了 dll、lib、headers
【Setting up an OGRE project】
1、simply derive from OgreBites::ApplicationContext and if you want to get input events from OgreBites::InputListener
class MyTestApp : public OgreBites::ApplicationContext, public OgreBites::InputListener
{
...
}
MyTestApp::MyTestApp() : OgreBites::ApplicationContext("OgreTutorialApp")
{
}
2、handle input
bool MyTestApp::keyPressed(const OgreBites::KeyboardEvent& evt)
{
if (evt.keysym.sym == OgreBites::SDLK_ESCAPE)
{
getRoot()->queueEndRendering();
}
return true;
}
3、main
int main(int argc, char *argv[])
{
MyTestApp app;
app.initApp();
app.getRoot()->startRendering();
app.closeApp();
return ;
}
【Your First Scene】
1、SceneManager
There are multiples types of SceneManagers. There are managers focused on rendering terrain and other managers focused on rendering BSP maps. The different types of SceneManager are listed here.
2、SceneNode
An Entity is not rendered in your scene until it is attached to a SceneNode.
3、setAmbientLight
root可以创建 sceneManager,sceneManager可以设置环境光。(注意不是通过light设置)
// get a pointer to the already created root
Root* root = getRoot();
SceneManager* scnMgr = root->createSceneManager(); scnMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
4、createLight
通过 sceneManager 创建 Light。
Light* light = scnMgr->createLight("MainLight");
SceneNode* lightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
lightNode->attachObject(light);
lightNode->setPosition(, , );
5、createCamera
通过 sceneManager 创建 Camera
SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode();
// create the camera
Camera* cam = scnMgr->createCamera("myCam");
cam->setNearClipDistance(); // specific to this sample
cam->setAutoAspectRatio(true);
camNode->attachObject(cam);
camNode->setPosition(, , );
// and tell it to render into the main window
getRenderWindow()->addViewport(cam);
6、createEntity
Entity* ogreEntity = scnMgr->createEntity("ogrehead.mesh");
7、createChildSceneNode
SceneNode* ogreNode = scnMgr->getRootSceneNode()->createChildSceneNode();
ogreNode->attachObject(ogreEntity);
SceneNodes are used to set a lot more than just position. They also manage the scale and rotation of objects.
Entity* ogreEntity3 = scnMgr->createEntity("ogrehead.mesh");
SceneNode* ogreNode3 = scnMgr->getRootSceneNode()->createChildSceneNode();
ogreNode3->setPosition(, , );
ogreNode3->setScale(, 1.2, );
ogreNode3->attachObject(ogreEntity3);
8、OGRE使用右手坐标系。
9、Rotating An Entity.

10、Libraries and Plugins
Ogre is divided into three shared library groups: main library, plugins, and third-party libraries.
1)Main library
The Ogre library is contained within OgreMain.dll or libOgreMain.so depending on your platform. This library must be included in all of your Ogre applications.
2)Plugins
The core plugins that are included with Ogre have names that start with "Plugin_" and "Codec_".
Ogre also uses plugins for the different render systems (such as OpenGL, DirectX, etc). These plugins start with "RenderSystem_".
11、Configuration Files
Ogre uses several configuration files (*.cfg). You can place these files the same directory as your executable or in any of the default lookup paths described here.
Ogre must find 'plugins.cfg' and 'resources.cfg' to function properly.
1)plugins.cfg
This file tells Ogre which plugins to load. You modify this file when you want to load a different set of plugins.
# Plugin=RenderSystem_Direct3D9
# Plugin=RenderSystem_Direct3D10
# Plugin=RenderSystem_Direct3D11
Plugin=RenderSystem_GL
You can also decide where Ogre looks for plugins by changing the 'PluginFolder' variable.
PluginFolder=/usr/local/lib/OGRE
2)resources.cfg
This file contains a list of the directories Ogre will use to search for resources. Resources include scripts, meshes, textures, GUI layouts, and others. Ogre will not search subdirectories, so you have to manually enter them.
[General]
FileSystem=../media
FileSystem=../media/materials/scripts
FileSystem=../media/materials/textures
FileSystem=../media/models
3)ogre.cfg
This file is generated by the Render Settings dialog that appears when you run your application. Do not distribute this file with your application. This file will be specific to your own setup.
【Lights, Cameras, and Shadows】
1、addViewport
Viewport* vp = getRenderWindow()->addViewport(cam);
vp->setBackgroundColour(ColourValue(, , ));
cam->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
2、setCastShadows(true)
Entity* ninjaEntity = scnMgr->createEntity("ninja.mesh");
ninjaEntity->setCastShadows(true);
scnMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ninjaEntity);
3、createPlane
The first thing we'll do is create an abstract Plane object. This is not the mesh, it is more of a blueprint. We create a plane by supplying a vector that is normal to our plane and its distance from the origin. So we have created a plane that is perpendicular to the y-axis and zero units from the origin.
Plane plane(Vector3::UNIT_Y, );
Now we'll ask the MeshManager to create us a mesh using our Plane blueprint. The MeshManager is already keeping track of the resources we loaded when initializing our application.
MeshManager::getSingleton().createPlane(
"ground", RGN_DEFAULT,
plane,
, , , ,
true,
, , ,
Vector3::UNIT_Z);
Entity* groundEntity = scnMgr->createEntity("ground");
scnMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundEntity);
groundEntity->setCastShadows(false);
groundEntity->setMaterialName("Examples/Rockwall");
4、setShadowTechnique
Enabling shadows in Ogre is easy. The SceneManager class has a Ogre::SceneManager::setShadowTechnique method we can use.
Ogre does not provide soft shadows as part of the engine. You can write your own vertex and fragment programs to implement soft shadows and many other things.
5、Light->setType
Ogre provides three types of lighting.
- Ogre::Light::LT_POINT - This Light speads out equally in all directions from a point.
- Ogre::Light::LT_SPOTLIGHT - This Light works like a flashlight. It produces a solid cylinder of light that is brighter at the center and fades off.
- Ogre::Light::LT_DIRECTIONAL - This Light simulates a huge source that is very far away - like daylight. Light hits the entire scene at the same angle everywhere.
Light* spotLight = scnMgr->createLight("SpotLight");
spotLight->setDiffuseColour(, , 1.0);
spotLight->setSpecularColour(, , 1.0);
spotLight->setType(Light::LT_SPOTLIGHT);
SceneNode* spotLightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
spotLightNode->attachObject(spotLight);
spotLightNode->setDirection(-, -, );
spotLightNode->setPosition(Vector3(, , ));
注意:OGRE中的Light比较奇怪,需要设置两种光,diffuse、specular。
【Trays GUI System】
1、
2、
3、
4、
5、
参考:
1、https://ogrecave.github.io/ogre/api/latest/building-ogre.html
OGRE Tutorials 1的更多相关文章
- CG&Game资源(转)
cg教程下载: http://cgpeers.com http://cgpersia.com http://bbs.ideasr.com/forum-328-1.html http://bbs.ide ...
- OGRE 1.9 的第一个程序(OGRE HelloWorld程序)
平台:win7, VS2010 先看运行结果吧: 1. 安装OGRE 下载OGRE SDK 1.9,解压,放在你喜欢的地方,在OGRE SDK文件加下创建“OGRE_HOME.bat.bat”文本文件 ...
- OGRE的学习资源
本文介绍从哪儿开始学习OGRE(Object-Oriented Graphics Rendering Engine的简称,又叫做OGRE 3D),如何在网上找寻OGRE的学习资源. 首先是wikipe ...
- Ogre1.8.1 Basic Tutorial 6 - The Ogre Startup Sequence
原文地址:http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Tutorial+6&structure=Tutorials 1. ...
- JDBC Tutorials: Commit or Rollback transaction in finally block
http://skeletoncoder.blogspot.com/2006/10/jdbc-tutorials-commit-or-rollback.html JDBC Tutorials: Com ...
- Basic Tutorials of Redis(2) - String
This post is mainly about how to use the commands to handle the Strings of Redis.And I will show you ...
- Run P4 without P4factory - A Simple Example In Tutorials.
前言 本文是我运行P4社区于Github开源教程Tutorials中的P4 SIGCOMM 2015 Tutorial一些实战小结,Github链接: Github. 测试的例子:P4 SIGCOMM ...
- [比较老的文章]三维渲染引擎 OGRE 与 OSG 的比较综述
1 .引言随着计算机可视化.虚拟现实技术的飞速发展,人们对实时真实感渲染以及场景复杂度提出了更高的要求.传统的直接使用底层图形接口如OpenGL.DirectX开发图形应用的模式越来越暴露出开发复杂性 ...
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
本文介绍 OGRE 3D 1.9 程序的启动过程,即从程序启动到3D图形呈现,背后有哪些OGRE相关的代码被执行.会涉及的OGRE类包括: Root RenderSystem RenderWindow ...
随机推荐
- 配置Tomcat使用https协议(配置SSL协议)
配置Tomcat使用https协议(配置SSL协议) 2014-01-20 16:38 58915人阅读 评论(3) 收藏 举报 转载地址:http://ln-ydc.iteye.com/blog/1 ...
- 在已安装64位oracle的服务器安装32位客户端
应用场景:服务器操作系统是win2012 64位,原先安装了64位oracle12,后来系统增加导入excel的功能,网站必须启用32位兼容模式,这时候发现原有的页面打不开,提示: 试图加载格式不正确 ...
- [ZZ] [精彩盘点] TesterHome 社区 2018年 度精华帖
原文地址: https://testerhome.com/topics/17646 相逢即是缘分,总有一篇适合您! 感觉好的请点赞收藏 ,感觉分类不严谨的,欢迎反馈给我! 测试方法&测试管理 ...
- 20164310Exp6 信息搜索和漏洞扫描
实践内容 (1)各种搜索技巧的应用 (2)DNS IP注册信息的查询 (3)基本的扫描技术:主机发现.端口扫描.OS及服务版本探测.具体服务的查点(以自己主机为目标) (4)漏洞扫描:会扫,会看报告, ...
- linux: 用户组, 文件权限详解
一.用户组 linux中每个用户必须属于一个组,不能独立于组外. 每个文件有所有者.所在组.其他组的概念 --所有者 一般为文件的创建者,谁创建了该文件,就天然的成为该文件的所有者 用ls ‐ahl命 ...
- php对函数的引用
function &example($tmp=0){ //定义一个函数,别忘了加“&”符 return $tmp; ...
- C#使用AppDomain时的异常分析:Object ‘XXXX.rem’ has been disconnected or does not exist at the server.
在使用C#的应用程序域的时候,碰到这么一个异常: System.Runtime.Remoting.RemotingException: Object ‘/76e7cd41_2cd2_4e89_9c03 ...
- VMWare给macos虚拟机扩容方法
一开始在VMWareWorkStation上创建macos虚拟机时,我考虑到物理硬盘大小有限,只分配了34G,随着不断的使用,虚拟机消耗的虚拟磁盘逐渐增长,因磁盘空间不足而导致无法在虚拟机中使用xco ...
- Windows 10(UWP)开发技巧 - PageUserControl
[本系列需要具有一定开发基础] 我们在开发中经常遇到这样的场景: 1.呈现详细信息,且包含一些操作.如:查看原图,支持放大,缩小,多图. 2.执行特定的行为,且要有回执结果.如:选择联系人,选中某图, ...
- 转: 解决Setting property 'source' to 'org.eclipse.jst.jee.server的问题
我发现这个问题上网搜索 ,找到的地址为:http://blog.csdn.net/z69183787/article/details/19911935 .但是他的标题上也有一个"转" ...