OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ParticleProperties Class Reference

#include <C4Particles.h>

Collaboration diagram for C4ParticleProperties:
[legend]

Public Member Functions

void SetCollisionFunc (const C4Value &source)
 
 C4ParticleProperties ()
 
void Set (C4PropList *dataSource)
 
void Floatify ()
 
bool CollisionDie (C4Particle *forParticle)
 
bool CollisionBounce (C4Particle *forParticle)
 
bool CollisionStop (C4Particle *forParticle)
 

Public Attributes

bool hasConstantColor
 
bool hasCollisionVertex
 
C4ParticleValueProvider size
 
C4ParticleValueProvider stretch
 
C4ParticleValueProvider forceX
 
C4ParticleValueProvider forceY
 
C4ParticleValueProvider speedDampingX
 
C4ParticleValueProvider speedDampingY
 
C4ParticleValueProvider colorR
 
C4ParticleValueProvider colorG
 
C4ParticleValueProvider colorB
 
C4ParticleValueProvider colorAlpha
 
C4ParticleValueProvider rotation
 
C4ParticleValueProvider phase
 
C4ParticleValueProvider collisionVertex
 
C4ParticleValueProvider collisionDensity
 
float bouncyness
 
C4ParticleCollisionCallback collisionCallback
 
uint32_t blitMode
 
uint32_t attachment
 

Detailed Description

Definition at line 199 of file C4Particles.h.

Constructor & Destructor Documentation

C4ParticleProperties::C4ParticleProperties ( )

Definition at line 703 of file C4Particles.cpp.

References C4ATTACH_None, and C4M_Solid.

704 {
705  blitMode = 0;
707  hasConstantColor = false;
708  hasCollisionVertex = false;
709  collisionCallback = 0;
710  bouncyness = 0.f;
711 
712  // all values in pre-floatified range (f.e. 0..255 instead of 0..1)
713  collisionDensity.Set(static_cast<float>(C4M_Solid));
714  collisionVertex.Set(0.f);
715  size.Set(8.f);
716  stretch.Set(1000.f);
717  forceX.Set(0.f);
718  forceY.Set(0.f);
719  speedDampingX.Set(1000.f);
720  speedDampingY.Set(1000.f);
721  colorR.Set(255.f);
722  colorG.Set(255.f);
723  colorB.Set(255.f);
724  colorAlpha.Set(255.f);
725  rotation.Set(0.f);
726  phase.Set(0.f);
727 }
C4ParticleValueProvider forceY
Definition: C4Particles.h:206
C4ParticleValueProvider phase
Definition: C4Particles.h:210
C4ParticleValueProvider stretch
Definition: C4Particles.h:205
C4ParticleValueProvider forceX
Definition: C4Particles.h:206
C4ParticleValueProvider colorG
Definition: C4Particles.h:208
C4ParticleValueProvider colorAlpha
Definition: C4Particles.h:208
const int32_t C4M_Solid
Definition: C4Constants.h:173
C4ParticleValueProvider rotation
Definition: C4Particles.h:209
C4ParticleCollisionCallback collisionCallback
Definition: C4Particles.h:214
void Set(const C4Value &value)
C4ParticleValueProvider speedDampingX
Definition: C4Particles.h:207
C4ParticleValueProvider speedDampingY
Definition: C4Particles.h:207
C4ParticleValueProvider collisionVertex
Definition: C4Particles.h:211
C4ParticleValueProvider collisionDensity
Definition: C4Particles.h:211
C4ParticleValueProvider colorB
Definition: C4Particles.h:208
C4ParticleValueProvider colorR
Definition: C4Particles.h:208
C4ParticleValueProvider size
Definition: C4Particles.h:205

Member Function Documentation

bool C4ParticleProperties::CollisionBounce ( C4Particle forParticle)

Definition at line 870 of file C4Particles.cpp.

References C4Particle::currentSpeedX, and C4Particle::currentSpeedY.

Referenced by SetCollisionFunc().

871 {
872  forParticle->currentSpeedX = -forParticle->currentSpeedX * bouncyness;
873  forParticle->currentSpeedY = -forParticle->currentSpeedY * bouncyness;
874  return true;
875 }
float currentSpeedX
Definition: C4Particles.h:310
float currentSpeedY
Definition: C4Particles.h:310

Here is the caller graph for this function:

bool C4ParticleProperties::CollisionDie ( C4Particle forParticle)
inline

Definition at line 229 of file C4Particles.h.

Referenced by SetCollisionFunc().

229 { return false; }

Here is the caller graph for this function:

bool C4ParticleProperties::CollisionStop ( C4Particle forParticle)

Definition at line 877 of file C4Particles.cpp.

References C4Particle::currentSpeedX, and C4Particle::currentSpeedY.

Referenced by SetCollisionFunc().

878 {
879  forParticle->currentSpeedX = 0.f;
880  forParticle->currentSpeedY = 0.f;
881  return true;
882 }
float currentSpeedX
Definition: C4Particles.h:310
float currentSpeedY
Definition: C4Particles.h:310

Here is the caller graph for this function:

void C4ParticleProperties::Floatify ( )

