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

#include <OOLaserShotEntity.h>

+ Inheritance diagram for OOLaserShotEntity:
+ Collaboration diagram for OOLaserShotEntity:

Instance Methods

(void) - setColor:
 
(void) - setRange:
 
(OOTexture *) - texture1
 
(OOTexture *) - texture2
 
(instancetype) - initLaserFromShip:direction:offset: [implementation]
 
(void) - dealloc [implementation]
 
(NSString *) - descriptionComponents [implementation]
 
(void) - update: [implementation]
 
(void) - drawImmediate:translucent: [implementation]
 
(BOOL) - isEffect [implementation]
 
(BOOL) - canCollide [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:
 
(BOOL) - checkCloseCollisionWith:
 
(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
 
(NSSet *) - allTextures
 
(id) - init [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
 

Class Methods

(instancetype) + laserFromShip:direction:offset:
 
(void) + setUpTexture
 
(OOTexture *) + innerTexture
 
(OOTexture *) + outerTexture
 
(void) + resetGraphicsState [implementation]
 

Private Attributes

GLfloat _color [4]
 
OOTimeDelta _lifetime
 
GLfloat _range
 
Vector _offset
 
Quaternion _relOrientation
 

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 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 36 of file OOLaserShotEntity.h.

Method Documentation

◆ canCollide

- (BOOL) canCollide
implementation

Reimplemented from Entity.

Definition at line 182 of file OOLaserShotEntity.m.

264{
265 return NO;
266}

◆ dealloc

◆ descriptionComponents

- (NSString *) descriptionComponents
implementation

Reimplemented from Entity.

Definition at line 55 of file OOLaserShotEntity.m.

137{
138 return [NSString stringWithFormat:@"ttl: %.3fs - %@ orientation %@", _lifetime, [super descriptionComponents], QuaternionDescription([self orientation])];
139}

◆ drawImmediate:translucent:

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

Reimplemented from Entity.

Definition at line 182 of file OOLaserShotEntity.m.

196 :(bool)immediate translucent:(bool)translucent
197{
198 if (!translucent || [UNIVERSE breakPatternHide]) return;
199
202
203
204 /* FIXME: spread damage across the lifetime of the shot,
205 hurting whatever is hit in a given frame.
206 -- Ahruman 2011-01-31
207 */
208 OOGL(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
209 OOGL(glEnable(GL_TEXTURE_2D));
211
213 [[self texture1] apply];
214 GLfloat s = sinf([UNIVERSE getTime]);
215 GLfloat phase = s*(_range/200.0f);
216 GLfloat phase2 = (1.0f+s)*(_range/200.0f);
217 GLfloat phase3 = -s*(_range/500.0f);
218 GLfloat phase4 = -(1.0f+s)*(_range/500.0f);
219
220 GLfloat laserTexCoords[] =
221 {
222 0.0f, phase, 0.0f, phase2, 1.0f, phase2, 1.0f, phase,
223
224 0.0f, phase, 0.0f, phase2, 1.0f, phase2, 1.0f, phase
225 };
226 GLfloat laserTexCoords2[] =
227 {
228 0.0f, phase3, 0.0f, phase4, 1.0f, phase4, 1.0f, phase3,
229
230 0.0f, phase3, 0.0f, phase4, 1.0f, phase4, 1.0f, phase3
231 };
232
233 OOGL(glColor4fv(_color));
234 glVertexPointer(3, GL_FLOAT, 0, kLaserVertices);
235 glTexCoordPointer(2, GL_FLOAT, 0, laserTexCoords2);
236 glDrawArrays(GL_QUADS, 0, 8);
237
240 glDrawArrays(GL_QUADS, 0, 8);
241
242 [[self texture2] apply];
244 OOGL(glColor4f(_color[0],_color[1],_color[2],0.9));
245 glTexCoordPointer(2, GL_FLOAT, 0, laserTexCoords);
246 glDrawArrays(GL_QUADS, 0, 8);
247
249 OOGL(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
250 OOGL(glDisable(GL_TEXTURE_2D));
251
253 OOCheckOpenGLErrors(@"OOLaserShotEntity after drawing %@", self);
254}
#define kLaserFlareWidth
static const GLfloat kLaserVertices[]
#define kLaserHalfWidth
#define kLaserCoreWidth
#define kLaserBrightness
#define OO_ENTER_OPENGL()
void OOGLScaleModelView(Vector scale)
void OOGLPushModelView(void)
OOMatrix OOGLPopModelView(void)
@ 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 UNIVERSE
Definition Universe.h:840

◆ initLaserFromShip:direction:offset:

- (instancetype) initLaserFromShip: (ShipEntity *) srcEntity
direction: (OOWeaponFacing) direction
offset: (Vector) offset 
implementation

Definition at line 55 of file OOLaserShotEntity.m.

59 :(ShipEntity *)srcEntity direction:(OOWeaponFacing)direction offset:(Vector)offset
60{
61 if (!(self = [super init])) return nil;
62
63 ShipEntity *ship = [srcEntity rootShipEntity];
64 Vector middle = OOBoundingBoxCenter([srcEntity boundingBox]);
65
66 NSCParameterAssert([srcEntity isShip] && [ship isShip]);
67
68 [self setStatus:STATUS_EFFECT];
69
70 if (ship == srcEntity)
71 {
72 // main laser offset
73 [self setPosition:HPvector_add([ship position], vectorToHPVector(OOVectorMultiplyMatrix(offset, [ship drawRotationMatrix])))];
74 }
75 else
76 {
77 // subentity laser
78 [self setPosition:[srcEntity absolutePositionForSubentityOffset:vectorToHPVector(middle)]];
79 }
80
81 Quaternion q = kIdentityQuaternion;
82 Vector q_up = vector_up_from_quaternion(q);
83 Quaternion q0 = [ship normalOrientation];
84 velocity = vector_multiply_scalar(vector_forward_from_quaternion(q0), [ship flightSpeed]);
85
86 switch (direction)
87 {
90 break;
91
94 break;
95
98 break;
99
101 quaternion_rotate_about_axis(&q, q_up, -M_PI/2.0);
102 break;
103 }
104
105 [self setOrientation:quaternion_multiply(q,q0)];
106 [self setOwner:ship];
107 [self setRange:[srcEntity weaponRange]];
109
110 _color[0] = kLaserRed/3.0;
111 _color[1] = kLaserGreen/3.0;
112 _color[2] = kLaserBlue/3.0;
113 _color[3] = kLaserAlpha;
114
115 _offset = (ship == srcEntity) ? offset : middle;
116 _relOrientation = q;
117
118 return self;
119}
#define kLaserRed
#define kLaserGreen
#define kLaserBlue
#define kLaserDuration
#define kLaserAlpha
#define M_PI
Definition OOMaths.h:73
return nil
Vector vector_up_from_quaternion(Quaternion quat)
Vector vector_forward_from_quaternion(Quaternion quat)
const Quaternion kIdentityQuaternion
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle)
OOWeaponFacing
Definition OOTypes.h:228
@ WEAPON_FACING_FORWARD
Definition OOTypes.h:229
@ WEAPON_FACING_NONE
Definition OOTypes.h:234
@ WEAPON_FACING_AFT
Definition OOTypes.h:230
@ WEAPON_FACING_PORT
Definition OOTypes.h:231
@ WEAPON_FACING_STARBOARD
Definition OOTypes.h:232
unsigned isShip
Definition Entity.h:91
ShipEntity * rootShipEntity()
Definition Entity.m:603
BoundingBox boundingBox
Definition Entity.h:145
HPVector position
Definition Entity.h:112
HPVector absolutePositionForSubentityOffset:(HPVector offset)
Definition Entity.m:675
Quaternion normalOrientation()
Definition Entity.m:738
Vector velocity
Definition Entity.h:140
id init()
Definition Entity.m:68
OOMatrix drawRotationMatrix()
Definition Entity.m:879
GLfloat weaponRange
Definition ShipEntity.h:311
voidpf uLong offset
Definition ioapi.h:140

◆ innerTexture

+ (OOTexture *) innerTexture

Definition at line 182 of file OOLaserShotEntity.m.

301{
302 if (sShotTexture2 == nil) [self setUpTexture];
303 return sShotTexture2;
304}
static OOTexture * sShotTexture2

◆ isEffect

- (BOOL) isEffect
implementation

Reimplemented from Entity.

Definition at line 182 of file OOLaserShotEntity.m.

258{
259 return YES;
260}

◆ laserFromShip:direction:offset:

+ (instancetype) laserFromShip: (ShipEntity *) ship
direction: (OOWeaponFacing) direction
offset: (Vector) offset 

Definition at line 55 of file OOLaserShotEntity.m.

122 :(ShipEntity *)ship direction:(OOWeaponFacing)direction offset:(Vector)offset
123{
124 return [[[self alloc] initLaserFromShip:ship direction:direction offset:offset] autorelease];
125}

◆ outerTexture

+ (OOTexture *) outerTexture

Definition at line 182 of file OOLaserShotEntity.m.

308{
309 if (sShotTexture == nil) [self setUpTexture];
310 return sShotTexture;
311}
static OOTexture * sShotTexture

◆ resetGraphicsState

+ (void) resetGraphicsState
implementation

Definition at line 182 of file OOLaserShotEntity.m.

315{
316 [sShotTexture release];
318 [sShotTexture2 release];
320}

◆ setColor:

- (void) setColor: (OOColor *) color

Definition at line 55 of file OOLaserShotEntity.m.

142 :(OOColor *)color
143{
144 _color[0] = kLaserBrightness * [color redComponent]/3.0;
145 _color[1] = kLaserBrightness * [color greenComponent]/3.0;
146 _color[2] = kLaserBrightness * [color blueComponent]/3.0;
147 // Ignore alpha; _color[3] is constant.
148}
float blueComponent()
Definition OOColor.m:362
float redComponent()
Definition OOColor.m:350
float greenComponent()
Definition OOColor.m:356

◆ setRange:

- (void) setRange: (GLfloat) range

Definition at line 55 of file OOLaserShotEntity.m.

151 :(GLfloat)range
152{
153 _range = range;
154 [self setCollisionRadius:range];
155}

Referenced by dealloc.

+ Here is the caller graph for this function:

◆ setUpTexture

+ (void) setUpTexture

Definition at line 182 of file OOLaserShotEntity.m.

281{
282 if (sShotTexture == nil)
283 {
284 sShotTexture = [[OOTexture textureWithName:@"oolite-laser-blur.png"
285 inFolder:@"Textures"
286 options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask | kOOTextureRepeatT
287 anisotropy:kOOTextureDefaultAnisotropy / 2.0
288 lodBias:0.0] retain];
289 [[OOGraphicsResetManager sharedManager] registerClient:(id<OOGraphicsResetClient>)[OOLaserShotEntity class]];
290
291 sShotTexture2 = [[OOTexture textureWithName:@"oolite-laser-blur2.png"
292 inFolder:@"Textures"
293 options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask | kOOTextureRepeatT
294 anisotropy:kOOTextureDefaultAnisotropy / 2.0
295 lodBias:0.0] retain];
296 }
297}
void registerClient:(id< OOGraphicsResetClient > client)
OOGraphicsResetManager * sharedManager()
id textureWithName:inFolder:options:anisotropy:lodBias:(NSString *name,[inFolder] NSString *directory,[options] OOTextureFlags options,[anisotropy] GLfloat anisotropy,[lodBias] GLfloat lodBias)
Definition OOTexture.m:134

◆ texture1

- (OOTexture *) texture1

Definition at line 182 of file OOLaserShotEntity.m.

269{
271}

◆ texture2

- (OOTexture *) texture2

Definition at line 182 of file OOLaserShotEntity.m.

275{
277}

◆ update:

- (void) update: (OOTimeDelta) delta_t
implementation

Reimplemented from Entity.

Definition at line 55 of file OOLaserShotEntity.m.

158 :(OOTimeDelta)delta_t
159{
160 [super update:delta_t];
161 _lifetime -= delta_t;
162 ShipEntity *ship = [self owner];
163
164 if ([ship isPlayer])
165 {
166 /*
167 Reposition this shot accurately. This overrides integration over
168 velocity in -[Entity update:], which is considered sufficient for
169 NPC ships.
170 */
171 [self setPosition:HPvector_add([ship position], vectorToHPVector(OOVectorMultiplyMatrix(_offset, [ship drawRotationMatrix])))];
172 [self setOrientation:quaternion_multiply(_relOrientation, [ship normalOrientation])];
173 }
174
175 if (_lifetime < 0)
176 {
177 [UNIVERSE removeEntity:self];
178 }
179}
double OOTimeDelta
Definition OOTypes.h:224
unsigned isPlayer
Definition Entity.h:93

Member Data Documentation

◆ _color

- (GLfloat _color[4])
private

Definition at line 39 of file OOLaserShotEntity.h.

Referenced by dealloc.

◆ _lifetime

- (OOTimeDelta) _lifetime
private

Definition at line 40 of file OOLaserShotEntity.h.

Referenced by dealloc.

◆ _offset

- (Vector) _offset
private

Definition at line 42 of file OOLaserShotEntity.h.

Referenced by dealloc.

◆ _range

- (GLfloat) _range
private

Definition at line 41 of file OOLaserShotEntity.h.

◆ _relOrientation

- (Quaternion) _relOrientation
private

Definition at line 43 of file OOLaserShotEntity.h.

Referenced by dealloc.


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