C++ Question How to determine if animation will not stop

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
Regarding this part of my code...

Code:
void Spacecraft::DefineAnimations (void)
{
    static UINT EngineGrp[2] = {8,11};
    static MGROUP_ROTATE Engine (0, EngineGrp, 2, _V(-0.432,0,0), _V(0,-1,0), (float)(PI*2));
    anim_eng = CreateAnimation (6);
    AddAnimationComponent (anim_eng, 0, 6, &Engine);
}
void Spacecraft::ActivateEngine(EngineStatus action)
{
    engine_status = action;
}

void Spacecraft::RevertEngine (void)
{
    ActivateEngine((engine_status == ENGINE_IDLE || engine_status == ENGINE_STOPPING) ?
        ENGINE_RUNNING : ENGINE_STOPPING);
}

void Spacecraft::clbkPostStep (double simt, double simdt, double mjd)
{

    if (engine_status >= ENGINE_STOPPING) {
        double da = simdt * ENGINE_SPEED;
        if (engine_status == ENGINE_STOPPING) {
            if (eng_proc > 0.0) eng_proc = max (0.0, eng_proc-da);
            else                engine_status = ENGINE_IDLE;
        } else {
            if (eng_proc < 1.0) eng_proc = min (1.0, eng_proc+da);
            else                engine_status = ENGINE_ON;
        }
        SetAnimation (anim_eng, eng_proc);
    }

}
What would I do to make sure that this animation continues on until I press the command key that activated it? Would I need to delete STOPPING and RUNNING? Then what would I substitute for it since I got rid of the previous words I just explained.
 

computerex

Addon Developer
Addon Developer
Joined
Oct 16, 2007
Messages
1,282
Reaction score
17
Points
0
Location
Florida
Every timestep, check if the state of the animation is greater or equal to 1.0. If so, set the state to zero.
 

marcogavazzeni

Addon Developer
Addon Developer
Joined
Jan 5, 2009
Messages
219
Reaction score
0
Points
16
Location
Near Verona
Website
orbiteritalia.forumotion.com
If you can help this code
Code:
[FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]
// Turbine Anims 
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// Engine start
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (engstart == 1)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (iopt >1 )iopt = 0;
iopt = iopt + engrot; 
engrot = engrot + 0.0005; 
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (engrot > 0.1333)
{
engstart = 2; 
engrot = 0.1333;
}


SetAnimation (anim_eng, iopt);
} 
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// Engine on 
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (engstart == 2)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (iopt >1 )iopt = 0;
iopt = iopt + 0.1333;

SetAnimation (anim_eng, iopt);
}
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// Engine stop
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (engstart == 3)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (iopt >1 )iopt = 0;
iopt = iopt + engrot;

engrot = engrot - 0.0005;

[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (engrot <= 0)
{
engstart = 0; 
engrot = 0;
}
SetAnimation (anim_eng, iopt);
[/SIZE][/FONT][/SIZE][/FONT]

You can find here complete:
[ame="http://www.orbithangar.com/searchid.php?ID=2672"]A-10A at KSC v2[/ame]
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
If you can help this code
Code:
[FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]
// Turbine Anims 
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// Engine start
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (engstart == 1)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (iopt >1 )iopt = 0;
iopt = iopt + engrot; 
engrot = engrot + 0.0005; 
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (engrot > 0.1333)
{
engstart = 2; 
engrot = 0.1333;
}


SetAnimation (anim_eng, iopt);
} 
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// Engine on 
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (engstart == 2)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (iopt >1 )iopt = 0;
iopt = iopt + 0.1333;

SetAnimation (anim_eng, iopt);
}
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// Engine stop
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (engstart == 3)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (iopt >1 )iopt = 0;
iopt = iopt + engrot;

engrot = engrot - 0.0005;

[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (engrot <= 0)
{
engstart = 0; 
engrot = 0;
}
SetAnimation (anim_eng, iopt);
[/SIZE][/FONT][/SIZE][/FONT]
You can find here complete:
A-10A at KSC v2
That is probably the best try for me to do, but I need to figure out how to fix it to where it is compatible with the 2010 SDK. Just having troubles with that. It is saying this....

Code:
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(125) : error C2059: syntax error : 'if'
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(126) : error C2447: '{' : missing function header (old-style formal list?)
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(145) : error C2059: syntax error : 'if'
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(146) : error C2143: syntax error : missing ';' before '{'
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(146) : error C2447: '{' : missing function header (old-style formal list?)
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(155) : error C2059: syntax error : 'if'
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(156) : error C2143: syntax error : missing ';' before '{'
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(156) : error C2447: '{' : missing function header (old-style formal list?)
 

orb

O-F Administrator,
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
It is saying this....

Code:
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(125) : error C2059: syntax error : 'if'
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(126) : error C2447: '{' : missing function header (old-style formal list?)
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(145) : error C2059: syntax error : 'if'
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(146) : error C2143: syntax error : missing ';' before '{'
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(146) : error C2447: '{' : missing function header (old-style formal list?)
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(155) : error C2059: syntax error : 'if'
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(156) : error C2143: syntax error : missing ';' before '{'
1>..\..\TransportVehicle\TransportVehicle\Spacecraft.cpp(156) : error C2447: '{' : missing function header (old-style formal list?)
Have you put that code inside a scope of function?
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
I put it under void Spacecraft::clbkPostStep (double simt, double simdt, double mjd).
 

orb

O-F Administrator,
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
I put it under void Spacecraft::clbkPostStep (double simt, double simdt, double mjd).

Check if you have brackets around the pasted code, i.e. check if you haven't done something like this:
PHP:
void Spacecraft::clbkPostStep (double simt, double simdt, double mjd) // if you have here a semicolon then remove it.
if (engstart == 1) // if there isn't an opening ({) brace before 'if', add it.
{
// the code
}
// add a closing (}) brace for function, if you haven't already.

Explanation of C2447 error.
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
Check if you have brackets around the pasted code, i.e. check if you haven't done something like this:
PHP:
void Spacecraft::clbkPostStep (double simt, double simdt, double mjd) // if you have here a semicolon then remove it.
if (engstart == 1) // if there isn't an opening ({) brace before 'if', add it.
{
// the code
}
// add a closing (}) brace for function, if you haven't already.
Explanation of C2447 error.
Yeah I actually thought of the brackets being misplaced when it first messed up. As far as I can see they are where they are supposed to be. Here is the full part.

Code:
 void Spacecraft::clbkPostStep (double simt, double simdt, double mjd)
 {
    if (engstart == 1)
    {
    if (iopt >1 )iopt = 0;
    iopt = iopt + engrot;
    
    engrot = engrot + 0.0005;
    
    if (engrot > 0.1333)
    {
        engstart = 2;
        
        engrot = 0.1333;
    }
    
    
    SetAnimation (anim_eng, iopt);
    }


    // Engine on
    
    if (engstart == 2)
    {
    if (iopt >1 )iopt = 0;
    iopt = iopt + 0.1333;
    
    SetAnimation (anim_eng, iopt);
}
   // Engine stop
    
    if (engstart == 3)
    {
    if (iopt >1 )iopt = 0;
    iopt = iopt + engrot;
    
    engrot = engrot - 0.0005;
    
    if (engrot <= 0)
    {
        engstart = 0;
        
        engrot = 0;
    }

    SetAnimation (anim_eng, iopt);
}
I put it as-is to see if I could even get it to work before I get to ansy. (Not my data)
 

orb

O-F Administrator,
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
And could you post what is on lines 120-126, and on lines 140-146 of Spacecraft.cpp?
 
Top