Вы находитесь на странице: 1из 113

Ogre 3D 1.

7

3D-
Ogre 3D

: Felix Kerger
: Striver


1 Ogre3D.......................................................................................................................5
Ogre 3D..................................................................................................5
Ogre 3D SDK..................................................................................................5
SDK................................................................................................................................6
Ogre 3D...........................................................................................................................7
Ogre 3D.....................................................................................................7
ExampleApplication........................................................................................................................9
...............................................................................................................10
...............................................................................................................................................11
: Ogre SDK Linux.......................................................11
2 Ogre 3D......................................................................................................................13
....................................................................................................................13
...................................................................................................17
..................................................................................................................18
....................................................................................................20
.............................................................................22
..............................................................................................24
..................................................................................27
......................................................................................29
........................................................................30
...............................................................................................................................................31
3 , ........................................................................................................................32
.....................................................................................................................32
.....................................................................................35
..............................................................................................................36
............................................................................................................39
...................................................................................................................40
.........................................................................................................................41
..........................................................................................................................42
..........................................................................................................44
...............................................................................................................................................45
4 Frame Listener..............................................46
........................................................................................................................46
..................................................................................................47
, , .............................50
.....................................................................................................51
....................................................................................................53
......................................................................................................................54
............................................................56
....................................................................................................................57
...............................................................................................................................................58
5 Ogre 3D...............................................................................................59
.................................................................................................................59
................................................................61
......................................................................................................63
.......................................................................................................................65
, ...........................................................................67
...............................................................................................................................................68
6 .........................................................................................................................69
7 ......................................................................................................................................69

8 -......................................................................................................69
9 Ogre3D..........................................................................................70
Ogre 3D.............................................................................................................................70
...................................................................................................................72
resources.cfg.......................................................................................................72
.....................................................................................................74
FrameListener...........................................................................................................76
FrameListener .....................................................................77
.........................................................................................................................81
................................................................................................82
()........................................................................................................84
...........................................................................................................85
.................................................................................................................87
.....................................................................................88
.................................................................................................................90
...............................................................................................................................................92
10 Ogre3D.....................................................................................93
.......................................................................................................93
.............................................................................................94
......................................................................................................96
........................................................................................................................97
........................................................................................98
affector'.................................................................................................................99
......................................................................................................................100
....................................................................................................................102
............................................................................103
...........................................................................................................105
Deflector ().............................................................................................................106
.............................................................................................................107
................................................................................................................108
, ..........................................................................109
Ogre 3D..................................................................................................................111
.............................................................................................................................................113
...........................................................................................................................................113

1 Ogre3D

.
, :

Ogre 3D

Ogre 3D

, Ogre 3D
.

Ogre 3D
Ogre 3D.

Ogre 3D
Ogre 3D SDK ,
.
1. http://www.ogre3d.org/download/sdk
2. .
, .
3. ,
OgreSDK.
4. , .
5. ,
OgreSDK_vc9_v1-7-1
6. . :
?

Ogre 3D SDK . Ogre 3D


,
. , Ogre 3D SDK.

Ogre 3D SDK
Ogre , ,
, . Ogre 3D
Windows, MacOSX, Ubuntu. MinGW iPhone.
, Ogre 3D .
SDK Windows, ,
.
, Ogre 3D Wiki,
http://www.ogre3d.org/wiki. Wiki ,
.

-,
, , . ,
.

SDK
, , SDK,
SDK. SDK, Windows.
Linux MacOS, -. , bin.
, : debug () release ().
lib. , Ogre 3D SDK
-/ .
,
. , ,
Ogre 3D.
debug release, dll-,
cfg-, (exe).
, Ogre 3D, , ,
.
OgreMain.dll DLL. Ogre
3D, . DLL , Plugin_
Ogre 3D, Ogre 3D. Ogre 3D
, Ogre 3D,
Ogre 3D . , ,
, ,
. , . Ogre 3D
, wiki. SDK
. ,
. DLL, RenderSystem_,
, (),
Ogre 3D. , Direct3D9 OpenGL.
, Ogre 3D Direct3D10, Direct3D11, OpenGL ES (OpenGL
) .
DLL-, cfg .
, Ogre 3D . Plugins.cfg
Ogre 3D, .
Direct3D OpenGL .
quakemap.cfg ,
Quake3. , .
resources.cfg , , ,
Ogre 3D . Ogre 3D
ZIP-. resources.cfg,
:
Zip=../../media/packs/SdkTrays.zip
FileSystem=../../media/thumbnails

Zip= , ZIP-, FileSystem= ,


. resources.cfg ,
, ,
Ogre 3D. , cfg- samples.cfg.
cfg-. ,

Ogre 3D SampleBrowser ( ).
SampleBrowser, .

Ogre 3D
Ogre 3D ,
, Ogre 3D .
, , ,
Ogre 3D.

Ogre 3D
, Ogre 3D ,
.
1. Ogre3D.
2. solution- Ogre3d.sln.
3. solution Build Solution.
4. Visual Studio .
, , .
5. , Ogre3D/bin.
6. SampleBrowser.exe.
7. :
8. , ,
Ogre 3D.
?

Ogre 3D, Ogre 3D SDK.


, , Ogre 3D.

-
-, .
a) Bloom, Glass, Old TV, Black and White, and Invert
b) Bloom, Glass, Old Monitor, Black and White, and Invert
c) Boom, Glass, Old TV, Color, and Invert

Ogre 3D.
Ogre 3D - ,
3D-.

IDE
, IDE ,
Ogre 3D.
1. .
2. main.cpp.
3. main:
int main (void)
{

return 0;
}

4. ExampleApplication.h :
#include "Ogre\ExampleApplication.h":

5. PathToYourOgreSDK\include\ include ( )
.
6. PathToYourOgreSDK\boost_1_42 include .
7. PathToYourOgreSDK\boost_1_42\lib library ().
8. main.cpp.
class Example1 : public ExampleApplication
{
public:
void createScene()
{
}
};

9. main:
Example1 app;
app.go();

10. PathToYourOgreSDK\lib\debug library.


11. OgreMain_d.lib .
12. OIS_d.lib .
13. .
14. PathToYourOgreSDK\bin\debug.
15. . Ogre 3D.
16. OK . . Escape,
.
?

Ogre 3D - . ,
include- library-, Ogre 3D.
5 6, include .
include Ogre 3D SDK, Ogre 3D OIS. OIS
- (Object Oriented Input
System), , ExampleApplication
. OIS Ogre 3D; ,
. Ogre 3D,
ExampleApplication , , ,
. ExampleApplication.h
include. Ogre 3D (threading),
boost . ,
, Ogre 3D. , Ogre 3D
, , ,
boost. , boost,
boost. boost

library (. 7).
10 PathToYourOgreSDK\lib\debug .
, Ogre 3D .
,
, - .
, lib\debug
\lib\release. 11 12. OgreMain_d.lib
OIS_d.lib .
, OgreMain.lib OIS.lib. , OgreMain.lib
OgreMain_d.lib, Ogre 3D,
, : OgreMain.dll OgreMain_d.dll. ,
OIS.lib OIS_d.lib, OIS_d.dll OIS.dll. ,
() Ogre 3D OIS , DLL
, ,
, DLL
. ,
DLL-, , .
, 14.
.

ExampleApplication
, Example1, ExampleApplication.
ExampleApplication , Ogre 3D SDK,
Ogre 3D , Ogre 3D.
ExampleApplication Ogre 3D , ,
, ,
. ExampleApplication,
createScene(). ExampleApplication
, , ,
Ogre 3D. , ExamplesApplication
.
main
go(), Ogre 3D. , Ogre 3D
Ogre.cfg, plugins.cfg, resources.cfg.
(debug) , "_d".
, ,
. Ogre.cfg ,
, ,
, . plugins.cfg
Ogre 3D, .
RenderSystem. Ogre 3D OpenGL
DirectX, . resources.cfg ,
Ogre 3D . Ogre 3D SDK
, , resources.cfg
. resources.cfg, ,
. ,
.


1. Ogre 3D
?
1. OgreD3DRenderSystem.lib
2. OgreMain.lib
3. OIS.lib
2. ,
Ogre 3D?
1. _debug
2. _d
3. _d


, .
, .


. .
createScene():
1. .
Ogre::Entity* ent =
mSceneMgr->createEntity("MyEntity","Sinbad.mesh");
mSceneMgr->getRootSceneNode()->attachObject(ent);

2. .
.
3. WASD,
.
4. .

mSceneMgr->createEntity("MyEntity","Sinbad.mesh");, Ogre
3D, Sinbad.mesh. mSceneMgr
SceneManager ( ) Ogre 3D, ExampleApplication.
, (entity), Ogre ,
, . , ;
. , Ogre 3D .
, Ogre 3D .
.
, , ,
.
: mSceneMgr->getRootSceneNode()->attachObject(ent);
, .
? , - Ogre 3D.
.

ExampleApplication

, , .

Ogre 3D SDK , ,
(include). ,
ExampleApplication, , .
.
, :
Ogre 3D,
,
ExampleApplication ,
, Ogre 3D
:
createEntity,
Ogre 3D, , Ogre 3D
, , , .

: Ogre SDK Linux


Windows MS VisualC++, ,
, ( ,
Ogre, Python). ,
- - . Ogre SDK
, Meego Linux 1.0. ,
Ogre SDK Windows, MacOSX Ubuntu.
SDK .
, , ,
- . Ogre 3D
BuildingOgre.txt, CMake ,
, , . -
, .
Meego: , , (
1 Nokia N9) . ,
, . 12- 13-
Meego 1.0. , Ogre 3D
, .
,
, sudo () .
CMake. BuildingOgre.txt ,
: sudo apt-get install cmake-gui. Meego, ,
, cmake:
yum install cmake
cmake-2.8.0-2.26.i586.rpm. RPMfind

RPM- cmake-gui, cmake-gui-2.8.1-1.i686.rpm, :


