Welcome to the forum

register! and help us get started! with this new darkgdk forum !


dont forget to introduce yourself Razz

enjoy! and good luck with your programming Smile


DirectX Limbs and Animations Code

Go down

DirectX Limbs and Animations Code

Post  Sweemoo on Sun Apr 25, 2010 10:21 pm

Hey guys heres the code for that little app i made a long time ago.



Code:

#include "DarkGDK.h"
#include <string.h>

float XAngleCamera = 0.0f;
float Max          = 0.0f;
float Cam_Distance = 50.0f;
int  xr = 0;
int  yr = 0;
int  zr = 0;
int  daInt = 1;
int  daFrame = 0;
char my_String[60];
char my_String2[60];
float LimbScaling = 100.0f;
int Cam_Height = 50;

void displayText (void);
void limbViewer (void);
void updateCamera (void);

// the main entry point for the application is this function
void DarkGDK ( void )
{
   dbSyncOn  ( );
   dbSyncRate ( 60 );

   dbInk ( dbRGB(0,175,0), dbRGB(0,0,0) );
   dbColorBackdrop(dbRGB(68,133,157));
   
   dbText(5,100,"Controls:");
   dbText(5,120,"Left Click to Rotate Camera.");
   dbText(5,140,"Use the Mouse Wheel to Zoom.");
   dbText(5,160,"+ and - on the numpad to scale the equipment model.");
   dbText(5,180,"Ins,Home,PgUp,PgDown,End, and Del are used to Rotate the Equipment Model.");
   dbText(5,200,"W A S D are used to control the Character Models animation frames.");
   dbText(5,220,"Hold the Right Mouse Button to move Camera vertically.");
         dbText(5,5,"Character Filename:");
         dbText(5,20,"Equipment Filename:");
         dbSync();
         dbSetCursor(160,5);
         strcpy(my_String,dbInput());
         dbSetCursor(160,20);
         strcpy(my_String2,dbInput());
         dbSync();
         dbLoadObject(my_String,1);
         dbPerformChecklistForObjectLimbs(1);
         dbPositionObject(1,0,-25,0);
         dbLoadObject(my_String2,3);
         dbPositionObject(3,1,0,.1);
         //dbScaleObject(3,875,875,875);
         dbMakeObjectSphere(2,0.001,1,1);
         //dbLoopObject(1);
         dbSetObjectSpeed(1,40);


   


   while ( LoopGDK ( ) )
   {
      displayText();
      limbViewer();
      updateCamera();
      dbSetObjectFrame(1,daFrame);
      dbGlueObjectToLimb(3,1,daInt);
      dbScaleObject(3,LimbScaling,LimbScaling,LimbScaling);
      dbRotateObject(3,xr,yr,zr);
      
      dbSync ( );
      
   }

   
   return;
}


void displayText (void)
{
      dbInk(dbRGB(0,0,0),dbRGB(0,0,0));
      dbBox(2.5,2.5,250,125);
      dbInk(dbRGB(0,175,0),dbRGB(0,0,0));
      dbText(5,5,"Total Limbs:");
      dbText(110,5,dbStr(dbChecklistQuantity()));
      dbText(5,20,"Int Value:");
      dbText(95,20,dbStr(daInt));
      dbText(5,35,"Limb Description:");
      dbText(145,35,dbChecklistString(daInt));
      dbText(5,50,"LIMB NAME:");
      dbText(95,50,dbLimbName(1,daInt));
      dbText(5,65,"LimbScaling:");
      dbText(105,65,dbStr(LimbScaling));
      dbText(5,80,"LimbRotation:");
      dbText(115,80,dbStr(xr));
      dbText(155,80,dbStr(yr));
      dbText(195,80,dbStr(zr));
      dbText(5,95,"Total Frames:");
      dbText(115,95,dbStr(dbTotalObjectFrames(1)));
      dbText(5,110,"Current Frame:");
      dbText(135,110,dbStr(dbObjectFrame(1)));

}


void limbViewer (void)
{
   
   //Checklist Control
   if (dbUpKey()) daInt += 1;
   if (dbDownKey()) daInt -= 1;
   if (daInt>dbChecklistQuantity()) daInt=dbChecklistQuantity();
   if (daInt<1) daInt=1;

   //Limbness
   if (dbKeyState(74)) LimbScaling -=1;
   if (dbKeyState(78)) LimbScaling +=1;

   //Frames Control
   if (dbKeyState(17)) daFrame +=1;
   if (dbKeyState(31)) daFrame -=1;
   if (dbKeyState(30)) daFrame -=10;
   if (dbKeyState(32)) daFrame +=10;
   if (daFrame>dbTotalObjectFrames(1)) daFrame=0;
   if (daFrame<0) daFrame=0;

   //Rotationz
   if (dbKeyState(210)) xr +=1;
   if (dbKeyState(211)) xr -=1;
   if (dbKeyState(199)) yr +=1;
   if (dbKeyState(207)) yr -=1;
   if (dbKeyState(201)) zr +=1;
   if (dbKeyState(209)) zr -=1;

}

