当前位置:网站首页>Ogre introduction
Ogre introduction
2022-07-07 13:28:00 【MirrorYuChen】
1.Ogre Library compilation
1.1 Download and install DIrectX SDK
Download and install from the link below DirectX SDK:
Download address :DirectX SDK
1.2 from git Pull the latest code
>> git clone --recursive [email protected]:OGRECave/ogre.git
>> git checkout v13.4.1
1.3 Use CMake compile Ogre
It is recommended to use cmake-gui, According to my experience , You can compile it once , Finally, a sdk Folder , It contains all the compiled files .
2.Ogre To configure
2.1 take sdk Under subdirectories bin Directory added to path route
2.2 Create a new one vs engineering , To configure sdk The next path include and lib
include The path is added as follows :
lib The path is added as follows :
Add additional dependencies :
3. Add test code
#include <iostream>
#include "Ogre.h"
#include "OgreApplicationContext.h"
#include "OgreInput.h"
#include "OgreRTShaderSystem.h"
using namespace Ogre;
using namespace OgreBites;
class Basic :
public ApplicationContext,
public InputListener {
public:
Basic();
virtual ~Basic() {}
void setup();
bool keyPressed(const KeyboardEvent& evt);
};
Basic::Basic() : ApplicationContext("Ogre") {}
void Basic::setup() {
// 1. Call the parent class
ApplicationContext::setup();
addInputListener(this);
// 2. Get a pointer to the created root
Root* root = getRoot();
SceneManager* scnMgr = root->createSceneManager();
// 3. Register our scene
RTShader::ShaderGenerator* shadergen = RTShader::ShaderGenerator::getSingletonPtr();
shadergen->addSceneManager(scnMgr);
// 4. Adjust the light
scnMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
// 5. New light
Light* light = scnMgr->createLight("MainLight");
SceneNode* lightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
lightNode->attachObject(light);
// 6. Light location
lightNode->setPosition(20, 80, 50);
// 7. The camera
SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode();
Camera* cam = scnMgr->createCamera("myCam");
cam->setNearClipDistance(5);
cam->setAutoAspectRatio(true);
camNode->attachObject(cam);
camNode->setPosition(0, 0, 140);
// 8. Tell him to render to the main window
getRenderWindow()->addViewport(cam);
// 9.Entity
Entity* ogreEntity = scnMgr->createEntity("ogrehead.mesh");
SceneNode* ogreNode = scnMgr->getRootSceneNode()->createChildSceneNode();
ogreNode->attachObject(ogreEntity);
// 10. Mobile camera
camNode->setPosition(0, 47, 222);
// 11.Entity2
Entity* ogreEntity2 = scnMgr->createEntity("ogrehead.mesh");
SceneNode* ogreNode2 = scnMgr->getRootSceneNode()->createChildSceneNode(Vector3(84, 48, 0));
ogreNode2->attachObject(ogreEntity2);
// 12.Entity3
Entity* ogreEntity3 = scnMgr->createEntity("ogrehead.mesh");
SceneNode* ogreNode3 = scnMgr->getRootSceneNode()->createChildSceneNode();
ogreNode3->setPosition(0, 104, 0);
ogreNode3->setScale(2, 1.2, 1);
ogreNode3->attachObject(ogreEntity3);
// 13.Entity4
Entity* ogreEntity4 = scnMgr->createEntity("ogrehead.mesh");
SceneNode* ogreNode4 = scnMgr->getRootSceneNode()->createChildSceneNode();
ogreNode4->setPosition(-84, 48, 0);
ogreNode4->roll(Degree(-90));
ogreNode4->attachObject(ogreEntity4);
}
bool Basic::keyPressed(const KeyboardEvent& evt) {
if (evt.keysym.sym == SDLK_ESCAPE) {
getRoot()->queueEndRendering();
}
return true;
}
int main(int argc, char** argv) {
try {
Basic app;
app.initApp();
app.getRoot()->startRendering();
app.closeApp();
}
catch (const std::exception& e) {
std::cerr << "Error occurred during execution: " << e.what() << '\n';
return 1;
}
return 0;
}
4. Deal with resource loading
4.1 take sdk Of bin All under the folder .dll Document and .cfg Copy the file to the project generated .exe Under the folder
>> E:\vs_project\OgreTest\x64\Release
4.2 modify resources.cfg file , Set the resource loading path
# Ogre Core Resources
[OgreInternal]
FileSystem=../../Media/Main
FileSystem=../../Media/RTShaderLib/GLSL
FileSystem=../../Media/Terrain/
# Resources required by the sample browser and most samples.
[Essential]
Zip=../../Media/packs/SdkTrays.zip
Zip=../../Media/packs/profiler.zip
FileSystem=../../Media/thumbnails
# Common sample resources needed by many of the samples.
# Rarely used resources should be separately loaded by the
# samples which require them.
[General]
# PBR media must come before the scripts that reference it
FileSystem=../../Media/PBR
FileSystem=../../Media/PBR/filament
FileSystem=../../Media/materials/textures/PBR
FileSystem=../../Media/materials/programs/GLSL
FileSystem=../../Media/materials/programs/GLSL120
FileSystem=../../Media/materials/programs/GLSL150
FileSystem=../../Media/materials/programs/GLSL400
FileSystem=../../Media/materials/programs/GLSLES
FileSystem=../../Media/materials/programs/SPIRV
FileSystem=../../Media/materials/programs/Cg
FileSystem=../../Media/materials/programs/HLSL
FileSystem=../../Media/materials/programs/HLSL_Cg
FileSystem=../../Media/materials/scripts
FileSystem=../../Media/materials/textures
FileSystem=../../Media/materials/textures/terrain
FileSystem=../../Media/models
FileSystem=../../Media/particle
FileSystem=../../Media/DeferredShadingMedia
FileSystem=../../Media/DeferredShadingMedia/DeferredShading/post
FileSystem=../../Media/PCZAppMedia
FileSystem=../../Media/materials/scripts/SSAO
FileSystem=../../Media/materials/textures/SSAO
FileSystem=../../Media/volumeTerrain
FileSystem=../../Media/CSMShadows
Zip=../../Media/packs/cubemap.zip
Zip=../../Media/packs/cubemapsJS.zip
Zip=../../Media/packs/dragon.zip
Zip=../../Media/packs/fresneldemo.zip
Zip=../../Media/packs/ogredance.zip
Zip=../../Media/packs/Sinbad.zip
Zip=../../Media/packs/skybox.zip
Zip=../../Media/volumeTerrain/volumeTerrainBig.zip
Zip=../../Media/packs/DamagedHelmet.zip
Zip=../../Media/packs/filament_shaders.zip
[BSPWorld]
Zip=../../Media/packs/oa_rpg3dm2.pk3
Zip=../../Media/packs/ogretestmap.zip
# Materials for visual tests
[Tests]
FileSystem=../Tests/Media
4.3 take sdk Next resource file Media Folder copy to the set path
4.4 Run the test example again
Reference material
- [1] Ogre course
边栏推荐
猜你喜欢
Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
Isprs2021/ remote sensing image cloud detection: a geographic information driven method and a new large-scale remote sensing cloud / snow detection data set
【学习笔记】AGC010
Vscade editor esp32 header file wavy line does not jump completely solved
1. Deep copy 2. Call apply bind 3. For of in differences
How to make join run faster?
centso7 openssl 报错Verify return code: 20 (unable to get local issuer certificate)
LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
ESP32 ① 编译环境
About the problem of APP flash back after appium starts the app - (solved)
随机推荐
1、深拷贝 2、call apply bind 3、for of for in 区别
国泰君安证券开户怎么开的?开户安全吗?
【学习笔记】AGC010
Practical case: using MYCAT to realize read-write separation of MySQL
Initialization script
Japanese government and enterprise employees got drunk and lost 460000 information USB flash drives. They publicly apologized and disclosed password rules
PACP学习笔记三:PCAP方法说明
存储过程的介绍与基本使用
Flink | 多流转换
MySQL master-slave replication
Pay close attention to the work of safety production and make every effort to ensure the safety of people's lives and property
[learning notes] agc010
OSI seven layer model
PACP学习笔记一:使用 PCAP 编程
Distributed transaction solution
The difference between cache and buffer
About how appium closes apps (resolved)
LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
【学习笔记】线段树选做
Write it down once Net a new energy system thread surge analysis