rpm -ihv --nodeps cmake-gui-2.8.1-1.i686.rpm
. ,
BuildingOgre.txt ( ),
( , -dev, -devel,
). ,
, , :
yum install freetype-devel zlib-devel cppunit-devel libXt-devel libXaw-devel libXxf86vm-devel
libXrandr-devel mesa-libGLU-devel
3 ( 6) Meego ,
, RPMfind rpm:
rpm -ihv freeimage-3.10.0-3.fc12.i686.rpm freeimage-devel-3.10.0-3.fc12.i686.rpm ois-1.2.02.fc13.i686.rpm ois-devel-1.2.0-2.fc13.i686.rpm zziplib-0.13.49-8.fc12.i686.rpm zziplibdevel-0.13.49-8.fc12.i686.rpm
boost-thread-devel boost-date-time-devel ,
boost-thread boost-date-time . boost
, .
- .
, Cg NVIDIA.
. ogre_src_v1-7-4,
, ogre-build.
CMake. cmake-gui, Where is source code
ogre_src_v1-7-4 , Where to build the
binaries ogre-build, .
Configure. - Unix Makefiles
Use default native compilers, Finish.
, Ogre 3D ,
, - /usr/local.
, , , . ,
, Configure , (. .
), .
Generate.
.
Linux. ogre-build make.
, , .
. make install.
, su sudo.
Ogre 3D. Ogre 3D ,
(
, Ogre 3D). ,
OGRE OIS.
complie.sh :
g++ -B /---Ogre3D/ MyPrg.cpp 'pkg-config --cflags --libs OGRE OIS' -o
MyPrg
MyPrg.cpp,
MyPrg. - (. .
/usr/local), , , -B /---Ogre3D/ .

2 Ogre 3D
, ,
.
, :

3D-

3D-,
.


, 1, Ogre 3D, 3D-
. , 3D .

Ogre 3D
1, Ogre 3D,
, .
:
1. ,
createScene():
Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","Sinbad.mesh");
mSceneMgr->getRootSceneNode()->attachObject(ent);

2. :
Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");

3. ;
:
mSceneMgr->getRootSceneNode()->addChild(node);
node->attachObject(ent);

4. .
5. , ,
1.
?

Node1.
. , 3D-
, .
RootSceneNode ( )

mSceneMgr->getRootSceneNode(), .
- .

, ,
. , -
; .
, RootSceneNode ( ) .
, , . Ogre 3D
, .
, , , .
mSceneMgr->getRootSceneNode()>addChild(node);. .
, node>attachObject(ent);. (entity) .
, . -,
, ,
. -, , .
. ,
, , . ,
, , , .
, , . ,
. :

, , .
, ,
3D-.
3D-

Ogre 3D 3D ,
3D. 3D ,
(x,y,z).

3D- ,
. ,
3D-.
. ,
, : . ,
;
.

: http://en.wikipedia.org/wiki/File:Cartesian_coordinate_system_handedness.svg
,
, . x,
y, z.
, 90 ,
. ,
. ,
.
Ogre 3D , ,
x , . y ,
z , y- (y-up
convention). ,
.
http://viz.aset.psu.edu/gho/sem_notes/3d_fundamentals/html/3d_coordinates.html
, ,
, , .


. -, .
, .
. ,
(transformation) 3D.
, : , , . (x,y,z),
, , .
(quaternion),

3D-, ,
, , ,
. ; ,
(x,y,z), ,
.
,
. ,
. 10
x, 10 x.
.
.

MyEntity (10,0,0), MyEntity2


(10,10,20). Ogre 3D.


1. MyEntity
MyEntity2:
a. MyEntity(60,60,60) MyEntity2(0,0,0)
b. MyEntity(70,50,60) MyEntity2(10,-10,0)
c. MyEntity(60,60,60) MyEntity2(10,10,10)


1. :
node->setPosition(10,0,0);

2. , ,
createScene():
Ogre::Entity* ent2 = mSceneMgr->createEntity( "MyEntity2", "Sinbad.mesh");

3. :
Ogre::SceneNode* node2 = mSceneMgr->createSceneNode("Node2");

4. :
node->addChild(node2);

5. :
node2->setPosition(0,10,20);

6. :
node2->attachObject(ent2);

7. , :

, .
, , 1 . ,
setPosition(x,y,z) . ,
. , MyEntity2 (10,10,20),
node2, MyEntity2, ,
(10,0,0). node2 (0,10,20).
, MyEntity2 (10,10,20).


1. node1, (0,20,0), -
node2, . ,
(10,10,10), node2?
a. (10,10,10)
b. (10,-10,10)
c. (-10,10,-10)

Have a go hero
, (10,10,30).


, . , ,
, .


,
createScene().
1. createScene().
2. Sinbad.mesh, .
(10,10,0), ,
:
Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity", "Sinbad.mesh");
Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
node->setPosition(10,10,0);
mSceneMgr->getRootSceneNode()->addChild(node);
node->attachObject(ent);

3. , ,
(10,0,0):
Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","Sinbad.mesh");
Ogre::SceneNode* node2 = mSceneMgr->createSceneNode("Node2");
node->addChild(node2);
node2->setPosition(10,0,0);

4. ,
:
node2->pitch(Ogre::Radian(Ogre::Math::HALF_PI));
node2->attachObject(ent2);

5. , yaw ()
pitch () translate setPosition:

Ogre::Entity* ent3 = mSceneMgr->createEntity("MyEntity3","Sinbad.mesh");


Ogre::SceneNode* node3 = mSceneMgr->createSceneNode("Node3",);
node->addChild(node3);
node3->translate(20,0,0);
node3->yaw(Ogre::Degree(90.0f));
node3->attachObject(ent3);

6. roll () yaw pitch:


Ogre::Entity* ent4 = mSceneMgr->createEntity("MyEntity4","Sinbad.mesh");
Ogre::SceneNode* node4 = mSceneMgr->createSceneNode("Node4");
node->addChild(node4);
node4->setPosition(30,0,0);
node4->roll(Ogre::Radian(Ogre::Math::HALF_PI));
node4->attachObject(ent4);

7. , :

, ,
. .
, , ,
, , .
4 :
node2->pitch(Ogre::Radian(Ogre::Math::HALF_PI));

pitch(Ogre::Radian(Ogre::Math::HALF_PI)) x.
, ,
pi, .
5 , setPosition(x,y,z) translate(x,y,z).
setPosition(x,y,z) translate(x,y,z), , setPosition
. translate ,
.
(10,20,30) , setPosition(30,20,10), (30,20,10).
, translate(30,20,10), (40,40,40).
, , . ,
, ,
, setPosition(x,y,z). ,
,
translate(x,y,z).
, pitch(Ogre::Radian(Ogre::Math::HALF_PI))
yaw(Ogre::Degree(90.0f)). yaw() y.
Ogre::Radian() Ogre::Degree(). , pitch yaw
. , Ogre 3D Degree(),
,

. ,
. ,
, ,
.
6 ,
roll(). z. ,
roll(Ogre::Degree(90.0f)) roll(Ogre::Radian(Ogre::Math::HALF_PI)).

. ,
x, 3- y, z.
. , pitch()
x, yaw() y, roll() z.
Ogre::Degree(degree) Ogre::Radian(radian), ,
.


?
a. pitch, yawn, roll
b. pitch, yaw, roll
c. pitching, yaw, roll

Have a go hero Ogre::Degree


, ,
Ogre::Radian Ogre::Degree ,
.


,
, . ,
, .


, , .
1. createScene() :

Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","Sinbad.mesh");


Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
node->setPosition(10,10,0);
mSceneMgr->getRootSceneNode()->addChild(node);
node->attachObject(ent);

2. , :

Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","Sinbad.mesh");

3. ,
. , :
Ogre::SceneNode* node2 = node->createChildSceneNode("node2");
node2->setPosition(10,0,0);
node2->attachObject(ent2);

4. , setPosition(),

:
node2->scale(2.0f,2.0f,2.0f);

5. :
O g r e:: E n t i t y* ent3 = m S c e ne M g r->c reate E n t i t y(" M y E n t i t y 3","S i n ba d. m es h");

6. , 3,
:
Ogre::SceneNode* node3 = node->createChildSceneNode("node3",
Ogre::Vector3(20,0,0));

7. , , :
node3->scale(0.2f,0.2f,0.2f);

8. ,
:

. 3 .
, : node->createChildSceneNode("node2").
-
,
. , node2 , node.
4, scale().
(x,y,z), , . x, y, z
. (0.5,1.0,2.0) , x,
y, z. , ,
; ,
. , ,
, .
,
.
6 createChildSceneNode(),
. , ,
(x,y,z), . Ogre 3D
, Ogre::Vector3. , ,
.
, .
createChildSceneNode() , :
Ogre::SceneNode* node2 = mSceneMgr->createSceneNode("Node2");
node->addChild(node2);

Ogre::SceneNode* node2 = mSceneMgr->createSceneNode("Node2");


node->addChild(node2);
node2->setPosition(20,0,0);


Ogre::SceneNode* node2 = node->createChildSceneNode("Node2",
Ogre::Vector3(20,0,0));

Vector3, .
, .
, Ogre 3D
http://www.ogre3d.org/docs/api/html/index.html.
scale(), setScale().
, setPosition() translate().

-
1. createChildSceneNode().
2.
createChildSceneNode()?
Ogre::SceneNode* node2 = node->createChildSceneNode("node1",
Ogre::Vector3(10,20,30));

.
, , .
Ogre::SceneNode* node2 = mSceneMgr->createSceneNode("Node2");
node2->translate(Ogre::Vector3(10,20,30));
node->addChild(node2);

Have a go hero createChildSceneNode()


(refactor) , ,
createChildSceneNode().


, ,
. .

.
1. createScene().
2. , :
Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","Sinbad.mesh");
Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
node->setPosition(10,10,0);
mSceneMgr->getRootSceneNode()->addChild(node);
node->attachObject(ent);

3. , :
Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntitysNinja",
"ninja.mesh");

Ogre::SceneNode* node2 = node->createChildSceneNode("node2");


