Ticket #1944: sound_attribute.patch
File sound_attribute.patch, 6.6 KB (added by , 11 years ago) |
---|
-
source/graphics/Model.cpp
251 251 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 252 252 // BuildAnimation: load raw animation frame animation from given file, and build a 253 253 // animation specific to this model 254 CSkeletonAnim* CModel::BuildAnimation(const VfsPath& pathname, const CStr& name, float speed, float actionpos, float actionpos2 )254 CSkeletonAnim* CModel::BuildAnimation(const VfsPath& pathname, const CStr& name, float speed, float actionpos, float actionpos2, float soundpos) 255 255 { 256 256 CSkeletonAnimDef* def = m_SkeletonAnimManager.GetAnimation(pathname); 257 257 if (!def) … … 272 272 else 273 273 anim->m_ActionPos2 = actionpos2 * anim->m_AnimDef->GetDuration(); 274 274 275 if (soundpos == -1.f) 276 anim->m_SoundPos = -1.f; 277 else 278 anim->m_SoundPos = soundpos * anim->m_AnimDef->GetDuration(); 279 275 280 anim->m_ObjectBounds.SetEmpty(); 276 281 InvalidateBounds(); 277 282 -
source/graphics/Model.h
197 197 * @param speed animation speed as a factor of the default animation speed 198 198 * @param actionpos offset of 'action' event, in range [0, 1] 199 199 * @param actionpos2 offset of 'action2' event, in range [0, 1] 200 * @param sound offset of 'sound' event, in range [0, 1] 200 201 * @return new animation, or NULL on error 201 202 */ 202 CSkeletonAnim* BuildAnimation(const VfsPath& pathname, const CStr& name, float speed, float actionpos, float actionpos2 );203 CSkeletonAnim* BuildAnimation(const VfsPath& pathname, const CStr& name, float speed, float actionpos, float actionpos2, float soundpos); 203 204 204 205 /** 205 206 * Add a prop to the model on the given point. -
source/graphics/ObjectBase.cpp
71 71 AT(speed); 72 72 AT(event); 73 73 AT(load); 74 AT(sound); 74 75 AT(attachpoint); 75 76 AT(actor); 76 77 AT(frequency); … … 222 223 float pos = ae.Value.ToFloat(); 223 224 anim.m_ActionPos2 = clamp(pos, 0.f, 1.f); 224 225 } 226 else if (ae.Name == at_sound) 227 { 228 float pos = ae.Value.ToFloat(); 229 anim.m_SoundPos = clamp(pos, 0.f, 1.f); 230 } 225 231 } 226 232 currentVariant->m_Anims.push_back(anim); 227 233 } -
source/graphics/ObjectBase.h
39 39 struct Anim 40 40 { 41 41 // constructor 42 Anim() : m_Speed(1.f), m_ActionPos(-1.f), m_ActionPos2(-1.f) {} 43 42 Anim() : m_Speed(1.f), m_ActionPos(-1.f), m_ActionPos2(-1.f), m_SoundPos(-1.f) {} 44 43 // name of the animation - "Idle", "Run", etc 45 44 CStr m_AnimName; 46 45 // filename of the animation - manidle.psa, manrun.psa, etc … … 51 50 // happens, or -1.0 if unspecified 52 51 float m_ActionPos; 53 52 float m_ActionPos2; 53 float m_SoundPos; 54 54 }; 55 55 56 56 struct Prop -
source/graphics/ObjectEntry.cpp
164 164 165 165 if (! it->second.m_FileName.empty()) 166 166 { 167 CSkeletonAnim* anim = model->BuildAnimation(it->second.m_FileName, name, it->second.m_Speed, it->second.m_ActionPos, it->second.m_ActionPos2 );167 CSkeletonAnim* anim = model->BuildAnimation(it->second.m_FileName, name, it->second.m_Speed, it->second.m_ActionPos, it->second.m_ActionPos2, it->second.m_SoundPos); 168 168 if (anim) 169 169 m_Animations.insert(std::make_pair(name, anim)); 170 170 } … … 179 179 anim->m_Speed = 0.f; 180 180 anim->m_ActionPos = 0.f; 181 181 anim->m_ActionPos2 = 0.f; 182 anim->m_SoundPos = 0.f; 182 183 m_Animations.insert(std::make_pair("idle", anim)); 183 184 184 185 // Ignore errors, since they're probably saying this is a non-animated model -
source/graphics/SkeletonAnim.h
46 46 // ActionPos2 is used for loading projectile ammunition. 47 47 float m_ActionPos; 48 48 float m_ActionPos2; 49 float m_SoundPos; 49 50 // object space bounds of the model when this animation is applied to it 50 51 CBoundingBoxAligned m_ObjectBounds; 51 52 }; -
source/graphics/UnitAnimation.cpp
67 67 state.time = 0.f; 68 68 state.pastLoadPos = false; 69 69 state.pastActionPos = false; 70 state.pastSoundPos = false; 70 71 71 72 m_AnimStates.push_back(state); 72 73 … … 157 158 158 159 float actionPos = it->anims[it->animIdx]->m_ActionPos; 159 160 float loadPos = it->anims[it->animIdx]->m_ActionPos2; 161 float soundPos = it->anims[it->animIdx]->m_SoundPos; 160 162 bool hasActionPos = (actionPos != -1.f); 161 163 bool hasLoadPos = (loadPos != -1.f); 164 bool hasSoundPos = (soundPos != -1.f); 162 165 163 166 // Find the current animation speed 164 167 float speed; … … 183 186 if (hasLoadPos) 184 187 it->model->HideAmmoProp(); 185 188 186 if ( !m_ActionSound.empty())189 if ( !hasSoundPos && !m_ActionSound.empty() ) 187 190 { 188 191 CmpPtr<ICmpSoundManager> cmpSoundManager(*g_Game->GetSimulation2(), SYSTEM_ENTITY); 189 192 if (cmpSoundManager) … … 192 195 193 196 it->pastActionPos = true; 194 197 } 198 if (hasSoundPos && !it->pastSoundPos && it->time + advance >= soundPos) 199 { 200 if (!m_ActionSound.empty() ) 201 { 202 CmpPtr<ICmpSoundManager> cmpSoundManager(*g_Game->GetSimulation2(), SYSTEM_ENTITY); 203 if (cmpSoundManager) 204 cmpSoundManager->PlaySoundGroup(m_ActionSound, m_Entity); 205 } 195 206 207 it->pastSoundPos = true; 208 } 209 196 210 if (it->time + advance < duration) 197 211 { 198 212 // If we're still within the current animation, then simply update it … … 219 233 220 234 it->pastActionPos = false; 221 235 it->pastLoadPos = false; 236 it->pastSoundPos = false; 222 237 223 238 it->model->UpdateTo(it->time); 224 239 } -
source/graphics/UnitAnimation.h
100 100 float time; 101 101 bool pastLoadPos; 102 102 bool pastActionPos; 103 bool pastSoundPos; 103 104 }; 104 105 105 106 std::vector<SModelAnimState> m_AnimStates;