Ticket #1922: ParticleUpdates.patch
File ParticleUpdates.patch, 6.8 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/art/particles/smoke_light.xml
5 5 <blend mode="over"/> 6 6 7 7 <start_full/> 8 <use_relative_velocity/> 8 9 9 <constant name="emissionrate" value=" 5.0"/>10 <constant name="emissionrate" value="2.0"/> 10 11 <uniform name="lifetime" min="30.0" max="35.0"/> 11 12 12 13 <constant name="position.y" value="2.0"/> … … 14 15 <uniform name="angle" min="-2.0" max="2.0"/> 15 16 16 17 <uniform name="velocity.x" min="-0.3" max="0.3"/> 17 <uniform name="velocity.y" min=" 1.5" max="2.0"/>18 <uniform name="velocity.y" min="0.5" max="1.2"/> 18 19 <uniform name="velocity.z" min="-0.5" max="0.5"/> 19 20 <uniform name="velocity.angle" min="-2.0" max="2.0"/> 20 21 21 <uniform name="size" min="3.0" max="4.5"/> 22 <uniform name="size" min="1.0" max="1.5"/> 23 <uniform name="size.growth" min="1.0" max="1.5"/> 22 24 23 25 <uniform name="color.r" min="0.6" max="1.0"/> 24 26 <copy name="color.g" from="color.r"/> 25 27 <copy name="color.b" from="color.r"/> 26 28 29 <force y="0.2"/> 30 <force x="0.04"/> 31 <force z="0.04"/> 27 32 </particles> -
source/graphics/ParticleEmitterType.cpp
325 325 if (name == "velocity.z") return VAR_VELOCITY_Z; 326 326 if (name == "velocity.angle") return VAR_VELOCITY_ANGLE; 327 327 if (name == "size") return VAR_SIZE; 328 if (name == "size.growth") return VAR_SIZE_GROWTH; 328 329 if (name == "color.r") return VAR_COLOR_R; 329 330 if (name == "color.g") return VAR_COLOR_G; 330 331 if (name == "color.b") return VAR_COLOR_B; … … 348 349 m_Variables[VAR_VELOCITY_Z] = IParticleVarPtr(new CParticleVarConstant(0.f)); 349 350 m_Variables[VAR_VELOCITY_ANGLE] = IParticleVarPtr(new CParticleVarConstant(0.f)); 350 351 m_Variables[VAR_SIZE] = IParticleVarPtr(new CParticleVarConstant(1.f)); 352 m_Variables[VAR_SIZE_GROWTH] = IParticleVarPtr(new CParticleVarConstant(0.f)); 351 353 m_Variables[VAR_COLOR_R] = IParticleVarPtr(new CParticleVarConstant(1.f)); 352 354 m_Variables[VAR_COLOR_G] = IParticleVarPtr(new CParticleVarConstant(1.f)); 353 355 m_Variables[VAR_COLOR_B] = IParticleVarPtr(new CParticleVarConstant(1.f)); … … 355 357 m_BlendFuncSrc = GL_SRC_ALPHA; 356 358 m_BlendFuncDst = GL_ONE_MINUS_SRC_ALPHA; 357 359 m_StartFull = false; 360 m_UseRelativeVelocity = false; 358 361 m_Texture = g_Renderer.GetTextureManager().GetErrorTexture(); 359 362 360 363 CXeromyces XeroFile; … … 370 373 EL(texture); 371 374 EL(blend); 372 375 EL(start_full); 376 EL(use_relative_velocity); 373 377 EL(constant); 374 378 EL(uniform); 375 379 EL(copy); … … 430 434 { 431 435 m_StartFull = true; 432 436 } 437 else if (Child.GetNodeName() == el_use_relative_velocity) 438 { 439 m_UseRelativeVelocity = true; 440 } 433 441 else if (Child.GetNodeName() == el_constant) 434 442 { 435 443 int id = GetVariableID(Child.GetAttributes().GetNamedItem(at_name)); … … 530 538 particle.pos.Z = m_Variables[VAR_POSITION_Z]->Evaluate(emitter); 531 539 particle.pos += emitter.m_Pos; 532 540 533 particle.velocity.X = m_Variables[VAR_VELOCITY_X]->Evaluate(emitter); 534 particle.velocity.Y = m_Variables[VAR_VELOCITY_Y]->Evaluate(emitter); 535 particle.velocity.Z = m_Variables[VAR_VELOCITY_Z]->Evaluate(emitter); 536 541 if (m_UseRelativeVelocity) 542 { 543 float xVel = m_Variables[VAR_VELOCITY_X]->Evaluate(emitter); 544 float yVel = m_Variables[VAR_VELOCITY_Y]->Evaluate(emitter); 545 float zVel = m_Variables[VAR_VELOCITY_Z]->Evaluate(emitter); 546 CVector3D EmitterAngle = emitter.GetRotation().ToMatrix().Transform(CVector3D(xVel,yVel,zVel)); 547 particle.velocity.X = EmitterAngle.X; 548 particle.velocity.Y = EmitterAngle.Y; 549 particle.velocity.Z = EmitterAngle.Z; 550 } else { 551 particle.velocity.X = m_Variables[VAR_VELOCITY_X]->Evaluate(emitter); 552 particle.velocity.Y = m_Variables[VAR_VELOCITY_Y]->Evaluate(emitter); 553 particle.velocity.Z = m_Variables[VAR_VELOCITY_Z]->Evaluate(emitter); 554 } 537 555 particle.angle = m_Variables[VAR_ANGLE]->Evaluate(emitter); 538 556 particle.angleSpeed = m_Variables[VAR_VELOCITY_ANGLE]->Evaluate(emitter); 539 557 540 558 particle.size = m_Variables[VAR_SIZE]->Evaluate(emitter); 559 particle.sizeGrowth = m_Variables[VAR_SIZE_GROWTH]->Evaluate(emitter); 541 560 542 561 RGBColor color; 543 562 color.X = m_Variables[VAR_COLOR_R]->Evaluate(emitter); … … 564 583 p.pos += p.velocity * dt; 565 584 p.angle += p.angleSpeed * dt; 566 585 p.age += dt; 586 p.size += p.sizeGrowth * dt; 567 587 568 588 // Make alpha fade in/out nicely 569 589 // TODO: this should probably be done as a variable or something, -
source/graphics/ParticleEmitter.cpp
277 277 void CModelParticleEmitter::SetTransform(const CMatrix3D& transform) 278 278 { 279 279 m_Emitter->SetPosition(transform.GetTranslation()); 280 m_Emitter->SetRotation(transform.GetRotation()); 280 281 } -
source/graphics/ParticleEmitterType.h
67 67 VAR_VELOCITY_Z, 68 68 VAR_VELOCITY_ANGLE, 69 69 VAR_SIZE, 70 VAR_SIZE_GROWTH, 70 71 VAR_COLOR_R, 71 72 VAR_COLOR_G, 72 73 VAR_COLOR_B, … … 96 97 GLenum m_BlendFuncSrc; 97 98 GLenum m_BlendFuncDst; 98 99 bool m_StartFull; 99 100 bool m_UseRelativeVelocity; 101 100 102 float m_MaxLifetime; 101 103 size_t m_MaxParticles; 102 104 CBoundingBoxAligned m_MaxBounds; -
source/graphics/ParticleEmitter.h
21 21 #include "graphics/ModelAbstract.h" 22 22 #include "graphics/ParticleEmitterType.h" 23 23 #include "graphics/Texture.h" 24 #include "maths/Quaternion.h" 24 25 #include "renderer/VertexArray.h" 25 26 26 27 #include <map> … … 35 36 float angle; 36 37 float angleSpeed; 37 38 float size; 39 float sizeGrowth; 38 40 SColor4ub color; 39 41 float age; 40 42 float maxAge; … … 81 83 } 82 84 83 85 /** 86 * Set the rotation to be used for emission of new particles (note: depends on particles). 87 */ 88 void SetRotation(const CQuaternion& rot) 89 { 90 m_Rot = rot; 91 } 92 93 CQuaternion GetRotation() const 94 { 95 return m_Rot; 96 } 97 98 99 /** 84 100 * Get the bounding box of the center points of particles at their current positions. 85 101 */ 86 102 CBoundingBoxAligned GetParticleBounds() { return m_ParticleBounds; } … … 122 138 bool m_Active; 123 139 124 140 CVector3D m_Pos; 141 CQuaternion m_Rot; 125 142 126 143 std::map<std::string, float> m_EntityVariables; 127 144