node2->setPosition(10,0,0);
node2->setScale(0.02f,0.02f,0.02f);
n o d e2->attac h O b j e c t(ent2);

4. . ,
.

5. (40,10,0):
n o d e->setP os i t i o n(40, 10,0);

6. 180 x:
n o d e-> ya w( O g r e:: D e g r ee(180.0f));

7. .
8. , ,
.

, .
, , ,
, .
, , ,
, ,
, , .
,
. , ,
, ,

. , ,
. , ,
,
.

,
.


?
a.
b.

Have a go hero
, .


, ,
.


, ,
.
1. , createScene(); ,
.
2. :

Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","Sinbad.mesh");


Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
node->setPosition(0,0,400);
node->yaw(Ogre::Degree(180.0f));
mSceneMgr->getRootSceneNode()->addChild(node);
n o de->attac h O b j e c t(ent);

3. (0,0,10):
Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","Sinbad.mesh");
Ogre::SceneNode* node2 = node->createChildSceneNode("node2");
node2->setPosition(10,0,0);
node2->translate(0,0,10);
node2->attachObject(ent2);
Ogre::Entity* ent3 = mSceneMgr->createEntity("MyEntity3","Sinbad.mesh");
Ogre::SceneNode* node3 = node->createChildSceneNode("node3");
node3->setPosition(20,0,0);
node3->translate(0,0,10);
node3->attachObject(ent3);

4. . ,
:

5. :
node3->translate(0,0,10);

node3->translate(0,0,10,Ogre::Node::TS_WORLD);

6. ,
.

translate(). ,

.
3D-

, ,
Ogre::Node::TS_WORLD translate(),
, , . 3D-: (world) ,
(parent), (local) .
.
:

.
. ,
. ,
. ,
, translate(10,0,0).
:

, , ,
, .
translate(),
, , ,
5. , translate(),
,
. , ,
. , , (0,0,10) ,

,
, . ,
, .
, translate(0,0,10).

, (0,0,10) 10
. , z .
180 , (0,0,10) 10 ,
z .
, translate(),
.
. ,
. ,
. ,
. - translate()
. ,
, translate(). ,
, . ,
translate().
, . ,
Ogre::Node::TS_WORLD, ,
, 180
, , x z. ,
, .


.
,
.

1 . createScene().
2. ; ,
:
Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","Sinbad.mesh");
Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
node->setPosition(0,0,400);
node->yaw(Ogre::Degree(180.0f));
mSceneMgr->getRootSceneNode()->addChild(node);
node->attachObject(ent);

3. , 45 y
(0,0,20) :
Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","Sinbad.mesh");

Ogre::SceneNode* node2 = node->createChildSceneNode("node2");


node2->yaw(Ogre::Degree(45));
node2->translate(0,0,20);
node2->attachObject(ent2);

4. , 45 y
(0,0,20) :

Ogre::Entity* ent3 = mSceneMgr->createEntity("MyEntity3","Sinbad.mesh");


Ogre::SceneNode* node3 = node->createChildSceneNode("node3");
node3->yaw(Ogre::Degree(45));
node3->translate(0,0,20,Ogre::Node::TS_LOCAL);
node3->attachObject(ent3);

5. . ,
.

,
45 y. (0,0,20),
, -,
. ,
z. y, ,
, -
. . translate,
- , ,
, , ,
.
.
. , ,
.

Ogre 3D
, Ogre 3D.

Have a go hero
MyEntity2,
. , ;
, . :


, ;
.


, ,
:
1. , createScene(),
.
2. :
Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","sinbad.mesh");
Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
mSceneMgr->getRootSceneNode()->addChild(node);
node->attachObject(ent);

3. :

Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","sinbad.mesh");


Ogre::SceneNode* node2 = mSceneMgr->getRootSceneNode()>createChildSceneNode("Node2");
node2->setPosition(10,0,0);
node2->yaw(Ogre::Degree(90));
node2->roll(Ogre::Degree(90));
node2->attachObject(ent2);

4. , :
Ogre::Entity* ent3 = mSceneMgr->createEntity("MyEntity3","Sinbad.mesh");
Ogre::SceneNode* node3 = node->createChildSceneNode("node3");
node3->setPosition(20,0,0);
node3->yaw(Ogre::Degree(90),Ogre::Node::TS_WORLD);
node3->roll(Ogre::Degree(90),Ogre::Node::TS_WORLD);
node3->attachObject(ent3);

5. .

, , .
y, z.
- . ,
, 90 y, z
. ,
z , .

1 , .
2, , 90
y. 3, 90 z.
,
.

,
, , , ,
.


,
.
, .


, Ogre 3D, ,
, .
, :
,
, ,
,

, ,
, .

3 ,
, ,
.
:

, Ogre 3D, ,


, ,
, , , ,
. ,
, .
, .


, 3D- .
:
1. createScene().
2. , createScene():
Ogre::Plane plane(Vector3::UNIT_Y, -10);

3. :

