Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
planet.cpp File Reference
#include <math.h>
#include "vegastrike.h"
#include "unit_factory.h"
#include "planet.h"
#include "gfxlib.h"
#include "gfx/sphere.h"
#include "collection.h"
#include "ai/order.h"
#include "gfxlib_struct.h"
#include "vs_globals.h"
#include "config_xml.h"
#include <assert.h>
#include "cont_terrain.h"
#include "atmosphere.h"
#include "collide2/CSopcodecollider.h"
#include "images.h"
#include "gfx/halo.h"
#include "gfx/animation.h"
#include "cmd/script/flightgroup.h"
#include "gfx/ring.h"
#include "alphacurve.h"
#include "gfx/vsimage.h"
#include "vsfilesystem.h"
#include "gfx/camera.h"

Go to the source code of this file.

Classes

class  AtmosphereHalo
 

Functions

static void SetFogMaterialColor (Mesh *thus, const GFXColor &color, const GFXColor &dcolor)
 
MeshMakeFogMesh (const AtmosphericFogMesh &f, float radius)
 
const vector< string > & ParseDestinations (const string &value)
 
bool CrashForceDock (Unit *thus, Unit *dockingUn, bool force)
 
void abletodock (int dock)
 

Variables

vector< UnitContainer * > PlanetTerrainDrawQueue
 

Function Documentation

void abletodock ( int  dock)

Definition at line 1247 of file firekeyboard.cpp.

1248 {
1249  static bool play_anim = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "docking_comm_anim", "false" ) );
1250  switch (dock)
1251  {
1252  case 5:
1253  {
1254  static soundContainer reqsound;
1255  if (reqsound.sound == -2) {
1256  static string str = vs_config->getVariable( "cockpitaudio", "undocking_complete", "undocking_complete" );
1257  reqsound.loadsound( str );
1258  }
1259  reqsound.playsound();
1260  break;
1261  }
1262  case 4:
1263  {
1264  static soundContainer reqsound;
1265  if (reqsound.sound == -2) {
1266  static string str = vs_config->getVariable( "cockpitaudio", "undocking_failed", "undocking_failed" );
1267  reqsound.loadsound( str );
1268  }
1269  reqsound.playsound();
1270  break;
1271  }
1272  case 3:
1273  {
1274  static soundContainer reqsound;
1275  static string otherstr = vs_config->getVariable( "audio", "automatic_docking_zone", "automatic_landing_zone.wav" );
1276  if (otherstr != "" && rand() < RAND_MAX/2) {
1277  static int s = AUDCreateSoundWAV( otherstr, false );
1278  AUDPlay( s, QVector( 0, 0, 0 ), Vector( 0, 0, 0 ), 1 );
1279  } else {
1280  if (reqsound.sound == -2) {
1281  static string str = vs_config->getVariable( "cockpitaudio", "docking_complete", "docking_complete" );
1282  reqsound.loadsound( str );
1283  }
1284  reqsound.playsound();
1285  }
1286  break;
1287  }
1288  case 2:
1289  {
1290  static soundContainer reqsound;
1291  if (reqsound.sound == -2) {
1292  static string str = vs_config->getVariable( "cockpitaudio", "docking_failed", "docking_failed" );
1293  reqsound.loadsound( str );
1294  }
1295  reqsound.playsound();
1296  break;
1297  }
1298  case 1:
1299  {
1300  static soundContainer reqsound;
1301  if (reqsound.sound == -2) {
1302  static string str = vs_config->getVariable( "cockpitaudio", "docking_granted", "request_granted" );
1303  reqsound.loadsound( str );
1304  }
1305  reqsound.playsound();
1306  break;
1307  }
1308  case 0:
1309  {
1310  static soundContainer reqsound;
1311  if (reqsound.sound == -2) {
1312  static string str = vs_config->getVariable( "cockpitaudio", "docking_denied", "request_denied" );
1313  reqsound.loadsound( str );
1314  }
1315  reqsound.playsound();
1316  break;
1317  }
1318  }
1319 }
bool CrashForceDock ( Unit thus,
Unit dockingUn,
bool  force 
)

Definition at line 365 of file unit_generic.cpp.

References _Universe, abletodock(), Unit::CanDockWithMe(), NetClient::dockRequest(), Unit::ForceDock(), Unit::GetSerial(), Network, Unit::Position(), QVector, Unit::rSize(), UniverseUtil::SafeEntrancePoint(), Unit::SetPosAndCumPos(), Unit::UpgradeInterface(), and Universe::whichPlayerStarship().

Referenced by GamePlanet::reactToCollision(), and Unit::reactToCollision().

366 {
367  Unit *un = dockingUn;
368  int whichdockport = thus->CanDockWithMe( un, force );
369  if (whichdockport != -1) {
370  if (Network == NULL) {
371  QVector place = UniverseUtil::SafeEntrancePoint( un->Position(), un->rSize()*1.5 );
372  un->SetPosAndCumPos( place );
373  if (un->ForceDock( thus, whichdockport ) > 0) {
374  abletodock( 3 );
375  un->UpgradeInterface( thus );
376  return true;
377  }
378  } else {
379  int playernum = _Universe->whichPlayerStarship( dockingUn );
380  if (playernum >= 0)
381  Network[playernum].dockRequest( thus->GetSerial() );
382  return false;
383  }
384  }
385  return false;
386 }
Mesh* MakeFogMesh ( const AtmosphericFogMesh f,
float  radius 
)

