DesideriusPapp
New member
- Joined
- May 23, 2009
- Messages
- 21
- Reaction score
- 0
- Points
- 0
Hi all. I wonder if someone can give me a hint on the following.
I'm trying to set up a simple animation, and tried to follow the API documentation and sample code for ShuttleA. This is what I did:
The mesh index should be ok as I checked with MeshDebug, and the code compiles. I noticed ShuttleA uses clbkPostState, which I tried, compiled, but got no result whatsoever. I also tried SetAnimState in place of SetAnimation, and RegisterAnimSequence in place of CreateAnimation.
What is it I am missing? I've no C++ experience, so please be patient.
Thank you!
I'm trying to set up a simple animation, and tried to follow the API documentation and sample code for ShuttleA. This is what I did:
Code:
Strelka::Strelka (OBJHANDLE hVessel, int fmodel)
: VESSEL2 (hVessel, fmodel)
{
DefineAnimations();
BayStatus = CLOSED;
DoorProc = 0.0;
DoorSpeed = 0.1;
}
...
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Strelka::DefineAnimations()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] UINT bay_a_grps [1] = {61};[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MGROUP_ROTATE bay_a (0, bay_a_grps, 1, _V(7.08,7.08,184.9467), _V(-1,1,0), ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) (PI*2/3));[/SIZE]
[SIZE=2][COLOR=#0000ff] [/COLOR]BayAnimation = CreateAnimation (0.0);[/SIZE]
[SIZE=2][COLOR=#0000ff] [/COLOR]AddAnimationComponent (BayAnimation, 0, 1, &bay_a);[/SIZE]
[SIZE=2]}[/SIZE]
void Strelka::OperateBayDoor (double simt)
{
if (BayStatus == CLOSING || BayStatus == OPENING)
{
double da = oapiGetSimStep()*DoorSpeed;
if (BayStatus == CLOSING)
{
if (DoorProc > 0.0) DoorProc = max (0.0, DoorProc-da);
else BayStatus = CLOSED;
}
else
{
if (DoorProc < 1.0) DoorProc = min (1.0, DoorProc+da);
else BayStatus = OPEN;
}
SetAnimation (BayAnimation, DoorProc);
}
}
void Strelka::RevertBayDoor()
{
ActivateBayDoor (BayStatus == CLOSED || BayStatus == CLOSING ? OPENING : CLOSING);
}
void Strelka::ActivateBayDoor(BayDoorStatus action)
{
BayStatus = action;
}
int Strelka::clbkConsumeBufferedKey(DWORD key, bool down, char *keystate)
{
if (!down) return 0;
if (KEYMOD_SHIFT (keystate)) {}
else
{
if (KEYMOD_CONTROL (keystate))
{
switch (key)
{
case OAPI_KEY_K:
RevertBayDoor();
return 1;
}
}
}
return 0;
}
The mesh index should be ok as I checked with MeshDebug, and the code compiles. I noticed ShuttleA uses clbkPostState, which I tried, compiled, but got no result whatsoever. I also tried SetAnimState in place of SetAnimation, and RegisterAnimSequence in place of CreateAnimation.
What is it I am missing? I've no C++ experience, so please be patient.
Thank you!