|
@@ -35,6 +35,8 @@ void mesh_node_t::Deinit()
|
|
|
/// Called in material or blending stages
|
|
/// Called in material or blending stages
|
|
|
void mesh_node_t::Render()
|
|
void mesh_node_t::Render()
|
|
|
{
|
|
{
|
|
|
|
|
+ const material_t* mtl = material;
|
|
|
|
|
+
|
|
|
glPushMatrix();
|
|
glPushMatrix();
|
|
|
r::MultMatrix( transformation_wspace );
|
|
r::MultMatrix( transformation_wspace );
|
|
|
|
|
|
|
@@ -42,49 +44,49 @@ void mesh_node_t::Render()
|
|
|
if( skel_controller )
|
|
if( skel_controller )
|
|
|
{
|
|
{
|
|
|
// first the uniforms
|
|
// first the uniforms
|
|
|
- glUniformMatrix3fv( material->uni_locs.skinning_rotations, skel_controller->skel_node->skeleton->bones.size(), 1,
|
|
|
|
|
|
|
+ glUniformMatrix3fv( mtl->uni_locs.skinning_rotations, skel_controller->skel_node->skeleton->bones.size(), 1,
|
|
|
&(skel_controller->skel_node->skel_anim_controller->bone_rotations[0])[0] );
|
|
&(skel_controller->skel_node->skel_anim_controller->bone_rotations[0])[0] );
|
|
|
- glUniform3fv( material->uni_locs.skinning_translations, skel_controller->skel_node->skeleton->bones.size(),
|
|
|
|
|
|
|
+ glUniform3fv( mtl->uni_locs.skinning_translations, skel_controller->skel_node->skeleton->bones.size(),
|
|
|
&(skel_controller->skel_node->skel_anim_controller->bone_translations[0])[0] );
|
|
&(skel_controller->skel_node->skel_anim_controller->bone_translations[0])[0] );
|
|
|
|
|
|
|
|
// then the attributes
|
|
// then the attributes
|
|
|
- DEBUG_ERR( material->attrib_locs.vert_weight_bones_num == -1 );
|
|
|
|
|
|
|
+ DEBUG_ERR( mtl->attrib_locs.vert_weight_bones_num == -1 );
|
|
|
|
|
|
|
|
mesh->vbos.vert_weights.Bind();
|
|
mesh->vbos.vert_weights.Bind();
|
|
|
- glEnableVertexAttribArray( material->attrib_locs.vert_weight_bones_num );
|
|
|
|
|
- glVertexAttribPointer( material->attrib_locs.vert_weight_bones_num, 1, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(0) );
|
|
|
|
|
- glEnableVertexAttribArray( material->attrib_locs.vert_weight_bone_ids );
|
|
|
|
|
- glVertexAttribPointer( material->attrib_locs.vert_weight_bone_ids, 4, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(4) );
|
|
|
|
|
- glEnableVertexAttribArray( material->attrib_locs.vert_weight_weights );
|
|
|
|
|
- glVertexAttribPointer( material->attrib_locs.vert_weight_weights, 4, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(20) );
|
|
|
|
|
|
|
+ glEnableVertexAttribArray( mtl->attrib_locs.vert_weight_bones_num );
|
|
|
|
|
+ glVertexAttribPointer( mtl->attrib_locs.vert_weight_bones_num, 1, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(0) );
|
|
|
|
|
+ glEnableVertexAttribArray( mtl->attrib_locs.vert_weight_bone_ids );
|
|
|
|
|
+ glVertexAttribPointer( mtl->attrib_locs.vert_weight_bone_ids, 4, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(4) );
|
|
|
|
|
+ glEnableVertexAttribArray( mtl->attrib_locs.vert_weight_weights );
|
|
|
|
|
+ glVertexAttribPointer( mtl->attrib_locs.vert_weight_weights, 4, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(20) );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( material->attrib_locs.position != -1 )
|
|
|
|
|
|
|
+ if( mtl->attrib_locs.position != -1 )
|
|
|
{
|
|
{
|
|
|
mesh->vbos.vert_coords.Bind();
|
|
mesh->vbos.vert_coords.Bind();
|
|
|
- glVertexAttribPointer( material->attrib_locs.position, 3, GL_FLOAT, false, 0, NULL );
|
|
|
|
|
- glEnableVertexAttribArray( material->attrib_locs.position );
|
|
|
|
|
|
|
+ glVertexAttribPointer( mtl->attrib_locs.position, 3, GL_FLOAT, false, 0, NULL );
|
|
|
|
|
+ glEnableVertexAttribArray( mtl->attrib_locs.position );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( material->attrib_locs.normal != -1 )
|
|
|
|
|
|
|
+ if( mtl->attrib_locs.normal != -1 )
|
|
|
{
|
|
{
|
|
|
mesh->vbos.vert_normals.Bind();
|
|
mesh->vbos.vert_normals.Bind();
|
|
|
- glVertexAttribPointer( material->attrib_locs.normal, 3, GL_FLOAT, false, 0, NULL );
|
|
|
|
|
- glEnableVertexAttribArray( material->attrib_locs.normal );
|
|
|
|
|
|
|
+ glVertexAttribPointer( mtl->attrib_locs.normal, 3, GL_FLOAT, false, 0, NULL );
|
|
|
|
|
+ glEnableVertexAttribArray( mtl->attrib_locs.normal );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( material->attrib_locs.tex_coords != -1 )
|
|
|
|
|
|
|
+ if( mtl->attrib_locs.tex_coords != -1 )
|
|
|
{
|
|
{
|
|
|
mesh->vbos.tex_coords.Bind();
|
|
mesh->vbos.tex_coords.Bind();
|
|
|
- glVertexAttribPointer( material->attrib_locs.tex_coords, 2, GL_FLOAT, false, 0, NULL );
|
|
|
|
|
- glEnableVertexAttribArray( material->attrib_locs.tex_coords );
|
|
|
|
|
|
|
+ glVertexAttribPointer( mtl->attrib_locs.tex_coords, 2, GL_FLOAT, false, 0, NULL );
|
|
|
|
|
+ glEnableVertexAttribArray( mtl->attrib_locs.tex_coords );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if( material->attrib_locs.tanget != -1 )
|
|
|
|
|
|
|
+ if( mtl->attrib_locs.tanget != -1 )
|
|
|
{
|
|
{
|
|
|
mesh->vbos.vert_tangents.Bind();
|
|
mesh->vbos.vert_tangents.Bind();
|
|
|
- glVertexAttribPointer( material->attrib_locs.tanget, 4, GL_FLOAT, false, 0, NULL );
|
|
|
|
|
- glEnableVertexAttribArray( material->attrib_locs.tanget );
|
|
|
|
|
|
|
+ glVertexAttribPointer( mtl->attrib_locs.tanget, 4, GL_FLOAT, false, 0, NULL );
|
|
|
|
|
+ glEnableVertexAttribArray( mtl->attrib_locs.tanget );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
mesh->vbos.vert_indeces.Bind();
|
|
mesh->vbos.vert_indeces.Bind();
|
|
@@ -92,16 +94,16 @@ void mesh_node_t::Render()
|
|
|
glDrawElements( GL_TRIANGLES, mesh->vert_indeces.size(), GL_UNSIGNED_SHORT, 0 );
|
|
glDrawElements( GL_TRIANGLES, mesh->vert_indeces.size(), GL_UNSIGNED_SHORT, 0 );
|
|
|
|
|
|
|
|
// disable
|
|
// disable
|
|
|
- if( material->attrib_locs.position != -1 ) glDisableVertexAttribArray( material->attrib_locs.position );
|
|
|
|
|
- if( material->attrib_locs.normal != -1 ) glDisableVertexAttribArray( material->attrib_locs.normal );
|
|
|
|
|
- if( material->attrib_locs.tex_coords != -1 ) glDisableVertexAttribArray( material->attrib_locs.tex_coords );
|
|
|
|
|
- if( material->attrib_locs.tanget != -1 ) glDisableVertexAttribArray( material->attrib_locs.tanget );
|
|
|
|
|
|
|
+ if( mtl->attrib_locs.position != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.position );
|
|
|
|
|
+ if( mtl->attrib_locs.normal != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.normal );
|
|
|
|
|
+ if( mtl->attrib_locs.tex_coords != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.tex_coords );
|
|
|
|
|
+ if( mtl->attrib_locs.tanget != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.tanget );
|
|
|
|
|
|
|
|
if( skel_controller )
|
|
if( skel_controller )
|
|
|
{
|
|
{
|
|
|
- glDisableVertexAttribArray( material->attrib_locs.vert_weight_bones_num );
|
|
|
|
|
- glDisableVertexAttribArray( material->attrib_locs.vert_weight_bone_ids );
|
|
|
|
|
- glDisableVertexAttribArray( material->attrib_locs.vert_weight_weights );
|
|
|
|
|
|
|
+ glDisableVertexAttribArray( mtl->attrib_locs.vert_weight_bones_num );
|
|
|
|
|
+ glDisableVertexAttribArray( mtl->attrib_locs.vert_weight_bone_ids );
|
|
|
|
|
+ glDisableVertexAttribArray( mtl->attrib_locs.vert_weight_weights );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
vbo_t::UnbindAllTargets();
|
|
vbo_t::UnbindAllTargets();
|