Definition at line 60 of file planet.cpp.

References AtmosphericFogMesh::concavity, AtmosphericFogMesh::da, AtmosphericFogMesh::db, AtmosphericFogMesh::dg, AtmosphericFogMesh::dr, AtmosphericFogMesh::ea, AtmosphericFogMesh::eb, AtmosphericFogMesh::eg, AtmosphericFogMesh::er, AtmosphericFogMesh::focus, get_alpha(), VegaConfig::getVariable(), i, Mesh::LoadMesh(), AtmosphericFogMesh::max_alpha, AtmosphericFogMesh::meshname, AtmosphericFogMesh::min_alpha, override, XMLSupport::parse_int(), PngImage, AtmosphericFogMesh::scale, Mesh::setConvex(), SetFogMaterialColor(), AtmosphericFogMesh::tail_mode_end, AtmosphericFogMesh::tail_mode_start, VSFileSystem::TextureFile, XMLSupport::tostring(), Vector, and vs_config.

Referenced by GamePlanet::AddFog().

61 {
62  static int count = 0;
63  count++;
64  string nam = f.meshname+XMLSupport::tostring( count )+".png";
65  if (f.min_alpha != 0 || f.max_alpha != 255 || f.concavity != 0 || f.focus != .5 || f.tail_mode_start != -1
66  || f.tail_mode_end != -1) {
67  static int rez = XMLSupport::parse_int( vs_config->getVariable( "graphics", "atmosphere_texture_resolution", "512" ) );
68  unsigned char *tex = (unsigned char*) malloc( sizeof (char)*rez*4 );
69  for (int i = 0; i < rez; ++i) {
70  tex[i*4] = 255;
71  tex[i*4+1] = 255;
72  tex[i*4+2] = 255;
73  tex[i*4+3] = get_alpha( i, rez, f.min_alpha, f.max_alpha, f.focus, f.concavity, f.tail_mode_start, f.tail_mode_end );
74  }
75  //Writing in the homedir texture directory
76  ::VSImage image;
78  image.WriteImage( (char*) nam.c_str(), &tex[0], PngImage, rez, 1, true, 8, TextureFile );
79  }
80  vector< string >override;
81  override.push_back( nam );
82  Mesh *ret = Mesh::LoadMesh( f.meshname.c_str(), Vector( f.scale*radius, f.scale*radius, f.scale*radius ), 0, NULL, override );
83  ret->setConvex( true );
84  SetFogMaterialColor( ret, GFXColor( f.er, f.eg, f.eb, f.ea ), GFXColor( f.dr, f.dg, f.db, f.da ) );
85  return ret;
86 }
const vector< string >& ParseDestinations ( const string &  value)

Definition at line 178 of file galaxy.cpp.

Referenced by Mission::call_unit_launch(), Universe::getAdjacentStarSystems(), MakeStarSystem(), and UniverseUtil::showSplashScreen().

179 {
180  static vector< string >rv;
181  rv.clear();
182  string::size_type pos = 0, sep;
183  while ( ( sep = value.find( ' ', pos ) ) != string::npos ) {
184  rv.push_back( value.substr( pos, sep-pos ) );
185  pos = sep+1;
186  }
187  if ( pos < value.length() )
188  rv.push_back( value.substr( pos ) );
189  return rv;
190 }
static void SetFogMaterialColor ( Mesh thus,
const GFXColor color,
const GFXColor dcolor 
)
static

Definition at line 43 of file planet.cpp.

References GFXColor::a, GFXMaterial::aa, GFXMaterial::ab, GFXMaterial::ag, GFXMaterial::ar, GFXColor::b, GFXMaterial::da, GFXMaterial::db, GFXMaterial::dg, GFXMaterial::dr, GFXMaterial::ea, GFXMaterial::eb, GFXMaterial::eg, GFXMaterial::er, GFXColor::g, VegaConfig::getVariable(), XMLSupport::parse_float(), GFXMaterial::power, GFXColor::r, GFXMaterial::sa, GFXMaterial::sb, Mesh::SetMaterial(), GFXMaterial::sg, GFXMaterial::sr, and vs_config.

Referenced by MakeFogMesh().

44 {
45  GFXMaterial m;
46  m.ar = m.ag = m.ab = m.aa = m.sr = m.sg = m.sb = m.sa = 0;
47  m.power = 0;
48  static float emm = XMLSupport::parse_float( vs_config->getVariable( "graphics", "atmosphere_emmissive", "1" ) );
49  static float diff = XMLSupport::parse_float( vs_config->getVariable( "graphics", "atmosphere_diffuse", "1" ) );
50  m.er = emm*color.r;
51  m.eg = emm*color.g;
52  m.eb = emm*color.b;
53  m.ea = emm*color.a;
54  m.dr = diff*dcolor.r;
55  m.dg = diff*dcolor.g;
56  m.db = diff*dcolor.b;
57  m.da = diff*dcolor.a;
58  thus->SetMaterial( m );
59 }

Variable Documentation

vector< UnitContainer* > PlanetTerrainDrawQueue

Definition at line 361 of file planet.cpp.