Definition at line 729 of file C4Particles.cpp.

Referenced by C4ParticleSystem::Create().

730 {
731  bouncyness /= 1000.f;
732 
734  collisionVertex.Floatify(1000.f);
735  size.Floatify(2.f);
736  stretch.Floatify(1000.f);
737  forceX.Floatify(100.f);
738  forceY.Floatify(100.f);
739  speedDampingX.Floatify(1000.f);
740  speedDampingY.Floatify(1000.f);
741  colorR.Floatify(255.f);
742  colorG.Floatify(255.f);
743  colorB.Floatify(255.f);
744  colorAlpha.Floatify(255.f);
745  rotation.Floatify(180.0f / (float)M_PI);
746  phase.Floatify(1.f);
747 
749 }
void Floatify(float denominator)
C4ParticleValueProvider forceY
Definition: C4Particles.h:206
C4ParticleValueProvider phase
Definition: C4Particles.h:210
C4ParticleValueProvider stretch
Definition: C4Particles.h:205
C4ParticleValueProvider forceX
Definition: C4Particles.h:206
C4ParticleValueProvider colorG
Definition: C4Particles.h:208
C4ParticleValueProvider colorAlpha
Definition: C4Particles.h:208
bool IsConstant() const
Definition: C4Particles.h:157
C4ParticleValueProvider rotation
Definition: C4Particles.h:209
C4ParticleValueProvider speedDampingX
Definition: C4Particles.h:207
C4ParticleValueProvider speedDampingY
Definition: C4Particles.h:207
C4ParticleValueProvider collisionVertex
Definition: C4Particles.h:211
C4ParticleValueProvider collisionDensity
Definition: C4Particles.h:211
C4ParticleValueProvider colorB
Definition: C4Particles.h:208
C4ParticleValueProvider colorR
Definition: C4Particles.h:208
C4ParticleValueProvider size
Definition: C4Particles.h:205

Here is the caller graph for this function:

void C4ParticleProperties::Set ( C4PropList dataSource)

Definition at line 751 of file C4Particles.cpp.

References C4PropList::begin(), C4V_Nil, C4PropList::end(), C4Property::Key, C4StringTable::P, P_Alpha, P_Attach, P_B, P_BlitMode, P_CollisionDensity, P_CollisionVertex, P_DampingX, P_DampingY, P_ForceX, P_ForceY, P_G, P_OnCollision, P_Phase, P_R, P_Rotation, P_Size, P_Stretch, C4Value::Set(), Strings, and C4Property::Value.

Referenced by C4ParticleSystem::Create().

