More work on reloading textures for the Win32 port. Mostly works, although some models don't seem to get their textures back, and some get the wrong ones. Most issues sort themselves out after the player's next witchspace jump. Stars, nebulae, planet, particle, and subentity issues fixes though.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@456 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
03d71df977
commit
c86eb2ed3b
@ -781,11 +781,14 @@ static Universe *data_store_universe;
|
||||
#ifdef WIN32
|
||||
int fi;
|
||||
|
||||
//NSLog(@"Entity::reloadTextures called on [%@]", [self description]);
|
||||
|
||||
// Force the entity to reload the textures for each face by clearing the face's texture name.
|
||||
for (fi = 0; fi < n_faces; fi++)
|
||||
faces[fi].texName = 0;
|
||||
|
||||
[self initialiseTextures];
|
||||
[self generateDisplayList];
|
||||
// Force the display list to be regenerated next time a frame is drawn.
|
||||
[self regenerateDisplayList];
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -795,19 +798,16 @@ static Universe *data_store_universe;
|
||||
// roll out each face and texture in turn
|
||||
//
|
||||
int fi,ti ;
|
||||
//
|
||||
|
||||
for (fi = 0; fi < n_faces; fi++)
|
||||
{
|
||||
// texture
|
||||
NSString* texture = [NSString stringWithUTF8String:(char*)faces[fi].textureFileStr255];
|
||||
// if ((faces[fi].texName == 0)&&(faces[fi].textureFile))
|
||||
if ((faces[fi].texName == 0)&&(texture))
|
||||
{
|
||||
// load texture into Universe texturestore
|
||||
// NSLog(@"Off to load %@",faces[fi].textureFile);
|
||||
//NSLog(@"Off to load %@", texture);
|
||||
if (universe)
|
||||
{
|
||||
// faces[fi].texName = [[universe textureStore] getTextureNameFor:faces[fi].textureFile];
|
||||
faces[fi].texName = [[universe textureStore] getTextureNameFor: texture];
|
||||
}
|
||||
}
|
||||
@ -817,7 +817,6 @@ static Universe *data_store_universe;
|
||||
{
|
||||
if (!texture_name[ti])
|
||||
{
|
||||
// texture_name[ti] = [[universe textureStore] getTextureNameFor: texture_file[ti]];
|
||||
texture_name[ti] = [[universe textureStore] getTextureNameFor: [NSString stringWithUTF8String: (char*)texture_file[ti]]];
|
||||
// NSLog(@"DEBUG (initialiseTextures) Processed textureFile : %@ to texName : %d", entityData[ti].textureFile, entityData[ti].texName);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
@implementation ParticleEntity
|
||||
|
||||
- (id) init
|
||||
{
|
||||
{
|
||||
self = [super init];
|
||||
//
|
||||
quaternion_set_identity(&q_rotation);
|
||||
@ -172,9 +172,9 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
Vector v_right = vector_right_from_quaternion(q_rotation);
|
||||
GLfloat fs = [ship flight_speed];
|
||||
velocity = make_vector( v_forward.x * fs, v_forward.y * fs, v_forward.z * fs);
|
||||
|
||||
|
||||
// NSLog(@"DEBUG firing laser with offset [ %.3f, %.3f, %.3f]", offset.x, offset.y, offset.z);
|
||||
|
||||
|
||||
position.x += offset.x * v_right.x + offset.y * v_up.x + offset.z * v_forward.x;
|
||||
position.y += offset.x * v_right.y + offset.y * v_up.y + offset.z * v_forward.y;
|
||||
position.z += offset.x * v_right.z + offset.y * v_up.z + offset.z * v_forward.z;
|
||||
@ -279,17 +279,17 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
}
|
||||
|
||||
- (id) initExhaustFromShip:(ShipEntity *) ship offsetVector:(Vector) offset scaleVector:(Vector) scale
|
||||
{
|
||||
{
|
||||
self = [super init]; // sets rotMatrix and q_rotation to initial identities
|
||||
//
|
||||
status = STATUS_EFFECT;
|
||||
|
||||
exhaustScale = scale;
|
||||
|
||||
|
||||
position.x = offset.x; // position is relative to owner
|
||||
position.y = offset.y;
|
||||
position.z = offset.z;
|
||||
|
||||
|
||||
particle_type = PARTICLE_EXHAUST;
|
||||
//
|
||||
[self setOwner:ship];
|
||||
@ -314,22 +314,22 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
scale.x = [(NSString *)[values objectAtIndex:3] floatValue];
|
||||
scale.y = [(NSString *)[values objectAtIndex:4] floatValue];
|
||||
scale.z = [(NSString *)[values objectAtIndex:5] floatValue];
|
||||
|
||||
|
||||
self = [super init];
|
||||
//
|
||||
status = STATUS_EFFECT;
|
||||
|
||||
|
||||
exhaustScale = scale;
|
||||
// NSLog(@"Adding an exhaust to %@ >>%@<< scale: ( %3.1f, %3.1f, %3.1f)", ship, details, exhaustScale.x, exhaustScale.y, exhaustScale.z);
|
||||
|
||||
|
||||
position.x = offset.x; // position is relative to owner
|
||||
position.y = offset.y;
|
||||
position.z = offset.z;
|
||||
|
||||
|
||||
particle_type = PARTICLE_EXHAUST;
|
||||
//
|
||||
[self setOwner:ship];
|
||||
//
|
||||
//
|
||||
isParticle = YES;
|
||||
//
|
||||
return self;
|
||||
@ -673,9 +673,9 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
isParticle = YES;
|
||||
//
|
||||
[self setVelocity: make_vector( 0.0f, 0.0f, 0.0f)];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG *FLASH* initialised at [ %.2f, %.2f, %.2f]", fragPos.x, fragPos.y, fragPos.z);
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -713,9 +713,9 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
isParticle = YES;
|
||||
//
|
||||
[self setVelocity: make_vector( 0.0f, 0.0f, 0.0f)];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG *FLASH* initialised at [ %.2f, %.2f, %.2f]", fragPos.x, fragPos.y, fragPos.z);
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -769,7 +769,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
/*
|
||||
-------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
//
|
||||
size = billSize;
|
||||
//
|
||||
@ -791,7 +791,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
isParticle = YES;
|
||||
//
|
||||
[self setVelocity: make_vector( 0.0f, 0.0f, 0.0f)];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -902,7 +902,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
return;
|
||||
// OOColor *rgbColor = [a_color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
||||
OOColor *rgbColor = a_color;
|
||||
|
||||
|
||||
if (color) [color release];
|
||||
color = [rgbColor retain];
|
||||
|
||||
@ -955,9 +955,9 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
{
|
||||
// NSLog(@"DEBUG update for %@",self);
|
||||
[super update:delta_t];
|
||||
|
||||
|
||||
time_counter += delta_t;
|
||||
|
||||
|
||||
if (universe)
|
||||
{
|
||||
switch (particle_type)
|
||||
@ -993,55 +993,55 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
case PARTICLE_TEST :
|
||||
alpha = (sin(time_counter) + 2.0) / 3.0;
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_EXPLOSION :
|
||||
[self updateExplosion:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_HYPERRING :
|
||||
[self updateHyperring:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_LASER_BEAM_RED :
|
||||
case PARTICLE_LASER_BEAM :
|
||||
[self updateLaser:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_EXHAUST :
|
||||
[self updateExhaust2:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_ECM_MINE :
|
||||
[self updateECMMine:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_ENERGY_MINE :
|
||||
[self updateEnergyMine:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_FLASHER :
|
||||
[self updateFlasher:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_SPARK :
|
||||
[self updateSpark:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_FRAGBURST :
|
||||
[self updateFragburst:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_BURST2 :
|
||||
[self updateBurst2:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_FLASH :
|
||||
[self updateFlash:delta_t];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_BILLBOARD :
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_SHOT_EXPIRED :
|
||||
case PARTICLE_SHOT_YELLOW_PLASMA :
|
||||
case PARTICLE_SHOT_GREEN_PLASMA :
|
||||
@ -1107,7 +1107,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
else
|
||||
v0.z = 1.0;
|
||||
//equivalent of v_forward
|
||||
|
||||
|
||||
Vector arb1;
|
||||
if ((v0.x == 0.0)&&(v0.y == 0.0))
|
||||
{
|
||||
@ -1117,17 +1117,17 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
{
|
||||
arb1.x = 0.0; arb1.y = 0.0; arb1.z = 1.0;
|
||||
}
|
||||
|
||||
|
||||
Vector v1 = cross_product( v0, arb1 ); // 90 degrees to (v0 x arb1)
|
||||
//equivalent of v_right
|
||||
|
||||
|
||||
Vector v2 = cross_product( v0, v1 ); // 90 degrees to (v0 x v1)
|
||||
//equivalent of v_up
|
||||
|
||||
|
||||
vectors_into_gl_matrix( v0, v1, v2, rotMatrix);
|
||||
//
|
||||
// end of new billboard routine
|
||||
|
||||
|
||||
GLfloat tf = time_counter / duration;
|
||||
GLfloat stf = tf * tf;
|
||||
GLfloat expansion_speed = 0.0;
|
||||
@ -1135,12 +1135,12 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
expansion_speed = 240 + 10 / (tf * tf);
|
||||
if (expansion_speed > 1000.0)
|
||||
expansion_speed = 1000.0;
|
||||
|
||||
|
||||
velocity.z = expansion_speed;
|
||||
|
||||
|
||||
collision_radius += delta_t * expansion_speed; // expand
|
||||
energy = 10000 - 9000 * tf; // 10000 -> 1000
|
||||
|
||||
|
||||
alpha = 0.5 * ((0.025 / tf) + 1.0 - stf);
|
||||
if (alpha > 1.0) alpha = 1.0;
|
||||
color_fv[0] = 1.0 - 5.0 * tf;
|
||||
@ -1149,7 +1149,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
color_fv[1] = 1.0 - 5.0 * tf;
|
||||
if (color_fv[1] > 1.0) color_fv[1] = 1.0;
|
||||
if (color_fv[1] < 0.0) color_fv[1] = 0.0;
|
||||
|
||||
|
||||
// manageCollisions
|
||||
if ([collidingEntities count] > 0)
|
||||
{
|
||||
@ -1160,7 +1160,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
[e takeEnergyDamage:energy from:self becauseOf:[self owner]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// expire after ttl
|
||||
if (time_counter > duration) // until the timer runs out!
|
||||
[universe removeEntity:self];
|
||||
@ -1206,12 +1206,12 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
alpha = (duration - time_counter) / duration;
|
||||
if (alpha < 0.0) alpha = 0.0;
|
||||
if (alpha > 1.0) alpha = 1.0;
|
||||
|
||||
|
||||
// fade towards transparent red
|
||||
color_fv[0] = alpha * [color redComponent] + (1.0 - alpha) * 1.0;
|
||||
color_fv[1] = alpha * [color greenComponent];// + (1.0 - alpha) * 0.0;
|
||||
color_fv[2] = alpha * [color blueComponent];// + (1.0 - alpha) * 0.0;
|
||||
|
||||
|
||||
// disappear eventually
|
||||
if (time_counter > duration)
|
||||
[universe removeEntity:self];
|
||||
@ -1254,7 +1254,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
vertices[i].y += vertex_normal[i].y * delta_t;
|
||||
vertices[i].z += vertex_normal[i].z * delta_t;
|
||||
}
|
||||
|
||||
|
||||
// disappear eventually
|
||||
if (time_counter > duration)
|
||||
[universe removeEntity:self];
|
||||
@ -1277,7 +1277,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
vertices[i].y += vertex_normal[i].y * delta_t;
|
||||
vertices[i].z += vertex_normal[i].z * delta_t;
|
||||
}
|
||||
|
||||
|
||||
// disappear eventually
|
||||
if (time_counter > duration)
|
||||
[universe removeEntity:self];
|
||||
@ -1287,7 +1287,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
{
|
||||
GLfloat tf = duration * 0.667;
|
||||
GLfloat tf1 = duration - tf;
|
||||
|
||||
|
||||
// move as necessary
|
||||
position.x += velocity.x * delta_t;
|
||||
position.y += velocity.y * delta_t;
|
||||
@ -1296,19 +1296,19 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
// scale up
|
||||
size.width += delta_t * growth_rate;
|
||||
size.height = size.width;
|
||||
|
||||
|
||||
// fade up
|
||||
if ((time_counter)&&(time_counter < tf))
|
||||
alpha = time_counter/tf;
|
||||
|
||||
|
||||
// fade out
|
||||
if (time_counter > tf)
|
||||
alpha = (duration - time_counter)/tf1;
|
||||
|
||||
|
||||
// disappear eventually
|
||||
if (time_counter > duration)
|
||||
[universe removeEntity:self];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG *FLASH* time: %.2f size: %.2f alpha: %.2f", time_counter, size.width, alpha);
|
||||
|
||||
}
|
||||
@ -1319,13 +1319,13 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
GLfloat s1[8] = { 0.0, 0.707, 1.0, 0.707, 0.0, -0.707, -1.0, -0.707};
|
||||
GLfloat c1[8] = { 1.0, 0.707, 0.0, -0.707, -1.0, -0.707, 0.0, 0.707};
|
||||
ShipEntity *ship =(ShipEntity *)[universe entityForUniversalID:owner];
|
||||
|
||||
|
||||
if (!ship)
|
||||
return;
|
||||
|
||||
|
||||
Quaternion shipQrotation = ship->q_rotation;
|
||||
if (ship->isPlayer) shipQrotation.w = -shipQrotation.w;
|
||||
|
||||
|
||||
Frame zero;
|
||||
zero.q_rotation = shipQrotation;
|
||||
int dam = [ship damage];
|
||||
@ -1345,15 +1345,15 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
red_factor = 1.5;
|
||||
flare_length = 1.0 + 0.25 * flare_length;
|
||||
}
|
||||
|
||||
|
||||
if ((ranrot_rand() % 50) < dam - 50) // flicker the damaged engines
|
||||
red_factor = 0.0;
|
||||
if ((ranrot_rand() % 40) < dam - 60)
|
||||
green_factor = 0.0;
|
||||
if ((ranrot_rand() % 25) < dam - 75)
|
||||
flare_factor = 0.0;
|
||||
|
||||
if (flare_length < 0.1) flare_length = 0.1;
|
||||
|
||||
if (flare_length < 0.1) flare_length = 0.1;
|
||||
Vector currentPos = ship->position;
|
||||
Vector vfwd = vector_forward_from_quaternion(shipQrotation);
|
||||
GLfloat spd = 0.5 * [ship flight_speed];
|
||||
@ -1368,7 +1368,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
zero.position = make_vector( currentPos.x + vi.x * position.x + vj.x * position.y + vk.x * position.z,
|
||||
currentPos.y + vi.y * position.x + vj.y * position.y + vk.y * position.z,
|
||||
currentPos.z + vi.z * position.x + vj.z * position.y + vk.z * position.z);
|
||||
|
||||
|
||||
GLfloat i01 = -0.03;// * flare_length;
|
||||
GLfloat i03 = -0.12;// * flare_length;
|
||||
GLfloat i06 = -0.25;// * flare_length;
|
||||
@ -1383,13 +1383,13 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
GLfloat r06 = 1.0 - q06;
|
||||
GLfloat r08 = 1.0 - q08;
|
||||
Frame f01 = [self frameAtTime: i01 fromFrame: zero];
|
||||
Vector b01 = make_vector( r01 * i01 * vfwd.x, r01 * i01 * vfwd.y, r01 * i01 * vfwd.z);
|
||||
Vector b01 = make_vector( r01 * i01 * vfwd.x, r01 * i01 * vfwd.y, r01 * i01 * vfwd.z);
|
||||
Frame f03 = [self frameAtTime: i03 fromFrame: zero];
|
||||
Vector b03 = make_vector( r03 * i03 * vfwd.x, r03 * i03 * vfwd.y, r03 * i03 * vfwd.z);
|
||||
Vector b03 = make_vector( r03 * i03 * vfwd.x, r03 * i03 * vfwd.y, r03 * i03 * vfwd.z);
|
||||
Frame f06 = [self frameAtTime: i06 fromFrame: zero];
|
||||
Vector b06 = make_vector( r06 * i06 * vfwd.x, r06 * i06 * vfwd.y, r06 * i06 * vfwd.z);
|
||||
Vector b06 = make_vector( r06 * i06 * vfwd.x, r06 * i06 * vfwd.y, r06 * i06 * vfwd.z);
|
||||
Frame f08 = [self frameAtTime: i08 fromFrame: zero];
|
||||
Vector b08 = make_vector( r08 * i08 * vfwd.x, r08 * i08 * vfwd.y, r08 * i08 * vfwd.z);
|
||||
Vector b08 = make_vector( r08 * i08 * vfwd.x, r08 * i08 * vfwd.y, r08 * i08 * vfwd.z);
|
||||
Frame f10 = [self frameAtTime: i10 fromFrame: zero];
|
||||
|
||||
int ci = 0;
|
||||
@ -1414,11 +1414,11 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
Vector k1 = f01.k;
|
||||
Vector j1 = cross_product( master_i, k1);
|
||||
Vector i1 = cross_product( j1, k1);
|
||||
|
||||
|
||||
f01.position = make_vector(zero.position.x - vk.x, zero.position.y - vk.y, zero.position.z - vk.z);// 1m out from zero
|
||||
// i1 = vi;
|
||||
// j1 = vj; // initial vars
|
||||
|
||||
|
||||
i1.x *= exhaustScale.x; i1.y *= exhaustScale.x; i1.z *= exhaustScale.x;
|
||||
j1.x *= exhaustScale.y; j1.y *= exhaustScale.y; j1.z *= exhaustScale.y;
|
||||
for (i = 0; i < 8; i++)
|
||||
@ -1507,15 +1507,15 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
- (void) drawEntity:(BOOL) immediate :(BOOL) translucent;
|
||||
{
|
||||
NSString* debug_type = @"PLAIN";
|
||||
|
||||
|
||||
if (!universe)
|
||||
return;
|
||||
|
||||
|
||||
if ([universe breakPatternHide])
|
||||
return; // DON'T DRAW DURING BREAK PATTERN
|
||||
|
||||
|
||||
if ((particle_type == PARTICLE_FLASHER)&&(zero_distance > no_draw_distance)) return; // TOO FAR AWAY TO SEE
|
||||
|
||||
|
||||
if (translucent)
|
||||
{
|
||||
switch (particle_type)
|
||||
@ -1524,22 +1524,22 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
[self drawLaser];
|
||||
debug_type = @"PARTICLE_LASER_BEAM_RED";
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_EXHAUST :
|
||||
[self drawExhaust2];
|
||||
debug_type = @"PARTICLE_EXHAUST";
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_HYPERRING :
|
||||
[self drawHyperring];
|
||||
debug_type = @"PARTICLE_HYPERRING";
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_ECM_MINE :
|
||||
// not a visible entity
|
||||
debug_type = @"PARTICLE_ECM_MINE";
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_ENERGY_MINE :
|
||||
[self drawEnergyMine];
|
||||
debug_type = @"PARTICLE_ENERGY_MINE";
|
||||
@ -1549,22 +1549,22 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
[self drawFragburst];
|
||||
debug_type = @"PARTICLE_FRAGBURST";
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_BURST2 :
|
||||
[self drawBurst2];
|
||||
debug_type = @"PARTICLE_BURST2";
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_FLASH :
|
||||
debug_type = @"PARTICLE_FLASH";
|
||||
debug_type = @"PARTICLE_FLASH";
|
||||
[self drawParticle];
|
||||
break;
|
||||
|
||||
|
||||
case PARTICLE_BILLBOARD :
|
||||
debug_type = @"PARTICLE_BILLBOARD";
|
||||
debug_type = @"PARTICLE_BILLBOARD";
|
||||
[self drawBillboard];
|
||||
break;
|
||||
|
||||
|
||||
default :
|
||||
[self drawParticle];
|
||||
break;
|
||||
@ -1578,7 +1578,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
// NSLog(@"DEBUG drawing subentity %@ for %@", self, [universe entityForUniversalID:owner]);
|
||||
|
||||
if (particle_type == PARTICLE_EXHAUST)
|
||||
{
|
||||
{
|
||||
if (translucent)
|
||||
[self drawExhaust2];
|
||||
return;
|
||||
@ -1594,12 +1594,12 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
if (zero_distance > no_draw_distance)
|
||||
return; // TOO FAR AWAY TO DRAW
|
||||
}
|
||||
|
||||
|
||||
if ((particle_type == PARTICLE_FLASHER)&&(status != STATUS_INACTIVE))
|
||||
{
|
||||
gl_matrix temp_matrix;
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, temp_matrix);
|
||||
|
||||
|
||||
Vector abspos = position; // in control of it's own orientation
|
||||
Entity* father = my_owner;
|
||||
GLfloat* r_mat = [father drawRotationMatrix];
|
||||
@ -1614,15 +1614,15 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
father = nil;
|
||||
r_mat = [father drawRotationMatrix];
|
||||
}
|
||||
|
||||
|
||||
glPopMatrix(); // restore zero!
|
||||
glPushMatrix();
|
||||
// position and orientation is absolute
|
||||
glTranslatef( abspos.x, abspos.y, abspos.z);
|
||||
glMultMatrixf([[universe entityZero] drawRotationMatrix]);
|
||||
|
||||
|
||||
[self drawEntity:immediate :translucent];
|
||||
|
||||
|
||||
glLoadMatrixf( temp_matrix);
|
||||
}
|
||||
}
|
||||
@ -1631,33 +1631,33 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
- (void) drawParticle
|
||||
{
|
||||
int viewdir;
|
||||
|
||||
|
||||
GLfloat xx = 0.5 * size.width;
|
||||
GLfloat yy = 0.5 * size.height;
|
||||
|
||||
|
||||
if (alpha < 0.0)
|
||||
alpha = 0.0; // clamp the alpha value
|
||||
if (alpha > 1.0)
|
||||
alpha = 1.0; // clamp the alpha value
|
||||
|
||||
color_fv[3] = alpha;
|
||||
|
||||
|
||||
// movies:
|
||||
// draw data required xx, yy, color_fv[0], color_fv[1], color_fv[2]
|
||||
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
glColor4f( color_fv[0], color_fv[1], color_fv[2], alpha);
|
||||
|
||||
|
||||
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color_fv);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texName);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
|
||||
viewdir = [universe viewDir];
|
||||
|
||||
|
||||
switch (viewdir)
|
||||
{
|
||||
case VIEW_AFT :
|
||||
@ -1669,11 +1669,11 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
glTexCoord2f(1.0, 0.0);
|
||||
glVertex3f(-xx, yy, xx);
|
||||
|
||||
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
glVertex3f(xx, yy, xx);
|
||||
break;
|
||||
|
||||
|
||||
case VIEW_STARBOARD :
|
||||
glTexCoord2f(0.0, 1.0);
|
||||
glVertex3f(-xx, -yy, xx);
|
||||
@ -1683,11 +1683,11 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
glTexCoord2f(1.0, 0.0);
|
||||
glVertex3f(-xx, yy, -xx);
|
||||
|
||||
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
glVertex3f(-xx, yy, xx);
|
||||
break;
|
||||
|
||||
|
||||
case VIEW_PORT :
|
||||
glTexCoord2f(0.0, 1.0);
|
||||
glVertex3f(xx, -yy, -xx);
|
||||
@ -1697,11 +1697,11 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
glTexCoord2f(1.0, 0.0);
|
||||
glVertex3f(xx, yy, xx);
|
||||
|
||||
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
glVertex3f(xx, yy, -xx);
|
||||
break;
|
||||
|
||||
|
||||
default :
|
||||
glTexCoord2f(0.0, 1.0);
|
||||
glVertex3f(-xx, -yy, -xx);
|
||||
@ -1711,7 +1711,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
glTexCoord2f(1.0, 0.0);
|
||||
glVertex3f(xx, yy, -xx);
|
||||
|
||||
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
glVertex3f(-xx, yy, -xx);
|
||||
break;
|
||||
@ -1723,30 +1723,30 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
- (void) drawLaser
|
||||
{
|
||||
color_fv[3] = 0.75; // set alpha
|
||||
|
||||
|
||||
glDisable(GL_CULL_FACE); // face culling
|
||||
|
||||
|
||||
// movies:
|
||||
// draw data required collision_radius, color_fv[0], color_fv[1], color_fv[2]
|
||||
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
glColor4fv(color_fv);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
|
||||
glVertex3f(0.25, 0.0, 0.0);
|
||||
glVertex3f(0.25, 0.0, collision_radius);
|
||||
glVertex3f(-0.25, 0.0, collision_radius);
|
||||
glVertex3f(-0.25, 0.0, 0.0);
|
||||
|
||||
|
||||
glVertex3f(0.0, 0.25, 0.0);
|
||||
glVertex3f(0.0, 0.25, collision_radius);
|
||||
glVertex3f(0.0, -0.25, collision_radius);
|
||||
glVertex3f(0.0, -0.25, 0.0);
|
||||
|
||||
|
||||
glEnd();
|
||||
|
||||
|
||||
glEnable(GL_CULL_FACE); // face culling
|
||||
}
|
||||
|
||||
@ -1757,12 +1757,12 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
GLuint qstrip2[18] = { 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 16, 24, 9, 17}; // second quadstrip 28..45
|
||||
GLuint qstrip3[18] = { 17, 25, 18, 26, 19, 27, 20, 28, 21, 29, 22, 30, 23, 31, 24, 32, 17, 25}; // third quadstrip 46..63
|
||||
GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..73
|
||||
|
||||
|
||||
ShipEntity *ship =(ShipEntity *)[universe entityForUniversalID:owner];
|
||||
|
||||
|
||||
if (!ship)
|
||||
return;
|
||||
|
||||
|
||||
if ([ship speed_factor] <= 0.0) // don't draw if there's no fire!
|
||||
return;
|
||||
|
||||
@ -1772,7 +1772,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
glDisable( GL_TEXTURE_2D);
|
||||
glDisable( GL_CULL_FACE); // face culling
|
||||
glShadeModel( GL_SMOOTH);
|
||||
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer( 3, GL_FLOAT, 0, verts);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
@ -1787,7 +1787,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
glDrawElements( GL_QUAD_STRIP, 18, GL_UNSIGNED_INT, qstrip2);
|
||||
glDrawElements( GL_QUAD_STRIP, 18, GL_UNSIGNED_INT, qstrip3);
|
||||
glDrawElements( GL_TRIANGLE_FAN, 10, GL_UNSIGNED_INT, tfan2);
|
||||
|
||||
|
||||
glEnable( GL_CULL_FACE); // face culling
|
||||
glEnable( GL_TEXTURE_2D);
|
||||
}
|
||||
@ -1796,20 +1796,20 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
{
|
||||
int i;
|
||||
GLfloat aleph = (alpha < 2.0) ? alpha*0.5 : 1.0;
|
||||
|
||||
|
||||
GLfloat ex_em_hi[4] = {0.6, 0.8, 1.0, aleph}; // pale blue
|
||||
GLfloat ex_em_lo[4] = {0.2, 0.0, 1.0, 0.0}; // purplish-blue-black
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glDisable(GL_CULL_FACE); // face culling
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
//NSLog(@"... drawing hyppering inner_radius:%.1f alpha:%.2f", ring_inner_radius, aleph);
|
||||
|
||||
|
||||
// movies:
|
||||
// draw data required ring_inner_radius, ring_outer_radius
|
||||
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
for (i = 0; i < 65; i++)
|
||||
{
|
||||
@ -1827,12 +1827,12 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
- (void) drawEnergyMine
|
||||
{
|
||||
double szd = sqrt(zero_distance);
|
||||
|
||||
|
||||
color_fv[3] = alpha; // set alpha
|
||||
|
||||
|
||||
glDisable(GL_CULL_FACE); // face culling
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
int step = 4;
|
||||
|
||||
glColor4fv( color_fv);
|
||||
@ -1841,23 +1841,23 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
drawBallVertices( collision_radius, step, szd);
|
||||
//
|
||||
glEnd();
|
||||
|
||||
|
||||
// NSLog(@"DEBUG ENERGY BOMB radius: %.3f, expansion: %.3f, color: [ %.3f, %.3f, %.3f, %.3f]", collision_radius, velocity.z, color_fv[0], color_fv[1], color_fv[2], alpha);
|
||||
|
||||
|
||||
glEnable(GL_CULL_FACE); // face culling
|
||||
}
|
||||
|
||||
- (void) drawFragburst
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
int viewdir = universe->viewDirection;
|
||||
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, texName);
|
||||
glPushMatrix();
|
||||
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
@ -1865,7 +1865,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
drawQuadForView( viewdir, vertices[i].x, vertices[i].y, vertices[i].z, faces[i].normal.x, faces[i].normal.x);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
@ -1873,9 +1873,9 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
- (void) drawBurst2
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
int viewdir = universe->viewDirection;
|
||||
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, texName);
|
||||
@ -1888,7 +1888,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
drawQuadForView( viewdir, vertices[i].x, vertices[i].y, vertices[i].z, size.width, size.width);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
@ -1930,4 +1930,21 @@ void drawQuadForView(int viewdir, GLfloat x, GLfloat y, GLfloat z, GLfloat xx, G
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
||||
- (void) reloadTextures
|
||||
{
|
||||
//NSLog(@"ParticleEntity::reloadTextures called, calling super and resetTextureNames");
|
||||
|
||||
// Force the sky textures to be reloaded next time a frame is drawn.
|
||||
texName = 0;
|
||||
faces[0].texName = 0;
|
||||
faces[1].texName = 0;
|
||||
|
||||
// Reset the entity display list.
|
||||
[super reloadTextures];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
@ -189,11 +189,11 @@ void setUpSinTable()
|
||||
[sun_color getHue:&hue saturation:&sat brightness:&bri alpha:&alf];
|
||||
//
|
||||
float hue_drift = 0.34 * (randf() - randf());
|
||||
|
||||
|
||||
// set the lighting color for the sun
|
||||
GLfloat r,g,b,a;
|
||||
[sun_color getRed:&r green:&g blue:&b alpha:&a];
|
||||
|
||||
|
||||
GLfloat sun_ambient[] = { 0.0, 0.0, 0.0, 1.0}; // ambient light about 5%
|
||||
sun_diffuse[0] = 0.5 * (1.0 + r); // paler
|
||||
sun_diffuse[1] = 0.5 * (1.0 + g); // paler
|
||||
@ -207,7 +207,7 @@ void setUpSinTable()
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, sun_ambient);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, sun_diffuse);
|
||||
glLightfv(GL_LIGHT1, GL_SPECULAR, sun_specular);
|
||||
|
||||
|
||||
//
|
||||
// main disc less saturation more brightness
|
||||
color = [OOColor colorWithCalibratedHue: hue saturation: sat * 0.333 brightness: 1.0 alpha: alf];
|
||||
@ -257,7 +257,7 @@ void setUpSinTable()
|
||||
}
|
||||
|
||||
- (id) initAsAtmosphereForPlanet:(PlanetEntity *) planet
|
||||
{
|
||||
{
|
||||
int i;
|
||||
int percent_land;
|
||||
double aleph = 1.0 / sqrt(2.0);
|
||||
@ -279,7 +279,7 @@ void setUpSinTable()
|
||||
shuttles_on_ground = 0;
|
||||
last_launch_time = 0.0;
|
||||
shuttle_launch_interval = 60 * 60;
|
||||
|
||||
|
||||
scan_class = CLASS_NO_DRAW;
|
||||
//
|
||||
q_rotation.w = aleph; // represents a 90 degree rotation around x axis
|
||||
@ -319,9 +319,9 @@ void setUpSinTable()
|
||||
amb_polar_sea[1] = 0.9 + gen_rnd_number() / 2560.0;
|
||||
amb_polar_sea[2] = 0.9 + gen_rnd_number() / 2560.0;
|
||||
amb_polar_sea[3] = 0.75; // 75% clouds
|
||||
|
||||
|
||||
atmosphere = nil;
|
||||
|
||||
|
||||
// NSLog(@"DEBUG atmosphere testing [PlanetEntity initialiseBaseVertexArray]");
|
||||
[self initialiseBaseVertexArray];
|
||||
|
||||
@ -337,7 +337,7 @@ void setUpSinTable()
|
||||
|
||||
// set speed of rotation
|
||||
rotational_velocity = 0.01 + 0.02 * randf(); // 0.01 .. 0.03 avr 0.02;
|
||||
|
||||
|
||||
//
|
||||
usingVAR = [self OGL_InitVAR];
|
||||
//
|
||||
@ -350,7 +350,7 @@ void setUpSinTable()
|
||||
}
|
||||
|
||||
- (id) initAsCoronaForPlanet:(PlanetEntity *) planet
|
||||
{
|
||||
{
|
||||
self = [super init];
|
||||
//
|
||||
isTextured = NO;
|
||||
@ -377,9 +377,9 @@ void setUpSinTable()
|
||||
amb_land[1] = 0.85;
|
||||
amb_land[2] = 1.0;
|
||||
amb_land[3] = 1.0; // blue color
|
||||
|
||||
|
||||
atmosphere = nil;
|
||||
|
||||
|
||||
[self setOwner:planet];
|
||||
//
|
||||
isPlanet = YES;
|
||||
@ -388,7 +388,7 @@ void setUpSinTable()
|
||||
}
|
||||
|
||||
- (id) initWithSeed:(Random_Seed) p_seed fromUniverse:(Universe *) uni
|
||||
{
|
||||
{
|
||||
int i;
|
||||
int percent_land;
|
||||
double aleph = 1.0 / sqrt(2.0);
|
||||
@ -411,15 +411,15 @@ void setUpSinTable()
|
||||
textureName = [[uni textureStore] getTextureNameFor:(NSString*)[planetinfo objectForKey:@"texture"]];
|
||||
isTextured = (textureName != 0);
|
||||
}
|
||||
|
||||
|
||||
shuttles_on_ground = 1 + floor(techlevel * 0.5);
|
||||
last_launch_time = 0.0;
|
||||
shuttle_launch_interval = 3600.0 / shuttles_on_ground; // all are launched in an hour
|
||||
last_launch_time = -(ranrot_rand() % 60) * shuttle_launch_interval/60.0;
|
||||
last_launch_time = 30.0 - shuttle_launch_interval; // debug - launch 30s after player enters universe
|
||||
|
||||
|
||||
//NSLog(@"shuttles on ground:%d launch_interval:%.1f minutes", shuttles_on_ground, shuttle_launch_interval/60);
|
||||
|
||||
|
||||
//collision_radius = 25000.0; // 25km across
|
||||
collision_radius = radius_km * 10.0; // scale down by a factor of 100 !
|
||||
//
|
||||
@ -439,19 +439,19 @@ void setUpSinTable()
|
||||
//
|
||||
[self rescaleTo:1.0];
|
||||
//
|
||||
|
||||
|
||||
percent_land = (gen_rnd_number() % 48);
|
||||
|
||||
|
||||
//// possibly get percent_land from planetinfo.plist entry
|
||||
//
|
||||
if ([planetinfo objectForKey:@"percent_land"])
|
||||
{
|
||||
percent_land = [(NSNumber *)[planetinfo objectForKey:@"percent_land"] intValue];
|
||||
}
|
||||
|
||||
|
||||
// save the current random number generator seed
|
||||
RNG_Seed saved_seed = currentRandomSeed();
|
||||
|
||||
|
||||
//NSLog(@"Planet surface is %d percent land.",percent_land);
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
@ -464,14 +464,14 @@ void setUpSinTable()
|
||||
polar_color_factor = 1.0;
|
||||
//
|
||||
Vector land_hsb, sea_hsb, land_polar_hsb, sea_polar_hsb;
|
||||
|
||||
land_hsb.x = gen_rnd_number() / 256.0; land_hsb.y = gen_rnd_number() / 256.0; land_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
|
||||
land_hsb.x = gen_rnd_number() / 256.0; land_hsb.y = gen_rnd_number() / 256.0; land_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
while (dot_product(land_hsb,sea_hsb) > .80) // make sure land and sea colors differ significantly
|
||||
{
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
}
|
||||
|
||||
|
||||
//// possibly get land_hsb and sea_hsb from planetinfo.plist entry
|
||||
//
|
||||
if ([planetinfo objectForKey:@"land_hsb_color"])
|
||||
@ -480,11 +480,11 @@ void setUpSinTable()
|
||||
sea_hsb = [Entity vectorFromString:(NSString *)[planetinfo objectForKey:@"sea_hsb_color"]];
|
||||
//
|
||||
////
|
||||
|
||||
|
||||
// polar areas are brighter but have less color (closer to white)
|
||||
//
|
||||
land_polar_hsb.x = land_hsb.x; land_polar_hsb.y = (land_hsb.y / 5.0); land_polar_hsb.z = 1.0 - (land_hsb.z / 10.0);
|
||||
sea_polar_hsb.x = sea_hsb.x; sea_polar_hsb.y = (sea_hsb.y / 5.0); sea_polar_hsb.z = 1.0 - (sea_hsb.z / 10.0);
|
||||
land_polar_hsb.x = land_hsb.x; land_polar_hsb.y = (land_hsb.y / 5.0); land_polar_hsb.z = 1.0 - (land_hsb.z / 10.0);
|
||||
sea_polar_hsb.x = sea_hsb.x; sea_polar_hsb.y = (sea_hsb.y / 5.0); sea_polar_hsb.z = 1.0 - (sea_hsb.z / 10.0);
|
||||
|
||||
amb_land[0] = [[OOColor colorWithCalibratedHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] redComponent];
|
||||
amb_land[1] = [[OOColor colorWithCalibratedHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] blueComponent];
|
||||
@ -502,24 +502,24 @@ void setUpSinTable()
|
||||
amb_polar_sea[1] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] blueComponent];
|
||||
amb_polar_sea[2] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] greenComponent];
|
||||
amb_polar_sea[3] = 1.0;
|
||||
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseVertexArray]");
|
||||
[self initialiseBaseVertexArray];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
||||
setRandomSeed(saved_seed);
|
||||
[self initialiseBaseTerrainArray:percent_land];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG painting %d vertices", next_free_vertex);
|
||||
for (i = 0; i < next_free_vertex; i++)
|
||||
[self paintVertex:i :planet_seed];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG scaling %d vertices", next_free_vertex);
|
||||
[self scaleVertices];
|
||||
|
||||
|
||||
// set speed of rotation
|
||||
rotational_velocity = 0.01 * randf(); // 0.0 .. 0.01 avr 0.005;
|
||||
|
||||
|
||||
// do atmosphere
|
||||
//
|
||||
atmosphere = [[PlanetEntity alloc] initAsAtmosphereForPlanet:self];
|
||||
@ -538,7 +538,7 @@ void setUpSinTable()
|
||||
}
|
||||
|
||||
- (id) initPlanetFromDictionary:(NSDictionary*) dict inUniverse:(Universe *) uni
|
||||
{
|
||||
{
|
||||
int i;
|
||||
int percent_land;
|
||||
double aleph = 1.0 / sqrt(2.0);
|
||||
@ -584,14 +584,14 @@ void setUpSinTable()
|
||||
{
|
||||
radius_km = [[dict objectForKey:@"radius"] intValue];
|
||||
}
|
||||
|
||||
|
||||
shuttles_on_ground = 0;
|
||||
last_launch_time = 0.0;
|
||||
shuttle_launch_interval = 3600.0 / shuttles_on_ground; // all are launched in an hour
|
||||
last_launch_time = 3600.0;
|
||||
|
||||
|
||||
//NSLog(@"shuttles on ground:%d launch_interval:%.1f minutes", shuttles_on_ground, shuttle_launch_interval/60);
|
||||
|
||||
|
||||
collision_radius = radius_km * 10.0; // scale down by a factor of 100 !
|
||||
//
|
||||
scan_class = CLASS_NO_DRAW;
|
||||
@ -610,7 +610,7 @@ void setUpSinTable()
|
||||
//
|
||||
[self rescaleTo:1.0];
|
||||
//
|
||||
|
||||
|
||||
percent_land = (gen_rnd_number() % 48);
|
||||
if ([dict objectForKey:@"percent_land"])
|
||||
{
|
||||
@ -618,10 +618,10 @@ void setUpSinTable()
|
||||
}
|
||||
if (isTextured)
|
||||
percent_land = 0;
|
||||
|
||||
|
||||
// save the current random number generator seed
|
||||
RNG_Seed saved_seed = currentRandomSeed();
|
||||
|
||||
|
||||
//NSLog(@"Planet surface is %d percent land.",percent_land);
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
@ -636,14 +636,14 @@ void setUpSinTable()
|
||||
polar_color_factor = [[dict objectForKey:@"polar_color_factor"] doubleValue];
|
||||
//
|
||||
Vector land_hsb, sea_hsb, land_polar_hsb, sea_polar_hsb;
|
||||
|
||||
|
||||
if (!isTextured)
|
||||
{
|
||||
land_hsb.x = gen_rnd_number() / 256.0; land_hsb.y = gen_rnd_number() / 256.0; land_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
land_hsb.x = gen_rnd_number() / 256.0; land_hsb.y = gen_rnd_number() / 256.0; land_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
while (dot_product(land_hsb,sea_hsb) > .80) // make sure land and sea colors differ significantly
|
||||
{
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -651,7 +651,7 @@ void setUpSinTable()
|
||||
land_hsb.x = 0.0; land_hsb.y = 0.0; land_hsb.z = 1.0; // non-saturated fully bright (white)
|
||||
sea_hsb.x = 0.0; sea_hsb.y = 1.0; sea_hsb.z = 1.0; // fully-saturated fully bright (red)
|
||||
}
|
||||
|
||||
|
||||
//// possibly get land_hsb and sea_hsb from planetinfo.plist entry
|
||||
//
|
||||
if ([dict objectForKey:@"land_hsb_color"])
|
||||
@ -664,11 +664,11 @@ void setUpSinTable()
|
||||
}
|
||||
//
|
||||
////
|
||||
|
||||
|
||||
// polar areas are brighter but have less color (closer to white)
|
||||
//
|
||||
land_polar_hsb.x = land_hsb.x; land_polar_hsb.y = (land_hsb.y / 5.0); land_polar_hsb.z = 1.0 - (land_hsb.z / 10.0);
|
||||
sea_polar_hsb.x = sea_hsb.x; sea_polar_hsb.y = (sea_hsb.y / 5.0); sea_polar_hsb.z = 1.0 - (sea_hsb.z / 10.0);
|
||||
land_polar_hsb.x = land_hsb.x; land_polar_hsb.y = (land_hsb.y / 5.0); land_polar_hsb.z = 1.0 - (land_hsb.z / 10.0);
|
||||
sea_polar_hsb.x = sea_hsb.x; sea_polar_hsb.y = (sea_hsb.y / 5.0); sea_polar_hsb.z = 1.0 - (sea_hsb.z / 10.0);
|
||||
|
||||
amb_land[0] = [[OOColor colorWithCalibratedHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] redComponent];
|
||||
amb_land[1] = [[OOColor colorWithCalibratedHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] blueComponent];
|
||||
@ -686,26 +686,26 @@ void setUpSinTable()
|
||||
amb_polar_sea[1] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] blueComponent];
|
||||
amb_polar_sea[2] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] greenComponent];
|
||||
amb_polar_sea[3] = 1.0;
|
||||
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseVertexArray]");
|
||||
[self initialiseBaseVertexArray];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
||||
setRandomSeed(saved_seed);
|
||||
[self initialiseBaseTerrainArray:percent_land];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG painting %d vertices", next_free_vertex);
|
||||
for (i = 0; i < next_free_vertex; i++)
|
||||
[self paintVertex:i :planet_seed];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG scaling %d vertices", next_free_vertex);
|
||||
[self scaleVertices];
|
||||
|
||||
|
||||
// set speed of rotation
|
||||
rotational_velocity = 0.01 * randf(); // 0.0 .. 0.01 avr 0.005;
|
||||
if ([dict objectForKey:@"rotational_velocity"])
|
||||
rotational_velocity = [[dict objectForKey:@"rotational_velocity"] doubleValue];
|
||||
|
||||
|
||||
// do atmosphere
|
||||
//
|
||||
atmosphere = [[PlanetEntity alloc] initAsAtmosphereForPlanet:self];
|
||||
@ -713,7 +713,7 @@ void setUpSinTable()
|
||||
|
||||
// set energy
|
||||
energy = collision_radius * 1000.0;
|
||||
|
||||
|
||||
//
|
||||
usingVAR = [self OGL_InitVAR];
|
||||
//
|
||||
@ -726,7 +726,7 @@ void setUpSinTable()
|
||||
}
|
||||
|
||||
- (id) initMoonFromDictionary:(NSDictionary*) dict inUniverse:(Universe *) uni
|
||||
{
|
||||
{
|
||||
int i;
|
||||
int percent_land;
|
||||
double aleph = 1.0 / sqrt(2.0);
|
||||
@ -772,14 +772,14 @@ void setUpSinTable()
|
||||
{
|
||||
radius_km = [[dict objectForKey:@"radius"] intValue];
|
||||
}
|
||||
|
||||
|
||||
shuttles_on_ground = 0;
|
||||
last_launch_time = 0.0;
|
||||
shuttle_launch_interval = 3600.0 / shuttles_on_ground; // all are launched in an hour
|
||||
last_launch_time = 3600.0;
|
||||
|
||||
|
||||
//NSLog(@"shuttles on ground:%d launch_interval:%.1f minutes", shuttles_on_ground, shuttle_launch_interval/60);
|
||||
|
||||
|
||||
collision_radius = radius_km * 10.0; // scale down by a factor of 100 !
|
||||
//
|
||||
scan_class = CLASS_NO_DRAW;
|
||||
@ -798,7 +798,7 @@ void setUpSinTable()
|
||||
//
|
||||
[self rescaleTo:1.0];
|
||||
//
|
||||
|
||||
|
||||
percent_land = (gen_rnd_number() % 48);
|
||||
if ([dict objectForKey:@"percent_land"])
|
||||
{
|
||||
@ -806,10 +806,10 @@ void setUpSinTable()
|
||||
}
|
||||
if (isTextured)
|
||||
percent_land = 100;
|
||||
|
||||
|
||||
// save the current random number generator seed
|
||||
RNG_Seed saved_seed = currentRandomSeed();
|
||||
|
||||
|
||||
//NSLog(@"Planet surface is %d percent land.",percent_land);
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
@ -824,14 +824,14 @@ void setUpSinTable()
|
||||
polar_color_factor = [[dict objectForKey:@"polar_color_factor"] doubleValue];
|
||||
//
|
||||
Vector land_hsb, sea_hsb, land_polar_hsb, sea_polar_hsb;
|
||||
|
||||
|
||||
if (!isTextured)
|
||||
{
|
||||
land_hsb.x = gen_rnd_number() / 256.0; land_hsb.y = gen_rnd_number() / 256.0; land_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
land_hsb.x = gen_rnd_number() / 256.0; land_hsb.y = gen_rnd_number() / 256.0; land_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
while (dot_product(land_hsb,sea_hsb) > .80) // make sure land and sea colors differ significantly
|
||||
{
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
sea_hsb.x = gen_rnd_number() / 256.0; sea_hsb.y = gen_rnd_number() / 256.0; sea_hsb.z = 0.5 + gen_rnd_number() / 512.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -839,7 +839,7 @@ void setUpSinTable()
|
||||
land_hsb.x = 0.0; land_hsb.y = 0.0; land_hsb.z = 1.0; // non-saturated fully bright (white)
|
||||
sea_hsb.x = 0.0; sea_hsb.y = 1.0; sea_hsb.z = 1.0; // fully-saturated fully bright (red)
|
||||
}
|
||||
|
||||
|
||||
//// possibly get land_hsb and sea_hsb from planetinfo.plist entry
|
||||
//
|
||||
if ([dict objectForKey:@"land_hsb_color"])
|
||||
@ -852,11 +852,11 @@ void setUpSinTable()
|
||||
}
|
||||
//
|
||||
////
|
||||
|
||||
|
||||
// polar areas are brighter but have less color (closer to white)
|
||||
//
|
||||
land_polar_hsb.x = land_hsb.x; land_polar_hsb.y = (land_hsb.y / 5.0); land_polar_hsb.z = 1.0 - (land_hsb.z / 10.0);
|
||||
sea_polar_hsb.x = sea_hsb.x; sea_polar_hsb.y = (sea_hsb.y / 5.0); sea_polar_hsb.z = 1.0 - (sea_hsb.z / 10.0);
|
||||
land_polar_hsb.x = land_hsb.x; land_polar_hsb.y = (land_hsb.y / 5.0); land_polar_hsb.z = 1.0 - (land_hsb.z / 10.0);
|
||||
sea_polar_hsb.x = sea_hsb.x; sea_polar_hsb.y = (sea_hsb.y / 5.0); sea_polar_hsb.z = 1.0 - (sea_hsb.z / 10.0);
|
||||
|
||||
amb_land[0] = [[OOColor colorWithCalibratedHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] redComponent];
|
||||
amb_land[1] = [[OOColor colorWithCalibratedHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] blueComponent];
|
||||
@ -874,30 +874,30 @@ void setUpSinTable()
|
||||
amb_polar_sea[1] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] blueComponent];
|
||||
amb_polar_sea[2] = [[OOColor colorWithCalibratedHue:sea_polar_hsb.x saturation:sea_polar_hsb.y brightness:sea_polar_hsb.z alpha:1.0] greenComponent];
|
||||
amb_polar_sea[3] = 1.0;
|
||||
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseVertexArray]");
|
||||
[self initialiseBaseVertexArray];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG testing [PlanetEntity initialiseBaseTerrainArray:%d]", percent_land);
|
||||
setRandomSeed(saved_seed);
|
||||
[self initialiseBaseTerrainArray:percent_land];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG painting %d vertices", next_free_vertex);
|
||||
for (i = 0; i < next_free_vertex; i++)
|
||||
[self paintVertex:i :planet_seed];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG scaling %d vertices", next_free_vertex);
|
||||
[self scaleVertices];
|
||||
|
||||
|
||||
// set speed of rotation
|
||||
rotational_velocity = 0.01 * randf(); // 0.0 .. 0.01 avr 0.005;
|
||||
if ([dict objectForKey:@"rotational_velocity"])
|
||||
rotational_velocity = [[dict objectForKey:@"rotational_velocity"] doubleValue];
|
||||
|
||||
|
||||
// do NO atmosphere
|
||||
//
|
||||
atmosphere = nil;
|
||||
|
||||
|
||||
energy = collision_radius * 1000.0;
|
||||
|
||||
//
|
||||
@ -982,19 +982,19 @@ void setUpSinTable()
|
||||
NSLog(@"DEBUG %@ %d collided with planet at (%.1f,%.1f,%.1f)",[ship name], [ship universal_id], p1.x,p1.y,p1.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void) update:(double) delta_t
|
||||
{
|
||||
{
|
||||
if (usingVAR)
|
||||
[self OGL_UpdateVAR];
|
||||
|
||||
|
||||
[super update:delta_t];
|
||||
sqrt_zero_distance = sqrt(zero_distance);
|
||||
|
||||
|
||||
switch (planet_type)
|
||||
{
|
||||
case PLANET_TYPE_GREEN :
|
||||
@ -1007,18 +1007,18 @@ void setUpSinTable()
|
||||
shuttles_on_ground--;
|
||||
last_launch_time = ugt;
|
||||
}
|
||||
|
||||
|
||||
// normal planetary rotation
|
||||
quaternion_rotate_about_y( &q_rotation, rotational_velocity * delta_t);
|
||||
quaternion_normalise(&q_rotation);
|
||||
quaternion_into_gl_matrix(q_rotation, rotMatrix);
|
||||
|
||||
|
||||
if (atmosphere)
|
||||
{
|
||||
[atmosphere update:delta_t];
|
||||
double alt = sqrt_zero_distance - collision_radius;
|
||||
double atmo = 10.0 * (atmosphere->collision_radius - collision_radius); // effect starts at 10x the height of the clouds
|
||||
|
||||
|
||||
if ((alt > 0)&&(alt <= atmo))
|
||||
{
|
||||
double aleph = (atmo - alt) / atmo;
|
||||
@ -1038,7 +1038,7 @@ void setUpSinTable()
|
||||
quaternion_into_gl_matrix(q_rotation, rotMatrix);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case PLANET_TYPE_CORONA :
|
||||
case PLANET_TYPE_SUN :
|
||||
{
|
||||
@ -1047,13 +1047,13 @@ void setUpSinTable()
|
||||
Vector v0 = position;
|
||||
Vector p0 = (player)? player->position: make_vector( 0.0f, 0.0f, 0.0f);
|
||||
v0.x -= p0.x; v0.y -= p0.y; v0.z -= p0.z; // vector from player to position
|
||||
|
||||
|
||||
if (v0.x||v0.y||v0.z)
|
||||
v0 = unit_vector(&v0);
|
||||
else
|
||||
v0.z = 1.0;
|
||||
//equivalent of v_forward
|
||||
|
||||
|
||||
Vector arb1;
|
||||
if ((v0.x == 0.0)&&(v0.y == 0.0))
|
||||
{
|
||||
@ -1063,13 +1063,13 @@ void setUpSinTable()
|
||||
{
|
||||
arb1.x = 0.0; arb1.y = 0.0; arb1.z = 1.0;
|
||||
}
|
||||
|
||||
|
||||
Vector v1 = cross_product( v0, arb1 ); // 90 degrees to (v0 x arb1)
|
||||
//equivalent of v_right
|
||||
|
||||
|
||||
Vector v2 = cross_product( v0, v1 ); // 90 degrees to (v0 x v1)
|
||||
//equivalent of v_up
|
||||
|
||||
|
||||
vectors_into_gl_matrix( v0, v1, v2, rotMatrix);
|
||||
|
||||
if (planet_type == PLANET_TYPE_CORONA)
|
||||
@ -1083,7 +1083,7 @@ void setUpSinTable()
|
||||
v_sun.z = 1.0;
|
||||
polar_color_factor = dot_product( v_sun, v0);
|
||||
}
|
||||
|
||||
|
||||
if (throw_sparks&&(planet_type == PLANET_TYPE_SUN)&&(velocity.z > 0)) // going NOVA!
|
||||
{
|
||||
if (velocity.x >= 0.0) // countdown
|
||||
@ -1116,7 +1116,7 @@ void setUpSinTable()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// update corona
|
||||
if (![universe reducedDetail])
|
||||
{
|
||||
@ -1132,7 +1132,7 @@ void setUpSinTable()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1179,20 +1179,20 @@ void setUpSinTable()
|
||||
if (subdivideLevel > 4)
|
||||
subdivideLevel = 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
glFrontFace(GL_CW); // face culling - front faces are AntiClockwise!
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
The depth test gets disabled in parts of this and instead
|
||||
we rely on the painters algorithm instead.
|
||||
|
||||
|
||||
The depth buffer isn't granular enough to cope with huge objects at vast
|
||||
distances.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
switch (planet_type)
|
||||
{
|
||||
case PLANET_TYPE_ATMOSPHERE :
|
||||
@ -1201,7 +1201,7 @@ void setUpSinTable()
|
||||
if (!translucent)
|
||||
{
|
||||
GLfloat mat1[] = { 1.0, 1.0, 1.0, 1.0 }; // opaque white
|
||||
|
||||
|
||||
if (!isTextured)
|
||||
glDisable(GL_TEXTURE_2D); // stop any problems from this being left on!
|
||||
else
|
||||
@ -1209,7 +1209,7 @@ void setUpSinTable()
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //wrap around horizontally
|
||||
}
|
||||
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
glColor4fv(mat1);
|
||||
@ -1296,13 +1296,13 @@ void setUpSinTable()
|
||||
}
|
||||
}
|
||||
glFrontFace(GL_CW);
|
||||
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat1);
|
||||
|
||||
if (atmosphere)
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
|
||||
glPopMatrix(); // get old draw matrix back
|
||||
glPushMatrix(); // and store it again
|
||||
glTranslatef(position.x,position.y,position.z); // centre on the planet
|
||||
@ -1310,18 +1310,18 @@ void setUpSinTable()
|
||||
glMultMatrixf([atmosphere rotationMatrix]);
|
||||
// draw atmosphere entity
|
||||
[atmosphere drawEntity:immediate :translucent];
|
||||
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case PLANET_TYPE_SUN :
|
||||
if (!translucent)
|
||||
{
|
||||
int steps = 2 * (MAX_SUBDIVIDE - subdivideLevel);
|
||||
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_LIGHTING);
|
||||
glColor4fv( amb_land);
|
||||
@ -1329,7 +1329,7 @@ void setUpSinTable()
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
drawBallVertices( collision_radius, steps, sqrt_zero_distance);
|
||||
glEnd();
|
||||
|
||||
|
||||
if (![universe reducedDetail])
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
@ -1353,7 +1353,7 @@ void setUpSinTable()
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case PLANET_TYPE_CORONA :
|
||||
if (!translucent)
|
||||
{
|
||||
@ -1362,19 +1362,19 @@ void setUpSinTable()
|
||||
GLfloat r = 0.42 * bri;
|
||||
GLfloat g = 0.42 * bri;
|
||||
GLfloat b = 0.5 * bri;
|
||||
|
||||
|
||||
GLfloat amb_1[4] = {1.0, 1.0, 1.0, 1.0 };
|
||||
double r0 = (my_owner)? my_owner->collision_radius: 5000;
|
||||
|
||||
GLfloat col1[4] = { r, g, b, 1.0};
|
||||
GLfloat col2[4] = { r, g, b, 0.0};
|
||||
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, amb_1);
|
||||
|
||||
|
||||
drawCorona( r0, collision_radius, 6 - subdivideLevel, sqrt_zero_distance, col1, col2);
|
||||
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
@ -1392,7 +1392,7 @@ void drawBall (double radius, int step, double z_distance)
|
||||
return;
|
||||
int i;
|
||||
double s, c;
|
||||
double r = radius * z_distance / sqrt( z_distance * z_distance - radius * radius);
|
||||
double r = radius * z_distance / sqrt( z_distance * z_distance - radius * radius);
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glVertex3i( 0, 0, 0);
|
||||
for ( i = 0; i < 360; i += step )
|
||||
@ -1413,7 +1413,7 @@ void drawBallVertices (double radius, int step, double z_distance)
|
||||
return;
|
||||
int i;
|
||||
GLfloat s, c;
|
||||
GLfloat r = radius * z_distance / sqrt( z_distance * z_distance - radius * radius);
|
||||
GLfloat r = radius * z_distance / sqrt( z_distance * z_distance - radius * radius);
|
||||
glVertex3i( 0, 0, 0);
|
||||
for ( i = 0; i < 360; i += step )
|
||||
{
|
||||
@ -1430,20 +1430,20 @@ void drawCorona (double inner_radius, double outer_radius, int step, double z_di
|
||||
return;
|
||||
int i;
|
||||
GLfloat s0, c0, s1, c1;
|
||||
|
||||
|
||||
double r = inner_radius;
|
||||
double c = outer_radius;
|
||||
double z = z_distance;
|
||||
double x = sqrt( z * z - r * r);
|
||||
|
||||
|
||||
GLfloat r1 = r * x / z;
|
||||
GLfloat z1 = r * r / z;
|
||||
|
||||
|
||||
GLfloat r0 = c * x / z;
|
||||
GLfloat z0 = c * r / z;
|
||||
|
||||
|
||||
// NSLog(@"DEBUG r1 = %.4f z1 = %.4f r0 = %.4f z0 = %.4f", r1, z1, r0, z0);
|
||||
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
for ( i = 0; i < 360; i += step )
|
||||
{
|
||||
@ -1468,38 +1468,38 @@ void drawActiveCorona (double inner_radius, double outer_radius, int step, doubl
|
||||
if (inner_radius >= z_distance) // inside the sphere
|
||||
return;
|
||||
int i;
|
||||
|
||||
|
||||
NSRange activity = NSMakeRange(0.34, 1.0);
|
||||
|
||||
|
||||
GLfloat s0, c0, s1, c1;
|
||||
|
||||
|
||||
double r = inner_radius;
|
||||
double c = outer_radius;
|
||||
double z = z_distance;
|
||||
double x = sqrt( z * z - r * r);
|
||||
|
||||
|
||||
GLfloat r1 = r * x / z;
|
||||
GLfloat z1 = r * r / z;
|
||||
|
||||
|
||||
GLfloat r0 = c * x / z;
|
||||
GLfloat z0 = c * r / z;
|
||||
|
||||
|
||||
// NSLog(@"DEBUG r1 = %.4f z1 = %.4f r0 = %.4f z0 = %.4f", r1, z1, r0, z0);
|
||||
|
||||
GLfloat rv0, rv1, rv2;
|
||||
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
for ( i = 0; i < 360; i += step )
|
||||
{
|
||||
rv0 = (1.0 - corona_stage) * rvalue[i + rv] + corona_stage * rvalue[i + rv + 360];
|
||||
rv1 = (1.0 - corona_stage) * rvalue[i + rv + 1] + corona_stage * rvalue[i + rv + 361];
|
||||
rv2 = (1.0 - corona_stage) * rvalue[i + rv + 2] + corona_stage * rvalue[i + rv + 362];
|
||||
|
||||
|
||||
s1 = r1 * sin_value[i];
|
||||
c1 = r1 * cos_value[i];
|
||||
glColor4f( col4v1[0] * (activity.location + rv0*activity.length), col4v1[1] * (activity.location + rv1*activity.length), col4v1[2] * (activity.location + rv2*activity.length), col4v1[3]);
|
||||
glVertex3f( s1, c1, -z1);
|
||||
|
||||
|
||||
s0 = r0 * sin_value[i];
|
||||
c0 = r0 * cos_value[i];
|
||||
glColor4f( col4v1[0], col4v1[1], col4v1[2], 0);
|
||||
@ -1509,7 +1509,7 @@ void drawActiveCorona (double inner_radius, double outer_radius, int step, doubl
|
||||
rv0 = (1.0 - corona_stage) * rvalue[rv] + corona_stage * rvalue[360 + rv];
|
||||
rv1 = (1.0 - corona_stage) * rvalue[1 + rv] + corona_stage * rvalue[361 + rv];
|
||||
rv2 = (1.0 - corona_stage) * rvalue[2 + rv] + corona_stage * rvalue[362 + rv];
|
||||
|
||||
|
||||
glColor4f( col4v1[0] * (activity.location + rv0*activity.length), col4v1[1] * (activity.location + rv1*activity.length), col4v1[2] * (activity.location + rv2*activity.length), col4v1[3]);
|
||||
glVertex3f( 0.0, r1, -z1); //repeat the zero value to close
|
||||
glColor4f( col4v1[0], col4v1[1], col4v1[2], 0);
|
||||
@ -1570,7 +1570,7 @@ void drawActiveCorona (double inner_radius, double outer_radius, int step, doubl
|
||||
{
|
||||
int i;
|
||||
Vector vert;
|
||||
|
||||
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
vert = vertices[i]; // not guaranteed non-zero
|
||||
@ -1588,11 +1588,11 @@ void drawActiveCorona (double inner_radius, double outer_radius, int step, doubl
|
||||
{
|
||||
#ifdef GNUSTEP
|
||||
// TODO: Find a suitable replacement fn for APPLE
|
||||
#else
|
||||
#else
|
||||
if (usingVAR)
|
||||
glBindVertexArrayAPPLE(gVertexArrayRangeObjects[0]);
|
||||
#endif
|
||||
|
||||
|
||||
glDrawElements( GL_TRIANGLES, 3 * n_triangles[subdivide], GL_UNSIGNED_INT, &vertexdata.index_array[triangle_start[subdivide]]);
|
||||
}
|
||||
|
||||
@ -1602,34 +1602,34 @@ void drawActiveCorona (double inner_radius, double outer_radius, int step, doubl
|
||||
Quaternion q1;
|
||||
Vector launch_pos = position;
|
||||
double start_distance = collision_radius + 125.0;
|
||||
|
||||
|
||||
quaternion_set_random(&q1);
|
||||
|
||||
|
||||
Vector vf = vector_forward_from_quaternion(q1);
|
||||
|
||||
|
||||
launch_pos.x += start_distance * vf.x;
|
||||
launch_pos.y += start_distance * vf.y;
|
||||
launch_pos.z += start_distance * vf.z;
|
||||
|
||||
|
||||
shuttle_ship = [universe getShipWithRole:@"shuttle"]; // retain count = 1
|
||||
if (shuttle_ship)
|
||||
{
|
||||
[shuttle_ship setPosition:launch_pos];
|
||||
[shuttle_ship setQRotation:q1];
|
||||
|
||||
|
||||
[shuttle_ship setScanClass: CLASS_NEUTRAL];
|
||||
|
||||
|
||||
[shuttle_ship setCargoFlag:CARGO_FLAG_FULL_PLENTIFUL];
|
||||
|
||||
|
||||
[shuttle_ship setStatus:STATUS_IN_FLIGHT];
|
||||
|
||||
|
||||
//[shuttle_ship setReportAImessages:YES]; // debug
|
||||
|
||||
[universe addEntity:shuttle_ship];
|
||||
[[shuttle_ship getAI] setStateMachine:@"risingShuttleAI.plist"]; // must happen after adding to the universe!
|
||||
|
||||
//NSLog(@"Planet %@ in universe %@ Launching shuttle: %@ %d", self, universe, [shuttle_ship name], [shuttle_ship universal_id]);
|
||||
|
||||
|
||||
[shuttle_ship release];
|
||||
}
|
||||
}
|
||||
@ -1652,7 +1652,7 @@ static BOOL last_one_was_textured;
|
||||
{
|
||||
int i;
|
||||
NSAutoreleasePool* mypool = [[NSAutoreleasePool alloc] init]; // use our own pool since this routine is quite hard on memory
|
||||
|
||||
|
||||
if (last_one_was_textured != isTextured)
|
||||
{
|
||||
[PlanetEntity resetBaseVertexArray];
|
||||
@ -1663,11 +1663,11 @@ static BOOL last_one_was_textured;
|
||||
// NSLog(@"DEBUG %@ creating textured vertex data texture_uv_array = <%x>", self, texture_uv_array);
|
||||
// else
|
||||
// NSLog(@"DEBUG %@ creating plain vertex data", self);
|
||||
|
||||
|
||||
if (edge_to_vertex == nil)
|
||||
{
|
||||
edge_to_vertex = [[NSMutableDictionary dictionaryWithCapacity:7680] retain]; // make a new one
|
||||
|
||||
|
||||
int vi,fi;
|
||||
next_free_vertex = 0;
|
||||
//
|
||||
@ -1705,9 +1705,9 @@ static BOOL last_one_was_textured;
|
||||
triangle_start[newlevel] = triangle_start[sublevel] + n_triangles[sublevel] * 3;
|
||||
n_triangles[newlevel] = n_triangles[sublevel] * 4;
|
||||
//
|
||||
|
||||
|
||||
// NSLog(@"Building new level of subdivision - level %d.", newlevel);
|
||||
|
||||
|
||||
int tri;
|
||||
for (tri = 0; tri < n_triangles[sublevel]; tri++)
|
||||
{
|
||||
@ -1734,20 +1734,20 @@ static BOOL last_one_was_textured;
|
||||
vertex_index_array[triangle_start[newlevel] + tri * 12 + 9] = v01;
|
||||
vertex_index_array[triangle_start[newlevel] + tri * 12 +10] = v12;
|
||||
vertex_index_array[triangle_start[newlevel] + tri * 12 +11] = v20;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// NSLog(@"Current total number of vertices %d.", next_free_vertex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// NSLog(@"edge_to_vertex %@", edge_to_vertex);
|
||||
|
||||
|
||||
// all done - copy the indices to the instance
|
||||
//
|
||||
for (i = 0; i < MAX_TRI_INDICES; i++)
|
||||
vertexdata.index_array[i] = vertex_index_array[i];
|
||||
|
||||
|
||||
[mypool release];
|
||||
}
|
||||
|
||||
@ -1763,14 +1763,14 @@ int baseVertexIndexForEdge(int va, int vb, BOOL textured)
|
||||
else
|
||||
{
|
||||
int vindex = next_free_vertex++;
|
||||
|
||||
|
||||
// calculate position of new vertex
|
||||
base_vertex_array[vindex] = base_vertex_array[va];
|
||||
base_vertex_array[vindex].x += base_vertex_array[vb].x;
|
||||
base_vertex_array[vindex].y += base_vertex_array[vb].y;
|
||||
base_vertex_array[vindex].z += base_vertex_array[vb].z;
|
||||
base_vertex_array[vindex] = unit_vector(&base_vertex_array[vindex]); // guaranteed non-zero
|
||||
|
||||
|
||||
// NSLog(@"%d [%@]= (%.3f,%.3f,%.3f)", vindex, key, base_vertex_array[vindex].x, base_vertex_array[vindex].y, base_vertex_array[vindex].z);
|
||||
|
||||
if (textured)
|
||||
@ -1898,7 +1898,7 @@ int baseVertexIndexForEdge(int va, int vb, BOOL textured)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
paint_color[i] = (r * paint_sea[i])*0.01 + ((100 - r) * paint_land[i])*0.01;
|
||||
|
||||
|
||||
// finally initialise the color array entry
|
||||
vertexdata.color_array[vi*4 + i] = paint_color[i];
|
||||
}
|
||||
@ -1959,5 +1959,25 @@ double longitudeFromVector(Vector v)
|
||||
velocity.z = 10000;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
||||
- (void) reloadTextures
|
||||
{
|
||||
//NSLog(@"PlanetEntity::reloadTextures called, clearing planet draw lists and calling super");
|
||||
|
||||
int i;
|
||||
// Clear out the planet's various detail level display lists.
|
||||
for (i = 0; i < MAX_SUBDIVIDE; i++)
|
||||
{
|
||||
glDeleteLists(displayListNames[i], 1);
|
||||
displayListNames[i] = 0;
|
||||
}
|
||||
|
||||
// Don't know if this will help for planets, but it shouldn't hurt.
|
||||
[super reloadTextures];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@end
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -51,7 +51,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
@implementation SkyEntity
|
||||
|
||||
- (id) init
|
||||
{
|
||||
{
|
||||
self = [super init];
|
||||
//
|
||||
quaternion_set_identity(&q_rotation);
|
||||
@ -83,7 +83,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
//
|
||||
[self set_up_billboards:col1 :col2];
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
usingVAR = [self OGL_InitVAR];
|
||||
//
|
||||
@ -99,7 +99,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
|
||||
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2
|
||||
{
|
||||
{
|
||||
self = [super init];
|
||||
//
|
||||
n_stars = SKY_N_STARS;
|
||||
@ -148,10 +148,10 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
|
||||
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2 andSystemInfo:(NSDictionary *) systeminfo
|
||||
{
|
||||
{
|
||||
OOColor* color1 = col1;
|
||||
OOColor* color2 = col2;
|
||||
|
||||
|
||||
self = [super init];
|
||||
//
|
||||
n_stars = SKY_N_STARS;
|
||||
@ -178,7 +178,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
blob_scale = SKY_BLOB_SCALE;
|
||||
blob_scale_prime = 0.005 / blob_scale;
|
||||
//
|
||||
|
||||
|
||||
//// possible systeminfo overrides
|
||||
//
|
||||
if ([systeminfo objectForKey:@"sky_rgb_colors"])
|
||||
@ -242,13 +242,13 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
//
|
||||
////
|
||||
|
||||
|
||||
sky_color = [[color2 blendedColorWithFraction:0.5 ofColor:color1] retain];
|
||||
//
|
||||
// init stars
|
||||
//
|
||||
[self set_up_billboards:color1 :color2];
|
||||
|
||||
|
||||
//
|
||||
usingVAR = [self OGL_InitVAR];
|
||||
//
|
||||
@ -321,7 +321,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
Vector star_vector[n_stars];
|
||||
GLfloat star_color[n_stars][4];
|
||||
Vector star_quad[4][n_stars];
|
||||
|
||||
|
||||
// blobs
|
||||
Vector blob_vector[n_blobs];
|
||||
GLfloat blob_color[n_blobs][4];
|
||||
@ -358,7 +358,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
star_quad[3][i].x = star_quad[0][i].x + p_size * vi.x;
|
||||
star_quad[3][i].y = star_quad[0][i].y + p_size * vi.y;
|
||||
star_quad[3][i].z = star_quad[0][i].z + p_size * vi.z;
|
||||
|
||||
|
||||
int j;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
@ -368,7 +368,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
|
||||
//** SET UP VERTEX ARRAY DATA **//
|
||||
|
||||
|
||||
// set up texture and vertex arrays
|
||||
starsData.texture_uv_array[ 4*i*2 + 0] = 0; starsData.texture_uv_array[ 4*i*2 + 1] = 0;
|
||||
starsData.vertex_array[ 4*i*3 + 0] = star_quad[0][i].x; starsData.vertex_array[ 4*i*3 + 1] = star_quad[0][i].y; starsData.vertex_array[ 4*i*3 + 2] = star_quad[0][i].z;
|
||||
@ -378,7 +378,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
starsData.vertex_array[ 4*i*3 + 6] = star_quad[2][i].x; starsData.vertex_array[ 4*i*3 + 7] = star_quad[2][i].y; starsData.vertex_array[ 4*i*3 + 8] = star_quad[2][i].z;
|
||||
starsData.texture_uv_array[ 4*i*2 + 6] = 0; starsData.texture_uv_array[ 4*i*2 + 7] = 1;
|
||||
starsData.vertex_array[ 4*i*3 + 9] = star_quad[3][i].x; starsData.vertex_array[ 4*i*3 + 10] = star_quad[3][i].y; starsData.vertex_array[ 4*i*3 + 11] = star_quad[3][i].z;
|
||||
|
||||
|
||||
// set up color array
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
@ -421,14 +421,14 @@ Your fair use and other rights are in no way affected by the above.
|
||||
double p_size = blob_scale * r1 * BILLBOARD_DEPTH / 500.0;
|
||||
blob_color[i][3] *= 0.5 + (float)r1 / 32.0; // make smaller blobs dimmer
|
||||
blob_quad[0][i] = blob_vector[i];
|
||||
|
||||
|
||||
// rotate vi and vj a random amount
|
||||
double r = randf() * PI * 2.0;
|
||||
quaternion_rotate_about_axis(&q, vk, r);
|
||||
vi = vector_right_from_quaternion(q);
|
||||
vj = vector_up_from_quaternion(q);
|
||||
//
|
||||
|
||||
|
||||
blob_quad[1][i].x = blob_quad[0][i].x + p_size * vj.x;
|
||||
blob_quad[1][i].y = blob_quad[0][i].y + p_size * vj.y;
|
||||
blob_quad[1][i].z = blob_quad[0][i].z + p_size * vj.z;
|
||||
@ -438,7 +438,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
blob_quad[3][i].x = blob_quad[0][i].x + p_size * vi.x;
|
||||
blob_quad[3][i].y = blob_quad[0][i].y + p_size * vi.y;
|
||||
blob_quad[3][i].z = blob_quad[0][i].z + p_size * vi.z;
|
||||
|
||||
|
||||
int j;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
@ -446,9 +446,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
blob_quad[j][i].y -= 0.5 * p_size * (vi.y + vj.y);
|
||||
blob_quad[j][i].z -= 0.5 * p_size * (vi.z + vj.z);
|
||||
}
|
||||
|
||||
|
||||
//** SET UP VERTEX ARRAY DATA **//
|
||||
|
||||
|
||||
// set up texture and vertex arrays
|
||||
blobsData.texture_uv_array[ 4*i*2 + 0] = 0; blobsData.texture_uv_array[ 4*i*2 + 1] = 0;
|
||||
blobsData.vertex_array[ 4*i*3 + 0] = blob_quad[0][i].x; blobsData.vertex_array[ 4*i*3 + 1] = blob_quad[0][i].y; blobsData.vertex_array[ 4*i*3 + 2] = blob_quad[0][i].z;
|
||||
@ -458,7 +458,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
blobsData.vertex_array[ 4*i*3 + 6] = blob_quad[2][i].x; blobsData.vertex_array[ 4*i*3 + 7] = blob_quad[2][i].y; blobsData.vertex_array[ 4*i*3 + 8] = blob_quad[2][i].z;
|
||||
blobsData.texture_uv_array[ 4*i*2 + 6] = 0; blobsData.texture_uv_array[ 4*i*2 + 7] = 1;
|
||||
blobsData.vertex_array[ 4*i*3 + 9] = blob_quad[3][i].x; blobsData.vertex_array[ 4*i*3 + 10] = blob_quad[3][i].y; blobsData.vertex_array[ 4*i*3 + 11] = blob_quad[3][i].z;
|
||||
|
||||
|
||||
// set up color array
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
@ -469,7 +469,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
|
||||
p_size *= 500/BILLBOARD_DEPTH; // back to normal scale
|
||||
|
||||
|
||||
// shuffle it around a bit in a random walk
|
||||
q.x += p_size * blob_scale_prime * (randf() - 0.5);
|
||||
q.y += p_size * blob_scale_prime * (randf() - 0.5);
|
||||
@ -511,7 +511,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
|
||||
- (void) drawEntity:(BOOL) immediate :(BOOL) translucent
|
||||
{
|
||||
{
|
||||
if ([universe breakPatternHide]) return; // DON'T DRAW
|
||||
|
||||
//
|
||||
@ -524,7 +524,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
glDisable(GL_CULL_FACE); // face culling
|
||||
//
|
||||
glShadeModel(GL_SMOOTH); // smoothing for color values...
|
||||
|
||||
|
||||
if (immediate)
|
||||
{
|
||||
switch (sky_type)
|
||||
@ -532,9 +532,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
case SKY_POINTS :
|
||||
NSLog(@"ERROR: SkyEntity SKY_POINTS deprecated");
|
||||
break;
|
||||
|
||||
|
||||
case SKY_BILLBOARDS :
|
||||
|
||||
|
||||
if ((star_textureName == 0)&&(universe))
|
||||
star_textureName = [[universe textureStore] getTextureNameFor:@"star64.png"];
|
||||
if ((blob_textureName == 0)&&(universe))
|
||||
@ -546,43 +546,43 @@ Your fair use and other rights are in no way affected by the above.
|
||||
// stars
|
||||
#ifdef GNUSTEP
|
||||
// TODO: find replacement for APPLE function
|
||||
#else
|
||||
#else
|
||||
if (usingVAR)
|
||||
glBindVertexArrayAPPLE(gVertexArrayRangeObjects[0]);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// if (usingVAR)
|
||||
// NSLog(@"DEBUG using accelerated memory technique to draw %@ (%@)", self, basefile);
|
||||
//
|
||||
//
|
||||
glBindTexture(GL_TEXTURE_2D, star_textureName);
|
||||
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer( 3, GL_FLOAT, 0, starsData.vertex_array);
|
||||
// 3 coords per vertex
|
||||
// of type GL_FLOAT
|
||||
// 0 stride (tightly packed)
|
||||
// pointer to first vertex
|
||||
|
||||
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer( 2, GL_INT, 0, starsData.texture_uv_array);
|
||||
// 2 coords per vertex
|
||||
// of type GL_INT
|
||||
// 0 stride (tightly packed)
|
||||
// pointer to first coordinate pair
|
||||
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer( 4, GL_FLOAT, 0, starsData.color_array);
|
||||
// 4 values per vertex color
|
||||
// of type GL_FLOAT
|
||||
// 0 stride (tightly packed)
|
||||
// pointer to quadruplet
|
||||
|
||||
|
||||
glDisableClientState(GL_INDEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_EDGE_FLAG_ARRAY);
|
||||
|
||||
|
||||
glDrawArrays( GL_QUADS, 0, 4 * n_stars);
|
||||
|
||||
|
||||
//
|
||||
// blobs
|
||||
if (![universe reducedDetail])
|
||||
@ -593,33 +593,33 @@ Your fair use and other rights are in no way affected by the above.
|
||||
#else
|
||||
if (usingVAR)
|
||||
glBindVertexArrayAPPLE(gVertexArrayRangeObjects[1]);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer( 3, GL_FLOAT, 0, blobsData.vertex_array);
|
||||
// 3 coords per vertex
|
||||
// of type GL_FLOAT
|
||||
// 0 stride (tightly packed)
|
||||
// pointer to first vertex
|
||||
|
||||
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer( 2, GL_INT, 0, blobsData.texture_uv_array);
|
||||
// 2 coords per vertex
|
||||
// of type GL_INT
|
||||
// 0 stride (tightly packed)
|
||||
// pointer to first coordinate pair
|
||||
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer( 4, GL_FLOAT, 0, blobsData.color_array);
|
||||
// 4 values per vertex color
|
||||
// of type GL_FLOAT
|
||||
// 0 stride (tightly packed)
|
||||
// pointer to quadruplet
|
||||
|
||||
|
||||
glDisableClientState(GL_INDEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_EDGE_FLAG_ARRAY);
|
||||
|
||||
|
||||
glDrawArrays( GL_QUADS, 0, 4 * n_blobs);
|
||||
|
||||
}
|
||||
@ -638,7 +638,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// reapply lighting &c
|
||||
glEnable(GL_CULL_FACE); // face culling
|
||||
glEnable(GL_LIGHTING);
|
||||
@ -648,8 +648,20 @@ Your fair use and other rights are in no way affected by the above.
|
||||
checkGLErrors([NSString stringWithFormat:@"SkyEntity after drawing %@", self]);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
||||
- (void) reloadTextures
|
||||
{
|
||||
//NSLog(@"SkyEntity::reloadTextures called, calling super and resetTextureNames");
|
||||
|
||||
// Force the sky textures to be reloaded next time a frame is drawn.
|
||||
star_textureName = 0;
|
||||
blob_textureName = 0;
|
||||
|
||||
// Reset the entity display list.
|
||||
[super reloadTextures];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
@ -74,23 +74,23 @@ Your fair use and other rights are in no way affected by the above.
|
||||
#endif
|
||||
NSSize imageSize;
|
||||
GLuint texName;
|
||||
|
||||
|
||||
unsigned char *texBytes;
|
||||
BOOL freeTexBytes;
|
||||
|
||||
|
||||
int texture_h = 4;
|
||||
int texture_w = 4;
|
||||
int image_h, image_w;
|
||||
int n_planes, im_bytes, tex_bytes;
|
||||
|
||||
|
||||
int im_bytesPerRow;
|
||||
|
||||
int texi = 0;
|
||||
|
||||
|
||||
int texi = 0;
|
||||
|
||||
if (![textureDictionary objectForKey:filename])
|
||||
{
|
||||
NSMutableDictionary* texProps = [NSMutableDictionary dictionaryWithCapacity:3]; // autoreleased
|
||||
#ifndef GNUSTEP
|
||||
#ifndef GNUSTEP
|
||||
texImage = [ResourceManager imageNamed:filename inFolder:@"Textures"];
|
||||
#else
|
||||
texImage = [ResourceManager surfaceNamed:filename inFolder:@"Textures"];
|
||||
@ -105,12 +105,12 @@ Your fair use and other rights are in no way affected by the above.
|
||||
[myException raise];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifndef GNUSTEP
|
||||
NSArray* reps = [texImage representations];
|
||||
|
||||
|
||||
// NSLog(@"DEBUG texture %@ representations:\n%@", filename, reps);
|
||||
|
||||
|
||||
int i;
|
||||
for (i = 0; ((i < [reps count]) && !bitmapImageRep); i++)
|
||||
{
|
||||
@ -128,17 +128,17 @@ Your fair use and other rights are in no way affected by the above.
|
||||
[myException raise];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// imageSize = [texImage size]; // Gives size in points, which is bad.
|
||||
imageSize = NSMakeSize( [bitmapImageRep pixelsWide], [bitmapImageRep pixelsHigh]); // Gives size in pixels, which is good.
|
||||
image_w = imageSize.width;
|
||||
image_h = imageSize.height;
|
||||
|
||||
|
||||
while (texture_w < image_w)
|
||||
texture_w *= 2;
|
||||
while (texture_h < image_h)
|
||||
texture_h *= 2;
|
||||
|
||||
|
||||
n_planes = [bitmapImageRep samplesPerPixel];
|
||||
im_bytes = image_w * image_h * n_planes;
|
||||
tex_bytes = texture_w * texture_h * n_planes;
|
||||
@ -149,12 +149,12 @@ Your fair use and other rights are in no way affected by the above.
|
||||
imageSize = NSMakeSize([texImage surface]->w, [texImage surface]->h);
|
||||
image_w = imageSize.width;
|
||||
image_h = imageSize.height;
|
||||
|
||||
|
||||
while (texture_w < image_w)
|
||||
texture_w *= 2;
|
||||
while (texture_h < image_h)
|
||||
texture_h *= 2;
|
||||
|
||||
|
||||
n_planes = [texImage surface]->format->BytesPerPixel;
|
||||
im_bytesPerRow = [texImage surface]->pitch;
|
||||
unsigned char* imageBuffer = [texImage surface]->pixels;
|
||||
@ -169,12 +169,12 @@ Your fair use and other rights are in no way affected by the above.
|
||||
// NSLog(@"DEBUG filling image data for %@ (%d x %d) with special sauce!", filename, texture_w, texture_h);
|
||||
fillSquareImageDataWithBlur(imageBuffer, texture_w, n_planes);
|
||||
}
|
||||
|
||||
|
||||
if ((texture_w > image_w)||(texture_h > image_h)) // we need to scale the image to the texture dimensions
|
||||
{
|
||||
texBytes = malloc(tex_bytes);
|
||||
freeTexBytes = YES;
|
||||
|
||||
|
||||
// do bilinear scaling
|
||||
int x, y, n;
|
||||
float texel_w = (float)image_w / (float)texture_w;
|
||||
@ -195,7 +195,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
py0 = (y1 - y_lo) / texel_h;
|
||||
py1 = 1.0 - py0;
|
||||
}
|
||||
|
||||
|
||||
for ( x = 0; x < texture_w; x++)
|
||||
{
|
||||
float x_lo = texel_w * x;
|
||||
@ -203,7 +203,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
int x0 = floor(x_lo);
|
||||
int x1 = floor(x_hi);
|
||||
float acc = 0;
|
||||
|
||||
|
||||
float px0 = 1.0;
|
||||
float px1 = 0.0;
|
||||
if (x1 > x0)
|
||||
@ -211,19 +211,19 @@ Your fair use and other rights are in no way affected by the above.
|
||||
px0 = (x1 - x_lo) / texel_w;
|
||||
px1 = 1.0 - px0;
|
||||
}
|
||||
|
||||
|
||||
int xy00 = y0 * im_bytesPerRow + n_planes * x0;
|
||||
int xy01 = y0 * im_bytesPerRow + n_planes * x1;
|
||||
int xy10 = y1 * im_bytesPerRow + n_planes * x0;
|
||||
int xy11 = y1 * im_bytesPerRow + n_planes * x1;
|
||||
|
||||
|
||||
for (n = 0; n < n_planes; n++)
|
||||
{
|
||||
acc = py0 * (px0 * imageBuffer[ xy00 + n] + px1 * imageBuffer[ xy10 + n])
|
||||
+ py1 * (px0 * imageBuffer[ xy01 + n] + px1 * imageBuffer[ xy11 + n]);
|
||||
texBytes[ texi++] = (char)acc; // float -> char
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -232,16 +232,16 @@ Your fair use and other rights are in no way affected by the above.
|
||||
texBytes = imageBuffer;
|
||||
freeTexBytes = NO;
|
||||
}
|
||||
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glGenTextures(1, &texName); // get a new unique texture name
|
||||
glBindTexture(GL_TEXTURE_2D, texName);
|
||||
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // adjust this
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // adjust this
|
||||
|
||||
|
||||
switch (n_planes) // fromt he number of planes work out how to treat the image as a texture
|
||||
{
|
||||
case 4:
|
||||
@ -263,14 +263,14 @@ Your fair use and other rights are in no way affected by the above.
|
||||
[myException raise];
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
//
|
||||
// if (n_planes == 4)
|
||||
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_w, texture_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, texBytes);
|
||||
// else
|
||||
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_w, texture_h, 0, GL_RGB, GL_UNSIGNED_BYTE, texBytes);
|
||||
|
||||
|
||||
if (freeTexBytes) free(texBytes);
|
||||
|
||||
|
||||
// add to dictionary
|
||||
//
|
||||
[texProps setObject:[NSNumber numberWithInt:texName] forKey:@"texName"];
|
||||
@ -299,6 +299,20 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
- (void) reloadTextures
|
||||
{
|
||||
#ifdef WIN32
|
||||
int i;
|
||||
|
||||
// Free up the texture image data from video memory. I assume this is a reasonable thing
|
||||
// to do for any platform, but just in case... stick it in a WIN32 only condition.
|
||||
NSArray *keys = [textureDictionary allKeys];
|
||||
for (i = 0; i < [keys count]; i++)
|
||||
{
|
||||
GLuint texName = (GLuint)[(NSNumber *)[[textureDictionary objectForKey:[keys objectAtIndex:i]] objectForKey:@"texName"] intValue];
|
||||
NSLog(@"deleting texture #%d (%@)", texName, (NSString *)[keys objectAtIndex:i]);
|
||||
glDeleteTextures(1, &texName);
|
||||
}
|
||||
#endif
|
||||
|
||||
[textureDictionary removeAllObjects];
|
||||
return;
|
||||
}
|
||||
@ -320,16 +334,16 @@ void fillSquareImageDataWithBlur(unsigned char * imageBuffer, int width, int npl
|
||||
d = r;
|
||||
float fi = 255.0 - 255.0 * d * r1;
|
||||
unsigned char i = (unsigned char)fi;
|
||||
|
||||
|
||||
i_error += fi - i; // accumulate the error between i and fi
|
||||
|
||||
|
||||
if ((i_error > 1.0)&&(i < 255))
|
||||
{
|
||||
// NSLog(@"DEBUG err correct");
|
||||
i_error -= 1.0;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
int p;
|
||||
for (p = 0; p < nplanes - 1; p++)
|
||||
{
|
||||
|
@ -443,13 +443,16 @@ Your fair use and other rights are in no way affected by the above.
|
||||
Universe *universe = [gameController universe];
|
||||
if (universe)
|
||||
{
|
||||
NSLog(@"WIN32: clearing texture store cache");
|
||||
[[universe textureStore] reloadTextures]; // clears the cached references
|
||||
PlayerEntity *player = (PlayerEntity *)[universe entityZero];
|
||||
if (player)
|
||||
{
|
||||
NSLog(@"WIN32: resetting text texture");
|
||||
[[player hud] setPlayer:player]; // resets the reference to the asciitext texture
|
||||
}
|
||||
|
||||
NSLog(@"WIN32: resetting entity textures");
|
||||
int i;
|
||||
Entity **elist = universe->sortedEntities;
|
||||
for (i = 0; i < universe->n_entities; i++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user