Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
nebula.cpp
Go to the documentation of this file.
1
#include "
nebula.h
"
2
#include "
vegastrike.h
"
3
#include "
vsfilesystem.h
"
4
#include <assert.h>
5
#include "
config_xml.h
"
6
#include "
vs_globals.h
"
7
#include <sys/stat.h>
8
#include "
xml_support.h
"
9
#include "
gfx/mesh.h
"
10
#include "
gfx/cockpit.h
"
11
12
#undef BOOST_NO_CWCHAR
13
14
using
XMLSupport::EnumMap
;
15
using
XMLSupport::Attribute
;
16
using
XMLSupport::AttributeList
;
17
18
extern
double
interpolation_blend_factor
;
19
void
GameNebula::SetFogState
()
20
{
21
float
thisfadein = (
lastfadein
*(1-
interpolation_blend_factor
)+(
fadeinvalue
)*
interpolation_blend_factor
);
22
GFXFogMode
(
fogmode
);
23
GFXFogDensity
(
Density
*thisfadein );
24
GFXFogLimits
(
fognear
,
fogfar
*thisfadein );
25
GFXFogColor
(
GFXColor
(
color
.i,
color
.j,
color
.k, 1 ) );
26
GFXFogIndex
(
index
);
27
}
28
29
//WARNING : USED TO CALL a GameUnit constructor but now Nebula::Nebula calls a Unit one
30
GameNebula::GameNebula
(
const
char
*unitfile,
bool
SubU,
int
faction
,
Flightgroup
*fg,
int
fg_snumber ) :
31
GameUnit
<
Nebula
> ( unitfile, SubU, faction, string(
""
), fg, fg_snumber )
32
{
33
Nebula::InitNebula
( unitfile, SubU, faction, fg, fg_snumber );
34
fadeinvalue
= 0;
35
lastfadein
= 0;
36
}
37
void
GameNebula::UpdatePhysics2
(
const
Transformation
&trans,
38
const
Transformation
&old_physical_state,
39
const
Vector
&accel,
40
float
difficulty,
41
const
Matrix
&transmat,
42
const
Vector
&CumulativeVelocity,
43
bool
ResolveLast,
44
UnitCollection
*uc )
45
{
46
static
float
nebdelta =
XMLSupport::parse_float
(
vs_config
->
getVariable
(
"graphics"
,
"fog_time"
,
".01"
) );
47
lastfadein
=
fadeinvalue
;
48
fadeinvalue
-= nebdelta*
SIMULATION_ATOM
;
49
if
(
fadeinvalue
< 0)
50
fadeinvalue
= 0;
51
this->
GameUnit< Nebula >::UpdatePhysics2
( trans,
52
old_physical_state,
53
accel,
54
difficulty,
55
transmat,
56
CumulativeVelocity,
57
ResolveLast,
58
uc );
59
Vector
t1
;
60
float
dis;
61
unsigned
int
i
;
62
if
(
_Universe
->
activeStarSystem
() ==
_Universe
->
AccessCockpit
()->
activeStarSystem
) {
63
for
(i = 0; i <
NUM_CAM
; i++)
64
if
(
Inside
(
_Universe
->
AccessCamera
( i )->
GetPosition
(), 0,
t1
, dis ) )
65
PutInsideCam
( i );
66
}
67
if
(
nummesh
() > 0) {
68
i = rand()%(
nummesh
() );
69
Vector
randexpl( rand()%2*
rSize
()-
rSize
(), rand()%2*
rSize
()-
rSize
(), rand()%2*
rSize
()-
rSize
() );
70
if
( ( (
int
) (
explosiontime
/SIMULATION_ATOM) ) != 0 )
71
if
( !( rand()%( (
int
) (
explosiontime
/SIMULATION_ATOM) ) ) )
72
meshdata
[i]->AddDamageFX( randexpl,
Vector
( 0, 0, 0 ), .00001,
color
);
73
}
74
}
75
76
void
GameNebula::PutInsideCam
(
int
i )
77
{
78
static
float
nebdelta =
XMLSupport::parse_float
(
vs_config
->
getVariable
(
"graphics"
,
"fog_time"
,
".01"
) );
79
static
float
fadeinrate =
XMLSupport::parse_float
(
vs_config
->
getVariable
(
"graphics"
,
"fog_fade_in_percent"
,
"0.5"
) );
80
if
(
_Universe
->
AccessCamera
() ==
_Universe
->
AccessCamera
( i ) ) {
81
fadeinvalue
+= (1+fadeinrate)*nebdelta*
SIMULATION_ATOM
;
82
if
(
fadeinvalue
> 1)
83
fadeinvalue
= 1;
84
}
85
_Universe
->
AccessCamera
( i )->
SetNebula
(
this
);
86
}
87
src
cmd
nebula.cpp
Generated on Fri May 29 2015 23:07:14 for Vegastrike 0.5.1 rc1 by
1.8.4