libmoldeo (Moldeo 1.0 Core)
1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
|
Clase que implementa un administrador de shaders. More...
#include <moShaderManager.h>
Public Member Functions | |
moShaderManager () | |
virtual | ~moShaderManager () |
virtual MOboolean | Init () |
virtual MOboolean | Finish () |
void | Delete () |
MOint | GetShaderIndex (moText p_name, MOboolean p_create_shader) |
MOint | AddShader (MOuint p_type, moText p_name) |
MOint | AddShader (moText p_filename) |
MOint | AddShader (MOuint p_type, moText p_name, moText p_vert_fn, moText p_frag_fn, moTexturedGrid p_tex_grid) |
MOboolean | DeleteShader (MOint p_idx) |
MOuint | GetShaderCount () |
moShader * | GetShader (MOuint p_idx) |
moTextureFilterIndex * | GetTextureFilterIndex () |
moShaderGLSL & | GetRenderShader () |
MOuint | GetRSHPositionIndex () |
MOuint | GetRSHColorsIndex () |
MOuint | GetRSHColorIndex () |
MOuint | GetRSHOpacityIndex () |
MOuint | GetRSHTextureIndex () |
MOuint | GetRSHNormalIndex () |
MOuint | GetRSHProjectionMatrixIndex () |
MOuint | GetRSHTexCoordIndex () |
MOuint | GetRSHTexCoordEdgeIndex () |
MOuint | GetRSHWireframeWidthIndex () |
MOuint | GetRSHTexWSegmentsIndex () |
MOuint | GetRSHTexHSegmentsIndex () |
MOuint | GetRSHLightIndex () |
Public Member Functions inherited from moResource | |
moResource () | |
virtual | ~moResource () |
moResourceType | GetResourceType () |
Public Member Functions inherited from moMoldeoObject | |
moMoldeoObject () | |
moMoldeoObject (moMoldeoObjectType p_type) | |
virtual | ~moMoldeoObject () |
virtual MOboolean | Init (moResourceManager *p_pResources) |
virtual MOboolean | CreateConnectors () |
virtual MOboolean | UpdateConnectors () |
virtual MOboolean | RefreshValue (moParam ¶m, int value_index) |
virtual MOboolean | ResolveValue (moParam ¶m, int value_index, bool p_refresh=false) |
virtual void | Update (moEventList *p_EventList) |
void | SetResourceManager (moResourceManager *p_pResourceManager) |
moResourceManager * | GetResourceManager () |
MOint | GetId () const |
void | SetId (MOint p_id) |
moMoldeoObjectType | GetType () const |
void | SetType (moMoldeoObjectType p_type) |
void | SetName (const moText &p_name) |
void | SetLabelName (const moText &p_labelname) |
void | SetKeyName (const moText &p_keyname) |
const moText & | GetKeyName () const |
const moText & | GetName () const |
const moText & | GetLabelName () const |
moConfig * | GetConfig () |
void | SyncConnections () |
virtual int | Save (const moText &p_save_filename=moText("")) |
void | SetConfigName (const moText &p_configname) |
const moText & | GetConfigName () const |
const moText & | GetDescription () const |
Devuelve al descripción del objeto. More... | |
void | SetDescription (const moText &p_Description) |
Fija la descripción de este objeto. More... | |
const moMobDefinition & | GetMobDefinition () const |
void | SetMobDefinition (const moMobDefinition &p_MobDef) |
virtual moConfigDefinition * | GetDefinition (moConfigDefinition *p_configdefinition=NULL) |
moOutlets * | GetOutlets () |
moInlets * | GetInlets () |
MOint | GetInletIndex (moText p_connector_name) const |
MOint | GetOutletIndex (moText p_connector_name) const |
virtual void | RegisterFunctions () |
beware ! call only once or die!!! More... | |
virtual int | ScriptCalling (moLuaVirtualMachine &vm, int iFunctionNumber) |
virtual void | HandleReturns (moLuaVirtualMachine &vm, const char *strFunc) |
virtual const moMobState & | GetState () const |
virtual bool | SetState (const moMobState &p_MobState) |
virtual void | Activate () |
virtual void | Deactivate () |
virtual bool | Activated () const |
virtual void | Select () |
virtual void | Unselect () |
virtual bool | Selected () const |
virtual void | SetConsoleParamIndex (MOint p_paramindex) |
virtual void | SetConsoleValueIndex (MOint p_valueindex) |
virtual const moText & | ToJSON () |
Public Member Functions inherited from moAbstract | |
moAbstract () | |
virtual | ~moAbstract () |
MOboolean | Initialized () |
Pregunta si está inicializado. More... | |
Public Member Functions inherited from moScript | |
moScript () | |
virtual | ~moScript (void) |
void | InitScript () |
void | FinishScript () |
bool | IsInitialized () |
bool | CompileFile (const char *strFilename) |
bool | CompileBuffer (unsigned char *pbBuffer, size_t szLen) |
int | RegisterFunction (const char *strFuncName, moScript::Function &fun) |
int | RegisterFunction (const char *strFuncName) |
int | RegisterBaseFunction (const char *strFuncName) |
bool | SelectScriptFunction (const char *strFuncName) |
void | AddFunctionParam (int iInt) |
void | AddFunctionParam (float fFloat) |
void | AddFunctionParam (char *string) |
bool | RunSelectedFunction (int nReturns=0) |
bool | ScriptHasFunction (const char *strScriptName) |
int | methods (void) |
virtual int | ResetScriptCalling () |
virtual int | NextScriptCalling () |
moLuaVirtualMachine & | mvm (void) |
Clase que implementa un administrador de shaders.
Clase que implementa un administrador de shaders.
Definition at line 55 of file moShaderManager.h.
moShaderManager::moShaderManager | ( | ) |
El constructor por defecto de la clase.
Definition at line 251 of file moShaderManager.cpp.
|
inlinevirtual |
El destructor por defecto de la clase.
Definition at line 66 of file moShaderManager.h.
Agrega un shader de tipo p_type (MO_SHADER_GLSL o MO_SHADER_CG) en blanco, es decir, sin vértices de fragmentos o vértices asociados al mismo.
p_type | especifica si el shader es CG o GLSL. |
p_name | nombre del shader a crear. |
Definition at line 294 of file moShaderManager.cpp.
Agrega un shader especificado en el archivo de configuración p_filename. Este archivo contiene la siguiente información: el tipo de shader (CG o GLSL), los archivos contieniendo el código de los shaders de vértices y fragmentos, y la configuración de la grilla 2D utilizada para implementar deformaciones de texturas.
Definition at line 326 of file moShaderManager.cpp.
MOint moShaderManager::AddShader | ( | MOuint | p_type, |
moText | p_name, | ||
moText | p_vert_fn, | ||
moText | p_frag_fn, | ||
moTexturedGrid | p_tex_grid | ||
) |
Agrega un shader de tipo p_type (MO_SHADER_GLSL o MO_SHADER_CG), carga en el mismo los shaders de vértices y fragmentos cuyo código está contenido en los archivos especificados, y asocia la grilla pasada como parámetro.
p_type | especifica si el shader es CG o GLSL. |
p_name | nombre del shader a crear. |
p_vert_fn | archivo con el código del shader de vértices. |
p_vert_fn | archivo con el código del shader de fragmentos. |
p_tex_grid | objeto de grilla 2D para deformación de texturas. |
Definition at line 419 of file moShaderManager.cpp.
|
inline |
Elimina todos los shaders cargados hasta el momento.
Definition at line 83 of file moShaderManager.h.
Elimina el shader con índice p_idx.
p_idx | índice del shader a eliminar. |
Definition at line 433 of file moShaderManager.cpp.
|
virtual |
Método de finalización.
Reimplemented from moResource.
Definition at line 267 of file moShaderManager.cpp.
|
inline |
Definition at line 145 of file moShaderManager.h.
|
inline |
Definition at line 157 of file moShaderManager.h.
|
inline |
Definition at line 153 of file moShaderManager.h.
|
inline |
Definition at line 195 of file moShaderManager.h.
|
inline |
Definition at line 169 of file moShaderManager.h.
|
inline |
Definition at line 161 of file moShaderManager.h.
|
inline |
Definition at line 149 of file moShaderManager.h.
|
inline |
Definition at line 173 of file moShaderManager.h.
|
inline |
Definition at line 181 of file moShaderManager.h.
|
inline |
Definition at line 177 of file moShaderManager.h.
|
inline |
Definition at line 192 of file moShaderManager.h.
|
inline |
Definition at line 165 of file moShaderManager.h.
|
inline |
Definition at line 189 of file moShaderManager.h.
|
inline |
Definition at line 185 of file moShaderManager.h.
Devuelve un puntero al shader con índice p_idx.
p_idx | índice del shader . |
Definition at line 139 of file moShaderManager.h.
|
inline |
Devuelve el número de shaders.
Definition at line 133 of file moShaderManager.h.
Devuelve el índice del shader con nombre p_name. Si el shader no existe y p_create_shader es true, entonces intenta crear un nuevo shader interpretando a p_name como el nombre del archivo de configuración del mismo.
p_name | nombre del shader a buscar. |
p_create_shader | si es true intenta crear el shader si el mismo no es encontrado. |
Definition at line 282 of file moShaderManager.cpp.
|
inline |
Definition at line 141 of file moShaderManager.h.
|
virtual |
Método de inicialización.
#version 150
uniform mat4 model; uniform vec3 cameraPosition;
material settings uniform sampler2D materialTex; uniform float materialShininess; uniform vec3 materialSpecularColor;
uniform struct Light { vec3 position; vec3 intensities; //a.k.a the color of the light float attenuation; float ambientCoefficient; } light;
in vec2 fragTexCoord; in vec3 fragNormal; in vec3 fragVert;
out vec4 finalColor;
void main() { vec3 normal = normalize(transpose(inverse(mat3(model))) * fragNormal); vec3 surfacePos = vec3(model * vec4(fragVert, 1)); vec4 surfaceColor = texture(materialTex, fragTexCoord); vec3 surfaceToLight = normalize(light.position - surfacePos); vec3 surfaceToCamera = normalize(cameraPosition - surfacePos);
ambient vec3 ambient = light.ambientCoefficient * surfaceColor.rgb * light.intensities;
diffuse float diffuseCoefficient = max(0.0, dot(normal, surfaceToLight)); vec3 diffuse = diffuseCoefficient * surfaceColor.rgb * light.intensities;
specular float specularCoefficient = 0.0; if(diffuseCoefficient > 0.0) specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normal))), materialShininess); vec3 specular = specularCoefficient * materialSpecularColor * light.intensities;
attenuation float distanceToLight = length(light.position - surfacePos); float attenuation = 1.0 / (1.0 + light.attenuation * pow(distanceToLight, 2));
linear color (color before gamma correction) vec3 linearColor = ambient + attenuation*(diffuse + specular);
final color (after gamma correction) vec3 gamma = vec3(1.0/2.2); finalColor = vec4(pow(linearColor, gamma), surfaceColor.a); }
check moResourceInit
Reimplemented from moResource.
Definition at line 101 of file moShaderManager.cpp.