Robotran C Documentation
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OglShapeRenderer Class Reference

OglShapeRenderer class is an implementation of MbsShapeRenderer that render a MbsShape3D using Open GL. More...

#include <OglShapeRenderer.hh>

Inheritance diagram for OglShapeRenderer:
MbsShapeRenderer

Public Member Functions

 OglShapeRenderer (std::string vertex_file, std::string fragment_file, MbsWorld3D *w, OglWorldRenderer *world_rend)
 Constructor. More...
 
virtual ~OglShapeRenderer ()
 destructor of the OglShapeRenderer More...
 
virtual void Init (std::vector< glm::vec3 > vertices, std::vector< glm::vec3 > colors, std::vector< glm::vec3 > normals, std::vector< unsigned int > indexes)
 Init the current shape renderer: create Ogl object necessary to represnet the shape. More...
 
virtual void Update (glm::mat4 model_mat, glm::mat4 MVP, glm::mat3 M_inv_trans, MbsWorld3D *world_3d, float shiny_mat, glm::vec3 const &specular_mat, float transparency)
 Execute the necessary code to render this shape: Update the Ogl transform and add it to the pipeline. More...
 
virtual void ShadowDepth (int index)
 update of the shadow depth buffer More...
 
virtual void SetModelMat (glm::mat4 const &model_mat)
 set the model matrix More...
 

Protected Member Functions

void LightsInit (float shiny_mat, glm::vec3 const &specular_mat, float transparency)
 initalize the lights More...
 
void LightsUpdate ()
 update the lights More...
 
std::string StringLoc (const char *fieldName, size_t index)
 generate a string to get the location of a specific field (to communicate with fragment shader), without property More...
 
std::string StringLoc (const char *fieldName, const char *propertyName, size_t index)
 generate a string to get the location of a specific field (to communicate with fragment shader), with property More...
 
void MVPDepth (int index)
 update mvpDepth and depthBiasMVP (uniform matrices for shadow shaders) More...
 

Protected Attributes

glm::mat4 model_mat
 model matrix ==> the same as the one stored in MbsShape3D More...
 
int nb_indexes
 size of the indexes vector More...
 
MbsWorld3D * world_3d
 3D world More...
 
OglWorldRendererworld_rend
 reference to the world renderer that creat this shape renderer More...
 
std::vector< ShaderLightsh_lights
 shaders for lights More...
 
int shader_flag
 flag for shaders More...
 
Shader shader
 main shader More...
 
Shader * depth_shader
 depth shader More...
 
std::vector< GLuint > lightPosID
 ID of the light position. More...
 
std::vector< GLuint > lightColID
 ID of the light color. More...
 
std::vector< GLuint > lightAttID
 ID of the light attenuation. More...
 
std::vector< GLuint > lightAmbID
 ID of the light ambiance. More...
 
std::vector< GLuint > lightConAngID
 ID of the light cone angle (for spots) More...
 
std::vector< GLuint > lightConDirID
 ID of the light cone direction (for spots) More...
 
GLuint mvpID
 ID of the MVP matrix. More...
 
GLuint modelMatID
 ID of the model matrix. More...
 
GLuint MInvTransID
 ID of transpose and inverse of the model matrix. More...
 
glm::mat4 biasMatrix
 bias matrix More...
 
std::vector< glm::mat4 > mvpDepth
 MVP depth matrix. More...
 
std::vector< glm::mat4 > depthBiasMVP
 depth bias More...
 
std::string depth_vert_sh
 vertex depth shader path More...
 
std::string depth_frag_sh
 fragment depth shader path More...
 
bool light_init
 flag to know if the ligth is initialized More...
 
GLuint VAO_id
 VAO. More...
 
GLuint VBO_vertex_id
 VBO for vertices. More...
 
GLuint VBO_color_id
 VBO for colors. More...
 
GLuint VBO_normal_id
 VBO for normals. More...
 
GLuint VBO_indexes_id
 VBO for indexes. More...
 
GLuint transID
 ID of the transparency. More...
 
GLuint nbLightsID
 ID of the number of lights. More...
 
GLuint cameraID
 ID of the camera. More...
 
GLuint shininessID
 ID of the shininess (shape material) More...
 
GLuint specularID
 ID of the specular value (shape material) More...
 
std::vector< GLuint > depthBiasID
 ID of the depth bias. More...
 
