13 for (
unsigned int i = 0; inp[
i] !=
'\0';
i++)
14 if (inp[
i] ==
'/' || inp[
i] ==
'\\')
21 char *tmp2 = strdup( textname );
24 for (i = 0; tmp[i] !=
'\0' && (isalpha( tmp[i] ) || tmp[i] ==
'_'); i++) {}
39 , velocity( velocity )
41 , inittheta( initpos )
44 , current_orbit_frame( 0 )
47 orbiting_average[t] =
QVector( 0, 0, 0 );
49 orbit_list_filled =
false;
51 double delta = x_size.Magnitude()-y_size.Magnitude();
55 focus = x_size*( delta/x_size.Magnitude() );
57 focus = y_size*( -delta/y_size.Magnitude() );
67 const double div2pi = ( 1.0/(2.0*
PI) );
69 theta = inittheta+velocity *
getNewTime()*div2pi;
89 if (averaging < 1.0
f) averaging = 1.0f;
93 unsigned int o = current_orbit_frame++;
95 if (current_orbit_frame == 0)
96 orbit_list_filled =
true;
98 if (orbiting_average[o].
i == 0 && orbiting_average[o].
j == 0 && orbiting_average[o].
k == 0) {
101 orbiting_average[o] = desired;
103 current_orbit_frame = 2;
104 orbit_list_filled =
false;
110 if (orbit_list_filled) {
111 sum_position = orbiting_average[o];
115 sum_position = orbiting_average[0];
119 for (
int i = 0;
i < limit;
i++) {
121 sum_position += orbiting_average[o];
125 sum_diff *= ( 1./(limit) );
126 sum_position *= ( 1./(limit+1) );
129 sum_diff *= ratio_simatom;
130 unsigned int number_to_fill;
133 if (ratio_simatom <= 1)
136 sum_position += ( sum_diff*(number_to_fill/ -2.) );
137 for (o = 0; o < number_to_fill; o++) {
138 orbiting_average[o] = sum_position;
139 sum_position += sum_diff;
146 orbiting_average[o] = desired;
154 QVector sum_orbiting_average( 0, 0, 0 );
157 if (orbit_list_filled)
160 limit = current_orbit_frame;
161 for (
int o = 0; o < limit; o++)
162 sum_orbiting_average += orbiting_average[o];
163 sum_orbiting_average *= 1./(limit == 0 ? 1 : limit);
165 const double div2pi = ( 1.0/(2.0*
PI) );
168 float truetheta = inittheta+velocity *
getNewTime()*div2pi;
169 theta = theta*( (averaging-1.0f)/averaging )+truetheta*(1.0f/averaging);
174 QVector destination = origin-focus+sum_orbiting_average+x_offset+y_offset;
177 printf(
"(%.2f %.2f %.2f)\n(%.2f %.2f %.2f) del %.2f spd %.2f\n",
189 static float Unreasonable_value =
192 if (v2 > Unreasonable_value*Unreasonable_value ) {
201 using namespace VSFileSystem;
202 char strdir[2] = {direction, 0};
203 string elxmesh = string( strdir )+
"_elevator.bfxm";
204 string elevator_mesh = name+
"_"+faction+elxmesh;
209 else elevator_mesh = name+elxmesh;
210 return elevator_mesh;
237 Matrix ElevatorLoc(
Vector( dir.j, dir.k, dir.i ), dir,
Vector( dir.k, dir.i, dir.j ) );
240 string elevator_mesh =
GetElMeshName( name, faction, direction );
252 if (dir.Dot(
Vector( 1, 1, 1 ) ) > 0)
253 ElevatorLoc.
p.Set( dir.i*mx.i, dir.j*mx.j, dir.k*mx.k );
255 ElevatorLoc.
p.Set( -dir.i*mn.i, -dir.j*mn.j, -dir.k*mn.k );
274 assert( *satiterator );
275 if ( (*satiterator)->isUnit() ==
PLANETPTR ) {
302 const string &filename,
303 const string &technique,
304 const string &unitname,
307 const vector< string > &dest,
310 const vector< GFXLightLocal > &ligh,
320 assert( *satiterator );
321 if ( (*satiterator)->isUnit() ==
PLANETPTR ) {
324 filename, technique, unitname,
336 if (isunit ==
true) {
337 Unit *sat_unit = NULL;
343 (*satiterator)->SetAI(
new PlanetaryOrbit( *satiterator, vely, pos, x, y,
QVector( 0, 0, 0 ),
this ) );
344 (*satiterator)->SetOwner(
this );
347 if (dest.size() != 0)
350 filename, technique, unitname,
351 blendSrc, blendDst, dest,
352 QVector( 0, 0, 0 ),
this, ourmat, ligh, faction, fullname, inside_out ) );
382 const string &filename,
383 const string &technique,
384 const string &unitname,
385 const vector< string > &dest,
391 unsigned int lights_num )
397 radius *= bodyradius;
404 bool notJumppoint = dest.empty();
405 for (
unsigned int i = 0;
i < dest.size(); ++
i)
410 this->fullname =
name;
414 static float densityOfJumpPoint =
417 hull = (4./3)*
M_PI*radius*radius*radius*(notJumppoint ? densityOfRock : densityOfJumpPoint);
418 this->
Mass = (4./3)*
M_PI*radius*radius*radius*( notJumppoint ? densityOfRock : (densityOfJumpPoint/100000) );
426 static float planetdockportminsize =
429 float dock = radius*planetdockportsize;
430 if (dock-radius < planetdockportminsize)
431 dock = radius+planetdockportminsize;
434 string tempname = unitname.empty() ?
::getCargoUnitName( filename.c_str() ) : unitname;
443 if ( un->
name !=
string(
"LOAD_FAILED" ) ) {
456 un->
name =
"Defense_grid";
458 static bool neutralplanets =
460 if (neutralplanets) {
462 this->faction = neutralfaction;
467 if ( un->
name ==
string(
"LOAD_FAILED" ) || (!smartplanets) )
478 const string &filename,
479 const string &technique,
480 const string &unitname,
481 const vector< string > &dest,
487 unsigned int lights_num )
495 filename, technique, unitname,
504 for (
unsigned int i = 0;
i < lights_num;
i++) {