1 #ifndef B_OBJECT_MANAGER_H
2 #define B_OBJECT_MANAGER_H
27 #include "vmmlib/util.hpp"
36 typedef std::unordered_map< std::string, ShaderPtr >
ShaderMap;
37 typedef std::unordered_map< std::string, TexturePtr >
TextureMap;
38 typedef std::unordered_map< std::string, CubeMapPtr >
CubeMapMap;
39 typedef std::unordered_map< std::string, DepthMapPtr >
DepthMapMap;
40 typedef std::unordered_map< std::string, FontPtr >
FontMap;
41 typedef std::unordered_map< std::string, MaterialPtr >
MaterialMap;
43 typedef std::unordered_map< std::string, ModelPtr >
ModelMap;
45 typedef std::unordered_map< std::string, CameraPtr >
CameraMap;
47 typedef std::unordered_map< std::string, LightPtr >
LightMap;
49 typedef std::unordered_map< std::string, DrawablePtr >
DrawableMap;
171 ShaderPtr generateShader(
const std::string &shaderName, GLuint shaderMaxLights,
bool ambientLighting,
const MaterialData &materialData,
bool variableNumberOfLights,
bool isText);
260 ModelPtr createSprite(
const std::string &name,
const std::string &textureFileName, GLuint shaderMaxLights = 0,
bool variableNumberOfLights =
false,
bool flipT =
false,
PropertiesPtr properties =
nullptr);
312 CubeMapPtr createCubeMap(
const std::string &name, GLsizei width, GLenum format = GL_RGBA,
const std::vector<ImageDataPtr> &imageData = {});
337 CameraPtr createCamera(
const std::string &name,
const vmml::Vector3f &position,
const vmml::Vector3f &rotationAxes);
346 CameraPtr createCamera(
const std::string &name, GLfloat fov, GLfloat aspect, GLfloat near, GLfloat far);
357 CameraPtr createCamera(
const std::string &name,
const vmml::Vector3f &position,
const vmml::Vector3f &rotationAxes, GLfloat fov, GLfloat aspect, GLfloat near, GLfloat far);
374 LightPtr createLight(
const std::string &name,
const vmml::Vector3f &position,
const vmml::Vector3f &color);
384 LightPtr createLight(
const std::string &name,
const vmml::Vector3f &position,
const vmml::Vector3f &color, GLfloat intensity, GLfloat attenuation, GLfloat radius);
395 LightPtr createLight(
const std::string &name,
const vmml::Vector3f &position,
const vmml::Vector3f &diffuseColor,
const vmml::Vector3f &specularColor, GLfloat intensity, GLfloat attenuation, GLfloat radius);
602 void removeFont(
const std::string &name,
bool del);
618 void removeModel(
const std::string &name,
bool del);
655 void clear(
bool del);
664 std::string getRawName(
const std::string &fileName, std::string *ext =
nullptr);
669 TextureMap _textures;
670 CubeMapMap _cubeMaps;
671 DepthMapMap _depthMaps;
673 MaterialMap _materials;
674 PropertiesMap _properties;
676 TextSpriteMap _textSprites;
678 MatrixStackMap _matrixStacks;
680 FramebufferMap _framebuffers;
681 DrawableMap _drawables;
683 vmml::Vector3f _ambientColor;
685 std::string _shaderVersionDesktop;
686 std::string _shaderVersionES;
bool addModel(const std::string &name, ModelPtr ptr)
Add a 3D model (returns true if successful)
Definition: ObjectManager.cpp:537
void removeDepthMap(const std::string &name, bool del)
Remove a depth map.
Definition: ObjectManager.cpp:723
std::shared_ptr< Font > FontPtr
Definition: Font.h:84
TexturePtr loadTexture(const std::string &fileName)
Load a texture.
Definition: ObjectManager.cpp:102
bool addLight(const std::string &name, LightPtr ptr)
Add a light (returns true if successful)
Definition: ObjectManager.cpp:565
bool addTexture(const std::string &name, TexturePtr ptr)
Add a texture (returns true if successful)
Definition: ObjectManager.cpp:495
TexturePtr getTexture(const std::string &name)
Get a texture.
Definition: ObjectManager.cpp:593
bool addFramebuffer(const std::string &name, FramebufferPtr ptr)
Add a framebuffer (returns true if successful)
Definition: ObjectManager.cpp:572
std::shared_ptr< Camera > CameraPtr
Definition: Camera.h:187
std::unordered_map< std::string, FontPtr > FontMap
Definition: ObjectManager.h:40
void removeModel(const std::string &name, bool del)
Remove a 3D model.
Definition: ObjectManager.cpp:749
MatrixStackPtr getMatrixStack(const std::string &name)
Get a matrix stack.
Definition: ObjectManager.cpp:656
std::unordered_map< std::string, TexturePtr > TextureMap
Definition: ObjectManager.h:37
GLuint DEFAULT_SHADER_MAX_LIGHTS()
Definition: Configuration.cpp:52
vmml::Vector3f getAmbientColor()
Get the ambient color of the scene.
Definition: ObjectManager.cpp:694
std::unordered_map< std::string, CameraPtr > CameraMap
Definition: ObjectManager.h:45
void removeDrawable(const std::string &name)
Remove a drawable.
Definition: ObjectManager.cpp:788
std::shared_ptr< Texture > TexturePtr
Definition: Texture.h:67
ShaderPtr loadShaderFile(const std::string &shaderName, GLuint shaderMaxLights=bRenderer::DEFAULT_SHADER_MAX_LIGHTS(), bool variableNumberOfLights=false, bool ambientLighting=true, bool diffuseLighting=true, bool specularLighting=true, bool cubicReflectionMap=false)
Load a shader.
Definition: ObjectManager.cpp:145
bool addCamera(const std::string &name, CameraPtr ptr)
Add a camera (returns true if successful)
Definition: ObjectManager.cpp:551
std::shared_ptr< Shader > ShaderPtr
Definition: Shader.h:211
ObjectManager()
Constructor.
Definition: ObjectManager.h:55
CameraPtr getCamera(const std::string &name)
Get a camera.
Definition: ObjectManager.cpp:649
std::unordered_map< std::string, ShaderPtr > ShaderMap
Definition: ObjectManager.h:36
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:179
std::unordered_map< std::string, FramebufferPtr > FramebufferMap
Definition: ObjectManager.h:48
CubeMapPtr createCubeMap(const std::string &name, const std::vector< TextureData > &data)
Create a cube map.
Definition: ObjectManager.cpp:330
std::unordered_map< std::string, MaterialPtr > MaterialMap
Definition: ObjectManager.h:41
PropertiesPtr getProperties(const std::string &name)
Get properties.
Definition: ObjectManager.cpp:628
MaterialPtr loadObjMaterial(const std::string &fileName, const std::string &materialName, const std::string &shaderName="", GLuint shaderMaxLights=bRenderer::DEFAULT_SHADER_MAX_LIGHTS(), bool variableNumberOfLights=false, bool ambientLighting=true)
Load a material.
Definition: ObjectManager.cpp:22
CubeMapPtr loadCubeMap(const std::string &name, const std::vector< std::string > &fileNames)
Load a cube map.
Definition: ObjectManager.cpp:116
void clear(bool del)
Clear all objects.
Definition: ObjectManager.cpp:793
void removeProperties(const std::string &name)
Remove properties.
Definition: ObjectManager.cpp:744
std::unordered_map< std::string, PropertiesPtr > PropertiesMap
Definition: ObjectManager.h:42
void removeCamera(const std::string &name)
Remove a camera.
Definition: ObjectManager.cpp:765
std::shared_ptr< DepthMap > DepthMapPtr
Definition: DepthMap.h:28
bool addProperties(const std::string &name, PropertiesPtr ptr)
Add properties (returns true if successful)
Definition: ObjectManager.cpp:530
An interface for the underlying data of a shader.
Definition: IShaderData.h:10
void setShaderVersionES(const std::string &shaderVersionES)
Set the shader version used on mobile devices systems.
Definition: ObjectManager.cpp:12
MatrixStackPtr createMatrixStack(const std::string &name)
Create a matrix stack.
Definition: ObjectManager.cpp:427
std::shared_ptr< Framebuffer > FramebufferPtr
Definition: Framebuffer.h:114
FramebufferPtr getFramebuffer(const std::string &name)
Get a framebuffer.
Definition: ObjectManager.cpp:670
TextSpritePtr createTextSprite(const std::string &name, vmml::Vector3f color, const std::string &text, FontPtr font, PropertiesPtr properties=nullptr)
Create a text sprite to display strings on the screen.
Definition: ObjectManager.cpp:289
std::string getShaderVersionDesktop()
Get the shader version used on desktop systems.
Definition: ObjectManager.cpp:684
bool addShader(const std::string &name, ShaderPtr ptr)
Add a shader (returns true if successful)
Definition: ObjectManager.cpp:488
FramebufferPtr createFramebuffer(const std::string &name)
Create a framebuffer that adjusts its size automatically according to the viewport size...
Definition: ObjectManager.cpp:472
std::unordered_map< std::string, TextSpritePtr > TextSpriteMap
Definition: ObjectManager.h:44
void removeFont(const std::string &name, bool del)
Remove a font.
Definition: ObjectManager.cpp:731
ModelPtr getModel(const std::string &name)
Get a 3D model.
Definition: ObjectManager.cpp:635
bool addDrawable(const std::string &name, DrawablePtr ptr)
Add a drawable (returns true if successful)
Definition: ObjectManager.cpp:579
void setShaderVersionDesktop(const std::string &shaderVersionDesktop)
Set the shader version used on desktop systems.
Definition: ObjectManager.cpp:7
std::unordered_map< std::string, DepthMapPtr > DepthMapMap
Definition: ObjectManager.h:39
DepthMapPtr getDepthMap(const std::string &name)
Get a depth map.
Definition: ObjectManager.cpp:607
bool addCubeMap(const std::string &name, CubeMapPtr ptr)
Add a cube map (returns true if successful)
Definition: ObjectManager.cpp:502
bool addMatrixStack(const std::string &name, MatrixStackPtr ptr)
Add a matrix stack (returns true if successful)
Definition: ObjectManager.cpp:558
DepthMapPtr createDepthMap(const std::string &name, GLint width, GLint height)
Create a depth map.
Definition: ObjectManager.cpp:361
ShaderPtr generateShader(const std::string &shaderName, GLuint shaderMaxLights, bool ambientLighting, const MaterialData &materialData, bool variableNumberOfLights, bool isText)
Generate a shader.
Definition: ObjectManager.cpp:160
void removeCubeMap(const std::string &name, bool del)
Remove a cube map.
Definition: ObjectManager.cpp:715
The underlying data of a texture.
Definition: TextureData.h:13
PropertiesPtr createProperties(const std::string &name)
Create properties.
Definition: ObjectManager.cpp:225
LightPtr getLight(const std::string &name)
Get a light.
Definition: ObjectManager.cpp:663
vmml::Vector3f DEFAULT_AMBIENT_COLOR()
Definition: Configuration.cpp:23
MaterialPtr createMaterial(const std::string &name, ShaderPtr shader)
Create empty material.
Definition: ObjectManager.cpp:182
std::unordered_map< std::string, ModelPtr > ModelMap
Definition: ObjectManager.h:43
MaterialPtr createMaterialShaderCombination(const std::string &name, const MaterialData &materialData, bool shaderFromFile, GLuint shaderMaxLights=bRenderer::DEFAULT_SHADER_MAX_LIGHTS(), bool variableNumberOfLights=false, bool ambientLighting=true, bool isText=false)
Create a material and a shader fitting its characteristics.
Definition: ObjectManager.cpp:203
std::shared_ptr< GLubyte > ImageDataPtr
Definition: TextureData.h:8
virtual ~ObjectManager()
Virtual destructor.
Definition: ObjectManager.h:64
bool addFont(const std::string &name, FontPtr ptr)
Add a font (returns true if successful)
Definition: ObjectManager.cpp:516
CubeMapPtr getCubeMap(const std::string &name)
Get a cube map.
Definition: ObjectManager.cpp:600
TexturePtr createTexture(const std::string &name, const TextureData &textureData)
Create a texture.
Definition: ObjectManager.cpp:307
FontPtr loadFont(const std::string &fileName, GLuint fontPixelSize)
Load a font (e.g. TrueType fonts (TTF) or OpenType fonts (OTF)
Definition: ObjectManager.cpp:132
void removeFramebuffer(const std::string &name, bool del)
Remove a framebuffer.
Definition: ObjectManager.cpp:780
void removeTextSprite(const std::string &name, bool del)
Remove a text sprite.
Definition: ObjectManager.cpp:757
bool addMaterial(const std::string &name, MaterialPtr ptr)
Add a material (returns true if successful)
Definition: ObjectManager.cpp:523
CameraPtr createCamera(const std::string &name)
Create a camera.
Definition: ObjectManager.cpp:391
void removeTexture(const std::string &name, bool del)
Remove a texture.
Definition: ObjectManager.cpp:707
void removeShader(const std::string &name, bool del)
Remove a shader.
Definition: ObjectManager.cpp:699
bool addDepthMap(const std::string &name, DepthMapPtr ptr)
Add a depth map (returns true if successful)
Definition: ObjectManager.cpp:509
std::string getShaderVersionES()
Get the shader version used on mobile devices systems.
Definition: ObjectManager.cpp:689
void setAmbientColor(const vmml::Vector3f &ambientColor)
Set an ambient color for the scene.
Definition: ObjectManager.cpp:17
ModelPtr loadObjModel(const std::string &fileName, bool flipT=false, bool flipZ=false, bool shaderFromFile=false, GLuint shaderMaxLights=bRenderer::DEFAULT_SHADER_MAX_LIGHTS(), bool variableNumberOfLights=false, bool ambientLighting=true, PropertiesPtr properties=nullptr)
Load a 3D model.
Definition: ObjectManager.cpp:53
std::shared_ptr< IDrawable > DrawablePtr
Definition: IDrawable.h:30
DrawablePtr getDrawable(const std::string &name)
Get a drawable.
Definition: ObjectManager.cpp:677
std::shared_ptr< TextSprite > TextSpritePtr
Definition: TextSprite.h:75
std::shared_ptr< Light > LightPtr
Definition: Light.h:127
MaterialPtr getMaterial(const std::string &name)
Get a material.
Definition: ObjectManager.cpp:621
ShaderPtr getShader(const std::string &name)
Get a shader.
Definition: ObjectManager.cpp:586
This class manages all objects in a project and makes sure no object is created twice.
Definition: ObjectManager.h:32
std::unordered_map< std::string, CubeMapPtr > CubeMapMap
Definition: ObjectManager.h:38
std::shared_ptr< ObjectManager > ObjectManagerPtr
Definition: ObjectManager.h:690
std::unordered_map< std::string, MatrixStackPtr > MatrixStackMap
Definition: ObjectManager.h:46
The underlying data of a material.
Definition: MaterialData.h:10
ModelPtr createModel(const std::string &name, const ModelData &modelData, bool shaderFromFile, GLuint shaderMaxLights=bRenderer::DEFAULT_SHADER_MAX_LIGHTS(), bool variableNumberOfLights=false, bool ambientLighting=true, PropertiesPtr properties=nullptr)
Create a model.
Definition: ObjectManager.cpp:235
std::string DEFAULT_SHADER_VERSION_DESKTOP()
Definition: Configuration.cpp:50
TextSpritePtr getTextSprite(const std::string &name)
Get a text sprite.
Definition: ObjectManager.cpp:642
std::unordered_map< std::string, DrawablePtr > DrawableMap
Definition: ObjectManager.h:49
void removeMatrixStack(const std::string &name)
Remove a matrix stack.
Definition: ObjectManager.cpp:770
Definition: ModelData.h:11
std::unordered_map< std::string, LightPtr > LightMap
Definition: ObjectManager.h:47
ModelPtr createSprite(const std::string &name, MaterialPtr material, bool flipT=false, PropertiesPtr properties=nullptr)
Create a sprite.
Definition: ObjectManager.cpp:262
void removeMaterial(const std::string &name)
Remove a material.
Definition: ObjectManager.cpp:739
FontPtr getFont(const std::string &name)
Get a font.
Definition: ObjectManager.cpp:614
bool addTextSprite(const std::string &name, TextSpritePtr ptr)
Add a text sprite (returns true if successful)
Definition: ObjectManager.cpp:544
std::shared_ptr< MatrixStack > MatrixStackPtr
Definition: MatrixStack.h:51
std::shared_ptr< CubeMap > CubeMapPtr
Definition: CubeMap.h:33
std::shared_ptr< Model > ModelPtr
Definition: Model.h:188
std::string DEFAULT_SHADER_VERSION_ES()
Definition: Configuration.cpp:51
std::shared_ptr< Material > MaterialPtr
Definition: Material.h:135
ShaderPtr createShader(const std::string &name, const IShaderData &shaderData)
Create a shader.
Definition: ObjectManager.cpp:371
void removeLight(const std::string &name)
Remove a light.
Definition: ObjectManager.cpp:775
LightPtr createLight(const std::string &name)
Create a light.
Definition: ObjectManager.cpp:436
Definition: ShaderDataGenerator.h:8