std::vector< GLuint > shadowMapID
 ID of the shadow map. More...
 
std::vector< GLuint > shadowBiasID
 ID of the shadow bias. More...
 
std::vector< GLuint > spreadID
 ID of the spread factor for Poisson disk. More...
 
std::vector< GLuint > mvpDepthID
 ID of the depth matrices MVP. More...
 
std::vector< GLuint > frameBuffer
 frame buffer More...
 
std::vector< GLuint > depthTexture
 depth textures More...
 
std::vector< int > depth_semi_x_width
 X semi width of the shadow map depth textures (in pixels) More...
 
std::vector< int > depth_semi_y_width
 X semi width of the shadow map depth textures (in pixels) More...
 
std::vector< float > depth_ratio_width
 ration between the X and Y width components of the depth texture More...
 

Detailed Description

OglShapeRenderer class is an implementation of MbsShapeRenderer that render a MbsShape3D using Open GL.

Constructor & Destructor Documentation

◆ OglShapeRenderer()

OglShapeRenderer ( std::string  vertex_file,
std::string  fragment_file,
MbsWorld3D *  wrld3d,
OglWorldRenderer wr 
)

Constructor.

constructor of an OglShapeRenderer

OglShapeRenderer implements the necessary functions to render a MbsShape3D using OpenGL.

Parameters
[in]vertex_filevertex shader file to load (with path)
[in]fragment_filefragment shader file to load (with path)
[in]world_3d3D world
[in]wrthe MbsWorldRenderer object associated to this renderer

◆ ~OglShapeRenderer()

~OglShapeRenderer ( )
virtual

destructor of the OglShapeRenderer

Member Function Documentation

◆ Init()

void Init ( std::vector< glm::vec3 >  vertices,
std::vector< glm::vec3 >  colors,
std::vector< glm::vec3 >  normals,
std::vector< unsigned int >  indexes 
)
virtual

Init the current shape renderer: create Ogl object necessary to represnet the shape.

initialize the shape renderer by giving the parameters of the shape (vertices, colors, normals, ...)

Parameters
[in]verticesthe vertices of the shape that must be rendered by this ShapeRenderer
[in]colorsthe colors associated to the vertices defined in vertices
[in]normalsthe normals associated to the vertices defined in vertices
[in]indexesthe vertex indices defining the triangles of the shape (i.e. the connectivity)

Implements MbsShapeRenderer.

◆ LightsInit()

void LightsInit ( float  shiny_mat,
glm::vec3 const &  specular_mat,
float  transparency 
)
protected

initalize the lights

◆ LightsUpdate()

void LightsUpdate ( )
protected

update the lights

◆ MVPDepth()

void MVPDepth ( int  index)
protected

update mvpDepth and depthBiasMVP (uniform matrices for shadow shaders)

Parameters
[in]indexID of the current active light, and so the current depth texture

◆ SetModelMat()

virtual void SetModelMat ( glm::mat4 const &  model_mat)
inlinevirtual

set the model matrix

Implements MbsShapeRenderer.

◆ ShadowDepth()

void ShadowDepth ( int  index)
virtual

update of the shadow depth buffer

Parameters
[in]indexID of the current active light, and so the current depth texture

Implements MbsShapeRenderer.

◆ StringLoc() [1/2]

std::string StringLoc ( const char *  fieldName,
const char *  propertyName,
size_t  index 
)
protected

generate a string to get the location of a specific field (to communicate with fragment shader), with property

Parameters
[in]fieldNamename of the field
[in]propertyNamename of the property
[in]indexID
Returns
requested string

◆ StringLoc() [2/2]

std::string StringLoc ( const char *  fieldName,
size_t  index 
)
protected

generate a string to get the location of a specific field (to communicate with fragment shader), without property

Parameters
[in]fieldNamename of the field
[in]indexID
Returns
requested string

◆ Update()

void Update ( glm::mat4  model_mat,
glm::mat4  MVP,
glm::mat3  M_inv_trans,
MbsWorld3D *  world_3d,
float  shiny_mat,
glm::vec3 const &  specular_mat,
float  transparency 
)
virtual

Execute the necessary code to render this shape: Update the Ogl transform and add it to the pipeline.

update the shape position

Parameters
[in]model_matthe transformation matrix setting the position/orientation of the shape
[in]MVPthe transformation matrix from the model to the view
[in]M_inv_transthe inverse of the transformation matrix
[in]world_3dthe MbsWorld3D in which the shape must be rendered
[in]shiny_matthe shiny_mat property of the shape
[in]specular_matthe specular_mat property of the shape
[in]transparencythe transparency property of the shape

Implements MbsShapeRenderer.

Member Data Documentation

◆ biasMatrix

glm::mat4 biasMatrix
protected

bias matrix

◆ cameraID

GLuint cameraID
protected

ID of the camera.

◆ depth_frag_sh

std::string depth_frag_sh
protected

fragment depth shader path

◆ depth_ratio_width

std::vector<float> depth_ratio_width
protected

ration between the X and Y width components of the depth texture

◆ depth_semi_x_width

std::vector<int> depth_semi_x_width
protected

X semi width of the shadow map depth textures (in pixels)

◆ depth_semi_y_width

std::vector<int> depth_semi_y_width
protected

X semi width of the shadow map depth textures (in pixels)

◆ depth_shader

Shader* depth_shader
protected

depth shader

◆ depth_vert_sh

std::string depth_vert_sh
protected

vertex depth shader path

◆ depthBiasID

std::vector<GLuint> depthBiasID
protected

ID of the depth bias.

◆ depthBiasMVP

std::vector<glm::mat4> depthBiasMVP
protected

depth bias

◆ depthTexture

std::vector<GLuint> depthTexture
protected

depth textures

◆ frameBuffer

std::vector<GLuint> frameBuffer
protected

frame buffer

◆ light_init

bool light_init
protected

flag to know if the ligth is initialized

◆ lightAmbID

std::vector<GLuint> lightAmbID
protected

ID of the light ambiance.

◆ lightAttID

std::vector<GLuint> lightAttID
protected

ID of the light attenuation.

◆ lightColID

std::vector<GLuint> lightColID
protected

ID of the light color.

◆ lightConAngID

std::vector<GLuint> lightConAngID
protected

ID of the light cone angle (for spots)

◆ lightConDirID

std::vector<GLuint> lightConDirID
protected

ID of the light cone direction (for spots)

◆ lightPosID

std::vector<GLuint> lightPosID
protected

ID of the light position.

◆ MInvTransID

GLuint MInvTransID
protected

ID of transpose and inverse of the model matrix.

◆ model_mat

glm::mat4 model_mat
protected

model matrix ==> the same as the one stored in MbsShape3D

◆ modelMatID

GLuint modelMatID
protected

ID of the model matrix.

◆ mvpDepth

std::vector<glm::mat4> mvpDepth
protected

MVP depth matrix.

◆ mvpDepthID

std::vector<GLuint> mvpDepthID
protected

ID of the depth matrices MVP.

◆ mvpID

GLuint mvpID
protected

ID of the MVP matrix.

◆ nb_indexes

int nb_indexes
protected

size of the indexes vector

◆ nbLightsID

GLuint nbLightsID
protected

ID of the number of lights.

◆ sh_lights

std::vector<ShaderLight> sh_lights
protected

shaders for lights

◆ shader

Shader shader
protected

main shader

◆ shader_flag

int shader_flag
protected

flag for shaders

◆ shadowBiasID

std::vector<GLuint> shadowBiasID
protected

ID of the shadow bias.

◆ shadowMapID

std::vector<GLuint> shadowMapID
protected

ID of the shadow map.

◆ shininessID

GLuint shininessID
protected

ID of the shininess (shape material)

◆ specularID

GLuint specularID
protected

ID of the specular value (shape material)

◆ spreadID

std::vector<GLuint> spreadID
protected

ID of the spread factor for Poisson disk.

◆ transID

GLuint transID
protected

ID of the transparency.

◆ VAO_id

GLuint VAO_id
protected

VAO.

◆ VBO_color_id

GLuint VBO_color_id
protected

VBO for colors.

◆ VBO_indexes_id

GLuint VBO_indexes_id
protected

VBO for indexes.

◆ VBO_normal_id

GLuint VBO_normal_id
protected

VBO for normals.

◆ VBO_vertex_id

GLuint VBO_vertex_id
protected

VBO for vertices.

◆ world_3d

MbsWorld3D* world_3d
protected

3D world

◆ world_rend

OglWorldRenderer* world_rend
protected

reference to the world renderer that creat this shape renderer


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