Changeset 296 for trunk/src/gfx
- Timestamp:
- 07/31/14 08:08:31 (11 years ago)
- Location:
- trunk/src/gfx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/keyframed_mesh.cc
r294 r296 98 98 99 99 100 void nv::keyframed_mesh::update( program* a_program ) const100 void nv::keyframed_mesh::update( program* a_program ) 101 101 { 102 102 a_program->set_opt_uniform( "nv_interpolate", m_interpolation ); … … 123 123 } 124 124 125 nv::keyframed_mesh_gpu::keyframed_mesh_gpu( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map , program* a_program)125 nv::keyframed_mesh_gpu::keyframed_mesh_gpu( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map ) 126 126 : keyframed_mesh( a_device, a_data, a_tag_map ) 127 127 , m_loc_next_position( -1 ) … … 131 131 , m_gpu_next_frame( 0xFFFFFFFF ) 132 132 { 133 m_loc_next_position = a_program->get_attribute( "nv_next_position" )->get_location();134 m_loc_next_normal = a_program->get_attribute( "nv_next_normal" )->get_location();135 m_loc_next_tangent = a_program->try_get_attribute_location( "nv_next_tangent" );136 133 m_va = a_device->create_vertex_array( a_data, STATIC_DRAW ); 137 vertex_buffer* vb = m_va->find_buffer( slot::POSITION );138 m_va->add_vertex_buffer( m_loc_next_position, vb, FLOAT, 3, 0, m_vsize, false );139 m_va->add_vertex_buffer( m_loc_next_normal, vb, FLOAT, 3, sizeof( vec3 ), m_vsize, false );140 if ( m_has_tangent )141 m_va->add_vertex_buffer( m_loc_next_tangent, vb, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false );142 134 } 143 135 … … 145 137 void nv::keyframed_mesh_gpu::update( uint32 ms ) 146 138 { 139 if ( m_loc_next_position == -1 ) return; 147 140 animated_mesh::update( ms ); 148 141 … … 157 150 m_gpu_last_frame = m_last_frame; 158 151 } 159 if ( m_ gpu_next_frame != m_next_frame )152 if ( m_loc_next_position != -1 && m_gpu_next_frame != m_next_frame ) 160 153 { 161 154 m_va->update_vertex_buffer( m_loc_next_position, m_next_frame * m_vertex_count * m_vsize ); … … 164 157 m_gpu_next_frame = m_next_frame; 165 158 } 159 } 160 161 void nv::keyframed_mesh_gpu::update( program* a_program ) 162 { 163 if ( m_loc_next_position == -1 ) 164 { 165 m_loc_next_position = a_program->get_attribute( "nv_next_position" )->get_location(); 166 m_loc_next_normal = a_program->get_attribute( "nv_next_normal" )->get_location(); 167 if ( m_has_tangent ) 168 m_loc_next_tangent = a_program->get_attribute( "nv_next_tangent" )->get_location(); 169 170 vertex_buffer* vb = m_va->find_buffer( slot::POSITION ); 171 m_va->add_vertex_buffer( m_loc_next_position, vb, FLOAT, 3, 0, m_vsize, false ); 172 m_va->add_vertex_buffer( m_loc_next_normal, vb, FLOAT, 3, sizeof( vec3 ), m_vsize, false ); 173 if ( m_has_tangent ) 174 m_va->add_vertex_buffer( m_loc_next_tangent, vb, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false ); 175 } 176 keyframed_mesh::update( a_program ); 166 177 } 167 178 -
trunk/src/gfx/skeletal_mesh.cc
r295 r296 11 11 12 12 13 nv::skeletal_mesh ::skeletal_mesh( device* a_device, const mesh_data* a_mesh_data, const mesh_nodes_data* bones )14 : animated_mesh()13 nv::skeletal_mesh_cpu::skeletal_mesh_cpu( device* a_device, const mesh_data* a_mesh_data, const mesh_nodes_data* bones ) 14 : skeletal_mesh() 15 15 , m_data( a_mesh_data ) 16 16 { … … 29 29 } 30 30 31 void nv::skeletal_mesh ::update_animation( animation_entry* a_anim, uint32 a_anim_time )31 void nv::skeletal_mesh_cpu::update_animation( animation_entry* a_anim, uint32 a_anim_time ) 32 32 { 33 33 if ( a_anim ) 34 34 { 35 skeletal_animation_entry * anim = (skeletal_animation_entry*)a_anim;35 skeletal_animation_entry_cpu * anim = (skeletal_animation_entry_cpu*)a_anim; 36 36 anim->update_skeleton( m_transform.data(), (float)a_anim_time ); 37 37 { … … 70 70 71 71 72 void nv::skeletal_animation_entry ::update_skeleton( transform* skeleton, float time ) const72 void nv::skeletal_animation_entry_cpu::update_skeleton( transform* skeleton, float time ) const 73 73 { 74 74 float frame_duration = 1000.f / (float)m_node_data->get_frame_rate(); … … 85 85 86 86 87 nv::skeletal_mesh ::~skeletal_mesh()87 nv::skeletal_mesh_cpu::~skeletal_mesh_cpu() 88 88 { 89 89 delete m_va; 90 }91 92 void nv::skeletal_mesh::run_animation( animation_entry* a_anim )93 {94 if ( a_anim != nullptr )95 {96 update_animation( a_anim, 0 );97 }98 90 } 99 91 … … 209 201 210 202 nv::skeletal_mesh_gpu::skeletal_mesh_gpu( device* a_device, const mesh_data* a_mesh, const mesh_nodes_data* a_bone_data ) 211 : animated_mesh(), m_bone_data( a_bone_data ), m_transform( nullptr )203 : skeletal_mesh(), m_bone_data( a_bone_data ), m_transform( nullptr ) 212 204 { 213 205 m_va = a_device->create_vertex_array( a_mesh, nv::STATIC_DRAW ); … … 219 211 } 220 212 221 void nv::skeletal_mesh_gpu:: run_animation( animation_entry* a_anim)222 { 223 if ( m_bone_data && a_anim != nullptr)224 { 225 skeletal_animation_entry_gpu * anim = (skeletal_animation_entry_gpu*) (a_anim);213 void nv::skeletal_mesh_gpu::update_animation( animation_entry* a_anim, uint32 a_anim_time ) 214 { 215 if ( m_bone_data && a_anim ) 216 { 217 skeletal_animation_entry_gpu * anim = (skeletal_animation_entry_gpu*)a_anim; 226 218 anim->prepare( m_bone_data ); 227 update_animation( a_anim, 0 );228 }229 }230 231 void nv::skeletal_mesh_gpu::update_animation( animation_entry* a_anim, uint32 a_anim_time )232 {233 if ( m_bone_data && a_anim )234 {235 skeletal_animation_entry_gpu * anim = (skeletal_animation_entry_gpu*)a_anim;236 219 anim->update_skeleton( m_transform, a_anim_time ); 237 220 } 238 221 } 239 222 240 void nv::skeletal_mesh_gpu::update( program* a_program ) const223 void nv::skeletal_mesh_gpu::update( program* a_program ) 241 224 { 242 225 if ( m_bone_data )
Note: See TracChangeset
for help on using the changeset viewer.