Has anyone gotten the Enhanced Animation working with any of Dexsoft character models before?
We're using Example 1 of the Enhanced Animation with the villager character model from Dexsoft and it looks like the model moves about 3 frames very slowly and then stops. Is there something specific about DarkGDK and the bones of the model that maybe other engines don't have because I can play this character in a couple other engines without issue. I haven't modified Example 1 much at all honestly. It's just like:
#pragma warning( disable : 4244 4305 )
#include "DarkGDK.h"
#include "EnhancedAnimations.h"
//#include <fstream>
//#include <iostream>
//using namespace std;
void DarkGDK ( void )
{
// **********************
// Setup
// **********************
dbSyncOn ( );
dbSyncRate (0);
dbBackdropOn ( );
dbAutoCamOff ( );
dbMaximiseWindow( );
//dbSetWindowOff( );
dbSetWindowOn();
dbSetDisplayMode( 1024, 768, 32 );
// **********************
// Load Objects:
// **********************
// Load Character Model
// ---------------------------------------------
dbLoadObject( "media/villager.dbo", 1 );
dbSetObjectCull(1, 0);
dbYRotateObject( 1, 0 );
dbPositionObject(1, 0, 0, 0);
dbScaleObject(1, 100, 100, 100);
//dbFixObjectPivot( 1 );
dbLoadImage( "media/villager.jpg", 1 );
dbTextureObject( 1, 1 );
// Camera
// ---------------------------------------------
dbPositionCamera( 10, 20, -20);
dbPointCamera( 0, 0, 0);
// Set the default animation play speed (frames per second)
// ----------------------------------------------------------
EnAn_SetDefaultPlaySpeed( 15.0f );
// EXTRACT ANIMATION DATA FROM MODEL
// ************************************************
// Normaly, this would be done outside of your game as you are preparing your media.
// Extracting animations pulls the animation data out of your files
// and puts it into it's own file format
// Note: if you set the EndFrame# variable to -1, it will use the last frame in the model
EnAn_ObjExtractAnimation( 1, "Run1.anim", 0, -1 );
EnAn_ObjExtractAnimation( 1, "Walk1.anim", 0, -1 );
//EnAn_ObjExtractAnimation( 1, "Pose.anim", 0, 0 );
// LOAD ANIMATIONS
// ************************************************
// This will load the animations that you extracted above
// The "AnimID" variable is what will be used to refer to your loaded animation
//DWORD PoseAnim = EnAn_AnimLoad("Pose.anim");
DWORD WalkAnim = EnAn_AnimLoad("Walk1.anim");
DWORD RunAnim = EnAn_AnimLoad("Run1.anim");
// LIMB HIERARCHY
// ************************************************
// We need to know what limbs numbers go to the limbs that we want to control
// You can easily find out information about your limbs by doing something
// like this:
/*ofstream myfile( "limb data.txt");
for ( DWORD a = 1; a < EnAn_ObjTotalLimbs(1); a++ )
{
myfile << a << " = " << dbLimbName( 1, a ) << "\n";
myfile << "----------------------------------\n";
myfile << "Parent Limb: " << EnAn_ObjFindLimbParent( 1, a ) << " - " << dbLimbName( 1,EnAn_ObjFindLimbParent( 1, a ) ) << "\n";
myfile << "Direct Children:\n";
for ( DWORD b = 1; b < EnAn_ObjTotalLimbs( 1 ); b++ )
{
if ( EnAn_ObjIsLimbChild( 1, a, b ) == 1 && EnAn_ObjFindLimbParent( 1, b ) == a )
{
myfile << " " << b << " = " << dbLimbName( 1, b ) << "\n";
}
}
myfile << "\n";
}
myfile.close( );*/
// This model's hierarchy looks like this:
// Base
// |-Pelvis
// |-Spine
// |-ThighRight -> The rest of the model's Right Leg are children of ThighRight
// |-ThighLeft -> The rest of the model's Right Leg are children of ThighLeft
// |-Spine1
// |-Spine2 -> The rest of the model's UpperBody are children of Spine2
// When you want to control the model's upper body, you can simply refer to the Spine1 limb and include it's children
// All of the rest of the limb's actions should be set to what you want the lower body (movement) to do.
// CREATE OAC LINK TO OBJECT
// ************************************************
// This will allow you to apply animations to an object. It provides the object with all of the
// internal variables that are needed for control.
// The "oacID" variable is what will be used to work with that particular DBpro object
// Each DBpro object that you want to control with Enhanced Animations will need an oacID
DWORD oacID = EnAn_oacCreate( 1 );
// PLAY THE WALK ANIMATION
// ************************************************
// This command will begin playing the Walk animation on the object.
// The oacID refers to the object that it is linked to.
// The Limb variable will apply the animation to the specified limb. Enhanced Animations can play animations
// on entire objects OR specific limbs.
// The StartFrame and EndFrame parameters describe what is considered the beginning and end of the animation.
// If the EndFrame parameter is set to a negative number, then the last frame of the animation file will be used
// The current frame parameter describes what frame to begin playing on. If the loop parameter is set to one (1),
// then when the animation reaches the end frame, it will start over at the start frame.
// If the exChild (or Exclude child) parameter is set to one (1), then ONLY the specified limb will have the
// animation applied to it. Otherwise, the specified limb and all of it's children in the limb hierarchy will have
// the animation applied to it.
EnAn_oacPlayAnim( oacID, 1, WalkAnim, 1, 1, -1, 1, 0 );
// Get the current time value.
DWORD time = dbTimer();
DWORD elapsedTime = 0;
// **********************
// Main Loop:
// **********************
while ( LoopGDK ( ) )
{
if ( dbEscapeKey ( ) )
return;
//ELAPSED TIME
//*****************************************
// Get the amount of elspsed time since the last time check
elapsedTime = dbTimer() - time;
//Reset the time check
time = dbTimer();
//UPDATE THE OAC
//*****************************************
//This will update the object's animation by telling the object how much time has elapsed
EnAn_oacUpdate( oacID, elapsedTime );
//TRANSITION TO NEW ANIMATIONS
//*****************************************
//Using a transition animation work very similat to Playing an animation (as described above)
//The only difference is the addition of the TransTime parameter wich tells the object how long
//it should take for the transition from the currently playing animation to the new animation
//that you are transitioning to.
if (dbReturnKey() == 1)
{
//Transition to walk over 2 seconds
EnAn_oacAnimTransition( oacID, 1, WalkAnim, 0.0f, 0.0f, -1.0f, 2000, 1, 0 );
}
if (dbSpaceKey())
{
//Transition to run over 1 second
EnAn_oacAnimTransition( oacID, 1, RunAnim, 0.0f, 0.0f, -1.0f, 1000, 1, 0 );
}
if (dbShiftKey())
{
//Transition to pose over 1 second
//EnAn_oacAnimTransition( oacID, 1, PoseAnim, 0.0f, 0.0f, -1.0f, 1000, 1, 0 );
}
dbText ( 0,0,dbStr(dbScreenFPS()) );
dbText ( 0,10, "Enhanced Animations for GDK" );
dbText ( 0,20, "Example 01: The Basics" );
dbText ( 0,30, "By: Ron Erickson" );
dbText ( 0,40, "visit: www.GameToolshed.com" );
dbText ( 0,50, "-------------------------------------------------------------------" );
dbText ( 0,60, " This example shows the basics of how Enhanced Animations works!" );
dbText ( 0,70, " Press ENTER to switch to Walk animation" );
dbText ( 0,80, " Press SPACE to switch to Run animation" );
dbText ( 0,90, " Press SHIFT to switch to POSE" );
dbText ( 0,100, "-------------------------------------------------------------------" );
if ( EnAn_oacGetLimbPlayAnimID(oacID, 1) == WalkAnim )
{
dbText ( 0,110, " Current Play animation: Walk" );
}
if ( EnAn_oacGetLimbPlayAnimID(oacID, 1) == RunAnim )
{
dbText ( 0,110, " Current Play animation: Run" );
}
//if ( EnAn_oacGetLimbPlayAnimID(oacID, 1) == PoseAnim )
//{
// dbText ( 0,110, " Current Play animation: Pose" );
//}
if (EnAn_oacGetLimbTransIsActive(oacID, 1) == 1 )
{
if ( EnAn_oacGetLimbTransAnimID(oacID, 1) == WalkAnim )
{
dbText ( 0,120, " Switching to: Walk " );
}
if ( EnAn_oacGetLimbTransAnimID(oacID, 1) == RunAnim )
{
dbText ( 0,120, " Switching to: Run" );
}
//if ( EnAn_oacGetLimbTransAnimID(oacID, 1) == PoseAnim )
//{
// dbText ( 0,120, " Switching to: Pose" );
//}
}
dbSync ( );
}
}