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 701 of file C4Particles.cpp.

References C4ATTACH_None, and C4M_Solid.

702 {
703  blitMode = 0;
705  hasConstantColor = false;
706  hasCollisionVertex = false;
707  collisionCallback = 0;
708  bouncyness = 0.f;
709 
710  // all values in pre-floatified range (f.e. 0..255 instead of 0..1)
711  collisionDensity.Set(static_cast<float>(C4M_Solid));
712  collisionVertex.Set(0.f);
713  size.Set(8.f);
714  stretch.Set(1000.f);
715  forceX.Set(0.f);
716  forceY.Set(0.f);
717  speedDampingX.Set(1000.f);
718  speedDampingY.Set(1000.f);
719  colorR.Set(255.f);
720  colorG.Set(255.f);
721  colorB.Set(255.f);
722  colorAlpha.Set(255.f);
723  rotation.Set(0.f);
724  phase.Set(0.f);
725 }
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:172
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 868 of file C4Particles.cpp.

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

Referenced by SetCollisionFunc().

869 {
870  forParticle->currentSpeedX = -forParticle->currentSpeedX * bouncyness;
871  forParticle->currentSpeedY = -forParticle->currentSpeedY * bouncyness;
872  return true;
873 }
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 875 of file C4Particles.cpp.

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

Referenced by SetCollisionFunc().

876 {
877  forParticle->currentSpeedX = 0.f;
878  forParticle->currentSpeedY = 0.f;
879  return true;
880 }
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 727 of file C4Particles.cpp.

Referenced by C4ParticleSystem::Create().

728 {
729  bouncyness /= 1000.f;
730 
732  collisionVertex.Floatify(1000.f);
733  size.Floatify(2.f);
734  stretch.Floatify(1000.f);
735  forceX.Floatify(100.f);
736  forceY.Floatify(100.f);
737  speedDampingX.Floatify(1000.f);
738  speedDampingY.Floatify(1000.f);
739  colorR.Floatify(255.f);
740  colorG.Floatify(255.f);
741  colorB.Floatify(255.f);
742  colorAlpha.Floatify(255.f);
743  rotation.Floatify(180.0f / (float)M_PI);
744  phase.Floatify(1.f);
745 
747 }
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 749 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().

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

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

839 {
840  C4ValueArray *valueArray;
841  if (!(valueArray = source.getArray())) return;
842 
843  int arraySize = valueArray->GetSize();
844  if (arraySize < 1) return;
845 
846  int type = (*valueArray)[0].getInt();
847 
848  switch (type)
849  {
850  case C4PC_Die:
852  break;
853  case C4PC_Bounce:
855  bouncyness = 1.f;
856  if (arraySize >= 2)
857  bouncyness = ((float)(*valueArray)[1].getInt());
858  break;
859  case C4PC_Stop:
861  break;
862  default:
863  assert(false);
864  break;
865  }
866 }
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: