Changeset 281
- Timestamp:
- 07/08/14 21:49:37 (11 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/gfx/animation.hh
r249 r281 49 49 return interpolate( m_keys[index].value, m_keys[index + 1].value, factor ); 50 50 } 51 virtual void dump( stream* out_stream ) 51 virtual uint32 raw_size() const 52 { 53 return sizeof( size_t ) + m_keys.size() * sizeof( key ); 54 } 55 virtual void dump( stream* out_stream ) const 52 56 { 53 57 size_t sz = m_keys.size(); … … 77 81 virtual mat4 get_matrix( float time ) const = 0; 78 82 virtual transform get_transform( float time ) const = 0; 79 virtual void dump( stream* out_stream ) = 0;83 virtual void dump( stream* out_stream ) const = 0; 80 84 virtual void load( stream* in_stream ) = 0; 81 85 virtual bool empty() const = 0; 86 virtual uint32 raw_size() const = 0; 82 87 virtual ~key_animation_data() {} 83 88 }; … … 111 116 return result; 112 117 } 113 virtual void dump( stream* out_stream ) 118 virtual uint32 raw_size() const 119 { 120 return m_positions.raw_size() + m_rotations.raw_size() + m_scales.raw_size(); 121 } 122 virtual void dump( stream* out_stream ) const 114 123 { 115 124 m_positions.dump( out_stream ); … … 140 149 const transform* data() const { return m_keys.data(); } 141 150 142 virtual void dump( stream* out_stream ) 151 virtual uint32 raw_size() const 152 { 153 return sizeof( size_t ) + m_keys.size() * sizeof( transform ); 154 } 155 156 virtual void dump( stream* out_stream ) const 143 157 { 144 158 size_t sz = m_keys.size(); -
trunk/nv/interface/mesh_data.hh
r280 r281 32 32 } 33 33 34 bool is_index() const { return count > 0 && desc.slots[0].vslot == INDEX; }34 bool is_index() const { return count > 0 && desc.slots[0].vslot == slot::INDEX; } 35 35 36 36 uint32 size() const { return count * desc.size; } -
trunk/nv/interface/vertex.hh
r280 r281 16 16 { 17 17 18 enum slot18 enum class slot : uint8 19 19 { 20 20 POSITION = 0, … … 31 31 }; 32 32 33 // struct vertex_descriptor 34 // { 35 // static const datatype position_etype = NONE; 36 // static const datatype normal_etype = NONE; 37 // static const datatype texcoord_etype = NONE; 38 // static const datatype tangent_etype = NONE; 39 // static const datatype boneindex_etype = NONE; 40 // static const datatype boneweight_etype = NONE; 41 // static const datatype color_etype = NONE; 42 // }; 43 // 44 // template < typename VD > 45 // struct vertex_type 46 // : public VD 47 // 48 // { 49 // typedef typename enum_to_type< VD::position_etype >::type position_type; 50 // typedef typename enum_to_type< VD::normal_etype >::type normal_type; 51 // typedef typename enum_to_type< VD::texcoord_etype >::type texcoord_type; 52 // typedef typename enum_to_type< VD::tangent_etype >::type tangent_type; 53 // typedef typename enum_to_type< VD::boneindex_etype >::type boneindex_type; 54 // typedef typename enum_to_type< VD::boneweight_etype >::type boneweight_type; 55 // typedef typename enum_to_type< VD::color_etype >::type color_type; 56 // }; 33 enum animation_slot 34 { 35 // TIME = 0, 36 // POSITION = 1, 37 // ROTATION = 2, 38 // SCALE = 3, 39 // MATRIX = 4, 40 // ANIM_SLOT_MAX = 4, 41 // ANIM_SLOT_MAX_STORE = 5, 42 }; 57 43 58 44 namespace detail … … 66 52 67 53 template < typename VT > 68 struct vertex_has_slot_impl< VT, POSITION >54 struct vertex_has_slot_impl< VT, slot::POSITION > 69 55 { 70 56 private: … … 79 65 80 66 template < typename VT > 81 struct vertex_has_slot_impl< VT, NORMAL >67 struct vertex_has_slot_impl< VT, slot::NORMAL > 82 68 { 83 69 private: … … 92 78 93 79 template < typename VT > 94 struct vertex_has_slot_impl< VT, TEXCOORD >80 struct vertex_has_slot_impl< VT, slot::TEXCOORD > 95 81 { 96 82 private: … … 105 91 106 92 template < typename VT > 107 struct vertex_has_slot_impl< VT, TANGENT >93 struct vertex_has_slot_impl< VT, slot::TANGENT > 108 94 { 109 95 private: … … 118 104 119 105 template < typename VT > 120 struct vertex_has_slot_impl< VT, BONEINDEX >106 struct vertex_has_slot_impl< VT, slot::BONEINDEX > 121 107 { 122 108 private: … … 131 117 132 118 template < typename VT > 133 struct vertex_has_slot_impl< VT, BONEWEIGHT >119 struct vertex_has_slot_impl< VT, slot::BONEWEIGHT > 134 120 { 135 121 private: … … 144 130 145 131 template < typename VT > 146 struct vertex_has_slot_impl< VT, COLOR >132 struct vertex_has_slot_impl< VT, slot::COLOR > 147 133 { 148 134 private: … … 170 156 171 157 template < typename VT > 172 struct vertex_slot_info_impl< VT, POSITION, true >158 struct vertex_slot_info_impl< VT, slot::POSITION, true > 173 159 { 174 160 typedef decltype( VT::position ) value_type; … … 178 164 179 165 template < typename VT > 180 struct vertex_slot_info_impl< VT, TEXCOORD, true >166 struct vertex_slot_info_impl< VT, slot::TEXCOORD, true > 181 167 { 182 168 typedef decltype( VT::texcoord ) value_type; … … 186 172 187 173 template < typename VT > 188 struct vertex_slot_info_impl< VT, NORMAL, true >174 struct vertex_slot_info_impl< VT, slot::NORMAL, true > 189 175 { 190 176 typedef decltype( VT::normal ) value_type; … … 194 180 195 181 template < typename VT > 196 struct vertex_slot_info_impl< VT, TANGENT, true >182 struct vertex_slot_info_impl< VT, slot::TANGENT, true > 197 183 { 198 184 typedef decltype( VT::tangent ) value_type; … … 202 188 203 189 template < typename VT > 204 struct vertex_slot_info_impl< VT, BONEINDEX, true >190 struct vertex_slot_info_impl< VT, slot::BONEINDEX, true > 205 191 { 206 192 typedef decltype( VT::boneindex ) value_type; … … 210 196 211 197 template < typename VT > 212 struct vertex_slot_info_impl< VT, BONEWEIGHT, true >198 struct vertex_slot_info_impl< VT, slot::BONEWEIGHT, true > 213 199 { 214 200 typedef decltype( VT::boneweight ) value_type; … … 218 204 219 205 template < typename VT > 220 struct vertex_slot_info_impl< VT, COLOR, true >206 struct vertex_slot_info_impl< VT, slot::COLOR, true > 221 207 { 222 208 typedef decltype( VT::color ) value_type; … … 224 210 static const int offset = offsetof( VT, color ); 225 211 }; 226 212 213 template < typename KEY, animation_slot SLOT > 214 struct key_has_slot_impl 215 { 216 static bool const value = false; 217 }; 218 227 219 } 228 220 … … 243 235 uint32 offset; 244 236 slot vslot; 237 vertex_descriptor_slot() : etype(NONE), offset(0), vslot(slot::POSITION) {} 245 238 }; 246 239 247 240 struct vertex_descriptor 248 241 { 249 vertex_descriptor_slot slots[ SLOT_MAX_STORE ];242 vertex_descriptor_slot slots[ slot::SLOT_MAX_STORE ]; 250 243 uint32 count; 251 244 uint32 size; 245 246 vertex_descriptor() : count(0), size(0) {} 252 247 253 248 template < typename IDX > -
trunk/nv/interface/vertex_buffer.hh
r256 r281 100 100 m_map[ location ] = p; 101 101 } 102 void add_vertex_buffer( slot location, vertex_buffer* buffer, datatype datatype, size_t components, size_t offset = 0, size_t stride = 0, bool owner = true ) 103 { 104 add_vertex_buffer( (int)location, buffer, datatype, components, offset, stride, owner ); 105 } 102 106 103 107 void add_vertex_buffers( vertex_buffer* buffer, const mesh_raw_channel* channel ) … … 131 135 } 132 136 } 137 void update_vertex_buffer( slot location, vertex_buffer* b, bool owner ) 138 {update_vertex_buffer( (int)location, b, owner ); } 139 void update_vertex_buffer( slot location, size_t offset ) {update_vertex_buffer( (int)location, offset ); } 133 140 void set_index_buffer( index_buffer* buffer, datatype datatype, bool owner ) 134 141 { … … 152 159 return nullptr; 153 160 } 161 vertex_buffer* find_buffer( slot location ) { return find_buffer((int)location); } 154 162 bool has_index_buffer() const { return m_index != nullptr; } 155 163 datatype get_index_buffer_type() const { return m_index_type; } -
trunk/nv/io/string_table.hh
r280 r281 60 60 in->read( &m_size, sizeof( m_size ), 1 ); 61 61 m_offsets = new offset[ m_count ]; 62 m_data = new char[ m_ count];62 m_data = new char[ m_size ]; 63 63 in->read( m_offsets, sizeof( offset ), m_count ); 64 64 in->read( m_data, sizeof( char ), m_size ); … … 80 80 index insert( const std::string& s ); 81 81 string_table* create_table() const; 82 uint32 dump_size() const; 82 83 void dump( nv::stream* out ) const; 83 84 const char* get( index i ) const; -
trunk/src/gfx/keyframed_mesh.cc
r280 r281 139 139 m_loc_next_position = a_program->get_attribute( "nv_next_position" )->get_location(); 140 140 m_loc_next_normal = a_program->get_attribute( "nv_next_normal" )->get_location(); 141 m_va = a_device->create_vertex_array( a_data, nv::STATIC_DRAW );142 vertex_buffer* vb = m_va->find_buffer( nv::POSITION );143 m_va->add_vertex_buffer( m_loc_next_position, vb, nv::FLOAT, 3, 0, sizeof( vertex_pn ), false );144 m_va->add_vertex_buffer( m_loc_next_normal, vb, nv::FLOAT, 3, sizeof( vec3 ), sizeof( vertex_pn ), false );141 m_va = a_device->create_vertex_array( a_data, STATIC_DRAW ); 142 vertex_buffer* vb = m_va->find_buffer( slot::POSITION ); 143 m_va->add_vertex_buffer( m_loc_next_position, vb, FLOAT, 3, 0, sizeof( vertex_pn ), false ); 144 m_va->add_vertex_buffer( m_loc_next_normal, vb, FLOAT, 3, sizeof( vec3 ), sizeof( vertex_pn ), false ); 145 145 } 146 146 -
trunk/src/gfx/skeletal_mesh.cc
r275 r281 43 43 m_animation->update_skeleton( m_transform.data(), (float)m_animation_time * 0.001f ); 44 44 m_mesh_data->apply( m_transform.data() ); 45 vertex_buffer* vb = m_va->find_buffer( nv:: POSITION );45 vertex_buffer* vb = m_va->find_buffer( nv::slot::POSITION ); 46 46 vb->bind(); 47 47 vb->update( m_mesh_data->data(), 0, m_mesh_data->size() ); -
trunk/src/gui/gui_renderer.cc
r268 r281 268 268 { 269 269 nv::vertex_buffer* vb = (nv::vertex_buffer*)sr->buffer.get_buffer(); 270 sr->varray->update_vertex_buffer( nv:: POSITION, vb, false );271 sr->varray->update_vertex_buffer( nv:: TEXCOORD, vb, false );272 sr->varray->update_vertex_buffer( nv:: COLOR, vb, false );270 sr->varray->update_vertex_buffer( nv::slot::POSITION, vb, false ); 271 sr->varray->update_vertex_buffer( nv::slot::TEXCOORD, vb, false ); 272 sr->varray->update_vertex_buffer( nv::slot::COLOR, vb, false ); 273 273 } 274 274 sr->texture->bind( nv::TEX_DIFFUSE ); -
trunk/src/io/string_table.cc
r280 r281 70 70 } 71 71 72 nv::uint32 nv::string_table_creator::dump_size() const 73 { 74 return sizeof( index ) + sizeof( uint32 ) + 75 sizeof( offset ) * m_offsets.size() + 76 sizeof( char ) * m_data.size(); 77 } 78
Note: See TracChangeset
for help on using the changeset viewer.