40 #ifndef _graphicsscenemanager_cpp
41 #define _graphicsscenemanager_cpp
43 #include "Graphics/scenemanager.h"
45 #include "Physics/physicsmanager.h"
47 #include "UI/uimanager.h"
49 #include "areaeffectmanager.h"
51 #include "worldobject.h"
52 #include "stringtool.h"
135 String FreshSkyMaterialName =
"",
137 String FreshSkyMaterialGroupName =
"",
138 Boole FreshSkyDrawnFirst =
false,
142 ActiveSky=FreshSkyMethod;
143 SkyOrientation=FreshSkyOrientation;
144 SkyMaterialName=FreshSkyMaterialName;
145 SkyMaterialGroupName=FreshSkyMaterialGroupName;
146 SkyDrawnFirst=FreshSkyDrawnFirst;
147 SkyThePlane=FreshSkyThePlane;
157 SkyOrientation(0,0,0,0),
158 SkyMaterialGroupName(
""),
159 SkyDrawnFirst(false),
161 ShadowTextureSize(512),
172 Ogre::Root::getSingleton().destroySceneManager(OgreManager);
184 ThreadResources(NULL)
187 this->
SMD->
OgreManager = Ogre::Root::getSingleton().createSceneManager(InternalManagerTypeName);
195 ThreadResources(NULL)
203 if(!ManagerType.
Empty())
206 if(!CurrAttrib.
Empty())
207 ManagerName = CurrAttrib.
AsString();
209 if(ManagerName.empty())
210 ManagerName =
"Default";
211 this->
SMD->
OgreManager = Ogre::Root::getSingleton().createSceneManager(ManagerName+
"SceneManager");
214 Boole TextureShadows =
false;
216 if(!ShadowSettings.
Empty())
220 if(!CurrAttrib.
Empty())
222 TechniqueName = CurrAttrib.
AsString();
223 if(
"StencilModulative" == TechniqueName )
225 else if(
"StencilAdditive" == TechniqueName )
227 else if(
"TextureModulative" == TechniqueName )
229 else if(
"TextureAdditive" == TechniqueName )
231 else if(
"TextureAdditiveIntegrated" == TechniqueName )
233 else if(
"TextureModulativeIntegrated" == TechniqueName )
237 if(!TechniqueName.empty())
239 if(String::npos != TechniqueName.find(
"Texture"))
240 TextureShadows =
true;
242 CurrAttrib = ShadowSettings.
GetAttribute(
"ShadowColour");
246 CurrAttrib = ShadowSettings.
GetAttribute(
"ShadowFarDistance");
254 if(!TextureShadowSettings.
Empty() && TextureShadows)
256 CurrAttrib = TextureShadowSettings.
GetAttribute(
"ShadowTextureCount");
257 if(!CurrAttrib.
Empty())
260 CurrAttrib = TextureShadowSettings.
GetAttribute(
"ShadowTextureSize");
261 if(!CurrAttrib.
Empty())
278 Ogre::ShadowTechnique Type;
282 Type = Ogre::SHADOWTYPE_STENCIL_MODULATIVE;
285 Type = Ogre::SHADOWTYPE_STENCIL_ADDITIVE;
288 Type = Ogre::SHADOWTYPE_TEXTURE_MODULATIVE;
291 Type = Ogre::SHADOWTYPE_TEXTURE_ADDITIVE;
294 Type = Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED;
297 Type = Ogre::SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED;
300 Type = Ogre::SHADOWTYPE_NONE;
307 Ogre::ShadowTechnique ShadowType = this->
SMD->
OgreManager->getShadowTechnique();
310 case Ogre::SHADOWTYPE_STENCIL_MODULATIVE:
313 case Ogre::SHADOWTYPE_STENCIL_ADDITIVE:
316 case Ogre::SHADOWTYPE_TEXTURE_MODULATIVE:
319 case Ogre::SHADOWTYPE_TEXTURE_ADDITIVE:
322 case Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED:
325 case Ogre::SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED:
370 this->
SMD->
OgreManager->setSkyPlane(
true, SkyPlane_.
GetOgrePlane(), Material, Scale, Tiling, DrawFirst, Bow, XSegments, YSegments, Group);
391 Quaternion Orientation,
int XSegments,
int YSegments)
395 this->
SMD->
OgreManager->setSkyDome(
true, Material, Curvature, Tiling, Distance, DrawFirst, Orientation.
GetOgreQuaternion(), XSegments, YSegments, -1, Group);
423 this->
Proxies.push_back(NewProxy);
434 this->
Proxies.push_back(NewProxy);
441 this->
Proxies.push_back(NewProxy);
449 this->
Proxies.push_back(NewProxy);
456 this->
Proxies.push_back(NewProxy);
466 this->
Proxies.push_back(NewProxy);
476 this->
Proxies.push_back(NewProxy);
487 this->
Proxies.push_back(NewProxy);
494 this->
Proxies.push_back(NewProxy);
504 this->
Proxies.push_back(NewProxy);
515 this->
Proxies.push_back(NewProxy);
522 this->
Proxies.push_back(NewProxy);
533 this->
Proxies.push_back(NewProxy);
541 {
return this->
Proxies.at(Index); }
545 if( Mezzanine::PT_Graphics_All_Proxies & Type ) {
548 if( (*ProxIt)->GetProxyType() == Type ) {
549 if( 0 == Which )
return (*ProxIt);
558 {
return this->
Proxies.size(); }
564 if( ToBeDestroyed == (*ProxIt) ) {
565 WorldObject* Parent = (*ProxIt)->GetParentObject();
581 WorldObject* Parent = (*ProxIt)->GetParentObject();
592 {
return this->
Proxies.begin(); }
595 {
return this->
Proxies.end(); }
598 {
return this->
Proxies.begin(); }
601 {
return this->
Proxies.end(); }
608 this->
SMD->
OgreManager->setAmbientLight(Ogre::ColourValue(Red, Green, Blue, Alpha));
631 if( (*it)->GetProxyType() == Mezzanine::PT_Graphics_ParticleSystemProxy )
632 static_cast<ParticleSystemProxy*>( (*it) )->PauseParticleSystem(Pause);
674 {
return this->
SMD; }
693 if( Params.empty() ) {
696 String InternalManagerTypeName;
697 for( NameValuePairList::const_iterator ParIt = Params.begin() ; ParIt != Params.end() ; ++ParIt )
699 String Lower = (*ParIt).first;
701 if(
"internalmanagertypename" == Lower ) {
702 InternalManagerTypeName = (*ParIt).second;
705 return new SceneManager(Creator,InternalManagerTypeName);
715 delete ToBeDestroyed;
724 stream <<
"<SceneManager Version=\"1\" Name=\"" << Ev.
GetName()
730 <<
"\" SkyMethod=\"" << Ev.
WhichSky()
742 Ogre::SceneManager::SkyPlaneGenParameters Values=SMD->
OgreManager->getSkyPlaneGenParameters();
743 stream <<
"<SkyPlane Version=\"1"
747 <<
"\" Scale=\"" << Values.skyPlaneScale
748 <<
"\" Tiling=\"" << Values.skyPlaneTiling
749 <<
"\" Bow=\"" << Values.skyPlaneBow
750 <<
"\" XSegments=\"" << Values.skyPlaneXSegments
751 <<
"\" YSegments=\"" << Values.skyPlaneYSegments
759 Ogre::SceneManager::SkyBoxGenParameters Values = SMD->
OgreManager->getSkyBoxGenParameters();
760 stream <<
"<SkyBox Version=\"1"
764 <<
"\" Distance=\"" << Values.skyBoxDistance
772 Ogre::SceneManager::SkyDomeGenParameters Values=SMD->
OgreManager->getSkyDomeGenParameters();
773 stream <<
"<SkyDome Version=\"1"
777 <<
"\" Distance=\"" << Values.skyDomeDistance
778 <<
"\" Curvature=\"" << Values.skyDomeCurvature
779 <<
"\" Tiling=\"" << Values.skyDomeTiling
780 <<
"\" XSegments=\"" << Values.skyDomeXSegments
781 <<
"\" YSegments=\"" << Values.skyDomeYSegments
782 <<
"\" YSegments_keep=\"" << Values.skyDomeYSegments_keep
791 stream <<
"</SceneManager>";
819 Doc->GetFirstChild() >> Ev;
848 Child.GetFirstChild() >> AllAroundUs;
863 if(Child.GetFirstChild())
868 Child.GetFirstChild() >> InTheShade;
883 if(Child.GetAttribute(
"Version").AsInt() == 1)
888 Child.GetFirstChild().GetFirstChild() >> Orientation;
892 Ev.
CreateSkyBox( Child.GetAttribute(
"MaterialName").AsString(),
893 Child.GetAttribute(
"MaterialGroupName").AsString(),
894 Child.GetAttribute(
"Distance").AsReal(),
895 Child.GetAttribute(
"DrawFirst").AsBool(),
907 if(Child.GetAttribute(
"Version").AsInt() == 1)
912 Child.GetFirstChild().GetFirstChild() >> Orientation;
916 Ev.
CreateSkyDome( Child.GetAttribute(
"MaterialName").AsString(),
917 Child.GetAttribute(
"MaterialGroupName").AsString(),
918 Child.GetAttribute(
"Distance").AsReal(),
919 Child.GetAttribute(
"Curvature").AsReal(),
920 Child.GetAttribute(
"Tiling").AsReal(),
921 Child.GetAttribute(
"DrawFirst").AsBool(),
923 Child.GetAttribute(
"XSegments").AsInt(),
924 Child.GetAttribute(
"YSegments").AsInt());
937 Child.GetFirstChild() >> SkyOrientation;
939 if(Child.GetAttribute(
"Version").AsInt() == 1)
942 Child.GetAttribute(
"MaterialName").AsString(),
943 Child.GetAttribute(
"MaterialGroupName").AsString(),
944 Child.GetAttribute(
"Scale").AsReal(),
945 Child.GetAttribute(
"Tiling").AsReal(),
946 Child.GetAttribute(
"DrawFirst").AsBool(),
947 Child.GetAttribute(
"Bow").AsBool(),
948 Child.GetAttribute(
"XSegments").AsInt(),
949 Child.GetAttribute(
"YSegments").AsInt());
String GetOneTag(std::istream &stream)
Gets the first tag out of the Stream and returns it as a String.
std::ostream & operator<<(std::ostream &stream, const Mezzanine::LinearInterpolator< T > &Lint)
Used to Serialize an Mezzanine::LinearInterpolator to a human readable stream.
virtual String GetImplementationTypeName() const
This Allows any manager name to be sent to a stream. Primarily used for logging.
LightType
This is used by LightProxies to describe how light is emitted from the proxy source.
A light-weight handle for manipulating attributes in DOM tree.
UInt32 GetNumProxies() const
Gets the number of RenderableProxy instances in this manager.
SceneShadowTechnique
needs to be documented
SceneManagerData * SMD
Pointer to a class storing sensative internal data for the scene.
BillboardSetProxy * CreateBillboardSetProxy(const Boole AddToWorld)
Creates a new BillboardSetProxy with a pool size of 20.
SceneManagerData * _GetRawInternalDataPointer() const
Gets the raw internal internal data.
bool Boole
Generally acts a single bit, true or false.
This class contains utilities and functions to allow the manipulation of the Graphical scene...
virtual ~DefaultSceneManagerFactory()
Class destructor.
ManagerType
A listing of Manager Types.
Plane SkyThePlane
Used to describe a skyplane instead of orientation.
Quaternion SkyOrientation
The orientation of the sky, unless it's a Skyplane, this this is all 0s.
SceneManagerData(SceneManager *_SM)
Create One of these, the data every scenemanager needs.
EntityProxy * CreateEntityProxy(const Boole AddToWorld)
Creates a new EntityProxy.
virtual UInt32 GetProxyID() const
Gets the unique ID of this proxy.
Document * PreParseClassFromSingleTag(const String &NameSpace, const String &ClassName, const String &OneTag)
Perform a basic series of checks for extracting meaning from a single xml tag.
unsigned short ShadowTextureSize
The size.
LightProxy * CreateLightProxy(const Boole AddToWorld)
Creates a new LightProxy.
Node GetFirstChild() const
Get the first child Node of this Node.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
This class is used to check and modify the properties of a graphics mesh.
virtual void AddToWorld()
Performs all the necessary task to ensure this object is connected to it's respective world and ready...
void DisableSky()
If any sky is active, disable it.
A simple reference counting pointer.
CameraProxy * CreateCamera()
Creates a new camera.
String GetManagerImplName() const
Gets the name of the manager that is created by this factory.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
void DisableSky(SceneManager *ScenePTR)
Disable the sky ina given scenemanager.
void DisableSkyPlane()
Disables the currently active skyplane.
void SetShadowTextureSize(unsigned short Size)
Sets the size of all texture based shadows.
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
Ogre::Plane GetOgrePlane() const
Gets an Ogre::Plane that contains this Planes information.
void SetShadowFarDistance(const Real &FarDist)
Sets the maximum distance from the camera that shadows will be visible.
IDType GenerateID()
Generates a new ID unique to the pool made by this generator.
A flat plane use to draw the sky.
void PauseAllParticles(Boole Pause)
Pauses(or unpauses) all particles stored in this manager.
void SetShadowColour(const ColourValue &ShadowColour)
Sets the colour to be used when casting shadows.
UIDGenerator ProxyIDGen
Generator responsible for creating unique IDs for CollidableProxy instances.
This is the base proxy class for world proxies wrapping functionality of the graphics subsystem...
SceneShadowTechnique GetSceneShadowTechnique() const
Gets the currently set shadow technique.
This is the proxy class for placing and manipulating a mesh in the scene.
This file contains the declaration for the World proxy wrapping billboard functionality.
This file contains the declaration for the World proxy wrapping light functionality.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
ManagerBase::ManagerType GetManagerType() const
Gets the type of manager that is created by this factory.
bool Empty() const
Is this storing anything at all?
static const ManagerBase::ManagerType InterfaceType
A ManagerType enum value used to describe the type of interface/functionality this manager provides...
This is used to represent a flat infinite slice of the game world.
This implements the exception hiearchy for Mezzanine.
Node GetNextSibling() const
Attempt to retrieve the next sibling of this Node.
virtual void Pause(const UInt32 PL)
Sets the pause state of this manager, or has no effect depending on the value passed in...
SceneManager::SkyMethod ActiveSky
The currently active sky, if set to anything other than SkyNone, then the 5 other skycache variable m...
WorldManager * CreateManager(World *Creator, const NameValuePairList &Params)
Creates a manager of the type represented by this factory.
This is the proxy class for placing and manipulating a set of 2D billboards in the scene...
~SceneManagerData()
Destructor.
SceneManager(World *Creator, const String &InternalManagerTypeName="DefaultSceneManager")
Class Constructor.
float Real
A Datatype used to represent a real floating point number.
ProxyContainer Proxies
Container storing all of the RenderableProxy instances created by this manager.
This is the base class from which classes that are insertable into the physical world.
ParticleSystemProxy * CreateParticleSystemProxy(const String &Template, const Boole AddToWorld)
Creates a new ParticleSystemProxy.
void CreateSkyDome(const String &Material, const String &Group, Real Distance, Real Curvature=10.0, Real Tiling=8.0, Boole DrawFirst=true, Quaternion Orientation=Quaternion(), int XSegments=16, int YSegments=16)
Creates a skydome for use in making a sky.
void SetAmbientLight(Real Red=1.0, Real Green=1.0, Real Blue=1.0, Real Alpha=1.0)
Sets the ambient light for the scene.
virtual ~SceneManager()
Class destructor.
Whole AsWhole(Whole def=0) const
Attempts to convert the value of the attribute to a Whole and returns the results.
ColourValue GetShadowColour() const
Gets the colour being used when casting shadows.
Ogre::Quaternion GetOgreQuaternion(Boole normalize=false) const
Gets a Ogre quaternion.
static const String ImplementationName
A String containing the name of this manager implementation.
A box using 5 Rectangles to draw the sky.
This file contains the declaration for the World proxy wrapping camera functionality.
Boole ReserveID(const IDType ID)
Adds a specific ID to the pool of used IDs.
A light-weight handle for manipulating nodes in DOM tree.
Stencil shadow technique which renders all shadow volumes as a modulation after all the non-transpare...
const String ConstString
A Datatype used to a series of imutable characters.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
ProxyType
Used by all World proxies to describe what their derived types are.
uint32_t UInt32
An 32-bit unsigned integer.
Stores internal data for the SCeneManager to keep it from cluttering the Header file.
This file contains the declaration for the World proxy wrapping basic entity(mesh) functionality...
bool Empty() const
Is this storing anything at all?
unsigned short GetShadowTextureSize() const
Retrieve the size of textures.
virtual void Initialize()
Configures this manager for use prior to entering the main loop.
Texture-based shadow technique which involves a render-to-texture of the shadow caster and a projecti...
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
String SkyMaterialName
The Name of the Material the sky is made of.
Boole SkyDrawnFirst
When is the sky drawn, first or per Z-order.
void DestroyAllProxies()
Deletes all stored RenderableProxy instances.
std::list< NameValuePair > NameValuePairList
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Texture-based shadow technique which involves a render-to-texture of the shadow caster and a projecti...
ProxyIterator EndRenderableProxy()
Gets an iterator to one passed the last Renderable Proxy in this manager.
This is the base class for all managers that belong to a single world instance.
virtual void Initialize()
Configures this manager for use prior to entering the main loop.
This is the proxy class for placing and manipulating a camera in the scene.
Real GetShadowFarDistance() const
Gets the maximum distance from the camera that shadows will be visible.
Texture-based shadow technique which involves a render-to-texture of the shadow caster and a projecti...
DefaultSceneManagerFactory()
Class constructor.
This is the proxy class for placing and manipulating particles in the scene.
virtual ManagerType GetInterfaceType() const
This returns the type of this manager.
Thrown when the identity string wasn't valid at all.
Ogre::SceneManager * _GetGraphicsWorldPointer() const
Gets the internal Ogre Scene Manager pointer.
This is used to represent a point in space, or a vector through space.
String SkyMaterialGroupName
The name of the group the sky material is in.
Ogre::SceneManager * OgreManager
Pointer for the Ogre Scenemanager, where this manager gets it's functionality.
Stencil shadow technique which renders each light as a separate additive pass to the scene...
The bulk of the engine components go in this namspace.
This is the proxy class for placing and manipulating lighting in the scene.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
SkyMethod WhichSky() const
get the kind of sy in use
std::istream & operator>>(std::istream &stream, Mezzanine::LinearInterpolator< T > &Lint)
Used to de-serialize an Mezzanine::LinearInterpolator from a stream.
This file contains the declaration for the World proxy wrapping particle functionality.
RenderableProxy * GetProxy(const UInt32 Index) const
Gets a RenderableProxy instance by index.
void DestroyProxy(RenderableProxy *ToBeDestroyed)
Deletes a RenderableProxy.
This class represents a world for objects to interact within.
void UpdateSkyCache(SceneManager::SkyMethod FreshSkyMethod=SceneManager::SkyNone, String FreshSkyMaterialName="", Quaternion FreshSkyOrientation=Quaternion(0, 0, 0, 0), String FreshSkyMaterialGroupName="", Boole FreshSkyDrawnFirst=false, Plane FreshSkyThePlane=Plane(Vector3(0, 0, 0), 0))
update the information that is cached about the sky
Boole ReleaseID(const IDType ID)
Frees up an ID so that it can be reused.
void SetSceneShadowTechnique(SceneShadowTechnique Shadows)
Sets the type of shadows to be used when rendering the scene.
void CreateSkyPlane(const Plane &SkyPlane_, const String &Material, const String &Group, Real Scale=1000.0, Real Tiling=10.0, Boole DrawFirst=true, Real Bow=0, int XSegments=1, int YSegments=1)
Creates a skyplane for use in making a sky.
virtual void AddToWorld()
Performs all the necessary task to ensure this object is connected to it's respective world and ready...
A multifaceted hemispherical dome, the most sophisticated sky background.
virtual void Deinitialize()
Removes this manager from any necessary configuration so it can be safely disposed of...
Whole GetShadowTextureCount() const
Gets the currently set number of textures being used to make texture shadows.
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
This is used to store information about rotation in 3d space.
Ogre::ColourValue GetOgreColourValue() const
Creates and returns an Ogre ColourValue class with values equal to this one.
void DisableSkyDome()
Disables the currently active skydome.
SkyMethod
Used to help identify which method is used to draw the sky, if any.
ProxyContainer::iterator ProxyIterator
Iterator type for RenderableProxy instances stored by this class.
ProxyContainer::const_iterator ConstProxyIterator
Const Iterator type for RenderableProxy instances stored by this class.
void DisableSkyBox()
Disables the currently active skybox.
void SetShadowTextureCount(const Whole &Count)
Sets the number of textures to be alloted for creating shadows.
ProxyIterator BeginRenderableProxy()
Gets an iterator to the first Renderable Proxy in this manager.
This class represents all the rendering passes a rendered object has.
ConstString & GetName() const
Gets the name of this manager.
SceneManager * SM
A Pointer to the scenemanager this works with.
std::string String
A datatype used to a series of characters.
void DestroyManager(WorldManager *ToBeDestroyed)
Destroys a Manager created by this factory.
Texture-based shadow technique which involves a monochrome render-to-texture of the shadow caster and...
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
virtual void _NotifyProxyDestroyed(WorldProxy *ToBeDestroyed)=0
Notifies that a proxy belonging to this WorldObject is being forcibly destroyed, and it needs to upda...
void CreateSkyBox(const String &Material, const String &Group, Real Distance, Boole DrawFirst=true, Quaternion Orientation=Quaternion())
Creates a skybox for use in making a sky.
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
ColourValue GetAmbientLight() const
Retrieve the level of the ambient light.
Boole Initialized
Simple Boole indicating whether or not this manager has been initialized.