Ogre::MeshManager::getSingleton().createPlane("plane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);

4. :

Ogre::Entity* ent = mSceneMgr->createEntity("LightPlaneEntity", "plane");

5. :

mSceneMgr->getRootSceneNode()->createChildSceneNode()- >attachObject(ent);

6. , -, ,
:
ent->setMaterialName("Examples/BeachStones");

7. .
.

!
?

. 2
Ogre::Plane. ,
, .
( , ),
3D-. ,
. 1,
occlusion.

3, , .
, Ogre 3D MeshManager.
, . ,
, ,
.
Ogre::MeshManager::getSingleton().createPlane("plane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);

, . ,
.
, (namespaces) C++.
,
. ,
. , ,
, , 3D- 3D-.
3D

3D-, - ,
.
3D-
.

, . x- y-,
, .
, , , ,
. ,
, R.
, .
, .
.

, , ,
(Boolean) , Ogre 3D,
, . , ,
.
. -, .
, .
2D-,
, : x y. (x,y).
. (0,0)
, (1,1) . , 1.
, .
. (2,2)
. Ogre 3D, ,
. ,
.
.
. , .
, z .

4 ,
MeshManager. , ,
. 5 .
6 .
, . , ,
, .
. , , , ,
, .
, ,
. , media.
.


, , ,
, , - .


, ,
:
1. :
Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
mSceneMgr->getRootSceneNode()->addChild(node);

2. Light1 Ogre 3D,


:
Ogre::Light* light1 = mSceneMgr->createLight("Light1");
light1->setType(Ogre::Light::LT_POINT);

3. :

light1->setPosition(0,20,0);
light1->setDiffuseColour(1.0f,1.0f,1.0f);

4. , ,
:
Ogre::Entity* LightEnt = mSceneMgr->createEntity("MyEntity",
"sphere.mesh");
Ogre::SceneNode* node3 = node->createChildSceneNode("node3");
node3->setScale(0.1f,0.1f,0.1f);
node3->setPosition(0,20,0);
node3->attachObject(LightEnt);

5. ; ,
, .

,
.
1, .
, , .
2. ,
. ,
. , Ogre 3D
. Light1. Ogre 3D,

. ,
, : , , .
; .
. ,
. 3
. (r,g,b).
0.0 1.0 . 'r'
, 'g' , 'b' . (1.0,1.0,1.0) , (1.0,0.0,0.0)
, . , , setDiffuseColour(r,g,b),
. 4
, , .

Have a go hero
(20,20,20),
. , , .
:


, (spotlight)
, .


, , ,
:
1. , ,
. , ,
LigthEnt. :
Ogre::SceneNode* node2 = node->createChildSceneNode("node2");
node2->setPosition(0,100,0);

2. , , (spotlight):
Ogre::Light* light = mSceneMgr->createLight("Light1");
light->setType(Ogre::Light::LT_SPOTLIGHT);

3. ; , , :
light->setDirection(Ogre::Vector3(1,-1,0));
light->setSpotlightInnerAngle(Ogre::Degree(5.0f));
light->setSpotlightOuterAngle(Ogre::Degree(45.0f));

light->setSpotlightFalloff(0.0f);

4. ,
:
light->setDiffuseColour(Ogre::ColourValue(0.0f,1.0f,0.0f));
node2->attachObject(light);

5. ; :

, ;
.
1 , . 2
, ;
Ogre::Light::LT_SPOTLIGHT, . 3
; .

. ,
, , .
, . (direction)
, .
.
.
, . ,
. ,
, . InnerAngle OuterAngle, ,
, .
, (falloff). ,
, .
, .
, .

falloff () . ,
, .
, , ,
, .
, Ogre 3D, 20X20 .
, ,
,
, . , ,
. ,
20 200. :
Ogre::MeshManager::getSingleton().createPlane("plane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,200,200,true,1,5,5,Vector3::UNIT_Z);

,
.

; ,
, . ,
,
, . ,
, ,
, .
4 Ogre 3D.
, (r,g,b), .
Ogre::ColourValue (r,g,b), ,
() , ,

, .

Have a go hero
,
. ,
. ,
, .


.
(directional) .
, , ,
,
. , .
, .


1. createScene(), ,
.
2. , (directional) :
Ogre::Light* light = mSceneMgr->createLight("Light1");
light->setType(Ogre::Light::LT_DIRECTIONAL);

3. -:

light->setDiffuseColour(Ogre::ColourValue(1.0f,1.0f,1.0f));
light->setDirection(Ogre::Vector3(1,-1,0));

4. .

,
setDirection(1,-1,0).
,
. , ,
. , , ,
- . , ,
; .


, Ogre 3D, .


, - . ,
.


, , .
1. , Sinbad.mesh,
:

Ogre::Entity* Sinbad = mSceneMgr->createEntity("Sinbad", "Sinbad. mesh");


Ogre::SceneNode* SinbadNode = node- >createChildSceneNode("SinbadNode");

2. , ;
, . ,
:
SinbadNode->setScale(3.0f,3.0f,3.0f);
SinbadNode->setPosition(Ogre::Vector3(0.0f,4.0f,0.0f));
SinbadNode->attachObject(Sinbad);

3. .

. ,
, , .
.


3D- , .


.
1. createScene(),
:

mSceneMgr->setShadowTechnique(Ogre:: SHADOWTYPE_STENCIL_ADDITIVE);

2. .

. Ogre 3D
. Ogre 3D .
(additive) (stencil ) .
, .
, ,
.
, ,
. ,
, . ,
, .
, GPU Gems
NVIDIA, ShaderX, Siggraph
(http://www.siggraph.org/).


,
ExampleApplication. . , ,
.
, , ,
. ,
.


createScene(); ,
:
1. createCamera()
ExampleApplication:
void createCamera() {
}

2. , MyCamera1 mCamera:
mCamera = mSceneMgr->createCamera("MyCamera1");

3. :
mCamera->setPosition(0,100,200);
mCamera->lookAt(0,0,0);
mCamera->setNearClipDistance(5);

4. :
mCamera->setPolygonMode(Ogre::PM_WIREFRAME);

5. .
?

createCamera(),
. , ,
lookat(), .
(near) . 3D,
. , ,
.
, . culling (). ,
, near, ,
far, , .. ,
view frustum . frustum ; ,
, .

http://www.lighthouse3d.com/opengl/viewfrustum/. near
5. , ,
, .

.
R, , , ,
. R .
, , ;
.
createCamera(), ,
. setPosition(0,100,200)
, ; . ,
, , ,
, , . ,
- mCamera ExampleApplication.
ExampleApplication , , ,
.
, , (entity)
, .

Have a go hero
(look at) , ,
.
near, ,
. , ,
. near 50,
.


(viewport).
. 2D, . ,
. (background color),
, .

-, "
"
, ,
:
1. setShadowTechnique() createCamera().
, .
2. createViewports():
void createViewports() {
}

3. :

Ogre::Viewport* vp = mWindow->addViewport(mCamera);

4. :

vp->setBackgroundColour(ColourValue(0.0f,0.0f,1.0f));
mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp>getActualHeight()));

5. .

. ,
. , Ogre
3D , . ,
, getter setter.
, . :
; 3.
aspect ratio
; : aspect ratio = ,
.

Have a go hero
aspect ratio ,
. . ,
.


, ,
viewfrustum.
,
,

, frustum, :

. , FrameListener, .

4
Frame Listener
,
, .
.
, :

FrameListener
,
,
,


, ,
- . .


:
1. createScene() createCamera().
, ExampleApplication Example25. . .
2. createViewports().
3. - . -
:
private:
Ogre::SceneNode* _SinbadNode;

4. , createScene():

Ogre::Plane plane(Vector3::UNIT_Y, -10);


Ogre::MeshManager::getSingleton().createPlane("plane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,200,200,true,1,5,5,Vector3::UNIT_Z);
Ogre::Entity* ent = mSceneMgr->createEntity("LightPlaneEntity", "plane");
mSceneMgr->getRootSceneNode()->createChildSceneNode()- >attachObject(ent);
ent->setMaterialName("Examples/BeachStones");

5. :

Ogre::Light* light = mSceneMgr->createLight("Light1");


light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(Ogre::Vector3(1,-1,0));

6. ; :

Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");


mSceneMgr->getRootSceneNode()->addChild(node);
Ogre::Entity* Sinbad = mSceneMgr->createEntity("Sinbad", "Sinbad. mesh");
_SinbadNode = node->createChildSceneNode("SinbadNode");
_SinbadNode->setScale(3.0f,3.0f,3.0f);
_SinbadNode->setPosition(Ogre::Vector3(0.0f,4.0f,0.0f));
_SinbadNode->attachObject(Sinbad);

7. , ; :
mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);

8. , (0,100,200),
(0,0,0); createCamera():
mCamera = mSceneMgr->createCamera("MyCamera1");
mCamera->setPosition(0,100,200);
mCamera->lookAt(0,0,0);
mCamera->setNearClipDistance(5);

9. ,
:

, , .
, . ,
, .


; .


, , ExampleApplication.
:
1. , Example25FrameListener,
Ogre::FrameListener:
class Example25FrameListener : public Ogre::FrameListener
{
};

2. -, Ogre::SceneNode,
_node:
private:
Ogre::SceneNode* _node;

3. , Ogre::SceneNode
-:
public:
Example25FrameListener(Ogre::SceneNode* node)
{

_node = node;
}

4. , frameStarted(FrameEvent& evt),
(translate) (0.1,0,0), (true):
bool frameStarted(const Ogre::FrameEvent &evt)
{
_node->translate(Ogre::Vector3(0.1,0,0));
return true;
}

5. Example25 . .
private -
FrameListener, :
Ogre::FrameListener* FrameListener;

6. , NULL, ,
FrameListener :
Example25()
{
FrameListener = NULL;
}
~Example25()
{
if(FrameListener)
{
delete FrameListener;
}
}

7. ExampleApplication createFrameListener.
FrameListener, ,
, mRoot:
void createFrameListener()
{
FrameListener = new Example25FrameListener(_SinbadNode);
mRoot->addFrameListener(FrameListener);
}

8. . ,
, , ,
Escape. ,
, X , ,
, CTRL+C.

, .
FrameListener

, FrameListener.
, FrameListener () (observer).
, Ogre::FrameListener
Ogre 3D, addFrameListener() Ogre::Root.
, ,
. , frameStarted(). , (
, ) , Ogre::Root
FrameListener,
frameStarted(). ( 4) , 0.1
x. Framelistener . ,
, , , , ,
.
,
Escape. ,
FrameListener, ExampleApplication.
ExampleApplication SDK. ,
,
FrameListener. ,
. , ,
-.
4, (true). (false), Ogre
3D , , ,
.
"press Escape to exit the application" ( Escape, ).

FrameListener
() FrameListener?
a. Decorator

b. Bridge
c. Observer

,
,
,
, , .
, 0.1 x
, .
100 ; 10
. , 30
, 3 .
. ,
,
. Ogre 3D .

:
1. , (translate) , :
_node->translate(Ogre::Vector3(10,0,0) * evt.timeSinceLastFrame);

2. . ,
, .
?

-- -. , . ,
. ,
,
. 1 , Ogre 3D
FrameEvent frameStarted().
, :
, ,
. ,
. , (10,0,0).
, , 10 x .
, 10 ; ,
evt.timeSinceLastFrame 0.1f.
evt.timeSinceLastFrame (10,0,0), (1,0,0).
. 10
(10,0,0) ,
.

,

, ,

Have a go hero
,
.


,
, . ,
, Escape . ,
Ogre 3D; OIS ( ), Ogre 3D SDK,
ExampleFrameListener,
Ogre 3D.


, ,
:
1. (listener).
, Ogre 3D.
, :
Example27FrameListener(Ogre::SceneNode* node, RenderWindow* win)

2. :
Ogre::FrameListener* FrameListener = new Example27FrameListener(_SinbadNode,
mWindow);

3. .
:
size_t windowHnd = 0;
std::stringstream windowHndStr;

4. Ogre 3D , :
win->getCustomAttribute("WINDOW", &windowHnd);

5. :

windowHndStr << windowHnd;

6. OIS :

OIS::ParamList pl;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr. str()));

7. , :
_man = OIS::InputManager::createInputSystem( pl );

8. , :

_key = static_cast<OIS::Keyboard*> (_man->createInputObject(OIS::OISKeyboard,


false ));

9. , , . FrameListener,
OIS:
~Example27FrameListener()
{
_man->destroyInputObject(_key);
OIS::InputManager::destroyInputSystem(_man);
}

10. , ,

frameStarted() :
_key->capture();
if(_key->isKeyDown(OIS::KC_ESCAPE))
{
return false;
}

11. - FrameListener:
OIS::InputManager* _man;
OIS::Keyboard* _key;

12. .
, Escape.
?

,
. ,
FrameListener, .
1. ,
OIS. .

,
. ,
. ,
. Ogre 3D .
:
win->getCustomAttribute("WINDOW", &windowHnd);

, , Ogre 3D
getter-. -;
,
. WINDOW .
;
. ,
stringstream, , OIS. OIS
. , OIS ,
. 6
. 7
.
8.
? 10. , ,
, capture().
, , , ,
. ,
, escape . , ,
. , ,
Ogre 3D, . ,
, , ,
.


, ,
.


, ,
. WASD
:
1. , FrameListener
translate:
Ogre::Vector3 translate(0,0,0);

2. escape:
if(_key->isKeyDown(OIS::KC_W))
{
translate += Ogre::Vector3(0,0,-10);
}

3. . ,
:
if(_key->isKeyDown(OIS::KC_S))
{
translate += Ogre::Vector3(0,0,10);
}
if(_key->isKeyDown(OIS::KC_A))
{
translate += Ogre::Vector3(-10,0,0);
}
if(_key->isKeyDown(OIS::KC_D))
{
translate += Ogre::Vector3(10,0,0);
}

4. translate, , ,
, , :
_node->translate(translate*evt.timeSinceLastFrame);

5. ,
WASD

, WASD.
.
, , .

Have a go hero

,
, .
, ,

. , .


Escape, .
.


;
:
1. Framelistener, :
Example30FrameListener(Ogre::SceneNode* node, RenderWindow* win,
Ogre::Camera* cam)

2. - :
Ogre::Camera* _Cam;

3. :
_Cam = cam;

4. FrameListener, :
Ogre::FrameListener* FrameListener = new Example30FrameListener(_SinbadNode,
mWindow, mCamera);

5. , .
- :
OIS::Mouse* _mouse;

6. :
_mouse = static_cast<OIS::Mouse*>(_man->createInputObject( OIS::OISMouse,
false ));

7. , , ,
.
:
_mouse->capture();

8. , :

_node->translate(translate*evt.timeSinceLastFrame * _ movementspeed);

9. frameStarted(),
:

float rotX = _mouse->getMouseState().X.rel * evt. timeSinceLastFrame* -1;


float rotY = _mouse->getMouseState().Y.rel * evt. timeSinceLastFrame * -1;

10. :

_Cam->yaw(Ogre::Radian(rotX));
_Cam->pitch(Ogre::Radian(rotY));
_Cam->moveRelative(translate*evt.timeSinceLastFrame * _ movementspeed);

11. ,
FrameListener:
_man->destroyInputObject(_mouse);

12. . ,
.

.
,
FrameListener. 1 2, .
, .
. 6, ,
. 7, capture()
, .

, isKeyDown().
, getMouseState().
MouseState,
, , ,
, .

, .
, : x y.
X Y . ,
.
, , .
. , ,
.
, .
,
.
, ,
-1. -1 , ,
, . ,
. ,
yaw() pitch(). , , ,
, . ,
moveRelative().
, . , ,
(0,0,-1), .
, .
3D .


capture() ?

Have a go hero
-1 ,
.
capture() , .


, , 3, , , ,
R, .
framelistener.



, , , , ,
:
1. - framelistener,
:
Ogre::PolygonMode _PolyMode;

2. PM_SOLID:
_PolyMode = PM_SOLID;

:
_PolyMode = Ogre::PolygonMode::PM_SOLID;

, , 'Ogre::PolygonMode' is not a
class or namespace. ,
PM_SOLID, PM_WIREFRAME, PM_POINTS.
. . .
3. if frameStarted(),
, R. , .
(solid), ,
(wireframe):
if(_key->isKeyDown(OIS::KC_R))
{
if(_PolyMode == PM_SOLID)
{
_PolyMode = PM_WIREFRAME;
}

4. , , (point) :
else if(_PolyMode == PM_WIREFRAME)
{
_PolyMode = PM_POINTS;
}

5. :
else if(_PolyMode == PM_POINTS)
{
_PolyMode = PM_SOLID;
}

6. , ,
if:
_Cam->setPolygonMode(_PolyMode);
}

7. ;
R.
?

setPolygonMode(),
, , . ,
, ,
. , .
, , .
,
R. , , ,
, , R ,
. , R
, .
, , .



. , R, ,
, ,

R.


1. - (framelistener):
Ogre::Timer _timer;

2. :
_timer.reset();

3. , 0.25 ,
R. , :
if(_key->isKeyDown(OIS::KC_R) && _timer.getMilliseconds() > 250)
{

4. , ; ,
R :
_timer.reset();

5. ; R
.
?

Ogre 3D, : Ogre::Timer.


, , .
(reset) , ,
R, , 0.25 ,
reset(). , if ,
, , .
, 0.25 .
R,
0.25 .

Have a go hero
, ,
, , R
.

FrameListener, .
, OIS, ,
.
, :
,
,
,


, FrameListener,
.

5 Ogre 3D
, ,
3D, , Ogre 3D. 3D-
.
.
, :




...


.
.
. ,
, .
.


, ,
:
1. - FrameListener.
, ,
:
Ogre::Entity* _ent;
Ogre::AnimationState* _aniState;

2. FrameListener,
:
Example34FrameListener(Ogre::SceneNode* node,Ogre::Entity*
ent,RenderWindow* win,Ogre::Camera* cam)

3. -
-:
_ent = ent;

4. Dance ()
-, . ,
, :
_aniState = _ent->getAnimationState("Dance");
_aniState->setEnabled(true);
_aniState->setLoop(true);

5. , ,
. frameStarted();
, :
_aniState->addTime(evt.timeSinceLastFrame);

6. , ExampleApplication
FrameListener. - ,

:
Ogre::Entity* _SinbadEnt;

7. , ,
-.
Ogre::Entity* Sinbad = mSceneMgr->createEntity("Sinbad", "Sinbad.mesh");

:
_SinbadEnt = mSceneMgr->createEntity("Sinbad", "Sinbad.mesh");

8. :
_SinbadNode->attachObject(_SinbadEnt);

9. , FrameListener
:
Ogre::FrameListener* FrameListener = new
Example34FrameListener(_SinbadNode,_SinbadEnt,mWindow,mCamera);

10. . .

. 1
-,
. - ,
. Ogre::AnimationState, Ogre 3D
. 2 3 ;
, , 3
-, 1.
4; Dance
(). , ,
getAnimationState().
, AnimationState, , ,
null. , ,
. Ogre 3D, . ,
loop () , ,
. 5 ; .
, , ,
, Ogre 3D . , " "
, . ,
Ogre 3D, . ,
, . Ogre 3D
,
, .

, , , 0.25,
.
,
FrameListener.
, .


Ogre 3D,
, ?

Have a go hero
, ,
.
,
.


,
.


, :
1. Dance RunBase.
_aniState = _ent->getAnimationState("RunBase");

2. . ,
.

3. :
Ogre::AnimationState* _aniStateTop;

4. , , ,
. , , RunTop:
_aniStateTop = _ent->getAnimationState("RunTop");
_aniStateTop->setEnabled(true);
_aniStateTop->setLoop(true);

5. , ,
, :
_aniStateTop->addTime(evt.timeSinceLastFrame);

6. .
, .

. ,
AnimationState , ,
playAnimation(AnimationName), . Ogre 3D
,
playAnimation(AnimationName), .
, .
, addTime().

Have a go hero
,
0.5 4.0, , .


, .

, , .



, , :
1. -, FrameListener
:
float _WalkingSpeed;
float _rotation;

2. ; 50
:
_WalkingSpeed = 50.0f;
_rotation = 0.0f;

3. ,
. ,
Ogre 3D:
_aniState = _ent->getAnimationState("RunBase");
_aniState->setLoop(false);
_aniStateTop = _ent->getAnimationState("RunTop");
_aniStateTop->setLoop(false);

4. frameStarted() , ,
, , ,
, .
bool walked = false;
Ogre::Vector3 SinbadTranslate(0,0,0);

5. frameStarted() ,
. ()
. ,
, ,
, ,
, :
if(_key->isKeyDown(OIS::KC_UP))
{
SinbadTranslate += Ogre::Vector3(0,0,-1);
_rotation = 3.14f;
walked = true;
}

6. :
if(_key->isKeyDown(OIS::KC_DOWN))
{
SinbadTranslate += Ogre::Vector3(0,0,1);

_rotation = 0.0f;
walked = true;
}
if(_key->isKeyDown(OIS::KC_LEFT))
{
SinbadTranslate += Ogre::Vector3(-1,0,0);
_rotation = -1.57f;
walked = true;
}
if(_key->isKeyDown(OIS::KC_RIGHT))
{
SinbadTranslate += Ogre::Vector3(1,0,0);
_rotation = 1.57f;
walked = true;
}

7. , , , .
, , . ,
:
if(walked)
{
_aniState->setEnabled(true);
_aniStateTop->setEnabled(true);
if(_aniState->hasEnded())
{
_aniState->setTimePosition(0.0f);
}
if(_aniStateTop->hasEnded())
{
_aniStateTop->setTimePosition(0.0f);
}
}

8. ,
. ,
, . ,
, .
, , ,
:
else
{
_aniState->setTimePosition(0.0f);
_aniState->setEnabled(false);
_aniStateTop->setTimePosition(0.0f);
_aniStateTop->setEnabled(false);
}

9. ,
:
_node->translate(SinbadTranslate * evt.timeSinceLastFrame *
_WalkingSpeed);
_node->resetOrientation();
_node->yaw(Ogre::Radian(_rotation));

10. .

WASD, .
, ,
.


. ,
. 1 2
, . 3 ,
;
. , , ,
,
. .
, .
, .
frameStarted(). 4
, , :
, , ,
. 5 6
. ,
, .
7: , ,
, , .
, ,
. , ,
8. 9,
. , ,
. , yaw ,
, ,
. , ,
.


, ,
. ,
.


, :

1. createScene()
Sword1 Sword2:
Ogre::Entity* sword1 = mSceneMgr->createEntity("Sword1", "Sword.mesh");
Ogre::Entity* sword2 = mSceneMgr->createEntity("Sword2", "Sword.mesh");

2. , :
_SinbadEnt->attachObjectToBone("Handle.L", sword1);
_SinbadEnt->attachObjectToBone("Handle.R", sword2);

3. .
.

.
.
attachObjectToBone(). ,
, , .

(skeletons) (bones).
; , ,
.
. , ,
. .
3D-, ,
. ().
, .
; , .

, .
:
, ;
.

, , ,
, , .
, . Ogre 3D
. ,
, , ,
, , ,
,
. ,
- - , ,
.

,
, ,
Ogre 3D. ,
, , ,
.
.


, ,
.
1. createScene(), , ,
(set):
Ogre::AnimationStateSet* set = _SinbadEnt->getAllAnimationStates();

2. :
Ogre::AnimationStateIterator iter = set->getAnimationStateIterator();

3. , , :
while(iter.hasMoreElements())
{
std::cout << iter.getNext()->getAnimationName() << std::endl;
}

4. .
, :
Dance
DrawSwords
HandsClosed
HandsRelaxed
IdleBase
IdleTop
JumpEnd
JumpLoop
JumpStart
RunBase
RunTop
SliceHorizontal
SliceVertical

, , ,
. .
, , , ,
.

, ,
3D- .
, :

/ ,
,

, ,

, .
Ogre 3D,

.

6
7
8 -
:
6, 7 8 pozitiffcat, , ,
, .
http://forum.boolean.name/showthread.php?p=224502
, 01.06.2012.:
http://malcdevelop.ru/downloads/ogre_book_rus.zip

9 Ogre3D
.
:
, ExampleApplication.
,
, ,
.
:

, Ogre 3D
resources.cfg, ,
,
, ,
...

Ogre 3D
ExampleApplication
Ogre 3D; .

Ogre 3D
.
1. , Ogre3d.h,
main:
#include "Ogre\Ogre.h"
int main (void)
{
return 0;
}

2. Ogre 3D Root;
"plugin.cfg":
Ogre::Root* root = new Ogre::Root("plugins_d.cfg");

3. ,
, :
if(!root->showConfigDialog())
{
return -1;
}

4. :

Ogre::RenderWindow* window = root->initialise(true,"Ogre3D Beginners


Guide");

5. :
Ogre::SceneManager* sceneManager = root>createSceneManager(Ogre::ST_GENERIC);

6. camera:

Ogre::Camera* camera = sceneManager->createCamera("Camera");


camera->setPosition(Ogre::Vector3(0,0,50));

camera->lookAt(Ogre::Vector3(0,0,0));
camera->setNearClipDistance(5);

7.
:
Ogre::Viewport* viewport = window->addViewport(camera);
viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0));