752 {
753  if (!dataSource) return;
754 
755  C4PropList::Iterator iter = dataSource->begin(), end = dataSource->end();
756 
757  for (;iter != end; ++iter)
758  {
759  const C4Property * p = *iter;
760  C4String *key = p->Key;
761  assert(key && "PropList returns non-string as key");
762  const C4Value &property = p->Value;
763 
764  if(&Strings.P[P_R] == key)
765  {
766  colorR.Set(property);
767  }
768  else if(&Strings.P[P_G] == key)
769  {
770  colorG.Set(property);
771  }
772  else if(&Strings.P[P_B] == key)
773  {
774  colorB.Set(property);
775  }
776  else if(&Strings.P[P_Alpha] == key)
777  {
778  colorAlpha.Set(property);
779  }
780  else if(&Strings.P[P_ForceX] == key)
781  {
782  forceX.Set(property);
783  }
784  else if(&Strings.P[P_ForceY] == key)
785  {
786  forceY.Set(property);
787  }
788  else if(&Strings.P[P_DampingX] == key)
789  {
790  speedDampingX.Set(property);
791  }
792  else if(&Strings.P[P_DampingY] == key)
793  {
794  speedDampingY.Set(property);
795  }
796  else if(&Strings.P[P_Size] == key)
797  {
798  size.Set(property);
799  }
800  else if(&Strings.P[P_Stretch] == key)
801  {
802  stretch.Set(property);
803  }
804  else if(&Strings.P[P_Rotation] == key)
805  {
806  rotation.Set(property);
807  }
808  else if(&Strings.P[P_BlitMode] == key)
809  {
810  // needs to be constant
811  blitMode = (uint32_t) property.getInt();
812  }
813  else if(&Strings.P[P_Attach] == key)
814  {
815  // needs to be constant
816  attachment = (uint32_t) property.getInt();
817  }
818  else if(&Strings.P[P_Phase] == key)
819  {
820  phase.Set(property);
821  }
822  else if(&Strings.P[P_CollisionVertex] == key)
823  {
824  collisionVertex.Set(property);
825  if (property.GetType() != C4V_Nil)
826  hasCollisionVertex = true;
827  }
828  else if (&Strings.P[P_CollisionDensity] == key)
829  {
830  collisionDensity.Set(property);
831  }
832  else if(&Strings.P[P_OnCollision] == key)
833  {
834  SetCollisionFunc(property);
835  }
836  }
837 
838 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:57
C4ParticleValueProvider forceY
Definition: C4Particles.h:206
C4ParticleValueProvider phase
Definition: C4Particles.h:210
C4ParticleValueProvider stretch
Definition: C4Particles.h:205
C4ParticleValueProvider forceX
Definition: C4Particles.h:206
C4ParticleValueProvider colorG
Definition: C4Particles.h:208
Iterator end()
Definition: C4PropList.h:208
C4ParticleValueProvider colorAlpha
Definition: C4Particles.h:208
C4StringTable Strings
Definition: C4Globals.cpp:42
void SetCollisionFunc(const C4Value &source)
Iterator begin()
Definition: C4PropList.cpp:984
C4ParticleValueProvider rotation
Definition: C4Particles.h:209
void Set(const C4Value &value)
C4String * Key
Definition: C4PropList.h:56
C4ParticleValueProvider speedDampingX
Definition: C4Particles.h:207
C4ParticleValueProvider speedDampingY
Definition: C4Particles.h:207
C4ParticleValueProvider collisionVertex
Definition: C4Particles.h:211
C4ParticleValueProvider collisionDensity
Definition: C4Particles.h:211
C4ParticleValueProvider colorB
Definition: C4Particles.h:208
C4ParticleValueProvider colorR
Definition: C4Particles.h:208
C4ParticleValueProvider size
Definition: C4Particles.h:205

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ParticleProperties::SetCollisionFunc ( const C4Value source)

Definition at line 840 of file C4Particles.cpp.

References C4PC_Bounce, C4PC_Die, C4PC_Stop, CollisionBounce(), CollisionDie(), CollisionStop(), C4Value::getArray(), and C4ValueArray::GetSize().

841 {
842  C4ValueArray *valueArray;
843  if (!(valueArray = source.getArray())) return;
844 
845  int arraySize = valueArray->GetSize();
846  if (arraySize < 1) return;
847 
848  int type = (*valueArray)[0].getInt();
849 
850  switch (type)
851  {
852  case C4PC_Die:
854  break;
855  case C4PC_Bounce:
857  bouncyness = 1.f;
858  if (arraySize >= 2)
859  bouncyness = ((float)(*valueArray)[1].getInt());
860  break;
861  case C4PC_Stop:
863  break;
864  default:
865  assert(false);
866  break;
867  }
868 }
bool CollisionBounce(C4Particle *forParticle)
bool CollisionDie(C4Particle *forParticle)
Definition: C4Particles.h:229
C4ValueArray * getArray() const
Definition: C4Value.h:118
int32_t GetSize() const
Definition: C4ValueArray.h:36
C4ParticleCollisionCallback collisionCallback
Definition: C4Particles.h:214
bool CollisionStop(C4Particle *forParticle)

Here is the call graph for this function:

Member Data Documentation

uint32_t C4ParticleProperties::attachment

Definition at line 219 of file C4Particles.h.

Referenced by C4ParticleSystem::Create().

uint32_t C4ParticleProperties::blitMode

Definition at line 217 of file C4Particles.h.

Referenced by C4ParticleSystem::Create().

float C4ParticleProperties::bouncyness

Definition at line 213 of file C4Particles.h.

C4ParticleCollisionCallback C4ParticleProperties::collisionCallback

Definition at line 214 of file C4Particles.h.

Referenced by C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::collisionDensity

Definition at line 211 of file C4Particles.h.

Referenced by C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::collisionVertex

Definition at line 211 of file C4Particles.h.

Referenced by C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::colorAlpha

Definition at line 208 of file C4Particles.h.

Referenced by C4ParticleSystem::Create(), and C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::colorB

Definition at line 208 of file C4Particles.h.

Referenced by C4ParticleSystem::Create(), and C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::colorG

Definition at line 208 of file C4Particles.h.

Referenced by C4ParticleSystem::Create(), and C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::colorR

Definition at line 208 of file C4Particles.h.

Referenced by C4ParticleSystem::Create(), and C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::forceX

Definition at line 206 of file C4Particles.h.

Referenced by C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::forceY

Definition at line 206 of file C4Particles.h.

Referenced by C4Particle::Exec().

bool C4ParticleProperties::hasCollisionVertex

Definition at line 203 of file C4Particles.h.

Referenced by C4Particle::Exec().

bool C4ParticleProperties::hasConstantColor

Definition at line 202 of file C4Particles.h.

Referenced by C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::phase

Definition at line 210 of file C4Particles.h.

Referenced by C4ParticleSystem::Create(), and C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::rotation

Definition at line 209 of file C4Particles.h.

Referenced by C4Particle::Exec(), and C4Particle::SetPosition().

C4ParticleValueProvider C4ParticleProperties::size

Definition at line 205 of file C4Particles.h.

Referenced by C4Particle::Exec(), and C4Particle::SetPosition().

C4ParticleValueProvider C4ParticleProperties::speedDampingX

Definition at line 207 of file C4Particles.h.

Referenced by C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::speedDampingY

Definition at line 207 of file C4Particles.h.

Referenced by C4Particle::Exec().

C4ParticleValueProvider C4ParticleProperties::stretch

Definition at line 205 of file C4Particles.h.

Referenced by C4Particle::Exec().


The documentation for this class was generated from the following files: