Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOParticleSystem Class Reference

#include <OOParticleSystem.h>

+ Inheritance diagram for OOParticleSystem:
+ Collaboration diagram for OOParticleSystem:

Instance Methods

(id) - initWithPosition:velocity:count:minSpeed:maxSpeed:duration:baseColor:
 
(OOTexture *) - texture
 
(id) - init [implementation]
 
(NSString *) - descriptionComponents [implementation]
 
(BOOL) - canCollide [implementation]
 
(BOOL) - checkCloseCollisionWith: [implementation]
 
(void) - update: [implementation]
 
(void) - drawImmediate:translucent: [implementation]
 
(BOOL) - isEffect [implementation]
 
(NSSet *) - allTextures [implementation]
 
- Instance Methods inherited from Entity
(NSUInteger) - sessionID
 
(BOOL) - isShip
 
(BOOL) - isDock
 
(BOOL) - isStation
 
(BOOL) - isSubEntity
 
(BOOL) - isPlayer
 
(BOOL) - isPlanet
 
(BOOL) - isSun
 
(BOOL) - isSunlit
 
(BOOL) - isStellarObject
 
(BOOL) - isSky
 
(BOOL) - isWormhole
 
(BOOL) - isVisualEffect
 
(BOOL) - isWaypoint
 
(BOOL) - validForAddToUniverse
 
(void) - addToLinkedLists
 
(void) - removeFromLinkedLists
 
(void) - updateLinkedLists
 
(void) - wasAddedToUniverse
 
(void) - wasRemovedFromUniverse
 
(void) - warnAboutHostiles
 
(CollisionRegion *) - collisionRegion
 
(void) - setCollisionRegion:
 
(void) - setUniversalID:
 
(OOUniversalID- universalID
 
(BOOL) - throwingSparks
 
(void) - setThrowSparks:
 
(void) - throwSparks
 
(void) - setOwner:
 
(id) - owner
 
(ShipEntity *) - parentEntity
 
(ShipEntity *) - rootShipEntity
 
(void) - setPosition:
 
(void) - setPositionX:y:z:
 
(HPVector) - position
 
(Vector) - cameraRelativePosition
 
(GLfloat) - cameraRangeFront
 
(GLfloat) - cameraRangeBack
 
(void) - updateCameraRelativePosition
 
(Vector) - vectorTo:
 
(HPVector) - absolutePositionForSubentity
 
(HPVector) - absolutePositionForSubentityOffset:
 
(double) - zeroDistance
 
(double) - camZeroDistance
 
(NSComparisonResult) - compareZeroDistance:
 
(BoundingBox) - boundingBox
 
(GLfloat) - mass
 
(Quaternion) - orientation
 
(void) - setOrientation:
 
(Quaternion) - normalOrientation
 
(void) - setNormalOrientation:
 
(void) - orientationChanged
 
(void) - setVelocity:
 
(Vector) - velocity
 
(double) - speed
 
(GLfloat) - distanceTravelled
 
(void) - setDistanceTravelled:
 
(void) - setStatus:
 
(OOEntityStatus- status
 
(void) - setScanClass:
 
(OOScanClass- scanClass
 
(void) - setEnergy:
 
(GLfloat) - energy
 
(void) - setMaxEnergy:
 
(GLfloat) - maxEnergy
 
(void) - applyRoll:andClimb:
 
(void) - applyRoll:climb:andYaw:
 
(void) - moveForward:
 
(OOMatrix) - rotationMatrix
 
(OOMatrix) - drawRotationMatrix
 
(OOMatrix) - transformationMatrix
 
(OOMatrix) - drawTransformationMatrix
 
(GLfloat) - collisionRadius
 
(GLfloat) - frustumRadius
 
(void) - setCollisionRadius:
 
(NSMutableArray *) - collisionArray
 
(void) - applyVelocity:
 
(void) - takeEnergyDamage:from:becauseOf:weaponIdentifier:
 
(void) - dumpState
 
(void) - dumpSelfState
 
(double) - findCollisionRadius
 
(BOOL) - isVisible
 
(BOOL) - isInSpace
 
(BOOL) - isImmuneToBreakPatternHide
 
(GLfloat) - universalTime
 
(GLfloat) - spawnTime
 
(GLfloat) - timeElapsedSinceSpawn
 
(void) - setAtmosphereFogging:
 
(OOColor *) - fogUniform
 
(NSString *) - descriptionForObjDumpBasic
 
(NSString *) - descriptionForObjDump
 
(void) - dealloc [implementation]
 
(BOOL) - checkLinkedLists [implementation]
 
(id< OOWeakReferenceSupport >) - superShaderBindingTarget [implementation]
 
(Vector) - relativePosition [implementation]
 
(void) - subEntityReallyDied: [implementation]
 
(BOOL) - isBreakPattern
 
(void) - inspect [implementation]
 
(BOOL) - isECMBlast
 
(NSArray *) - debugInspectorModules [implementation]
 
(NSString *) - inspScanClassLine
 
(NSString *) - inspStatusLine
 
(NSString *) - inspRetainCountLine
 
(NSString *) - inspPositionLine
 
(NSString *) - inspVelocityLine
 
(NSString *) - inspOrientationLine
 
(NSString *) - inspEnergyLine
 
(NSString *) - inspOwnerLine
 
(NSString *) - inspTargetLine
 
(NSString *) - inspDescription [implementation]
 
(NSString *) - inspBasicIdentityLine [implementation]
 
(BOOL) - isExhaust
 
(BOOL) - isFlasher
 
(BOOL) - isVisibleToScripts
 
(NSString *) - oo_jsClassName
 
(void) - getJSClass:andPrototype:
 
(void) - deleteJSSelf
 
(jsval) - oo_jsValueInContext: [implementation]
 
(BOOL) - isCascadeWeapon
 
(BOOL) - isPlayerLikeShip
 
(GLfloat) - clock [implementation]
 
(unsigned) - pseudoFixedD100 [implementation]
 
(unsigned) - pseudoFixedD256 [implementation]
 
(unsigned) - systemGovernment [implementation]
 
(unsigned) - systemEconomy [implementation]
 
(unsigned) - systemTechLevel [implementation]
 
(unsigned) - systemPopulation [implementation]
 
(unsigned) - systemProductivity [implementation]
 
(BOOL) - isShipWithSubEntityShip:
 
(void) - drawSubEntityImmediate:translucent: [implementation]
 
- Instance Methods inherited from OOWeakRefObject
(id) - weakSelf
 
(id) - weakRetain [implementation]
 
(void) - weakRefDied: [implementation]
 
- Instance Methods inherited from <OOWeakReferenceSupport>
(id) - OO_RETURNS_RETAINED
 

Protected Attributes

Vector _particlePosition [kFragmentBurstMaxParticles]
 
Vector _particleVelocity [kFragmentBurstMaxParticles]
 
GLfloat _particleColor [kFragmentBurstMaxParticles][4]
 
GLfloat _particleSize [kFragmentBurstMaxParticles]
 
unsigned _count
 
unsigned _particleType
 
OOTimeDelta _timePassed
 
OOTimeDelta _duration
 
double _maxSpeed
 
- Protected Attributes inherited from Entity
HPVector lastPosition
 
Quaternion lastOrientation
 
GLfloat distanceTravelled
 
OOMatrix rotMatrix
 
Vector velocity
 
GLfloat energy
 
GLfloat maxEnergy
 
BoundingBox boundingBox
 
GLfloat mass
 
NSMutableArray * collidingEntities
 
OOTimeAbsolute spawnTime
 
struct JSObject * _jsSelf
 
- Protected Attributes inherited from OOWeakRefObject
OOWeakReferenceweakSelf
 

Additional Inherited Members

- Public Attributes inherited from Entity
OOUniversalID universalID
 
unsigned isShip: 1
 
unsigned isStation: 1
 
unsigned isPlayer: 1
 
unsigned isWormhole: 1
 
unsigned isSubEntity: 1
 
unsigned hasMoved: 1
 
unsigned hasRotated: 1
 
unsigned hasCollided: 1
 
unsigned isSunlit: 1
 
unsigned collisionTestFilter: 2
 
unsigned throw_sparks: 1
 
unsigned isImmuneToBreakPatternHide: 1
 
unsigned isExplicitlyNotMainStation: 1
 
unsigned isVisualEffect: 1
 
OOScanClass scanClass
 
GLfloat zero_distance
 
GLfloat cam_zero_distance
 
GLfloat no_draw_distance
 
GLfloat collision_radius
 
HPVector position
 
Vector cameraRelativePosition
 
Quaternion orientation
 
OOColoratmosphereFogging
 
int zero_index
 
Entityx_previous
 
Entityx_next
 
Entityy_previous
 
Entityy_next
 
Entityz_previous
 
Entityz_next
 
Entitycollision_chain
 
OOUniversalID shadingEntityID
 
Entitycollider
 
CollisionRegioncollisionRegion
 

Detailed Description

Definition at line 41 of file OOParticleSystem.h.

Method Documentation

◆ allTextures

- (NSSet *) allTextures
implementation

Reimplemented from Entity.

Definition at line 1 of file OOParticleSystem.m.

◆ canCollide

- (BOOL) canCollide
implementation

Reimplemented from Entity.

Definition at line 1 of file OOParticleSystem.m.

100{
101 return NO;
102}

◆ checkCloseCollisionWith:

- (BOOL) checkCloseCollisionWith: (Entity *) other
implementation

Reimplemented from Entity.

Definition at line 1 of file OOParticleSystem.m.

105 :(Entity *)other
106{
107 if (other == [self owner]) return NO;
108 return ![other isEffect];
109}
BOOL isEffect()
Definition Entity.m:196
id owner()
Definition Entity.m:583

◆ descriptionComponents

- (NSString *) descriptionComponents
implementation

Reimplemented from Entity.

Definition at line 1 of file OOParticleSystem.m.

94{
95 return [NSString stringWithFormat:@"ttl: %.3fs", _duration - _timePassed];
96}

◆ drawImmediate:translucent:

- (void) drawImmediate: (bool) immediate
translucent: (bool) translucent 
implementation

Reimplemented from Entity.

Definition at line 1 of file OOParticleSystem.m.

142 :(bool)immediate translucent:(bool)translucent
143{
144 if (!translucent || [UNIVERSE breakPatternHide]) return;
145
148
149 OOGL(glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT));
150
151 OOGL(glEnable(GL_TEXTURE_2D));
152 OOGL(glEnable(GL_BLEND));
153 OOGL(glBlendFunc(GL_SRC_ALPHA, GL_ONE));
154 [[self texture] apply];
155
156 HPVector viewPosition = [PLAYER viewpointPosition];
157 HPVector selfPosition = [self position];
158
159 unsigned i, count = _count;
160 Vector *particlePosition = _particlePosition;
161 GLfloat (*particleColor)[4] = _particleColor;
162 GLfloat *particleSize = _particleSize;
163
164 if ([UNIVERSE reducedDetail])
165 {
166 // Quick rendering - particle cloud is effectively a 2D billboard.
168 OOGLMultModelView(OOMatrixForBillboard(selfPosition, viewPosition));
169
170 OOGLBEGIN(GL_QUADS);
171 for (i = 0; i < count; i++)
172 {
173 glColor4fv(particleColor[i]);
174 DrawQuadForView(particlePosition[i].x, particlePosition[i].y, particlePosition[i].z, particleSize[i]);
175 }
176 OOGLEND();
177
179 }
180 else
181 {
182 float distanceThreshold = collision_radius * 2.0f; // Distance between player and middle of effect where we start to transition to "non-fast rendering."
183 float thresholdSq = distanceThreshold * distanceThreshold;
184 float distanceSq = cam_zero_distance;
185
186 if (distanceSq > thresholdSq)
187 {
188 /* Semi-quick rendering - particle positions are volumetric, but
189 orientation is shared. This can cause noticeable distortion
190 if the player is close to the centre of the cloud.
191 */
192 OOMatrix bbMatrix = OOMatrixForBillboard(selfPosition, viewPosition);
193
194 for (i = 0; i < count; i++)
195 {
197 OOGLTranslateModelView(particlePosition[i]);
198 OOGLMultModelView(bbMatrix);
199
200 glColor4fv(particleColor[i]);
201 OOGLBEGIN(GL_QUADS);
202 DrawQuadForView(0, 0, 0, particleSize[i]);
203 OOGLEND();
204
206 }
207 }
208 else
209 {
210 /* Non-fast rendering - each particle is billboarded individually.
211 The "individuality" factor interpolates between this behavior
212 and "semi-quick" to avoid jumping at the boundary.
213 */
214 float individuality = 3.0f * (1.0f - distanceSq / thresholdSq);
215 individuality = OOClamp_0_1_f(individuality);
216
217 for (i = 0; i < count; i++)
218 {
220 OOGLTranslateModelView(particlePosition[i]);
221 OOGLMultModelView(OOMatrixForBillboard(HPvector_add(selfPosition, vectorToHPVector(vector_multiply_scalar(particlePosition[i], individuality))), viewPosition));
222
223 glColor4fv(particleColor[i]);
224 OOGLBEGIN(GL_QUADS);
225 DrawQuadForView(0, 0, 0, particleSize[i]);
226 OOGLEND();
227
229 }
230 }
231
232 }
233
234 OOGL(glPopAttrib());
235
237 OOCheckOpenGLErrors(@"OOParticleSystem after drawing %@", self);
238}
#define OO_ENTER_OPENGL()
OOMatrix OOMatrixForBillboard(HPVector bbPos, HPVector eyePos)
Definition OOMatrix.m:191
void OOGLPushModelView(void)
void OOGLTranslateModelView(Vector vector)
void OOGLMultModelView(OOMatrix matrix)
OOMatrix OOGLPopModelView(void)
#define OOGLBEGIN
Definition OOOpenGL.h:253
@ OPENGL_STATE_ADDITIVE_BLENDING
Definition OOOpenGL.h:125
#define OOVerifyOpenGLState()
Definition OOOpenGL.h:136
BOOL OOCheckOpenGLErrors(NSString *format,...)
Definition OOOpenGL.m:39
#define OOSetOpenGLState(STATE)
Definition OOOpenGL.h:135
#define OOGL(statement)
Definition OOOpenGL.h:251
#define OOGLEND
Definition OOOpenGL.h:254
#define DrawQuadForView(x, y, z, sz)
unsigned count
float y
float x
#define UNIVERSE
Definition Universe.h:840
GLfloat collision_radius
Definition Entity.h:111
GLfloat cam_zero_distance
Definition Entity.h:109
GLfloat _particleSize[kFragmentBurstMaxParticles]
GLfloat _particleColor[kFragmentBurstMaxParticles][4]
Vector _particlePosition[kFragmentBurstMaxParticles]

◆ init

- (id) init
implementation

Reimplemented from Entity.

Definition at line 1 of file OOParticleSystem.m.

42{
43 [self release];
44 return nil;
45}
return nil

◆ initWithPosition:velocity:count:minSpeed:maxSpeed:duration:baseColor:

- (id) initWithPosition: (HPVector) position
velocity: (Vector) velocity
count: (unsigned) count
minSpeed: (float) minSpeed
maxSpeed: (float) maxSpeed
duration: (OOTimeDelta) duration
baseColor: (GLfloat[4]) baseColor 

Definition at line 1 of file OOParticleSystem.m.

51 :(HPVector)pos
52 velocity:(Vector)vel
53 count:(unsigned)count
54 minSpeed:(float)minSpeed
55 maxSpeed:(float)maxSpeed
56 duration:(OOTimeDelta)duration
57 baseColor:(GLfloat[4])baseColor
58{
59 NSParameterAssert(count <= kFragmentBurstMaxParticles);
60
61 if ((self = [super init]))
62 {
63 _count = count;
64 [self setPosition:pos];
65
66 velocity = vel;
67 _duration = duration;
69
70 for (unsigned i = 0; i < count; i++)
71 {
72 GLfloat speed = minSpeed + 0.5f * (randf()+randf()) * (maxSpeed - minSpeed); // speed tends toward middle of range
73 _particleVelocity[i] = vector_multiply_scalar(OORandomUnitVector(), speed);
74
75 Vector color = make_vector(baseColor[0] * 0.1f * (9.5f + randf()), baseColor[1] * 0.1f * (9.5f + randf()), baseColor[2] * 0.1f * (9.5f + randf()));
76 color = vector_normal(color);
77 _particleColor[i][0] = color.x;
78 _particleColor[i][1] = color.y;
79 _particleColor[i][2] = color.z;
80 _particleColor[i][3] = baseColor[3];
81
83 }
84
85 [self setStatus:STATUS_EFFECT];
86 scanClass = CLASS_NO_DRAW;
87 }
88
89 return self;
90}
@ kFragmentBurstMaxParticles
float maxSpeed
GLfloat baseColor[4]
double OOTimeDelta
Definition OOTypes.h:224
Vector OORandomUnitVector(void)
Definition OOVector.m:83
OOScanClass scanClass
Definition Entity.h:106
Vector velocity
Definition Entity.h:140
double speed()
Definition Entity.m:769
Vector _particleVelocity[kFragmentBurstMaxParticles]
OOTimeDelta _duration
float randf(void)

◆ isEffect

- (BOOL) isEffect
implementation

Reimplemented from Entity.

Definition at line 1 of file OOParticleSystem.m.

242{
243 return YES;
244}

◆ texture

- (OOTexture *) texture

Reimplemented in OOExplosionCloudEntity.

Definition at line 1 of file OOParticleSystem.m.

◆ update:

- (void) update: (OOTimeDelta) delta_t
implementation

Reimplemented from Entity.

Reimplemented in OOBigFragmentBurstEntity, OOExplosionCloudEntity, and OOSmallFragmentBurstEntity.

Definition at line 1 of file OOParticleSystem.m.

112 :(OOTimeDelta) delta_t
113{
114 [super update:delta_t];
115
116 _timePassed += delta_t;
117 collision_radius += delta_t * _maxSpeed;
118
119 unsigned i, count = _count;
120 Vector *particlePosition = _particlePosition;
121 Vector *particleVelocity = _particleVelocity;
122
123 for (i = 0; i < count; i++)
124 {
125 particlePosition[i] = vector_add(particlePosition[i], vector_multiply_scalar(particleVelocity[i], delta_t));
126 }
127
128 // disappear eventually.
129 if (_timePassed > _duration) [UNIVERSE removeEntity:self];
130}
OOTimeDelta _timePassed

Member Data Documentation

◆ _count

- (unsigned) _count
protected

Definition at line 48 of file OOParticleSystem.h.

◆ _duration

- (OOTimeDelta) _duration
protected

Definition at line 52 of file OOParticleSystem.h.

◆ _maxSpeed

- (double) _maxSpeed
protected

Definition at line 53 of file OOParticleSystem.h.

◆ _particleColor

- (GLfloat _particleColor[kFragmentBurstMaxParticles][4])
protected

Definition at line 46 of file OOParticleSystem.h.

◆ _particlePosition

- (Vector _particlePosition[kFragmentBurstMaxParticles])
protected

Definition at line 44 of file OOParticleSystem.h.

◆ _particleSize

- (GLfloat _particleSize[kFragmentBurstMaxParticles])
protected

Definition at line 47 of file OOParticleSystem.h.

Referenced by OOBigFragmentBurstEntity::if, and OOSmallFragmentBurstEntity::if.

◆ _particleType

- (unsigned) _particleType
protected

Definition at line 50 of file OOParticleSystem.h.

◆ _particleVelocity

- (Vector _particleVelocity[kFragmentBurstMaxParticles])
protected

Definition at line 45 of file OOParticleSystem.h.

◆ _timePassed

- (OOTimeDelta) _timePassed
protected

Definition at line 52 of file OOParticleSystem.h.


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