3 #include "cmd/planet.h"
6 #include "gfx/animation.h"
9 #include "cmd/container.h"
12 #include "gfx/cockpit.h"
14 #include "cmd/images.h"
15 #include "cmd/script/flightgroup.h"
25 static Animation *cachedani =
new Animation( game_options.
jumpgate.c_str(),
true, .1,
MIPMAP, false );
31 static std::vector< unsigned int >AnimationNulls;
43 static std::vector< ResizeAni >JumpAnimations;
44 static std::vector< ResizeAni >VolatileJumpAnimations;
47 if ( which < VolatileJumpAnimations.size() )
48 return VolatileJumpAnimations[which].a;
52 unsigned int AddAnimation(
const QVector &pos,
const float size,
bool mvolatile,
const std::string &name,
float percentgrow )
54 std::vector< ResizeAni > *ja = mvolatile ? &VolatileJumpAnimations : &JumpAnimations;
56 Animation *ani =
new Animation( name.c_str(),
true, .1,
MIPMAP, false );
58 if ( mvolatile || AnimationNulls.empty() ) {
60 ja->push_back(
ResizeAni( ani, percentgrow ) );
62 assert( JumpAnimations[AnimationNulls.back()].a == NULL );
63 JumpAnimations[AnimationNulls.back()] =
ResizeAni( ani, percentgrow );
64 i = AnimationNulls.back();
65 AnimationNulls.pop_back();
67 (*ja)[i].a->SetDimensions( size, size );
68 (*ja)[i].a->SetPosition( pos );
72 static unsigned int AddJumpAnimation(
const QVector &pos,
const float size,
bool mvolatile =
false )
81 JumpAnimations[ani].a = NULL;
82 AnimationNulls.push_back( ani );
88 for (
unsigned int kk = 0; kk <
pendingjump.size(); ++kk) {
94 un->GetOrientation( p, q, r );
96 JumpAnimations[k].a->SetPosition( un->Position()+r.Cast()*un->rSize()*(
pendingjump[kk]->delay+.25) );
97 JumpAnimations[k].a->SetOrientation( p, q, r );
99 *(un->GetJumpStatus().delay-
pendingjump[kk]->delay)/(
float) un->GetJumpStatus().delay;
100 JumpAnimations[k].a->SetDimensions( dd, dd );
105 for (i = 0; i < JumpAnimations.size(); ++i)
106 if (JumpAnimations[i].a)
107 JumpAnimations[i].a->Draw();
108 for (i = 0; i < VolatileJumpAnimations.size(); ++i)
109 if (VolatileJumpAnimations[i].a) {
111 VolatileJumpAnimations[i].a->GetDimensions( hei, wid );
112 VolatileJumpAnimations[i].a->SetDimensions( VolatileJumpAnimations[i].percent*hei,
113 VolatileJumpAnimations[i].percent*wid );
114 if ( VolatileJumpAnimations[i].a->Done() ) {
115 delete VolatileJumpAnimations[i].a;
116 VolatileJumpAnimations.erase( VolatileJumpAnimations.begin()+i );
119 VolatileJumpAnimations[i].a->Draw();
127 un->GetOrientation( p, q, r );
128 unsigned int myani = AddJumpAnimation( un->LocalPosition(), un->rSize()*game_options.
jumpgatesize, true );
129 VolatileJumpAnimations[myani].a->SetOrientation( p, q, r );
136 un->GetOrientation( p, q, r );
137 ani = AddJumpAnimation( un->Position()+r.Cast()*un->rSize()*(un->GetJumpStatus().delay+.25), 10*un->rSize() );
139 AUDPlay( jumpleave, un->LocalPosition(), un->GetVelocity(), 1 );