LiquidFun
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
b2Particle.h
1 /*
2 * Copyright (c) 2013 Google, Inc.
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 * 1. The origin of this software must not be misrepresented; you must not
11 * claim that you wrote the original software. If you use this software
12 * in a product, an acknowledgment in the product documentation would be
13 * appreciated but is not required.
14 * 2. Altered source versions must be plainly marked as such, and must not be
15 * misrepresented as being the original software.
16 * 3. This notice may not be removed or altered from any source distribution.
17 */
18 #ifndef B2_PARTICLE
19 #define B2_PARTICLE
20 
21 #include <Box2D/Common/b2Math.h>
22 
23 struct b2Color;
24 
27 enum b2ParticleFlag
28 {
29  b2_waterParticle = 0,
30  b2_zombieParticle = 1 << 1, // removed after next step
31  b2_wallParticle = 1 << 2, // zero velocity
32  b2_springParticle = 1 << 3, // with restitution from stretching
33  b2_elasticParticle = 1 << 4, // with restitution from deformation
34  b2_viscousParticle = 1 << 5, // with viscosity
35  b2_powderParticle = 1 << 6, // without isotropic pressure
36  b2_tensileParticle = 1 << 7, // with surface tension
37  b2_colorMixingParticle = 1 << 8, // mixing color between contacting particles
38  b2_destructionListener = 1 << 9, // call b2DestructionListener on destruction
39 };
40 
43 {
44  uint8 r,g,b,a;
45  b2ParticleColor() {}
48  b2ParticleColor(int32 r, int32 g, int32 b, int32 a) : r(r), g(g), b(b), a(a)
49  {}
50 
53  b2ParticleColor(const b2Color& color);
54 
57  bool IsZero() const
58  {
59  return !r && !g && !b && !a;
60  }
61 
64  b2Color GetColor() const;
65 
68  void Set(int32 r_, int32 g_, int32 b_, int32 a_)
69  {
70  r = r_;
71  g = g_;
72  b = b_;
73  a = a_;
74  }
75 
78  void Set(const b2Color& color);
79 };
80 
81 extern b2ParticleColor b2ParticleColor_zero;
82 
86 {
87 
89  {
90  flags = 0;
91  position = b2Vec2_zero;
92  velocity = b2Vec2_zero;
93  color = b2ParticleColor_zero;
94  userData = NULL;
95  }
96 
100  uint32 flags;
101 
104 
107 
110 
112  void* userData;
113 
114 };
115 
116 #endif
bool IsZero() const
Definition: b2Particle.h:57
b2Vec2 velocity
The linear velocity of the particle in world co-ordinates.
Definition: b2Particle.h:106
Color for debug drawing. Each value has the range [0,1].
Definition: b2Draw.h:26
b2Vec2 position
The world position of the particle.
Definition: b2Particle.h:103
Definition: b2Particle.h:85
void * userData
Use this to store application-specific body data.
Definition: b2Particle.h:112
b2ParticleColor color
The color of the particle.
Definition: b2Particle.h:109
uint32 flags
Definition: b2Particle.h:100
b2ParticleColor(int32 r, int32 g, int32 b, int32 a)
Definition: b2Particle.h:48
Small color object for each particle.
Definition: b2Particle.h:42
void Set(int32 r_, int32 g_, int32 b_, int32 a_)
Definition: b2Particle.h:68
A 2D column vector.
Definition: b2Math.h:64
b2Color GetColor() const
Definition: b2Particle.cpp:31