8.
:
camera->setAspectRatio(Ogre::Real(viewport->getActualWidth())/
Ogre::Real(viewport->getActualHeight()));

9. , ( Root) :
root->startRendering();

10. ;
, . , Escape,
. ,
CTRL+C , .
?

Ogre 3D - ExampleApplication.
ExampleApplication, Ogre3D.h,
ExampleApplication.h. ,
- Ogre 3D, . root ,
Ogre 3D , -,
, ,
. : , ,
. :
Root(const String & pluginFileName = "plugins.cfg", const String &
configFileName = "ogre.cfg", const String & logFileName = "Ogre.log")

,
Ogre log-. ,
, , ,
. - plugins.cfg,
Ogre 3D SDK,
, plugins_d.cfg.
ogre.cfg Ogre,
.
, / .
Ogre 3D
. ,
, _d
; log-.
, , Ogre 3D
3. cancel ,
- , -1 , , .
, 4.
, , ; ,
, .
- ; 3,
, , . , ,
, . ,

, :


Ogre 3D , ExampleApplication.
- : .


, .
1. aspect ratio ,
zip-, :
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../../Medi
a/packs/Sinbad.zip","Zip");

2. ,
:

Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

3. :

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


sceneManager->getRootSceneNode()->attachObject(ent);

4. ;
:

ResourceGroupManager, zip-,
,
createEntity() 3.

resources.cfg
zip- ,
, , .

ExampleApplication resources.cfg,
zip-, ,
. .

resources.cfg

,
resources.cfg.
1. zip- config-, resources_d.cfg:
Ogre::ConfigFile cf;
cf.load("resources_d.cfg");

2. , config-:

Ogre::ConfigFile::SectionIterator sectionIter = cf.getSectionIterator();

3. ,
config-, :
Ogre::String sectionName, typeName, dataname;
while (sectionIter.hasMoreElements())
{

4. :

sectionName = sectionIter.peekNextKey();

5. , , ,
; :
Ogre::ConfigFile::SettingsMultiMap *settings = sectionIter.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;

6. :

for (i = settings->begin(); i != settings->end(); ++i)


{

7. , :
typeName = i->first;
dataname = i->second;

8. , , , :
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(dataname,
typeName, sectionName);

-, . .
}}

9. , ,
.
?

Ogre 3D,
ConfigFile. ,
, . ConfigFile, resources_d.cfg.
;
#ifdef,
: . ExampleApplication ;
384 ExampleApplication.h:
#if OGRE_DEBUG_MODE
cf.load(mResourcePath + "resources_d.cfg");
#else

cf.load(mResourcePath + "resources.cfg");
#endif

, ,
; resource.cfg. , resource.cfg
:
[General]
FileSystem=D:/programming/ogre/ogre_trunk_1_7/Samples/Media

[General] , , [ ]
. ;
2 , , 3
while, , .
,
. FileSystem D:/programming/ogre/ogre_trunk_1_7/
Samples/Media. 4 ,
. -.
, , , ,
. , ,
8. ,
.


Ogre 3D ,
main,
.


, ,
Ogre main.
1. MyApplication, ,
Ogre 3D, Root:
class MyApplication
{
private:
Ogre::SceneManager* _sceneManager;
Ogre::Root* _root;

2. :
public:

3. loadResources(),
resources.cfg:
void loadResources()
{
Ogre::ConfigFile cf;
cf.load("resources_d.cfg");

4. :
Ogre::ConfigFile::SectionIterator sectionIter = cf.getSectionIterator();
Ogre::String sectionName, typeName, dataname;

while (sectionIter.hasMoreElements())
{

5. :
sectionName = sectionIter.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = sectionIter.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;

6. , :
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
dataname = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
dataname, typeName, sectionName);
}
}
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}

