adding wreckage to further prettify explosions
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@642 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
b9d73f856d
commit
b680d2a359
@ -22,6 +22,12 @@
|
||||
088496E00A4C1D1B00F32928 /* gotoWaypointAI.plist in Resources */ = {isa = PBXBuildFile; fileRef = 088496DE0A4C1D1B00F32928 /* gotoWaypointAI.plist */; };
|
||||
088496E10A4C1D1B00F32928 /* receiveDockingAI.plist in Resources */ = {isa = PBXBuildFile; fileRef = 088496DF0A4C1D1B00F32928 /* receiveDockingAI.plist */; };
|
||||
08CB1FED09D3F2AA001EA329 /* customsounds.plist in Resources */ = {isa = PBXBuildFile; fileRef = 08CB1FEC09D3F2AA001EA329 /* customsounds.plist */; };
|
||||
08DF8C070A5E74B300BCD981 /* wreck3.dat in Resources */ = {isa = PBXBuildFile; fileRef = 08DF8C020A5E74B200BCD981 /* wreck3.dat */; };
|
||||
08DF8C080A5E74B300BCD981 /* wreck1.dat in Resources */ = {isa = PBXBuildFile; fileRef = 08DF8C030A5E74B200BCD981 /* wreck1.dat */; };
|
||||
08DF8C090A5E74B300BCD981 /* wreck4.dat in Resources */ = {isa = PBXBuildFile; fileRef = 08DF8C040A5E74B200BCD981 /* wreck4.dat */; };
|
||||
08DF8C0A0A5E74B300BCD981 /* wreck5.dat in Resources */ = {isa = PBXBuildFile; fileRef = 08DF8C050A5E74B200BCD981 /* wreck5.dat */; };
|
||||
08DF8C0B0A5E74B300BCD981 /* wreck2.dat in Resources */ = {isa = PBXBuildFile; fileRef = 08DF8C060A5E74B200BCD981 /* wreck2.dat */; };
|
||||
08DF8C2D0A5E74DC00BCD981 /* wreck.png in Resources */ = {isa = PBXBuildFile; fileRef = 08DF8C2C0A5E74DC00BCD981 /* wreck.png */; };
|
||||
1A472917096B5454000E78D8 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A472916096B5454000E78D8 /* CoreAudio.framework */; };
|
||||
1A472921096B5468000E78D8 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A47291F096B5468000E78D8 /* AudioToolbox.framework */; };
|
||||
1A472922096B5468000E78D8 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A472920096B5468000E78D8 /* AudioUnit.framework */; };
|
||||
@ -384,6 +390,12 @@
|
||||
088496DE0A4C1D1B00F32928 /* gotoWaypointAI.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; name = gotoWaypointAI.plist; path = Resources/AIs/gotoWaypointAI.plist; sourceTree = "<group>"; };
|
||||
088496DF0A4C1D1B00F32928 /* receiveDockingAI.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; name = receiveDockingAI.plist; path = Resources/AIs/receiveDockingAI.plist; sourceTree = "<group>"; };
|
||||
08CB1FEC09D3F2AA001EA329 /* customsounds.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; name = customsounds.plist; path = Resources/Config/customsounds.plist; sourceTree = "<group>"; };
|
||||
08DF8C020A5E74B200BCD981 /* wreck3.dat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = wreck3.dat; path = Resources/Models/wreck3.dat; sourceTree = "<group>"; };
|
||||
08DF8C030A5E74B200BCD981 /* wreck1.dat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = wreck1.dat; path = Resources/Models/wreck1.dat; sourceTree = "<group>"; };
|
||||
08DF8C040A5E74B200BCD981 /* wreck4.dat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = wreck4.dat; path = Resources/Models/wreck4.dat; sourceTree = "<group>"; };
|
||||
08DF8C050A5E74B200BCD981 /* wreck5.dat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = wreck5.dat; path = Resources/Models/wreck5.dat; sourceTree = "<group>"; };
|
||||
08DF8C060A5E74B200BCD981 /* wreck2.dat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = wreck2.dat; path = Resources/Models/wreck2.dat; sourceTree = "<group>"; };
|
||||
08DF8C2C0A5E74DC00BCD981 /* wreck.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = wreck.png; path = Resources/Textures/wreck.png; sourceTree = "<group>"; };
|
||||
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||
1A472916096B5454000E78D8 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = /System/Library/Frameworks/CoreAudio.framework; sourceTree = "<absolute>"; };
|
||||
1A47291F096B5468000E78D8 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<absolute>"; };
|
||||
@ -781,6 +793,11 @@
|
||||
25F3E8610994FDBB002F25FD /* viperi_redux.dat */,
|
||||
25F3E8620994FDBB002F25FD /* worm_redux.dat */,
|
||||
25F3E8630994FDBB002F25FD /* worm_redux1.dat */,
|
||||
08DF8C030A5E74B200BCD981 /* wreck1.dat */,
|
||||
08DF8C060A5E74B200BCD981 /* wreck2.dat */,
|
||||
08DF8C020A5E74B200BCD981 /* wreck3.dat */,
|
||||
08DF8C040A5E74B200BCD981 /* wreck4.dat */,
|
||||
08DF8C050A5E74B200BCD981 /* wreck5.dat */,
|
||||
);
|
||||
name = Models;
|
||||
sourceTree = "<group>";
|
||||
@ -848,6 +865,7 @@
|
||||
25F3E7D50994FD4C002F25FD /* viperi_redux.png */,
|
||||
25F3E7D60994FD4C002F25FD /* worm_redux.png */,
|
||||
25F3E7D70994FD4C002F25FD /* worm_redux1.png */,
|
||||
08DF8C2C0A5E74DC00BCD981 /* wreck.png */,
|
||||
);
|
||||
name = Textures;
|
||||
sourceTree = "<group>";
|
||||
@ -1529,6 +1547,12 @@
|
||||
088496E00A4C1D1B00F32928 /* gotoWaypointAI.plist in Resources */,
|
||||
088496E10A4C1D1B00F32928 /* receiveDockingAI.plist in Resources */,
|
||||
080B3D5D0A5696D7004BE918 /* fttAI.plist in Resources */,
|
||||
08DF8C070A5E74B300BCD981 /* wreck3.dat in Resources */,
|
||||
08DF8C080A5E74B300BCD981 /* wreck1.dat in Resources */,
|
||||
08DF8C090A5E74B300BCD981 /* wreck4.dat in Resources */,
|
||||
08DF8C0A0A5E74B300BCD981 /* wreck5.dat in Resources */,
|
||||
08DF8C0B0A5E74B300BCD981 /* wreck2.dat in Resources */,
|
||||
08DF8C2D0A5E74DC00BCD981 /* wreck.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -4793,5 +4793,65 @@
|
||||
<key>weapon_energy</key>
|
||||
<real>4500</real>
|
||||
</dict>
|
||||
<!-- wreckage -->
|
||||
<key>wreckage-component</key>
|
||||
<dict>
|
||||
<key>ai_type</key>
|
||||
<string>nullAI.plist</string>
|
||||
<key>bounty</key>
|
||||
<integer>0</integer>
|
||||
<key>cargo_type</key>
|
||||
<string>CARGO_NOT_CARGO</string>
|
||||
<key>energy_recharge_rate</key>
|
||||
<real>0</real>
|
||||
<key>forward_weapon_type</key>
|
||||
<string>WEAPON_NONE</string>
|
||||
<key>max_energy</key>
|
||||
<real>2000</real>
|
||||
<key>max_flight_pitch</key>
|
||||
<real>2.0</real>
|
||||
<key>max_flight_roll</key>
|
||||
<real>2.0</real>
|
||||
<key>max_flight_speed</key>
|
||||
<real>500</real>
|
||||
<key>model</key>
|
||||
<string>wreck1.dat</string>
|
||||
<key>name</key>
|
||||
<string>Wreckage</string>
|
||||
<key>roles</key>
|
||||
<string>wreckage</string>
|
||||
<key>scanClass</key>
|
||||
<string>CLASS_CARGO</string>
|
||||
<key>thrust</key>
|
||||
<real>0.0</real>
|
||||
</dict>
|
||||
<key>more-wreckage2</key>
|
||||
<dict>
|
||||
<key>like_ship</key>
|
||||
<string>wreckage-component</string>
|
||||
<key>model</key>
|
||||
<string>wreck2.dat</string>
|
||||
</dict>
|
||||
<key>more-wreckage3</key>
|
||||
<dict>
|
||||
<key>like_ship</key>
|
||||
<string>wreckage-component</string>
|
||||
<key>model</key>
|
||||
<string>wreck3.dat</string>
|
||||
</dict>
|
||||
<key>more-wreckage4</key>
|
||||
<dict>
|
||||
<key>like_ship</key>
|
||||
<string>wreckage-component</string>
|
||||
<key>model</key>
|
||||
<string>wreck4.dat</string>
|
||||
</dict>
|
||||
<key>more-wreckage5</key>
|
||||
<dict>
|
||||
<key>like_ship</key>
|
||||
<string>wreckage-component</string>
|
||||
<key>model</key>
|
||||
<string>wreck5.dat</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -388,10 +388,14 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
- (void) reinit;
|
||||
|
||||
- (void) rescaleBy:(GLfloat) factor;
|
||||
|
||||
- (id) initWithDictionary:(NSDictionary *) dict;
|
||||
- (void) setUpShipFromDictionary:(NSDictionary *) dict;
|
||||
- (NSDictionary*) shipInfoDictionary;
|
||||
|
||||
- (void) setOctree:(Octree*) oct;
|
||||
|
||||
- (void) setDefaultWeaponOffsets;
|
||||
|
||||
////////////////
|
||||
@ -545,6 +549,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
- (GLfloat) max_flight_speed;
|
||||
- (GLfloat) speed_factor;
|
||||
|
||||
- (void) setTemperature:(GLfloat) value;
|
||||
- (void) setHeatInsulation:(GLfloat) value;
|
||||
|
||||
- (int) damage;
|
||||
- (void) dealEnergyDamageWithinDesiredRange;
|
||||
- (void) dealMomentumWithinDesiredRange:(double)amount;
|
||||
|
@ -201,6 +201,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
//
|
||||
debug_flag = 0;
|
||||
//
|
||||
octree = nil;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -232,6 +234,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
if (lastRadioMessage) [lastRadioMessage autorelease];
|
||||
|
||||
if (octree) [octree autorelease];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@ -364,6 +368,15 @@ NSString* describeStatus(int some_status)
|
||||
return [NSString stringWithFormat:@"<ShipEntity %@ %d>", name, universal_id];
|
||||
}
|
||||
|
||||
- (void) setOctree:(Octree*) oct
|
||||
{
|
||||
if (octree)
|
||||
[octree release];
|
||||
octree = oct;
|
||||
if (octree)
|
||||
[octree retain];
|
||||
}
|
||||
|
||||
static NSMutableDictionary* smallOctreeDict = nil;
|
||||
- (void) setModel:(NSString*) modelName
|
||||
{
|
||||
@ -385,21 +398,24 @@ static NSMutableDictionary* smallOctreeDict = nil;
|
||||
smallOctreeDict = [(NSMutableDictionary *)[NSMutableDictionary alloc] initWithCapacity:30];
|
||||
if ([smallOctreeDict objectForKey: modelName])
|
||||
{
|
||||
octree = (Octree*)[smallOctreeDict objectForKey: modelName];
|
||||
// octree = (Octree*)[smallOctreeDict objectForKey: modelName];
|
||||
[self setOctree:(Octree*)[smallOctreeDict objectForKey: modelName]];
|
||||
return;
|
||||
}
|
||||
//
|
||||
if ([octreeCache objectForKey: modelName])
|
||||
{
|
||||
octree = [[[Octree alloc] initWithDictionary:(NSDictionary*)[octreeCache objectForKey: modelName]] autorelease];
|
||||
// octree = [[[Octree alloc] initWithDictionary:(NSDictionary*)[octreeCache objectForKey: modelName]] autorelease];
|
||||
[self setOctree:[[[Octree alloc] initWithDictionary:(NSDictionary*)[octreeCache objectForKey: modelName]] autorelease]];
|
||||
[smallOctreeDict setObject: octree forKey: modelName]; //retained
|
||||
}
|
||||
else
|
||||
{
|
||||
// NSLog(@"DEBUG deriving octree for %@ ... model mass is %.2f", modelName, [self mass]);
|
||||
octree = [[self getGeometry] findOctreeToDepth: OCTREE_MAX_DEPTH]; // depth 5 or 6 seems optimum
|
||||
// octree = [[self getGeometry] findOctreeToDepth: OCTREE_MAX_DEPTH]; // depth 5 or 6 seems optimum
|
||||
[self setOctree:[[self getGeometry] findOctreeToDepth: OCTREE_MAX_DEPTH]]; // depth 5 or 6 seems optimum
|
||||
[smallOctreeDict setObject: octree forKey: modelName]; //retained
|
||||
[octreeCache setObject: [octree dict] forKey: modelName];
|
||||
// NSLog(@"DEBUG derived octree for %@ ... model mass is %.2ft octree volume is %.2ft", modelName, 0.001 * [self mass], 20.0 * 0.001 * [octree volume]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -801,8 +817,74 @@ static NSMutableDictionary* smallOctreeDict = nil;
|
||||
debug_flag = 0;
|
||||
//
|
||||
[self setCollisionRegion:nil];
|
||||
//
|
||||
[self setOctree: nil];
|
||||
}
|
||||
|
||||
|
||||
- (void) rescaleBy:(GLfloat) factor
|
||||
{
|
||||
// rescale vertices and rebuild vertex arrays
|
||||
//
|
||||
int i;
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
vertices[i].x *= factor;
|
||||
vertices[i].y *= factor;
|
||||
vertices[i].z *= factor;
|
||||
}
|
||||
[self setUpVertexArrays];
|
||||
usingVAR = [self OGL_InitVAR];
|
||||
if (usingVAR)
|
||||
[self OGL_AssignVARMemory:sizeof(EntityData) :(void *)&entityData :0];
|
||||
|
||||
// rescale the collision radii & bounding box
|
||||
//
|
||||
collision_radius *= factor;
|
||||
actual_radius *= factor;
|
||||
boundingBox.min.x *= factor;
|
||||
boundingBox.min.y *= factor;
|
||||
boundingBox.min.z *= factor;
|
||||
boundingBox.max.x *= factor;
|
||||
boundingBox.max.y *= factor;
|
||||
boundingBox.max.z *= factor;
|
||||
|
||||
// rescale octree
|
||||
//
|
||||
[self setOctree:[octree octreeScaledBy: factor]];
|
||||
|
||||
// rescale positions of subentities
|
||||
//
|
||||
int n_subs = [sub_entities count];
|
||||
for (i = 0; i < n_subs; i++)
|
||||
{
|
||||
Entity* se = (Entity*)[sub_entities objectAtIndex:i];
|
||||
se->position.x *= factor;
|
||||
se->position.y *= factor;
|
||||
se->position.z *= factor;
|
||||
|
||||
// rescale ship subentities
|
||||
if (se->isShip)
|
||||
[(ShipEntity*)se rescaleBy: factor];
|
||||
|
||||
// rescale particle subentities
|
||||
if (se->isParticle)
|
||||
{
|
||||
ParticleEntity* pe = (ParticleEntity*)se;
|
||||
NSSize sz = [pe size];
|
||||
sz.width *= factor;
|
||||
sz.height *= factor;
|
||||
[pe setSize: sz];
|
||||
}
|
||||
}
|
||||
|
||||
// rescale mass
|
||||
//
|
||||
mass *= factor * factor * factor;
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (id) initWithDictionary:(NSDictionary *) dict
|
||||
{
|
||||
self = [super init];
|
||||
@ -1102,6 +1184,9 @@ static NSMutableDictionary* smallOctreeDict = nil;
|
||||
if ([shipdict objectForKey:@"model"])
|
||||
[self setModel:(NSString *)[shipdict objectForKey:@"model"]];
|
||||
//
|
||||
if (octree)
|
||||
mass = 20.0 * [octree volume];
|
||||
//
|
||||
if ([shipdict objectForKey:KEY_NAME])
|
||||
{
|
||||
if (name)
|
||||
@ -1440,7 +1525,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
// octree check
|
||||
Octree* prime_octree = prime->octree;
|
||||
Octree* other_octree = other->octree;
|
||||
|
||||
|
||||
Vector prime_position = prime->position;
|
||||
|
||||
Triangle prime_ijk;
|
||||
@ -1839,6 +1924,8 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
||||
double distance = sqrt(magnitude2(subent->position)) + [subent findCollisionRadius];
|
||||
if (distance > collision_radius)
|
||||
collision_radius = distance;
|
||||
|
||||
mass += 20.0 * [subent->octree volume];
|
||||
}
|
||||
|
||||
|
||||
@ -3983,6 +4070,17 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
||||
return flight_speed / max_flight_speed;
|
||||
}
|
||||
|
||||
- (void) setTemperature:(GLfloat) value
|
||||
{
|
||||
ship_temperature = value;
|
||||
}
|
||||
|
||||
- (void) setHeatInsulation:(GLfloat) value
|
||||
{
|
||||
heat_insulation = value;
|
||||
}
|
||||
|
||||
|
||||
- (int) damage
|
||||
{
|
||||
return (int)(100 - (100 * energy / max_energy));
|
||||
@ -4228,7 +4326,8 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
||||
Vector v;
|
||||
Quaternion q;
|
||||
int speed_low = 200;
|
||||
int n_alloys = floor((boundingBox.max.z - boundingBox.min.z) / 50.0);
|
||||
// int n_alloys = floor((boundingBox.max.z - boundingBox.min.z) / 50.0);
|
||||
int n_alloys = floor(sqrtf( mass / 25000.0));
|
||||
|
||||
if (status == STATUS_DEAD)
|
||||
{
|
||||
@ -4288,7 +4387,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
||||
cargo_chance = 100; // chance of any given piece of cargo surviving decompression
|
||||
cargo_flag = CARGO_FLAG_CANISTERS;
|
||||
}
|
||||
|
||||
|
||||
int cargo_to_go = max_cargo * cargo_chance / 100;
|
||||
while (cargo_to_go > 15)
|
||||
cargo_to_go = ranrot_rand() % cargo_to_go;
|
||||
@ -4440,6 +4539,52 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
||||
return; // don't do anything more
|
||||
}
|
||||
|
||||
/*--*/
|
||||
//
|
||||
// I'm using this to test details for ejecting burning pieces of wreckage that in-turn explode into the alloys
|
||||
// n_pieces_of_wreckage == n_alloys
|
||||
//
|
||||
// a piece of wreckage should be approximately 1/8 of the mass of it's parent ship
|
||||
//
|
||||
// currently most pieces of wreckage are about 20x20x30 or 12000 mass units
|
||||
//
|
||||
if (n_alloys)
|
||||
{
|
||||
int n_wreckage = (n_alloys < 3)? n_alloys : 3;
|
||||
for (i = 0; i < n_wreckage; i++)
|
||||
{
|
||||
ShipEntity* wreck = [universe getShipWithRole:@"wreckage"]; // retain count = 1
|
||||
if (wreck)
|
||||
{
|
||||
GLfloat expected_mass = 0.1f * mass * (0.75 + 0.5 * randf());
|
||||
GLfloat wreck_mass = [wreck mass];
|
||||
GLfloat scale_factor = powf(expected_mass / wreck_mass, 0.33333333f); // cube root of volume ratio
|
||||
[wreck rescaleBy: scale_factor];
|
||||
|
||||
Vector rpos = resolveVectorInIJK( randomPositionInBoundingBox( boundingBox), make_triangle( v_right, v_up, v_forward));
|
||||
rpos.x += xposition.x;
|
||||
rpos.y += xposition.y;
|
||||
rpos.z += xposition.z;
|
||||
[wreck setPosition:rpos];
|
||||
|
||||
quaternion_set_random(&q);
|
||||
[wreck setQRotation:q];
|
||||
|
||||
[wreck setVelocity:make_vector(0.0, 0.0, 0.0)];
|
||||
|
||||
[wreck setTemperature: 1000.0]; // take 1000e heat damage per second
|
||||
[wreck setHeatInsulation: 1.0e7]; // very large! so it won't cool down
|
||||
[wreck setEnergy: 750.0 * randf() + 250.0 * i + 100.0]; // burn for 0.25s -> 1.25s
|
||||
|
||||
[wreck setStatus:STATUS_IN_FLIGHT];
|
||||
[universe addEntity: wreck];
|
||||
[wreck performTumble];
|
||||
[wreck release];
|
||||
}
|
||||
}
|
||||
}
|
||||
/*--*/
|
||||
|
||||
//NSLog(@"Throwing %d pieces of alloy", n_alloys);
|
||||
for (i = 0; i < n_alloys; i++)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user