Neo  0.5.0
Developer Documentation
Neo::Level Class Reference

The Level class contains all scenes and assets that are loaded. More...

#include <Level.h>

Public Member Functions

 Level (void)
 
 ~Level (void)
 
void clear (void)
 
void clearScenes (void)
 
FXManagergetFXManager (void)
 
FXRefcreateFX (ShaderRef *vertexShaderRef, ShaderRef *pixelShaderRef)
 
DataManagergetFontManager (void)
 
DataManagergetTextureManager (void)
 
DataManagergetShaderManager (void)
 
DataManagergetSoundManager (void)
 
DataManagergetMeshManager (void)
 
DataManagergetArmatureAnimManager (void)
 
DataManagergetTexturesAnimManager (void)
 
DataManagergetMaterialsAnimManager (void)
 
FontRefloadFont (const char *filename, unsigned int fontsize=128)
 Loads a font from a file and returns the new FontRef object. More...
 
MeshRefloadMesh (const char *filename, const bool preload=true)
 Loads a mesh from a file and returns the new MeshRef object. More...
 
ArmatureAnimRefloadArmatureAnim (const char *filename, const bool preload=true)
 
TexturesAnimRefloadTexturesAnim (const char *filename, const bool preload=true)
 
MaterialsAnimRefloadMaterialsAnim (const char *filename, const bool preload=true)
 
TextureRefloadTexture (const char *filename, const bool mipmap=true, const bool preload=true)
 Loads a texture from a file and returns the new TextureRef object. More...
 
SoundRefloadSound (const char *filename, const bool preload=true)
 Loads a sound from a file and returns the new SoundRef object. More...
 
ShaderRefloadShader (const char *filename, M_SHADER_TYPES type)
 
void sendToUpdateQueue (DataRef *ref)
 Appends a DataRef to the update queue. More...
 
void sendToClearQueue (DataRef *ref)
 Appends a DataRef to the clear queue. More...
 
void updateQueueDatas (void)
 Updates all DataRef's in the update queue. More...
 
void clearQueueDatas (void)
 Clear all DataRef's in the clear queue. More...
 
void changeCurrentScene (unsigned int id)
 Changes the current scene to the scene with the given ID. More...
 
void deleteScene (unsigned int id)
 Deletes the scene with the given ID. More...
 
bool getSceneIndexByName (const char *name, unsigned int *index)
 Retrieves the index of the scene with the given name. More...
 
SceneaddNewScene (void)
 Creates a new scene and returns a pointer to it. More...
 
ScenegetSceneByName (const char *name)
 Retrieves the scene with the given name. More...
 
ScenegetCurrentScene (void)
 Returns the current main scene. More...
 
void setCurrentSceneId (unsigned int id)
 Changes the current scene. More...
 
void setCurrentScene (Scene *s)
 
unsigned int getCurrentSceneId (void)
 Returns the current scene ID. More...
 
unsigned int getScenesNumber (void)
 Returns the number of scenes. More...
 
ScenegetSceneByIndex (unsigned int id)
 Searches the scene with the given ID. More...
 

Friends

class NeoEngine
 

Detailed Description

The Level class contains all scenes and assets that are loaded.

When loading a level, all assets like textures, shaders, fonts, sounds and meshes are only loaded once into memory for a maximum of efficiency. As soon as an asset is not used anymore it will be unloaded and the RAM it used will be free'd what allows to clean up during runtime.

Constructor & Destructor Documentation

Neo::Level::Level ( void  )
Neo::Level::~Level ( void  )

Member Function Documentation

Scene* Neo::Level::addNewScene ( void  )

Creates a new scene and returns a pointer to it.

Returns
The new scene
void Neo::Level::changeCurrentScene ( unsigned int  id)

Changes the current scene to the scene with the given ID.

The scene will not change straight away but it will be merely requested to do so in one of the next frames.

Parameters
idThe new scene ID
void Neo::Level::clear ( void  )
void Neo::Level::clearQueueDatas ( void  )

Clear all DataRef's in the clear queue.

This will call DataRef::clear for every object that is currently in the queue. The queue will be emptied so new requests can be handled.

void Neo::Level::clearScenes ( void  )
FXRef* Neo::Level::createFX ( ShaderRef vertexShaderRef,
ShaderRef pixelShaderRef 
)
void Neo::Level::deleteScene ( unsigned int  id)

Deletes the scene with the given ID.

