Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OOExplosionCloudEntity Class Reference

#include <OOExplosionCloudEntity.h>

+ Inheritance diagram for OOExplosionCloudEntity:
+ Collaboration diagram for OOExplosionCloudEntity:

Instance Methods

(id) - initExplosionCloudWithEntity:size:andSettings: [implementation]
 
(void) - dealloc [implementation]
 
(void) - update: [implementation]
 
(OOTexture *) - texture [implementation]
 
- Instance Methods inherited from OOParticleSystem
(id) - initWithPosition:velocity:count:minSpeed:maxSpeed:duration:baseColor:
 
(id) - init [implementation]
 
(NSString *) - descriptionComponents [implementation]
 
(BOOL) - canCollide [implementation]
 
(BOOL) - checkCloseCollisionWith: [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
 
(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
 

Class Methods

(instancetype) + explosionCloudFromEntity:withSettings:
 
(instancetype) + explosionCloudFromEntity:withSize:andSettings:
 

Private Attributes

float _growthRate
 
OOTimeDelta _cloudDuration
 
float _alpha
 
float _brightnessMult
 
OOTexture_texture
 
NSDictionary * _settings
 

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
 
- Protected Attributes inherited from OOParticleSystem
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
 

Detailed Description

Definition at line 30 of file OOExplosionCloudEntity.h.

Method Documentation

◆ dealloc

- (void) dealloc
implementation

Reimplemented from Entity.

Definition at line 49 of file OOExplosionCloudEntity.m.

178{
181 [super dealloc];
182}
#define DESTROY(x)
Definition OOCocoa.h:77

◆ explosionCloudFromEntity:withSettings:

+ (instancetype) explosionCloudFromEntity: (Entity *) entity
withSettings: (NSDictionary *) settings 

Definition at line 49 of file OOExplosionCloudEntity.m.

185 :(Entity *)entity withSettings:(NSDictionary *)settings
186{
187 return [[[self alloc] initExplosionCloudWithEntity:entity size:0 andSettings:settings] autorelease];
188}

◆ explosionCloudFromEntity:withSize:andSettings:

+ (instancetype) explosionCloudFromEntity: (Entity *) entity
withSize: (float) size
andSettings: (NSDictionary *) settings 

Definition at line 49 of file OOExplosionCloudEntity.m.

191 :(Entity *)entity withSize:(float)size andSettings:(NSDictionary *)settings
192{
193 return [[[self alloc] initExplosionCloudWithEntity:entity size:size andSettings:settings] autorelease];
194}
voidpf void uLong size
Definition ioapi.h:134

◆ initExplosionCloudWithEntity:size:andSettings:

- (id) initExplosionCloudWithEntity: (Entity *) entity
size: (float) size
andSettings: (NSDictionary *) settings 
implementation

Provided by category OOExplosionCloudEntity(OOPrivate).

Definition at line 49 of file OOExplosionCloudEntity.m.

58 :(Entity *)entity size:(float)size andSettings:(NSDictionary *)settings
59{
60 unsigned i;
61 unsigned maxCount = [UNIVERSE detailLevel] <= DETAIL_LEVEL_SHADERS ? 10 : 25;
62 HPVector pos = [entity position];
63 Vector vel = [entity velocity];
64
65 if (settings == nil) {
66 _settings = [[NSDictionary dictionary] retain];
67 } else {
68 _settings = [settings retain];
69 }
70
71 unsigned count = [_settings oo_unsignedIntForKey:kExplosionCount defaultValue:25];
72 if (count > maxCount) {
73 count = maxCount;
74 }
75
76 if (size == 0.0) {
77 size = [entity collisionRadius]*[_settings oo_floatForKey:kExplosionSize defaultValue:kExplosionDefaultSize];
78 }
79
80 _growthRate = [_settings oo_floatForKey:kExplosionGrowth defaultValue:kGrowthRateFactor] * size;
81 _alpha = [_settings oo_floatForKey:kExplosionAlpha defaultValue:kExplosionCloudAlpha];
82 _brightnessMult = [_settings oo_floatForKey:kExplosionBrightness defaultValue:kExplosionBrightnessMult];
83 if (_brightnessMult < 1.0f) _brightnessMult = 1.0f;
84 _cloudDuration = [_settings oo_doubleForKey:kExplosionDuration defaultValue:kExplosionCloudDuration];
85
86 GLfloat spread = [_settings oo_floatForKey:kExplosionSpread defaultValue:1.0];
87
88 NSString *textureFile = [_settings oo_stringForKey:kExplosionTexture defaultValue:@"oolite-particle-cloud2.png"];
89
90 _texture = [[OOTexture textureWithName:textureFile
91 inFolder:@"Textures"
92 options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask
93 anisotropy:kOOTextureDefaultAnisotropy
94 lodBias:0.0] retain];
95 if (_texture == nil)
96 {
97 [self release];
98 return nil;
99 }
100
101 GLfloat baseColor[4] = {1.0,1.0,1.0,1.0};
102
103 if (magnitude2(vel) > 1000000)
104 {
105 // slow down rapidly translating explosions
106 vel = vector_multiply_scalar(vector_normal(vel),1000);
107 }
108
109 if ((self = [super initWithPosition:pos velocity:vel count:count minSpeed:size*0.8f*spread maxSpeed:size*1.2f*spread duration:_cloudDuration baseColor:baseColor]))
110 {
111 NSString *color_order = [_settings oo_stringForKey:kExplosionColors defaultValue:@"rgb"];
112
113 for (i=0;i<count;i++)
114 {
115 if ([color_order isEqualToString:@"white"]) {
116 // grey
117 _particleColor[i][0] = _particleColor[i][1] = _particleColor[i][2] = randf();
118 } else {
119 float c1 = randf();
120 float c2 = randf();
121 float c3 = randf();
122 if (c2 > c1) {
123 c2 = c1;
124 }
125 if (c3 > c2) {
126 c3 = c2;
127 }
128 if ([color_order isEqualToString:@"rgb"])
129 {
130 _particleColor[i][0] = c1;
131 _particleColor[i][1] = c2;
132 _particleColor[i][2] = c3;
133 }
134 else if ([color_order isEqualToString:@"rbg"])
135 {
136 _particleColor[i][0] = c1;
137 _particleColor[i][1] = c3;
138 _particleColor[i][2] = c2;
139 }
140 else if ([color_order isEqualToString:@"grb"])
141 {
142 _particleColor[i][0] = c2;
143 _particleColor[i][1] = c1;
144 _particleColor[i][2] = c3;
145 }
146 else if ([color_order isEqualToString:@"gbr"])
147 {
148 _particleColor[i][0] = c3;
149 _particleColor[i][1] = c1;
150 _particleColor[i][2] = c2;
151 }
152 else if ([color_order isEqualToString:@"brg"])
153 {
154 _particleColor[i][0] = c2;
155 _particleColor[i][1] = c3;
156 _particleColor[i][2] = c1;
157 }
158 else if ([color_order isEqualToString:@"bgr"])
159 {
160 _particleColor[i][0] = c3;
161 _particleColor[i][1] = c2;
162 _particleColor[i][2] = c1;
163 }
164
165 }
166
170 _particleColor[i][3] = _alpha;
171 }
172 }
173 return self;
174}
float maxSpeed
GLfloat baseColor[4]
unsigned count
return nil
@ DETAIL_LEVEL_SHADERS
Definition OOTypes.h:246
GLfloat collisionRadius()
Definition Entity.m:905
HPVector position
Definition Entity.h:112
Vector velocity
Definition Entity.h:140
GLfloat _particleColor[kFragmentBurstMaxParticles][4]
id textureWithName:inFolder:options:anisotropy:lodBias:(NSString *name,[inFolder] NSString *directory,[options] OOTextureFlags options,[anisotropy] GLfloat anisotropy,[lodBias] GLfloat lodBias)
Definition OOTexture.m:134
float randf(void)

◆ texture

- (OOTexture *) texture
implementation

Reimplemented from OOParticleSystem.

Definition at line 49 of file OOExplosionCloudEntity.m.

289{
290 return _texture;
291}

◆ update:

- (void) update: (OOTimeDelta) delta_t
implementation

Reimplemented from OOParticleSystem.

Definition at line 49 of file OOExplosionCloudEntity.m.

197 :(OOTimeDelta)delta_t
198{
199 [super update:delta_t];
200
201 // Fade out.
202 GLfloat fadeRate = _count * _brightnessMult / 25.0;
203 unsigned i, count = _count;
204 GLfloat (*particleColor)[4] = _particleColor;
205
206 float newAlpha = _alpha * (1-(_timePassed / _cloudDuration));
207 NSString *color_order = [_settings oo_stringForKey:kExplosionColors defaultValue:@"rgb"];
208 NSUInteger primary = 0, secondary = 1, tertiary = 2;
209
210 if ([color_order isEqualToString:@"rgb"])
211 {
212 primary = 0;
213 secondary = 1;
214 tertiary = 2;
215 }
216 else if ([color_order isEqualToString:@"rbg"])
217 {
218 primary = 0;
219 secondary = 2;
220 tertiary = 1;
221 }
222 else if ([color_order isEqualToString:@"grb"])
223 {
224 primary = 1;
225 secondary = 0;
226 tertiary = 2;
227 }
228 else if ([color_order isEqualToString:@"gbr"])
229 {
230 primary = 1;
231 secondary = 2;
232 tertiary = 0;
233 }
234 else if ([color_order isEqualToString:@"brg"])
235 {
236 primary = 2;
237 secondary = 0;
238 tertiary = 1;
239 }
240 else if ([color_order isEqualToString:@"bgr"])
241 {
242 primary = 2;
243 secondary = 1;
244 tertiary = 0;
245 }
246
247
248 float fdelta_t = delta_t;
249 for (i=0;i<count;i++) {
250
251 _particleSize[i] += delta_t * _growthRate;
252
253 particleColor[i][3] = newAlpha;
254 if (![color_order isEqualToString:@"white"])
255 {
256
257 if (particleColor[i][tertiary] > 0.0f) // fade blue (white to yellow)
258 {
259 particleColor[i][tertiary] -= fdelta_t * 0.5f * fadeRate;
260 if (particleColor[i][tertiary] < 0.0f)
261 {
262 particleColor[i][tertiary] = 0.0f;
263 }
264 }
265 else if (particleColor[i][secondary] > 0.0f) // fade green (yellow to red)
266 {
267 particleColor[i][secondary] -= fdelta_t * fadeRate;
268 if (particleColor[i][secondary] < 0.0f)
269 {
270 particleColor[i][secondary] = 0.0f;
271 }
272 }
273 else if (particleColor[i][primary] > 0.0f) // fade red (red to black)
274 {
275 particleColor[i][primary] -= fdelta_t * 2.0f * fadeRate;
276 if (particleColor[i][primary] < 0.0f)
277 {
278 particleColor[i][primary] = 0.0f;
279 }
280 }
281
282 }
283 }
284
285}
double OOTimeDelta
Definition OOTypes.h:224
OOTimeDelta _timePassed
GLfloat _particleSize[kFragmentBurstMaxParticles]

Member Data Documentation

◆ _alpha

- (float) _alpha
private

Definition at line 35 of file OOExplosionCloudEntity.h.

◆ _brightnessMult

- (float) _brightnessMult
private

Definition at line 36 of file OOExplosionCloudEntity.h.

◆ _cloudDuration

- (OOTimeDelta) _cloudDuration
private

Definition at line 34 of file OOExplosionCloudEntity.h.

◆ _growthRate

- (float) _growthRate
private

Definition at line 33 of file OOExplosionCloudEntity.h.

◆ _settings

- (NSDictionary*) _settings
private

Definition at line 38 of file OOExplosionCloudEntity.h.

◆ _texture

- (OOTexture*) _texture
private

Definition at line 37 of file OOExplosionCloudEntity.h.


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