34#import "MyOpenGLView.h"
37#define kLaserDuration (0.09)
40#define kLaserRed (1.0f)
41#define kLaserGreen (0.0f)
42#define kLaserBlue (0.0f)
45#define kLaserBrightness (5.0f)
48#define kLaserAlpha (0.45f / kLaserBrightness)
50#define kLaserCoreWidth (0.4f)
51#define kLaserFlareWidth (1.8f)
52#define kLaserHalfWidth (3.6f)
61 if (!(
self = [super
init]))
return nil;
64 Vector middle = OOBoundingBoxCenter([srcEntity
boundingBox]);
70 if (ship == srcEntity)
124 return [[[
self alloc] initLaserFromShip:ship direction:direction offset:offset] autorelease];
138 return [NSString stringWithFormat:@"ttl: %.3fs - %@ orientation %@", _lifetime, [
super descriptionComponents], QuaternionDescription([
self orientation])];
142- (void) setColor:(
OOColor *)color
151- (void) setRange:(GLfloat)range
154 [
self setCollisionRadius:range];
160 [
super update:delta_t];
171 [
self setPosition:HPvector_add([ship
position], vectorToHPVector(OOVectorMultiplyMatrix(_offset, [ship
drawRotationMatrix])))];
172 [
self setOrientation:quaternion_multiply(_relOrientation, [ship
normalOrientation])];
177 [UNIVERSE removeEntity:self];
196- (void) drawImmediate:(
bool)immediate translucent:(
bool)translucent
198 if (!translucent || [
UNIVERSE breakPatternHide])
return;
208 OOGL(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
209 OOGL(glEnable(GL_TEXTURE_2D));
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);
220 GLfloat laserTexCoords[] =
222 0.0f, phase, 0.0f, phase2, 1.0f, phase2, 1.0f, phase,
224 0.0f, phase, 0.0f, phase2, 1.0f, phase2, 1.0f, phase
226 GLfloat laserTexCoords2[] =
228 0.0f, phase3, 0.0f, phase4, 1.0f, phase4, 1.0f, phase3,
230 0.0f, phase3, 0.0f, phase4, 1.0f, phase4, 1.0f, phase3
235 glTexCoordPointer(2, GL_FLOAT, 0, laserTexCoords2);
236 glDrawArrays(GL_QUADS, 0, 8);
240 glDrawArrays(GL_QUADS, 0, 8);
242 [[
self texture2] apply];
245 glTexCoordPointer(2, GL_FLOAT, 0, laserTexCoords);
246 glDrawArrays(GL_QUADS, 0, 8);
249 OOGL(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
250 OOGL(glDisable(GL_TEXTURE_2D));
286 options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask | kOOTextureRepeatT
293 options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask | kOOTextureRepeatT
static OOTexture * sShotTexture2
static const GLfloat kLaserVertices[]
static OOTexture * sShotTexture
#define OO_ENTER_OPENGL()
void OOGLScaleModelView(Vector scale)
void OOGLPushModelView(void)
OOMatrix OOGLPopModelView(void)
@ OPENGL_STATE_ADDITIVE_BLENDING
#define OOVerifyOpenGLState()
BOOL OOCheckOpenGLErrors(NSString *format,...)
#define OOSetOpenGLState(STATE)
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)
@ WEAPON_FACING_STARBOARD
void setOrientation:(Quaternion quat)
void setOwner:(Entity *ent)
ShipEntity * rootShipEntity()
HPVector absolutePositionForSubentityOffset:(HPVector offset)
Quaternion normalOrientation()
void setStatus:(OOEntityStatus stat)
void setPosition:(HPVector posn)
OOMatrix drawRotationMatrix()
void registerClient:(id< OOGraphicsResetClient > client)
OOGraphicsResetManager * sharedManager()
void resetGraphicsState()
OOTexture * outerTexture()
void setRange:(GLfloat range)
NSString * descriptionComponents()
Quaternion _relOrientation
OOTexture * innerTexture()
id textureWithName:inFolder:options:anisotropy:lodBias:(NSString *name,[inFolder] NSString *directory,[options] OOTextureFlags options,[anisotropy] GLfloat anisotropy,[lodBias] GLfloat lodBias)