Parameters
idThe ID of the scene
DataManager* Neo::Level::getArmatureAnimManager ( void  )
inline
Scene* Neo::Level::getCurrentScene ( void  )

Returns the current main scene.

Returns
The current scene.
unsigned int Neo::Level::getCurrentSceneId ( void  )
inline

Returns the current scene ID.

Returns
The ID of the current scene.
DataManager* Neo::Level::getFontManager ( void  )
inline
FXManager* Neo::Level::getFXManager ( void  )
inline
DataManager* Neo::Level::getMaterialsAnimManager ( void  )
inline
DataManager* Neo::Level::getMeshManager ( void  )
inline
Scene* Neo::Level::getSceneByIndex ( unsigned int  id)
inline

Searches the scene with the given ID.

Returns
The searched scene object.
Scene* Neo::Level::getSceneByName ( const char *  name)

Retrieves the scene with the given name.

Parameters
nameThe name to search for
Returns
The scene
bool Neo::Level::getSceneIndexByName ( const char *  name,
unsigned int *  index 
)

Retrieves the index of the scene with the given name.

The ID will be saved into the given pointer.

Parameters
nameThe name to search for
indexThe pointer to an integer to save the ID
Returns
Returns false if the scene can not be found.
unsigned int Neo::Level::getScenesNumber ( void  )
inline

Returns the number of scenes.

Returns
The number of scenes.
DataManager* Neo::Level::getShaderManager ( void  )
inline
DataManager* Neo::Level::getSoundManager ( void  )
inline
DataManager* Neo::Level::getTextureManager ( void  )
inline
DataManager* Neo::Level::getTexturesAnimManager ( void  )
inline
ArmatureAnimRef* Neo::Level::loadArmatureAnim ( const char *  filename,
const bool  preload = true 
)
FontRef* Neo::Level::loadFont ( const char *  filename,
unsigned int  fontsize = 128 
)

Loads a font from a file and returns the new FontRef object.

This method will never return NULL, even if the specified file does not exist or can not be read!

This means you have to ensure the file exists before calling this method!

Parameters
filenameThe path to the file.
sizeThe font size to load.
Returns
The new FontRef object.
MaterialsAnimRef* Neo::Level::loadMaterialsAnim ( const char *  filename,
const bool  preload = true 
)
MeshRef* Neo::Level::loadMesh ( const char *  filename,
const bool  preload = true 
)

Loads a mesh from a file and returns the new MeshRef object.

This method will never return NULL, even if the specified file does not exist or can not be read!

This means you have to ensure the file exists before calling this method!

Parameters
filenameThe file to load from.
Returns
The new MeshRef
ShaderRef* Neo::Level::loadShader ( const char *  filename,
M_SHADER_TYPES  type 
)
SoundRef* Neo::Level::loadSound ( const char *  filename,
const bool  preload = true 
)

Loads a sound from a file and returns the new SoundRef object.

This method will never return NULL, even if the specified file does not exist or can not be read!

This means you have to ensure the file exists before calling this method!

Parameters
filenameThe file to load from.
Returns
The new SoundRef
TextureRef* Neo::Level::loadTexture ( const char *  filename,
const bool  mipmap = true,
const bool  preload = true 
)

Loads a texture from a file and returns the new TextureRef object.

This method will never return NULL, even if the specified file does not exist or can not be read!

This means you have to ensure the file exists before calling this method!

Parameters
filenameThe file to load from.
mipmapIndicates if a mip map should be generated for this texture.
Returns
The new TextureRef
TexturesAnimRef* Neo::Level::loadTexturesAnim ( const char *  filename,
const bool  preload = true 
)
void Neo::Level::sendToClearQueue ( DataRef ref)

Appends a DataRef to the clear queue.

Parameters
refThe DataRef object.
void Neo::Level::sendToUpdateQueue ( DataRef ref)

Appends a DataRef to the update queue.

Parameters
refThe DataRef object.
void Neo::Level::setCurrentScene ( Scene s)
inline
void Neo::Level::setCurrentSceneId ( unsigned int  id)

Changes the current scene.

Parameters
idThe ID of the new scene.
void Neo::Level::updateQueueDatas ( void  )

Updates all DataRef's in the update queue.

This will call DataRef::update for every object that is currently in the queue. The queue will be emptied so new requests can be handled.

Friends And Related Function Documentation

friend class NeoEngine
friend

The documentation for this class was generated from the following file: