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
warptrail.cpp
Go to the documentation of this file.
1
#include "
mesh.h
"
2
#include "
lin_time.h
"
3
#include "
faction_generic.h
"
4
#include "
cmd/unit_generic.h
"
5
#include "
gfx/camera.h
"
6
#include "
config_xml.h
"
7
8
struct
warptrails
9
{
10
vector< Mesh* >
factions
;
11
vector< struct WarpTrail* >
warps
;
12
void
Draw
();
13
};
14
15
warptrails
wt
;
16
17
Mesh
*
GetWarpMesh
(
int
faction
,
warptrails
*wt );
18
19
struct
WarpTrail
20
{
21
QVector
start
;
22
UnitContainer
cur
;
23
float
tim
;
24
WarpTrail
(
Unit
*un,
QVector
beg,
float
tim
) :
cur
( un )
25
{
26
start
= beg;
27
this->tim =
tim
;
28
}
29
#if 0
30
bool
Draw
(
warptrails
*w )
31
{
32
tim
-=
GetElapsedTime
();
33
Unit
*un =
cur
.
GetUnit
();
34
if
(!un)
return
false
;
35
Mesh
*m =
GetWarpMesh
( un->
faction
, w );
36
if
(!m)
37
return
false
;
38
QVector
end( un->
Position
() );
39
float
length = (end-
start
).
Magnitude
();
40
float
d
= ( .5*(end+
start
)-
_Universe
->
AccessCamera
()->
GetPosition
().Cast() ).
Magnitude
();
41
Vector
p,
q
, r;
42
r = (end-
start
).Cast();
43
q =
Vector
( 0, 1, 0 );
44
p = r.Cross( q );
45
q = r.Cross( p );
46
p.Normalize();
47
q.Normalize();
48
Matrix
matrix( p, q, r, end );
49
m->
Draw
( length, matrix, d );
50
return
tim
> 0;
51
}
52
#else
53
bool
Draw
(
warptrails
*w )
54
{
55
tim
-=
GetElapsedTime
();
56
Unit
*un =
cur
.
GetUnit
();
57
if
(!un)
return
false
;
58
Mesh
*m =
GetWarpMesh
( un->
faction
, w );
59
if
(!m)
60
return
false
;
61
QVector
end( un->
Position
() );
62
float
length = (end-
start
).
Magnitude
();
63
float
d = ( end-
_Universe
->
AccessCamera
()->
GetPosition
().Cast() ).
Magnitude
();
64
Vector
p,
q
, r;
65
r = (end-
start
).Cast();
66
r.Normalize();
67
static
float
stretch =
XMLSupport::parse_float
(
vs_config
->
getVariable
(
"graphics"
,
"warp_trail_stretch"
,
"300"
) );
68
r *= un->
rSize
()*stretch;
69
q =
Vector
( 0, 1, 0 );
70
p = r.Cross( q );
71
q = p.Cross( r );
72
p.Normalize();
73
p *= un->
rSize
();
74
q.Normalize();
75
q *= un->
rSize
();
76
Matrix
matrix( p, q, r, end );
77
m->
Draw
( length, matrix, d );
78
d = (
start
-
_Universe
->
AccessCamera
()->
GetPosition
().Cast() ).
Magnitude
();
79
matrix.
p
=
start
+r;
80
m->
Draw
( length, matrix, d );
81
return
tim
> 0;
82
}
83
#endif
84
};
85
86
void
warptrails::Draw
()
87
{
88
for
(
unsigned
int
i
= 0;
i
<
warps
.size(); ++
i
)
89
if
( !
warps
[
i
]->
Draw
(
this
) ) {
90
delete
warps
[
i
];
91
warps
.erase(
warps
.begin()+
i
);
92
i
--;
93
}
94
}
95
96
void
AddWarp
(
Unit
*un,
QVector
beg,
float
tim )
97
{
98
wt.
warps
.push_back(
new
WarpTrail
( un, beg, tim ) );
99
}
100
101
void
WarpTrailDraw
()
102
{
103
wt.
Draw
();
104
}
105
106
Mesh
*
GetWarpMesh
(
int
faction
,
warptrails
*w )
107
{
108
using namespace
VSFileSystem;
109
while
( faction >= static_cast<int>(w->
factions
.size()) )
110
w->
factions
.push_back( NULL );
111
string
fac =
FactionUtil::GetFaction
( faction );
112
fac +=
"_warp.bfxm"
;
113
VSError
err;
114
if
( ( err =
LookForFile
( fac,
MeshFile
) ) >
Ok
) {
115
fac =
"neutral_warp.bfxm"
;
116
if
( ( err =
LookForFile
( fac,
MeshFile
) ) >
Ok
)
117
return
NULL;
118
}
119
if
(!w->
factions
[faction])
120
w->
factions
[
faction
] =
Mesh::LoadMesh
( fac.c_str(),
Vector
( 1, 1, 1 ),
faction
, NULL );
121
return
w->
factions
[
faction
];
122
}
123
src
gfx
warptrail.cpp
Generated on Fri May 29 2015 23:07:30 for Vegastrike 0.5.1 rc1 by
1.8.4