`
java-mans
  • 浏览: 11342446 次
文章分类
社区版块
存档分类
最新评论

OGER SDK研究之四 Demo_SkyBox 天空盒

 
阅读更多

SkyBox.h

/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2006 Torus Knot Software Ltd
Also see acknowledgements in Readme.html

You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the engine.

-----------------------------------------------------------------------------
*/

/**
/file
SkyBox.h 天空盒
/brief
Specialisation of OGRE's framework application to show the
skybox feature where a wrap-around environment is projected
onto a cube around the camera.
//加入一个天空盒
*/

#include "ExampleApplication.h"

ParticleSystem *pThrusters;//粒子系统

class SkyBoxFrameListener : public ExampleFrameListener
{
private:
static float fDefDim;
static float fDefVel;

public:
SkyBoxFrameListener(RenderWindow* win, Camera* cam) : ExampleFrameListener( win, cam )
{
}
//每一帧开始前的处理
bool frameStarted( const FrameEvent& evt )
{
if( ExampleFrameListener::frameStarted( evt ) == false )
return false;

if( mKeyboard->isKeyDown( OIS::KC_N ) )
{
//如果按键N 设置粒子系统的尺寸增大
pThrusters->setDefaultDimensions( fDefDim + 0.25, fDefDim + 0.25 );
fDefDim += 0.25;
}

if( mKeyboard->isKeyDown( OIS::KC_M ) )
{
//如果按键M 设置粒子系统的尺寸减小
pThrusters->setDefaultDimensions( fDefDim - 0.25, fDefDim - 0.25 );
fDefDim -= 0.25;
}

if( mKeyboard->isKeyDown( OIS::KC_H ) )
{
//如果按键H 设置粒子系统的速度增加
pThrusters->getEmitter( 0 )->setParticleVelocity( fDefVel + 1 );
pThrusters->getEmitter( 1 )->setParticleVelocity( fDefVel + 1 );
fDefVel += 1;
}

if( mKeyboard->isKeyDown( OIS::KC_J ) && !( fDefVel < 0.0f ) )
{
//如果按键J 设置粒子系统的速度减缓
pThrusters->getEmitter( 0 )->setParticleVelocity( fDefVel - 1 );
pThrusters->getEmitter( 1 )->setParticleVelocity( fDefVel - 1 );
fDefVel -= 1;
}

return true;
}
};

float SkyBoxFrameListener::fDefDim = 25.0f;
float SkyBoxFrameListener::fDefVel = 50.0f;

class SkyBoxApplication : public ExampleApplication
{
public:
SkyBoxApplication() {}

protected:
virtual void createFrameListener(void)
{
//创建自定义帧监听器并连接
mFrameListener= new SkyBoxFrameListener(mWindow, mCamera);
mRoot->addFrameListener(mFrameListener);
}

// Just override the mandatory create scene method
// 创建场景
void createScene(void)
{
// Set ambient light
// 设置环境光
mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

// Create a skybox
// 设置天空盒
mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 50 );

// Create a light
// 创建一个灯光
Light* l = mSceneMgr->createLight("MainLight");
// Accept default settings: point light, white diffuse, just set position
// NB I could attach the light to a SceneNode if I wanted it to move automatically with
// other objects, but I don't
//设置自创建灯光的位置
l->setPosition(20,80,50);

// Also add a nice starship in
// 由模型文件创建一个实体
Entity *ent = mSceneMgr->createEntity( "razor", "razor.mesh" );

//将实体加入到主场景中
mSceneMgr->getRootSceneNode()->attachObject( ent );

//创建一个粒子系统
pThrusters = mSceneMgr->createParticleSystem( "ParticleSys1", 200 );

//设置粒子系统的材质
pThrusters ->setMaterialName( "Examples/Flare" );
//设置粒子的大小
pThrusters ->setDefaultDimensions( 25, 25 );

//创建两个点粒子发射器
ParticleEmitter *pEmit1 = pThrusters ->addEmitter( "Point" );
ParticleEmitter *pEmit2 = pThrusters ->addEmitter( "Point" );

// Thruster 1
//第一发射器参数设置(角度,生命时长,衰减速率,运动速度,方向,色彩)
pEmit1->setAngle( Degree(3) );
pEmit1->setTimeToLive( 0.2 );
pEmit1->setEmissionRate( 70 );

pEmit1->setParticleVelocity( 50 );

pEmit1->setDirection(- Vector3::UNIT_Z);
pEmit1->setColour( ColourValue::White, ColourValue::Red);

// Thruster 2
//第二发射器参数设置(角度,生命时长,衰减速率,运动速度,方向,色彩)
pEmit2->setAngle( Degree(3) );
pEmit2->setTimeToLive( 0.2 );
pEmit2->setEmissionRate( 70 );

pEmit2->setParticleVelocity( 50 );

pEmit2->setDirection( -Vector3::UNIT_Z );
pEmit2->setColour( ColourValue::White, ColourValue::Red );

// Set the position of the thrusters
//设置发射器的位置
pEmit1->setPosition( Vector3( 5.7f, 0.0f, 0.0f ) );
pEmit2->setPosition( Vector3( -18.0f, 0.0f, 0.0f ) );

//将粒子系统加入到场景中
mSceneMgr->getRootSceneNode()->createChildSceneNode( Vector3( 0.0f, 6.5f, -67.0f ) )
->attachObject(pThrusters);
}

};

SkyBox.cpp:

/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2006 Torus Knot Software Ltd
Also see acknowledgements in Readme.html

You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the engine.
-----------------------------------------------------------------------------
*/

/**
/file
SkyBox.cpp
/brief
Shows OGRE's skybox feature where a wrap-around environment is projected
onto a cube around the camera.
*/

#include "SkyBox.h"

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
// Create application object
SkyBoxApplication app;

try {
app.go();
} catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "An exception has occured: " <<
e.getFullDescription().c_str() << std::endl;
#endif
}

return 0;
}

#ifdef __cplusplus
}
#endif

分享到:
评论

相关推荐

    Oger_3d_1.7_beginner's_guide中文第一章

    Oger3d1.7版本的初学者指南, 基本上就是step by step 模式,非常适合刚接触oger的童鞋

    超强OGRE中文教程bychenhong

    这是目前我能找到的最有实际意义的ogre教程,不泛泛而谈,而是面向实用,在这里向原书作者表示深深的感谢。

    易语言模块易语言OGRE类库1.1.rar

    易语言模块易语言OGRE类库1.1.rar 易语言模块易语言OGRE类库1.1.rar 易语言模块易语言OGRE类库1.1.rar 易语言模块易语言OGRE类库1.1.rar 易语言模块易语言OGRE类库1.1.rar 易语言模块易语言OGRE类库1.1.rar

    ogre最新技术

    ogre最新技术,最新开发文档资料,供初学者学习

    ogre 易语言指南

    ogre 指南编写改造的易语言指南,适合初学者使用。请阅读 有很多很有价值的内容 。讲得也很清楚。

    OGRE-草地的制作

    OGRE-草地的制作 OGRE-草地的制作 OGRE-草地的制作 OGRE-草地的制作

    OGRE使用指南v0[1].01a.pdf

    本教程的目的是从使用者的角度将 OGRE 引擎最基本的概念和使用方法做一个较全面 的介绍。本教程隐藏了 OGRE 引擎内部的底层内容,力求做到简单、易懂,是 OGRE 引擎 的入门教程。

    ORGE简体中文基础教程

    ORGE的基础教程,简体中文 非常适合入门的资料

    Ogre_3D_1.7_beginner_Guide中文版

    翻译的还是不错的,中英文对照,初学者可以借着了解下OGER编程

    Ogre_VC9_AppWizard_1.7.1_2

    OGER库自己下载,必须是1.7.1版本 VS为VS2008版本 以上装好之后,然后运行此程序,然后会弹出一个说明文本,如果出现问题就仔细看一下。如果没有问题的话,就打开VS2008,新建工程,在向导中的工程类型选择Visual ...

    toOgerBot:Telegram机器人,用于向Oger进行内联翻译

    安装此程序: :

    跑步者

    跑步者该存储库包含一些附件脚本...nodes.tsv -o termlist.tsv在文档上运行OGER 您可以按以下步骤对文本文档运行OGER, python runner.py run-oger abstract.txt -t termlist.tsv -o out.json -f bioc_json注意:此命令

    HinautDominey2013_PLoS_ONE:有关论文《 Hinaut&Dominey》的源代码,《公共科学杂志》 2013年第1期-one source code

    Hinaut X,Dominey PF(2013)正面-纹波系统中语法结构的实时并行处理:使用储层计算的递归网络模拟研究。 公共科学学报8(2):e52946。 原代码仍然的的。 带有说明的自述文件是。 Python版本和依赖项 此代码...

    OGRE使用指南(入门教程)

    非常全面的OGER使用指南,如果你是新手,这是最好的一本入门教程!99%属于原创!

    CEImagesetEditor-v0.6.2

    非常好用的一个截图编辑器,对于使用OGER开发的人或使用CEGUI的人来说很好用

    Ogre引擎-教程

    本教程由本人自己整理,内容来自网络各个角落。 内部包含7个文档和一个问题 里面有描述游戏大概架构的文档以及OGER引擎的文档

    使用ogre做的练练看游戏

    使用oger做的练练看游戏,里面用到了CEGUI做界面,FMOD播放声音,OIS控制输入,免费给大家分享,有任何问题请邮件: xieaiwanli@hotmail.com

    DevOO-Optimod

    DevOO-Optimod用法从命令行操作系统/Linux # start the app./gradlew run# run the tests./... 然后:文件 &gt; 导入 =&gt; Gradle 项目 执照麻省理工学院许可证 (MIT) 版权所有 (c) 2014 Robin Ricard、Edouard Oger、M

    eoger.me:个人网站

    这是目前托管在上的 Edouard Oger 个人网站的源代码存储库。 主要依赖 Node.js (0.10.x) 快递 (4.9.x) socket.io (1.2.x) React (0.12.x) Browserify (6.3.x) 吞咽(3.8.x) 安装 $ git clone ...

Global site tag (gtag.js) - Google Analytics