Project

General

Profile

SO3Engine
SO3Scene.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
32#ifndef __SO3SCENE_H__
33#define __SO3SCENE_H__
34
42#include <Ogre.h>
43
44#include <sstream>
45#include <iostream>
46
47namespace SO3
48{
49
50 // Response Flash CallBack is Inside
51 class MMOUSE
52 {
53 public:
54 int x;
55 int y;
56 int vx;
57 int vy;
58 int scroll;
59 int btn;
60 int index;
61 int state;
62 int flags;
63 protected:
64 private:
65 public:
70 {
71 x = 0;
72 y = 0;
73 vx = 0;
74 vy = 0;
75 scroll = 0;
76 btn = 0;
77 index = -1;
78 state = 0;
79 flags = 0;
80 }
81
85 MMOUSE(int cx, int cy, int cbtn, int cindex = 0, int cscroll = 0, int cstate = 0, int cflags = 0, int cvx = 0, int cvy = 0)
86 {
87 x = cx;
88 y = cy;
89 btn = cbtn;
90 scroll = cscroll;
91 index = cindex;
92 state = cstate;
93 flags = cflags;
94 vx = cvx;
95 vy = cvy;
96 }
97
101 MMOUSE(const MMOUSE& mmouse)
102 {
103 x = mmouse.x;
104 y = mmouse.y;
105 scroll = mmouse.scroll;
106 btn = mmouse.btn;
107 index = mmouse.index;
108 state = mmouse.state;
109 flags = mmouse.flags;
110 vx = mmouse.vx;
111 vy = mmouse.vy;
112 }
113
118 {
119 }
120 protected:
121 private:
122 };
123
124 class _SO3_Export SScene : public SData
125 {
126 public:
127 Ogre::SceneManager* O3SceneManager;
128 Ogre::MeshManager* O3MeshManager;
129 Ogre::MaterialManager* O3MaterialManager;
130 Ogre::SkeletonManager* O3SkeletonManager;
131 Ogre::TextureManager* O3TextureManager;
138 Ogre::MaterialPtr skyBoxMat;
139 Ogre::MaterialPtr skyDomeMat;
140 Ogre::MaterialPtr skyPlaneMat;
141 Ogre::MaterialPtr materialCaster;
142 Ogre::MaterialPtr materialReceiver;
143 Ogre::Plane skyPlane;
144 Ogre::String curMessage;
145 SEnvironment* environment; // Sky and wate
146 protected:
147 private:
149 SNodeMap nodeList;
150 SEntityMap asyncEntities;
151 STerrainMap terrainList;
152 SNode* rootNode;
153 SPhysicWorld* physicWorld;
154 SAnimMap animationList;
155 int animationCounter;
156 SLightingManager* lightingManager;
157 Ogre::ColourValue cAmbientLight;
158 SGroupMaterialMap listOfMaterial;
159 SGroupTextureMap listOfTexture;
160 Ogre::Timer mPreTimer;
161 Ogre::Timer mPostTimer;
162 SShadowManager::ShadowType mLastShadowType;
163 Ogre::RaySceneQuery* mRayQuery;
164
165 //debug overlay
166 Ogre::Overlay* SO3DebugOverlay;
167 Ogre::OverlayContainer* SO3DebugPanel;
168 Ogre::TextAreaOverlayElement* SO3DebugTextArea;
169 Ogre::ResourcePtr SO3DebugFont;
170 public:
174 SScene(SRoot* parent, const std::string& sceneName);
175
179 ~SScene();
180
183 void clearOgreScene();
184
187 Ogre::SceneManager* GetOgreScenePointer();
188
192 SNode* GetRootNode();
193
197 SNode* GetNode(const std::string& nodeName) const;
198
202 void PreUpdate();
203
207 void PostUpdate();
208
212 const SNodeMap& GetNodeList() const;
213
217 const STerrainMap& GetTerrainList() const;
218
222 SNode* CreateNode(const std::string& newNodeName);
223
227 SNode* CreateNodeWithUniqueName(const std::string& basename);
228
232 void DeleteNode(SNode* existingNode);
233
237 SVirtualPointer* CreateVirtualPointer(const std::string& basename);
238
242 SCamera* CreateCamera(const std::string& newCameraName);
243
247 SEntity* CreateEntity(const std::string& groupName, const std::string& newEntityName, const std::string& meshName, bool loadInBackground = false);
248
252 SEntity* CreateEntity(const std::string& newEntityName, const SEntity::EntityPrefabType& prefabType);
253
257 SEntity* CreateEntity(const std::string& entityName, const std::string& ressourceGroup, Ogre::MeshPtr meshPointer);
258
262 SEntity* CloneEntity(const std::string& newEntityName, SEntity* entity);
263
267 SEntity* CreatePlane(const std::string& groupName, const std::string& newEntityName, const SPointFloat& sizev, const SPointInt& seg, const SPointFloat& uv);
268
272 SEntity* CreateSphere(const std::string& groupName, const std::string& newEntityName, const float& radius, const int& rings, const int& segments);
273
277 SEntity* CreateCone(const std::string& groupName, const std::string& newEntityName, const float& radius, const float& height, const int& segments);
278
282 SEntity* CreateOctahedron(const std::string& groupName, const std::string& newEntityName, const float& base, const float& bottom, const float& dist);
283
287 void DeleteEntity(SEntity* existingEntity);
288
292 void ReloadEntities();
293
297 SLineEntity* CreateLineEntity(const std::string& newLineEntityName, bool dashed = false, bool disableDepth = false);
298
302 void DeleteLineEntity(SLineEntity* existingLineEntity);
303
307 void UpdateLightsShadowParameters();
308
312 SSkeleton* CreateSkeleton(const std::string& newSkeletonName, SEntity* entity);
313
317 void DeleteSkeleton(SSkeleton* existingSkeleton);
318
322 SBone* CreateBone(const std::string& newBoneName, SSkeleton* skeleton, const unsigned short& id);
323
327 void DeleteBone(SBone* existingBone);
328
332 SParticleSystem* CreateParticleSystem(const std::string& newParticleSystemName, const std::string& particleSystemTemplate);
333
337 void DeleteParticleSystem(SParticleSystem* existingParticleSystem);
338
342 SLight* CreateLight(const std::string& newLightName);
343
347 void DeleteLight(SLight* existingLight);
348
352 SDynamicCubeMap* CreateDynamicCubeMap(const std::string& newDynamicCubeMapName);
353
357 void DeleteDynamicCubeMap(SDynamicCubeMap* existingDynamicCubeMap);
358
362 SRenderToTexture* CreateRenderToTexture(const std::string& newRttName, SCamera* povCamera);
363
367 void DeleteRenderToTexture(SRenderToTexture* existingRenderToTexture);
368
372 SDynamicReflectionMap* CreateDynamicReflectionMap(SViewPort* viewport, const std::string& newDynamicReflectionMapName);
373
377 void DeleteDynamicReflectionMap(SDynamicReflectionMap* existingDynamicReflectionMap);
378
382 SMaterial* CreateMaterial(const std::string& groupname, const std::string& matname, const bool& loadedFromScript = false);
383
387 void DeleteMaterial(SMaterial* material);
388
392 SMaterial* GetMaterial(const std::string& groupName, const std::string& materialName, bool searchOtherGroups = true);
393
395
399 const SMaterialMap* GetMaterials(const std::string& groupName);
400
404 const SGroupMaterialMap* GetMaterials();
405
406 void CleanGroupMaterials(const std::string& groupName);
407
411 STexture* CreateTexture(const std::string& groupname, const std::string& texname, const std::string& path, const int& w = 0, const int& h = 0);
412
413 STexture* CreateTexture(const std::string& groupname, const std::string& texname, Ogre::Image image);
414
418 void DeleteTexture(STexture* texture);
419
423 STexture* GetTexture(const std::string& groupName, const std::string& texName);
424
428 const STextureMap* GetTextures(const std::string& groupName);
429
433 const SGroupTextureMap* GetTextures();
434
435 void CleanGroupTextures(const std::string& groupName);
436
440 STerrain* CreateTerrain(const std::string& name);
441
445 void DeleteTerrain(STerrain* terrain);
446
450 void UpdateAllTerrains();
451
455 void DeleteAllTerrains();
456
459 SRoot* GetParent();
460
463 SPhysicWorld* GetPhysicsWorld();
464
467 SSequenceAnimation* CreateAnimationSequence(const std::string& animationName);
468
472 void AddAnimation(SAnim* existingAnimation);
473
477 void RemoveAnimation(SAnim* existingAnimation);
478
482 void RemoveAnimation(const std::string& animationName);
483
487 void DeleteAnimation(SAnim* existingAnimation);
488
491 unsigned short GetNumAnimations();
492
495 SAnim* GetAnimation(const std::string& animationName);
496
499 SAnimMap GetAnimations() const;
500
503 SEnvironment* GetEnvironment() const;
504
507 SLightingManager* GetLightingManager();
508
512 SShadowManager::ShadowType GetShadowType();
513
517 void SetShadowType(const SShadowManager::ShadowType& shadowType);
518
522 SShadowManager::ShadowQuality GetShadowQuality();
523
527 void SetShadowQuality(const SShadowManager::ShadowQuality& quality);
528
531 SShadowManager* GetShadowManager();
532
535 void DestroyInternalRessources();
536
539 void ReloadInternalRessources();
540
543 Ogre::ColourValue GetAmbientLight();
544
547 void SetAmbientLight(const Ogre::ColourValue& color);
548
552 void UpdateCamera(SViewPort* viewport);
553
557 void RegisterViewport(SViewPort* viewport);
558
562 void UnregisterViewport(SViewPort* viewport);
563
567 bool ParseResourceScript(const std::string& groupName, const std::string& scriptName, const SResource::ResourceType& scriptType);
568
571 void SetDebugEnable(const bool& enable);
572
575 void SetDebugDisplay(const int& color, const int& posx, const int& posy, const int& width, const int& height, const int& charHeight);
576
579 void SetDebugText(const std::string& text);
580
583 void GetSimpleRayCast(Ogre::Ray cameraRay, SRaycastResult &result);
584
587 void GetSimpleRayCast(Ogre::Ray cameraRay, SEntity* selected, SRaycastResult &result);
588
591 Ogre::RaySceneQuery* GetRayquery() { return mRayQuery; };
592
596 void SetMaterialsPointSize(Ogre::Real size);
597 protected:
601 bool NodeExist(const std::string &name);
602
606 bool AddNode(SNode* existingNode);
607
611 void RemoveNode(SNode* existingNode);
612
616 void RemoveNode(const std::string& nodeName);
617
621 void DeleteAllNodes();
622
626 void DeleteAllAnimations();
627
631 void DeleteAllMaterials();
632
636 void DeleteAllTextures();
637
638 bool UnloadResource(Ogre::ResourceManager* resMgr, const std::string& resName, const std::string& groupName);
639 bool UnloadResource(Ogre::ParticleSystemManager* resMgr, const std::string& resName);
640 bool UnloadMaterials(const std::string& filename, const std::string& groupName);
641 bool UnloadCompositors(const std::string& filename, const std::string& groupName);
642 bool UnloadParticles(const std::string& filename, const std::string& groupName);
643 bool UnloadVertexPrograms(const std::string& filename, const std::string& groupName);
644 bool UnloadFragmentPrograms(const std::string& filename, const std::string& groupName);
645 private:
649 SScene();
650 };
651
652}
653
654#endif
librairies include
SCOL_EXPORT int cbmachine w
Definition SO3SCOL.cpp:5150
SRoot * scolRoot
Shared data.
Definition SO3SCOL.cpp:186
MMOUSE(int cx, int cy, int cbtn, int cindex=0, int cscroll=0, int cstate=0, int cflags=0, int cvx=0, int cvy=0)
Definition SO3Scene.h:85
MMOUSE(const MMOUSE &mmouse)
Definition SO3Scene.h:101
bool hasSkyPlane
Definition SO3Scene.h:136
Ogre::MaterialPtr materialReceiver
Definition SO3Scene.h:142
Ogre::SceneManager * O3SceneManager
Definition SO3Scene.h:127
Ogre::MaterialPtr skyPlaneMat
Definition SO3Scene.h:140
bool skyPlaneDrawFirst
Definition SO3Scene.h:137
Ogre::SkeletonManager * O3SkeletonManager
Definition SO3Scene.h:130
Ogre::String curMessage
Definition SO3Scene.h:144
Ogre::MaterialPtr skyBoxMat
Definition SO3Scene.h:138
Ogre::MaterialPtr materialCaster
Definition SO3Scene.h:141
Ogre::TextureManager * O3TextureManager
Definition SO3Scene.h:131
Ogre::MaterialPtr skyDomeMat
Definition SO3Scene.h:139
SEnvironment * environment
Definition SO3Scene.h:145
Ogre::MaterialManager * O3MaterialManager
Definition SO3Scene.h:129
bool skyDomeDrawFirst
Definition SO3Scene.h:135
bool hasSkyDome
Definition SO3Scene.h:134
bool IsMaterialExist(SMaterial *)
Ogre::RaySceneQuery * GetRayquery()
Definition SO3Scene.h:591
Ogre::MeshManager * O3MeshManager
Definition SO3Scene.h:128
Ogre::Plane skyPlane
Definition SO3Scene.h:143
bool skyBoxDrawFirst
Definition SO3Scene.h:133
bool hasSkyBox
Definition SO3Scene.h:132
std::unordered_map< std::string, STexture * > STextureMap
std::unordered_map< std::string, SMaterial * > SMaterialMap
std::unordered_map< SEntity *, std::string > SEntityMap
std::unordered_map< std::string, STextureMap * > SGroupTextureMap
std::unordered_map< std::string, STerrain * > STerrainMap
std::unordered_map< std::string, SNode * > SNodeMap
std::unordered_map< std::string, SAnim * > SAnimMap
std::unordered_map< std::string, SMaterialMap * > SGroupMaterialMap