OGRE 开源项目使用教程

OGRE 开源项目使用教程

ogrescene-oriented, flexible 3D engine (C++, Python, C#, Java)项目地址:https://gitcode.com/gh_mirrors/og/ogre

1. 项目的目录结构及介绍

OGRE(Open Graphics Engine)是一个开源的3D图形渲染引擎。以下是OGRE项目的主要目录结构及其介绍:

ogre/
├── CMake/
│   ├── Toolchains/
│   └── Utils/
├── Components/
│   ├── Bites/
│   ├── Hlms/
│   ├── Overlay/
│   ├── Paging/
│   ├── Property/
│   ├── RTShaderSystem/
│   ├── Terrain/
│   └── Volume/
├── Docs/
│   ├── Manual/
│   └── API/
├── PlugIns/
│   ├── CgProgramManager/
│   ├── OctreeSceneManager/
│   ├── ParticleFX/
│   └── STBICodec/
├── Samples/
│   ├── 2.0/
│   └── 1.12/
├── Tools/
│   ├── OgreXMLConverter/
│   └── ParticleEditor/
├── CMakeLists.txt
├── LICENSE
├── README.md
└── ogre.sln

目录介绍

  • CMake/: 包含CMake构建系统的工具链和实用程序。
  • Components/: 包含OGRE的各种组件,如Bites(输入处理)、Hlms(高级材质系统)等。
  • Docs/: 包含OGRE的手册和API文档。
  • PlugIns/: 包含OGRE的插件,如Cg程序管理器、Octree场景管理器等。
  • Samples/: 包含OGRE的示例项目。
  • Tools/: 包含OGRE的工具,如OgreXMLConverter和ParticleEditor。
  • CMakeLists.txt: CMake构建文件。
  • LICENSE: 项目许可证。
  • README.md: 项目自述文件。
  • ogre.sln: Visual Studio解决方案文件。

2. 项目的启动文件介绍

OGRE项目的启动文件通常是示例项目中的一个可执行文件。以Samples/2.0/ExampleApplication为例,启动文件为ExampleApplication.cpp

ExampleApplication.cpp

#include "Ogre.h"
#include "OgreApplicationContext.h"
#include "OgreInput.h"
#include "OgreRTShaderSystem.h"
#include <iostream>

class ExampleApplication : public OgreBites::ApplicationContext, public OgreBites::InputListener
{
public:
    ExampleApplication();
    void setup();
    bool keyPressed(const OgreBites::KeyboardEvent& evt);
};

ExampleApplication::ExampleApplication() : OgreBites::ApplicationContext("OgreExample")
{
}

void ExampleApplication::setup()
{
    OgreBites::ApplicationContext::setup();
    addInputListener(this);

    Ogre::Root* root = getRoot();
    Ogre::SceneManager* scnMgr = root->createSceneManager();

    Ogre::RTShader::ShaderGenerator* shadergen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
    shadergen->addSceneManager(scnMgr);

    Ogre::SceneNode* node = scnMgr->createSceneNode("Node1");
    scnMgr->getRootSceneNode()->addChild(node);

    Ogre::Entity* ent = scnMgr->createEntity("Sinbad.mesh");
    node->attachObject(ent);

    Ogre::Light* light = scnMgr->createLight("MainLight");
    Ogre::SceneNode* lightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
    lightNode->setPosition(0, 10, 15);
    lightNode->attachObject(light);

    Ogre::Camera* cam = scnMgr->createCamera("myCam");
    cam->setNearClipDistance(5);
    cam->setAutoAspectRatio(true);
    Ogre::SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode();
    camNode->setPosition(0, 0, 15);
    camNode->lookAt(Ogre::Vector3(0, 0, -1), Ogre::Node::TS_PARENT);
    camNode->attachObject(cam);

    OgreBites::InputContext inputContext = getInputContext();
    OgreBites::NativeWindowPair window = createWindow("

ogrescene-oriented, flexible 3D engine (C++, Python, C#, Java)项目地址:https://gitcode.com/gh_mirrors/og/ogre

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

姬虹俪Humble

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值