7. startup() () ,
Ogre 3D, plugins.cfg:
int startup()
{
_root = new Ogre::Root("plugins_d.cfg");

8. , , , -1,
:
if(!_root->showConfigDialog())
{
return -1;
}

9. :
Ogre::RenderWindow* window = _root->initialise(true,"Ogre3D Beginners
Guide");
_sceneManager = _root->createSceneManager(Ogre::ST_GENERIC);

10. :

Ogre::Camera* camera = _sceneManager->createCamera("Camera");


camera->setPosition(Ogre::Vector3(0,0,50));
camera->lookAt(Ogre::Vector3(0,0,0));
camera->setNearClipDistance(5);
Ogre::Viewport* viewport = window->addViewport(camera);
viewport->setBackgroundColour(Ogre::ColourValue(0.0,0.0,0.0));
camera->setAspectRatio(Ogre::Real(viewport->getActualWidth())/
Ogre::Real(viewport->getActualHeight()));

11. , , ,
; , Ogre 3D :
loadResources();
createScene();
_root->startRendering();
return 0;

12. createScene(),
:
void createScene()
{
Ogre::Entity* ent = _sceneManager->createEntity("Sinbad.mesh");

_sceneManager->getRootSceneNode()->attachObject(ent);
}

13. , NULL,
, :
MyApplication()
{
_sceneManager = NULL;
_root = NULL;
}

14. , ,
, :
~MyApplication()
{
delete _root;
}

15. , , main:
int main (void)
{
MyApplication app;
app.startup();
return 0;
}

16. ; .
?


. ,
, .
, ; startup() ,
. FrameListener,
Ogre 3D .

FrameListener
ExampleFrameListener;
.

FrameListener
,
FrameListener
1. MyFrameListener,
:
class MyFrameListener : public Ogre::FrameListener
{
public:

2. frameStarted,
:
bool frameStarted(const Ogre::FrameEvent& evt)
{

return false;
}

3. frameEnded, :
bool frameEnded(const Ogre::FrameEvent& evt)
{
return false;
}

4. , , frameRenderingQueued,
:
bool frameRenderingQueued(const Ogre::FrameEvent& evt)
{
return false;
}

5. , FrameListener:
MyFrameListener* _listener;

6. , listener NULL:
_listener = NULL;

7. :
delete _listener;

8. , FrameListener ;
startup():
_listener = new MyFrameListener();
_root->addFrameListener(_listener);

9. ; .
?

FrameListener,
ExampleFrameListener.
FrameListener. ,
. frameStarted, .
, Ogre 3D
. , FrameListener
; , .

FrameListener
FrameListener ; .
, .

FrameListener
, , FrameListener
.
1. ,
:
bool frameStarted(const Ogre::FrameEvent& evt)
{
std::cout << Frame started << std::endl;

return false;
}
bool frameEnded(const Ogre::FrameEvent& evt)
{
std::cout << Frame ended << std::endl;
return false;
}
bool frameRenderingQueued(const Ogre::FrameEvent& evt)
{
std::cout << Frame queued << std::endl;
return false;
}

, iostream
.
#include <iostream>

2. ;
Frame started.
?

"" FrameListener,
. ,
. , frameStarted
, .

, , frameStarted() ,
, , frameStarted() .

frameStarted()
FrameListener,
.
1. frameStarted, :
bool frameStarted(const Ogre::FrameEvent& evt)
{
std::cout << Frame started << std::endl;
return true;
}

2. . ,
, ,
:
Frame started
Frame queued
?

frameStarted , Ogre 3D

, frameRenderingQueued.
, , frameRenderingQueued
, ,
.

, ,
. , ,
, . ,
, , ,
. FrameListener' frameRenderingQueued
, , ,
. , , ,
. , frameRenderingQueued ,
,
. .
, , frameRenderingQueued
.


frameRenderingQueued()
, Frame Listener.
1. frameRenderingQueued, :
bool frameRenderingQueued (const Ogre::FrameEvent& evt)
{
std::cout << Frame queued << std::endl;
return true;
}

2. .
, , ,
:
Frame started
Frame queued
Frame ended
?

, frameRenderingQueued , Ogre
3D , frameEnded .

, ,
. , , frameEnded
, , ,
.

frameEnded()
.
1. frameEnded, :
bool frameEnded (const Ogre::FrameEvent& evt)
{
std::cout << Frame ended << std::endl;
return true;
}

2. .
:
Frame started
Frame queued
Frame ended
?

, ,
; , .


, ,
; .
Escape.


, , FrameListener, .
1. OIS.h, OIS:
#include "OIS\OIS.h"

2. FrameListener ,
InputManager :
OIS::InputManager* _InputManager;
OIS::Keyboard* _Keyboard;

3. FrameListener RenderWindow,
OIS, , :
MyFrameListener(Ogre::RenderWindow* win)
{

4. OIS , ,
;
:
OIS::ParamList parameters;
unsigned int windowHandle = 0;
std::ostringstream windowHandleString;

5. :
win->getCustomAttribute("WINDOW", &windowHandle);
windowHandleString << windowHandle;

6. , , ,
"WINDOW":
parameters.insert(std::make_pair("WINDOW", windowHandleString.str()));

7. , InputManager:
_InputManager = OIS::InputManager::createInputSystem(parameters);

8. :
_Keyboard = static_cast<OIS::Keyboard*>(_InputManager>createInputObject( OIS::OISKeyboard, false ));

9. , , :
~MyFrameListener()
{
_InputManager->destroyInputObject(_Keyboard);
OIS::InputManager::destroyInputSystem(_InputManager);
}

10. frameStarted,
, , Escape, ; ,
:
bool frameStarted(const Ogre::FrameEvent& evt)
{
_Keyboard->capture();

if(_Keyboard->isKeyDown(OIS::KC_ESCAPE))
{
return false;
}
return true;
}

11. , ,
FrameListener, :
_listener = new MyFrameListener(window);
_root->addFrameListener(_listener);

12. . ,
, Escape.
?

FrameListener ,
4, Frame Listener.
, ,
.


FrameListener',
?


startRendering .
, , ,
FrameListener.
; Ogre 3D ,
.

, ,
.
1. , ;
- ,
:
bool _keepRunning;

2. startRendering startup.
3. , renderOneFrame,
renderOneFrame
_keepRunning. ,
:
void renderOneFrame()
{
Ogre::WindowEventUtilities::messagePump();

_keepRunning = _root->renderOneFrame();
}

4. _keepRunning:
bool keepRunning()
{
return _keepRunning;
}

5. while main, ,
keepRunning .
renderOneFrame.
while(app.keepRunning())
{
app.renderOneFrame();
}

6. , ,
. , _keepRunning
. .
.
_keepRunning=true;

7. .
.
?

Ogre 3D .
Ogre 3D ,
, FrameListener
, .
. ,
-, ,
; 1. 2
startRendering, Ogre 3D. 3,
, Ogre 3D,
, .
, , ,
, " "
.
Ogre 3D renderOneFrame,
, : ,
frameStarted, frameRenderingQueued, frameEnded
FrameListener, , .
_keepRunning,
,
. renderOneFrame , , FrameListener
, _keepRunning .
-
_keepRunning.
5, _keepRunning
while. , ,

_keepRunning , FrameListener' ,
, while, . while
renderOneFrame,
. ,
.

()
4,
Frame Listener, , ,
frame listener, .

frame listener
FrameListener, ,
.
1. -
FrameListener: , , ,
, :
OIS::Mouse* _Mouse;
Ogre::Camera* _Cam;
float _movementspeed;

2. : , ,
50:
MyFrameListener(Ogre::RenderWindow* win,Ogre::Camera* cam)
{
_Cam = cam;
_movementspeed = 50.0f;

3. , InputManager:
_Mouse = static_cast<OIS::Mouse*>(_InputManager>createInputObject( OIS::OISMouse, false ));

4. .
. .:
_InputManager->destroyInputObject(_Mouse);

5. , W, A, S, D,
frameStarted:
Ogre::Vector3 translate(0,0,0);
if(_Keyboard->isKeyDown(OIS::KC_W))
{
translate += Ogre::Vector3(0,0,-1);
}
if(_Keyboard->isKeyDown(OIS::KC_S))
{
translate += Ogre::Vector3(0,0,1);
}
if(_Keyboard->isKeyDown(OIS::KC_A))
{
translate += Ogre::Vector3(-1,0,0);
}
if(_Keyboard->isKeyDown(OIS::KC_D))

{
translate += Ogre::Vector3(1,0,0);
}
_Cam->moveRelative(translate*evt.timeSinceLastFrame * _movementspeed);

6. :
_Mouse->capture();
float rotX = _Mouse->getMouseState().X.rel * evt.timeSinceLastFrame* -1;
float rotY = _Mouse->getMouseState().Y.rel * evt.timeSinceLastFrame * -1;
_Cam->yaw(Ogre::Radian(rotX));
_Cam->pitch(Ogre::Radian(rotY));

7. , , FrameListener:
_listener = new MyFrameListener(window,camera);

8. . ,
:


.
,
, .


,
, ,
.


, ,
.
1. FrameListener,
-, :
Ogre::Viewport* _viewport;

2. , ;
:
bool _comp1, _comp2, _comp3;

3.
. ,

:
bool _down1, _down2, _down3;

4. FrameListener',
:
MyFrameListener(Ogre::RenderWindow* win,Ogre::Camera* cam,Ogre::Viewport*
viewport)

5.
:
_viewport = viewport;
_comp1 = false;
_comp2 = false;
_comp3 = false;
_down1 = false;
_down2 = false;
_down3 = false;

6. 1 , ,
, ,
.
frameStarted:
if(_Keyboard->isKeyDown(OIS::KC_1) && ! _down1)
{
_down1 = true;
_comp1 = !comp1;
Ogre::CompositorManager::getSingleton().
setCompositorEnabled(_viewport, "Compositor2", _comp1);
}

7. :
if(_Keyboard->isKeyDown(OIS::KC_2) && ! _down2)
{
_down2 = true;
_comp2 = !comp2;
Ogre::CompositorManager::getSingleton().
setCompositorEnabled(_viewport, "Compositor3", _comp2);
}
if(_Keyboard->isKeyDown(OIS::KC_3) && ! _down3)
{
_down3 = true;
_comp3 = !comp3;
Ogre::CompositorManager::getSingleton().
setCompositorEnabled(_viewport, "Compositor7", _comp3);
}

8. , :
if(!_Keyboard->isKeyDown(OIS::KC_1))
{
_down1 = false;
}
if(!_Keyboard->isKeyDown(OIS::KC_2))
{
_down2 = false;
}

if(!_Keyboard->isKeyDown(OIS::KC_3))
{
_down3 = false;
}

9. startup() :
Ogre::CompositorManager::getSingleton().addCompositor(viewport,
"Compositor2");
Ogre::CompositorManager::getSingleton().addCompositor(viewport,
"Compositor3");
Ogre::CompositorManager::getSingleton().addCompositor(viewport,
"Compositor7");

10. FrameListener',
:
_listener = new MyFrameListener(window,camera,viewport);

11. . 1, 2, 3,
. 1 , 2 , 3
; ,
:

, ,
, 1, 2, 3. ,
, Ogre 3D
, .


, , 3D ,


, , createScene():
1. , , :
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -5);
Ogre::MeshManager::getSingleton().createPlane("plane",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,200,200,true,1,5,5,Ogre::Vector3::UNIT_Z);

2. , :
Ogre::Entity* ground= _sceneManager->createEntity("LightPlaneEntity",
"plane");
_sceneManager->getRootSceneNode()->createChildSceneNode()>attachObject(ground);
ground->setMaterialName("Examples/BeachStones");

3. - ;
:
Ogre::Light* light = _sceneManager->createLight("Light1");
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(Ogre::Vector3(1,-1,0));

4. :
_sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);

5. .
, , .

, , ,
, .


, ;
.


()
,
.
1. FrameListener' : ,
, , :
float _WalkingSpeed;
Ogre::SceneNode* _node;

2. :
MyFrameListener(Ogre::RenderWindow* win, Ogre::Camera* cam,
Ogre::Viewport* viewport, Ogre::SceneNode* node)

3. - 50:
_WalkingSpeed = 50.0f;
_node = node;

4. frameStarted ,
, :
Ogre::Vector3 SinbadTranslate(0,0,0);
float _rotation = 0.0f;

5. , ,
:
if(_Keyboard->isKeyDown(OIS::KC_UP))
{
SinbadTranslate += Ogre::Vector3(0,0,-1);
_rotation = 3.14f;
}
if(_Keyboard->isKeyDown(OIS::KC_DOWN))
{
SinbadTranslate += Ogre::Vector3(0,0,1);
_rotation = 0.0f;
}
if(_Keyboard->isKeyDown(OIS::KC_LEFT))
{
SinbadTranslate += Ogre::Vector3(-1,0,0);
_rotation = -1.57f;
}
if(_Keyboard->isKeyDown(OIS::KC_RIGHT))
{
SinbadTranslate += Ogre::Vector3(1,0,0);
_rotation = 1.57f;
}

6. :
_node->translate(SinbadTranslate * evt.timeSinceLastFrame *
_WalkingSpeed);
_node->resetOrientation();
_node->yaw(Ogre::Radian(_rotation));

7. ,
:
Ogre::SceneNode* _SinbadNode;

8. FrameListener :
_listener = new MyFrameListener(window,camera,viewport,_SinbadNode);

9. createScene
, ;
:
_SinbadNode = _sceneManager->getRootSceneNode()->createChildSceneNode();
_SinbadNode->attachObject(sinbadEnt);

10. .
:

,
FrameListener. , .


, ;
.


, , .
1. FrameListener' :
Ogre::AnimationState* _aniState;
Ogre::AnimationState* _aniStateTop;

2. ,
:
MyFrameListener(Ogre::RenderWindow* win, Ogre::Camera* cam,
Ogre::Viewport* viewport, Ogre::SceneNode* node, Ogre::Entity* ent)

3. AnimationState
:
_aniState = ent->getAnimationState("RunBase");
_aniState->setLoop(false);
_aniStateTop = ent->getAnimationState("RunTop");
_aniStateTop->setLoop(false);

4. , AnimationState, frameStarted,
, .
if, :
bool walked = false;
if(_Keyboard->isKeyDown(OIS::KC_UP))

{
SinbadTranslate += Ogre::Vector3(0,0,-1);
_rotation = 3.14f;
walked = true;
}
if(_Keyboard->isKeyDown(OIS::KC_DOWN))
{
SinbadTranslate += Ogre::Vector3(0,0,1);
_rotation = 0.0f;
walked = true;
}
if(_Keyboard->isKeyDown(OIS::KC_LEFT))
{
SinbadTranslate += Ogre::Vector3(-1,0,0);
_rotation = -1.57f;
walked = true;
}
if(_Keyboard->isKeyDown(OIS::KC_RIGHT))
{
SinbadTranslate += Ogre::Vector3(1,0,0);
_rotation = 1.57f;
walked = true;
}

5. , ; ,
:
if(walked)
{
_aniState->setEnabled(true);
_aniStateTop->setEnabled(true);
if(_aniState->hasEnded())
{
_aniState->setTimePosition(0.0f);
}
if(_aniStateTop->hasEnded())
{
_aniStateTop->setTimePosition(0.0f);
}
}

6. ,
:
else
{
_aniState->setTimePosition(0.0f);
_aniState->setEnabled(false);
_aniStateTop->setTimePosition(0.0f);
_aniStateTop->setEnabled(false);
}

7. ;
:
_aniState->addTime(evt.timeSinceLastFrame);

_aniStateTop->addTime(evt.timeSinceLastFrame);

8. :
Ogre::Entity* _SinbadEnt;

9. FrameListener:
_listener = new MyFrameListener(window, camera, viewport, _SinbadNode,
_SinbadEnt);

10. , , :
_SinbadEnt = _sceneManager->createEntity("Sinbad.mesh");
_SinbadNode = _sceneManager->getRootSceneNode()->createChildSceneNode();
_SinbadNode->attachObject(_SinbadEnt);

11. .
:

, ,
.

Have a go hero ,
, ,
.

,
Ogre 3D.
, :
Ogre 3D

FrameListener
,
.

, Ogre 3D . Ogre 3D
,
.

10 Ogre3D
,
,
.
Ogre 3D,
, .
:

, ,

Ogre 3D
,
...


,
, .


:
1. , .
, :
Ogre::ParticleSystem* partSystem = _sceneManager>createParticleSystem( "Smoke","Examples/Smoke");
_SinbadNode->attachObject(partSystem);

2. . ,
.

,
, .
, .
?


, , .
, ;
?
, ,
affector' (). ,
. ,
.
, .
, , , .
, .
.
, , .
, . , .
, .
.
, .

. Affector', , ,
. affector' , . Affector
, , , .

, ,
.


,
.


:
1. .particle.
media/particle.
2. MySmoke1:
particle_system MySmoke1

3. Example/Smoke,
10 :
material
particle_width
particle_height

Examples/Smoke
10
10

4. 500 ,
, :
quota
billboard_type

500
point

5. , 3
:
emitter Point
{
emission_rate

6. (1,0,0) 20
:
direction
velocity

1 0 0
20

7. . :
}
}

8. createScene
Ogre::ParticleSystem* partSystem = _sceneManager>createParticleSystem("Smoke","Examples/Smoke");

Ogre::ParticleSystem* partSystem = _sceneManager>createParticleSystem("Smoke","MySmoke1");

9. .
, .

. , .particle
. ,
particle_system, ,
, . 3 ,
. ,
SDK. ,
, . :
material Examples/Smoke
{
technique
{
pass

{
lighting off
scene_blend alpha_blend
depth_write off
diffuse vertexcolor
texture_unit
{
texture smoke.png
tex_address_mode clamp
}
}
}
}

10 . 4
,
; ,
.
, .
, , . 5
, . 6
. ,
, .


, ,
.


.
1. :
angle 30
time_to_live 10
colour 1 0 0 1

color,
. . .
2. . ,
.

, .
. angle
() ,
. Ogre 3D ,
.
30 , .
time_to_live , 10
. - 5. , , ,
.
colour
, , .


, ; ?


, .
.

time to live colour


,
, .
1. time_to_live :
time_to_live_min 1

time_to_live_max 10

2. :
colour_range_start 1 0 0
colour_range_end 0 0 1

3. ; .
, .
, ?
... . .

,
, Ogre 3D
.
,
-, .

time to live
time_to_live
time_to_live_min.


, ,

, .
1. emission_rate, direction,
velocity:
emitter Point
{
emission_rate 30
direction 1 0 0
velocity 20

2. , ,
, :
duration 1
repeat_delay 1
}

3. . ,
, .

duration (),
. repeat_delay ,
, . ,
, , ,
.


12 ,
, , .

affector'
, .
affector',
.

affector'
1. , affector, (Point) ,
30 20 100
:
emitter Point
{
emission_rate 30
direction 1 0 0
velocity 20
time_to_live 100

2. ,
. affector Scaler:
affector Scaler
{
rate 5
}

3. . ,
.

affector, .
Affector Scaler , .
, .


. .


1. , affector ColourFader, 0.25
:
affector ColourFader
{
red -0.25
green -0.25
blue -0.25
}

2. . ,
.

affector,
, .

Have a go hero
ColourFader , .
:


, ,
.
.

, affector' .
1. , 100 ,
4:
emitter Point
{
emission_rate 30
direction 1 0 0
velocity 20
time_to_live 4
}

2. ,
colorfader.
:
affector ColourFader2
{
red1 -1
green1 -1
blue1 -1

3. , ,
, ,

:
state_change 2
red2 +1
green2 +1
blue2 +1
}

4. .

affector ColorFader2. affector


, red1, green1, blue1, 2
state_change. red2, green2, blue2
. ,
affector, , ,
, , ,
.

, , .
1. affector, ColorInterpolator:
affector ColourInterpolator
{

2. , .

:
time0 0
colour0 1 1 1

3. ,
:
time1 0.25
colour1 1 0 0

4. , :
time2 0.5
colour2 0 1 0

5. , , , :
time3 0.75
colour3 0 0 1
time4 1
colour4 1 1 1

6. , affector,
, , ,
, .

affector,
. ColourInterpolator . ,
timeX colourX, X 0 5. time0 0 ,
, affector colour0 . time1 0.25
, , affector colour1,
. affector
. , .
,
, , .

,
.


,
, ,
.


,
.
1. affector ColourInterpolator.
2. affector DirectionRandomiser:
affector DirectionRandomiser
{

3. , affector
:
randomness 100

4. ,
, affector. 1.0 100 0
. , ,
, :
scope 1
keep_velocity true

5. . ,
, ,
, .

Affector DirectionRandomiser ,

. affector',
.

Deflector ()
affector, ,
.



, .
1. randomizer, affector DeflectorPlane:
affector DeflectorPlane
{

2. :
plane_point 0 20 0
plane_normal 0 -1 0

3. , ,
. , ,
1.0 :
bounce 1.0

4. deflector, ,
. ,
30 . ,
, .
emitter Point
{
emission_rate 30
direction 0 1 0
velocity 20
time_to_live 4
angle 30
}

5. .
.

Have a go hero
, (0,0,0) ,
. affector ColourInterpolator.
:


, , ,
, .

(box)
, .
1. Point Box:
emitter Box
{

2. , :
height 50
width 50

depth 50

3. 10 ,
20:
emission_rate 10
direction 0 1 0
velocity 20
}

4. . .
, .

, Box.
, ,
.
, , .
, , ,
.


box', , .

,
.
1. Ring:
emitter Ring
{

2. , :
height 50
width 50

3. , , , ,
. :
inner_height 0.9
inner_width 0.9

4. , :

emission_rate 50
direction 0 1 0
velocity 20
}

5. . ,
, .

,
. , , ,
. Width height , .
, , . (-
. ) inner_width
inner_height ,
. , .

,
, .


.
1. ,
:
particle_system Firework
{
material Examples/Smoke
particle_width 1

particle_height 1
quota 5000
billboard_type point
emitter Point
{
emission_rate 100
direction 0 1 0
velocity 50
angle 360
duration 0.1
repeat_delay 1
colour_range_start 0 0 0
colour_range_end 1 1 1
}
}

2. :
Ogre::ParticleSystem* partSystem1 = _sceneManager>createParticleSystem( "Firework1","Firework");
Ogre::ParticleSystem* partSystem2 = _sceneManager>createParticleSystem( "Firework2","Firework");
Ogre::ParticleSystem* partSystem3 = _sceneManager>createParticleSystem( "Firework3","Firework");
Ogre::ParticleSystem* partSystem4 = _sceneManager>createParticleSystem( "Firework4","Firework");
Ogre::ParticleSystem* partSystem5 = _sceneManager>createParticleSystem( "Firework5","Firework");

3. :

Ogre::SceneNode* node1 = _sceneManager->getRootSceneNode()>createChildSceneNode(Ogre::Vector3(0,10,0));


Ogre::SceneNode* node2 = _sceneManager->getRootSceneNode()>createChildSceneNode(Ogre::Vector3(10,11,0));
Ogre::SceneNode* node3 = _sceneManager->getRootSceneNode()>createChildSceneNode(Ogre::Vector3(20,9,0));
Ogre::SceneNode* node4 = _sceneManager->getRootSceneNode()>createChildSceneNode(Ogre::Vector3(-10,11,0));
Ogre::SceneNode* node5 = _sceneManager->getRootSceneNode()>createChildSceneNode(Ogre::Vector3(-20,19,0));

4. , :
node1->attachObject(partSystem1);
node2->attachObject(partSystem2);
node3->attachObject(partSystem3);
node4->attachObject(partSystem4);
node5->attachObject(partSystem5);

5. ,

, ,
.


, ,
.

Ogre 3D
,
Ogre 3D, Ogre 3D .
,
Ogre 3D. ,
, .
wiki http://www.Ogre3D.org/tikiwiki/OGRE+Libraries.
Speedtree

Speedtree , ,
.
, Ogre 3D Sinbad (binding) Ogre 3D.
Speedtree Ogre 3D .
http://www.ogre3d.org/tikiwiki/OgreSpeedtree.
Hydrax

Hydrax ,
Ogre 3D.
, , , ,
, .
http://www.ogre3d.org/tikiwiki/Hydrax.
Caelum

Caelum ,
Ogre 3D. , .
, , ,
. wiki

http://www.ogre3d.org/tikiwiki/Caelum.
Particle Universe

Particle Universe ( ). Particle


Universe Ogre 3D,
, Ogre 3D. ,
, ,
.
http://www.ogre3d.org/tikiwiki/Particle+Universe+plugin.
(GUI)

GUI, Ogre 3D,


, GUI,
. ,
, .
CEGUI

CEGUI - ,
Ogre 3D. ,
GUI, . GUI-
.

http://www.cegui.org.uk/wiki/index.php/Main_Page.
BetaGUI

BetaGUI ,
cpp-. Ogre 3D,
, , , ,
. ,
, ,
.
http://www.ogre3d.org/tikiwiki/BetaGUI.
QuickGUI

QuickGUI , BetaGUI. QuickGui


, .
QuickGUI GUI-,
. -
http://www.ogre3d.org/tikiwiki/QuickGUI.
Berkelium

Berkelium GUI-, ,
- . Ogre 3D , Google Chromium.
-. -
http://www.ogre3d.org/tikiwiki/Berkelium.


.
, :
,
affector'
Ogre 3D

, . , ,

, ,
. , , ,
3D-, , ,
.

Оценить