37#define kOverallAlpha 1.0f
38#define kTimeStep 0.05f
39#define kFadeLevel1 0.4f
40#define kFadeLevel2 0.2f
41#define kFadeLevel3 0.02f
42#define kScaleLevel1 1.0f
43#define kScaleLevel2 0.8f
44#define kScaleLevel3 0.6f
48@interface OOExhaustPlumeEntity (Private)
51- (
Frame)frameAtTime:(
double)t_frame fromFrame:(
Frame)frame_zero;
57+ (id)exhaustForShip:(
ShipEntity*)ship withDefinition:(NSArray*)definition andScale:(
float)scale
59 return [[[
self alloc] initForShip:ship withDefinition:definition andScale:(float)scale] autorelease];
62- (id)initForShip:(
ShipEntity*)ship withDefinition:(NSArray*)definition andScale:(
float)scaleFactor
64 if ([definition
count] == 0) {
69 if ((
self = [super
init])) {
124 GLfloat ex_emissive[4];
132 .timeframe = [UNIVERSE getTime],
133 .orientation = shipQrotation,
145 GLfloat flare_factor = fmaxf(
speed, 1.0) * ex_emissive[3] * hyper_fade;
147 GLfloat green_factor =
speed * ex_emissive[1] * hyper_fade;
174 GLfloat speedScale = fminf(1.0f,
speed * 5.0f);
177 GLfloat i01 = -0.00f * hyper_fade;
178 GLfloat i03 = -0.12f * exhaust_factor;
179 GLfloat i06 = -0.25f * exhaust_factor;
180 GLfloat i08 = -0.32f * exhaust_factor;
181 GLfloat i10 = -0.40f * exhaust_factor;
182 GLfloat q01 = i01 / i10;
183 GLfloat q03 = i03 / i10;
184 GLfloat q06 = i06 / i10;
185 GLfloat q08 = i08 / i10;
186 GLfloat r01 = 1.0f - q01;
187 GLfloat r03 = 1.0f - q03;
188 GLfloat r06 = 1.0f - q06;
189 GLfloat r08 = 1.0f - q08;
209 ex_emissive[1] = green_factor;
210 ex_emissive[0] = red_factor;
226 for (i = 0; i < 8; i++) {
251 for (i = 0; i < 8; i++) {
278 for (i = 0; i < 8; i++) {
304 for (i = 0; i < 8; i++) {
324 ex_emissive[3] = 0.0;
325 ex_emissive[1] = 0.0;
326 ex_emissive[0] = 0.0;
343static GLuint
tfan1[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 1 };
346static GLuint
tstr1[9] = { 1, 5, 9, 13, 17, 21, 25, 29, 33 };
347static GLuint
tstr2[9] = { 2, 6, 10, 14, 18, 22, 26, 30, 33 };
348static GLuint
tstr3[9] = { 3, 7, 11, 15, 19, 23, 27, 31, 33 };
349static GLuint
tstr4[9] = { 4, 8, 12, 16, 20, 24, 28, 32, 33 };
357static GLfloat
pA[6] = { 0.01, 0.0, 2.0, 4.0, 6.0, 10.0 };
359- (void)drawSubEntityImmediate:(
bool)immediate translucent:(
bool)translucent
365 if ([ship speedFactor] <= 0.001f)
374 HPVector cam = [PLAYER viewpointPosition];
375 for (
unsigned n = 0; n < 34 * 3; n++) {
389 OOGL(glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT));
391 OOGL(glDisable(GL_LIGHTING));
392 OOGL(glEnable(GL_BLEND));
393 OOGL(glDepthMask(GL_FALSE));
394 OOGL(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
395 OOGL(glEnable(GL_TEXTURE_2D));
399 OOGL(glShadeModel(GL_SMOOTH));
401 OOGL(glEnableClientState(GL_COLOR_ARRAY));
405 double intpart, dphase = 1.0 - modf((
double)[
UNIVERSE getTime] * 2.5, &intpart);
406 GLfloat phase = (GLfloat)dphase;
408 GLfloat texCoords[68] = {
483 OOGL(glTexCoordPointer(2, GL_FLOAT, 0, texCoords));
487 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT,
afttstr1));
488 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT,
afttstr2));
489 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT,
afttstr3));
490 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT,
afttstr4));
492 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 9, GL_UNSIGNED_INT,
tstr1));
493 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 9, GL_UNSIGNED_INT,
tstr2));
494 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 9, GL_UNSIGNED_INT,
tstr3));
495 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 9, GL_UNSIGNED_INT,
tstr4));
499 GLfloat fanTextures[18] = {
510 OOGL(glTexCoordPointer(2, GL_FLOAT, 0, fanTextures));
512 GLfloat fanColors[36];
518 fanColors[
i++] = 1.0;
523 fanColors[
i++] = 0.5;
525 OOGL(glColorPointer(4, GL_FLOAT, 0, fanColors));
527 OOGL(glDrawElements(GL_TRIANGLE_FAN, 10, GL_UNSIGNED_INT,
tfan1));
529 OOGL(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
530 OOGL(glDisable(GL_TEXTURE_2D));
532 OOGL(glDisableClientState(GL_COLOR_ARRAY));
539#define PREV(n) ((n + kExhaustFrameCount - 1) % kExhaustFrameCount)
540#define NEXT(n) ((n + 1) % kExhaustFrameCount)
558- (
Frame)frameAtTime:(
double)t_frame fromFrame:(
Frame)frame_zero
565 int t1 =
PREV(_nextFrame);
566 double moment_in_time = frame_zero.
timeframe + t_frame;
569 if (moment_in_time > _trackTime)
571 frame_one = _track[
t1];
572 period = (moment_in_time - t_frame) - _trackTime;
573 f0 = 1.0 + t_frame / period;
574 }
else if (moment_in_time < _track[_nextFrame].timeframe)
578 while (moment_in_time < _track[t1].timeframe) {
583 frame_zero = _track[
t0];
584 frame_one = _track[
t1];
586 f0 = (moment_in_time - _track[
t1].timeframe) / period;
590 double f1 = 1.0 - f0;
631- (void)rescaleBy:(GLfloat)factor
636- (void)rescaleBy:(GLfloat)factor writeToCache:(BOOL)writeToCache
652 options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask | kOOTextureRepeatT | kOOTextureRepeatS
674@implementation Entity (OOExhaustPlume)
static GLuint afttstr3[4]
static GLuint afttstr2[4]
static GLuint afttstr4[4]
static OOTexture * sPlumeTexture
static GLuint afttstr1[4]
OOINLINE HPVector vectorToHPVector(Vector v) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_subtract(HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPmagnitude(HPVector vec) INLINE_CONST_FUNC
OOINLINE HPVector make_HPvector(OOHPScalar vx, OOHPScalar vy, OOHPScalar vz) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_add(HPVector a, HPVector b) INLINE_CONST_FUNC
#define OO_ENTER_OPENGL()
HPVector OOHPVectorMultiplyMatrix(HPVector v, OOMatrix m) CONST_FUNC
void OOGLPushModelView(void)
OOMatrix OOGLPopModelView(void)
@ OPENGL_STATE_ADDITIVE_BLENDING
#define OOVerifyOpenGLState()
#define OOSetOpenGLState(STATE)
Vector vector_forward_from_quaternion(Quaternion quat) CONST_FUNC
const Quaternion kIdentityQuaternion
OOINLINE Vector vector_add(Vector a, Vector b) INLINE_CONST_FUNC
OOINLINE Vector make_vector(OOScalar vx, OOScalar vy, OOScalar vz) INLINE_CONST_FUNC
OOINLINE Vector cross_product(Vector first, Vector second) INLINE_CONST_FUNC
OOINLINE Vector vector_multiply_scalar(Vector v, OOScalar s) INLINE_CONST_FUNC
void setOwner:(Entity *ent)
OOMatrix drawTransformationMatrix()
Quaternion normalOrientation()
void setPosition:(HPVector posn)
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)
double findCollisionRadius()
GLfloat _exhaustBaseColors[34 *4]
Frame frameAtTime:fromFrame:(double t_frame, [fromFrame] Frame frame_zero)
void resetGraphicsState()
void setScale:(Vector scale)
GLfloat _glVertices[34 *3]
Frame _track[kExhaustFrameCount]
OOHPScalar _vertices[34 *3]
OOTexture * plumeTexture()
OOTimeAbsolute _trackTime
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)
OOColor * exhaustEmissiveColor()