void updateCamera (void)
{
   if(dbMouseClick()==2) Cam_Height = Cam_Height-dbMouseMoveY()/2;

   //Camera Mount
   dbPositionObject(2,dbObjectPositionX(1),dbObjectPositionY(1) + Cam_Height,dbObjectPositionZ(1));
   //Camera
   dbPositionCamera(dbObjectPositionX(2),dbObjectPositionY(2),dbObjectPositionZ(2));

   XAngleCamera = dbObjectAngleX(2);
   Max = dbObjectAngleX(2) + dbMouseMoveY() / 2;

   Cam_Distance = Cam_Distance-dbMouseMoveZ()/120;

   if (dbMouseClick()==1)
   {
      dbRotateCamera(dbObjectAngleX(2),dbObjectAngleY(2),dbObjectAngleZ(2));
      dbRotateObject( 2,  Max, dbObjectAngleY(2) + dbMouseMoveX() / 2 , dbObjectAngleZ(2) + dbMouseMoveY() / 2 ) ;
      dbMoveCamera( -Cam_Distance );
   }
   else
   {
      dbMoveCamera( -Cam_Distance );
   }


}

Sweemoo

Posts : 1
Join date : 2010-04-25

View user profile

Back to top Go down

Re: DirectX Limbs and Animations Code

Post  pqowieuryt101 on Sun Apr 25, 2010 10:26 pm

ahh thanks for posting this, that limbs program has helped me soo much. I've used it in all my games Razz
avatar
pqowieuryt101
Admin

Posts : 97
Join date : 2010-04-22

View user profile http://darkgdk.forumotion.com

Back to top Go down

Re: DirectX Limbs and Animations Code

Post  Instinct949 on Tue May 11, 2010 5:51 pm

hey thanks for this usefull post!


i will be needing somthing like this when i move to 3d



thanks again Smile
avatar
Instinct949
Admin

Posts : 21
Join date : 2010-05-05
Age : 23

View user profile

Back to top Go down

Re: DirectX Limbs and Animations Code

Post  F4SHADO on Mon May 24, 2010 5:12 pm

hmmm... i've never used limbs in DarkGDK, what do they do and how do they work

F4SHADO

Posts : 36
Join date : 2010-05-08
Location : Springfield, Illinois

View user profile https://www.youtube.com/user/F4SHADO

Back to top Go down

Re: DirectX Limbs and Animations Code

Post  pqowieuryt101 on Mon May 24, 2010 6:12 pm

they are very useful, each object has a set of limbs such as feet, legs, arms, head etc.

you can attach an object to any of these limbs say a sword to the hand limb. These means whenever the hand moves, say to hit an enemy the sword will move with it in a realistic way. Check my limbs video here for a tutorial Smile

https://www.youtube.com/watch?v=hi5R0WRiJus
avatar
pqowieuryt101
Admin

Posts : 97
Join date : 2010-04-22

View user profile http://darkgdk.forumotion.com

Back to top Go down

Re: DirectX Limbs and Animations Code

Post  F4SHADO on Mon May 24, 2010 6:45 pm

oh wow, thankyou, now i dont need to animate the character holding and firing the gun. shaves precious days of my programming time

KAMPAI cheers cheers cheers

F4SHADO

Posts : 36
Join date : 2010-05-08
Location : Springfield, Illinois

View user profile https://www.youtube.com/user/F4SHADO

Back to top Go down

Re: DirectX Limbs and Animations Code

Post  pqowieuryt101 on Mon May 24, 2010 8:14 pm

lol no problem, glad I helped Smile
avatar
pqowieuryt101
Admin

Posts : 97
Join date : 2010-04-22

View user profile http://darkgdk.forumotion.com

Back to top Go down

Re: DirectX Limbs and Animations Code

Post  F4SHADO on Tue May 25, 2010 7:13 pm

hello again. after compiling the code above, i just realized i dont know how to load a model into it.
help, plz. oh and any way of learning how to use limbs to the fullest???


Domo Arigato

and

Kampai cheers

F4SHADO

Posts : 36
Join date : 2010-05-08
Location : Springfield, Illinois

View user profile https://www.youtube.com/user/F4SHADO

Back to top Go down

Re: DirectX Limbs and Animations Code

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum