About Store Forum Documentation Contact



Post Reply 
animation mapping?
Author Message
ghreef Offline
Member

Post: #1
animation mapping?
Hello all.

I'm attempting to switch out the standard player models with my own meshs/physics/animations. I am having problems finding the actual animations that are tied to the player/mobs in RPG 2. I looked in the CHR files, the player files, the AI files. Also all the external headers. No where can I find where the animations are really tied to the meshes like I've seen in the animation source code for the tutorials. Can anyone point me to where it is? I think I'm going to have to pull it all out and rewrite it since there appear to be references all over the place for these things. I have multiple models, but they don't all share the same animation and skeleton references since some have tails, some don't etc...

Thanks,
gh
08-01-2011 04:56 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
RE: animation mapping?
animations can be set manually in the codes, please check gama basics tutorials, character animations tutorials.
default animations are in "SDK/Data/Anim"
08-02-2011 12:49 PM
Find all posts by this user Quote this message in a reply
ghreef Offline
Member

Post: #3
RE: animation mapping?
Yes, I looked at the animation tutorials. My challenge is that this format of code is no where to be found anywhere in the RPG2 source code. But, if the code is in SDK/data/anim and a new class to handle animations will "override" the animations set in SDK/data/anim, then I'll be ok. I was looking to change the code that already exists, but if it's not necessary, then I can trek on.

thanks.
oh, I looked into all this, I think there's some confusion. I know where the .anim files are. I have all my new ones in my own locations. What I am looking for is: where in the RPG2 code can I find "cskel.animate(L"../data/anim/walk.anim",Time.time()); " for walk, turn-r, crouch-r, all the anim files in the data/anim folder? I can't seem to find the code that is in the animation tutorial (cskel.animate(L"../data/anim/walk.anim",Time.time()); ) for all the anim files for the models in RPG2? That is what I can't seem to find, but it needs to be there to provide action based on the w,a,s,d type key presses. any of this make sense?

to simplify:
player presses keyboard "w"
that should tie somewhere to a cskel.animate call (I can't find this)
that should leverage the .anim file to show the in-game avatar "move"

It's that middle step I can't find in code.

Thanks.
(This post was last modified: 08-02-2011 02:22 PM by ghreef.)
08-02-2011 02:15 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #4
RE: animation mapping?
RPG2 uses the stock animation handling in the Game::Chr meaning you need company license to alter it, of course it is possible to build your own handlers which in some cases would be better to do.
(This post was last modified: 08-02-2011 02:39 PM by Zervox.)
08-02-2011 02:36 PM
Find all posts by this user Quote this message in a reply
ghreef Offline
Member

Post: #5
RE: animation mapping?
Thanks Zervox, very good to know.

Do I need to do anything to disable referencing Game::Chr animation handling, or can I just write my own class for animations and run with that?
08-02-2011 03:37 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #6
RE: animation mapping?
You could write your own chr class from game obj to make sure you only have what is really needed as base and write your animation structure, or you can write custom handling on top.

I personally tend to stay away from using the Game::Chr but mostly because when doing implementation of Recast&Detour so I really don't need all of the functions as they end up just being clutter.
08-02-2011 04:25 PM
Find all posts by this user Quote this message in a reply
ghreef Offline
Member

Post: #7
RE: animation mapping?
ok, little bit of an update but still needing some help here:

I have a worm - easy enough - with a skeleton, mesh, anim files etc...
I brought it all it the world I am working on.
I created an animate.h and animate.cpp file.

the keys to my .cpp file are:
Code:
CSkeleton cskel_mob_worm;

cskel_mob_worm.create(Skeletons("../data/obj/chr/critter/worm/worm.skel"),0.7f);

cskel_mob_worm.clear();
       cskel_mob_worm.animate(L"../data/obj/chr/critter/worm/attack1.anim",Time.time());
       cskel_mob_worm.animate(L"../data/obj/chr/critter/worm/attack2.anim",Time.time());
       cskel_mob_worm.animate(L"../data/obj/chr/critter/worm/walk.anim",Time.time());
I get an error on loading the game that "Point "HandL" not found in skeleton "obj\chr\critter\worm\worm.skel"
This is expected since my worm has different bones then the ones provided with RPG2 source. (I think I found the bone reference in the 'external dependencies' character.h under the struct SkelAnimCache function and "int" listing. My issue - most of my characters are drastically different and their bone structure is very different. How can I create a reference for each of my models to have different skeletons??

and I guess the bigger question - am I headed in the right direction here?

(humbly thankful)
(This post was last modified: 08-08-2011 03:49 AM by ghreef.)
08-08-2011 03:48 AM
Find all posts by this user Quote this message in a reply
ghreef Offline
Member

Post: #8
RE: animation mapping?
looking into this even more - and creating more confusion...

I checked out the horse. It doesn't have a bone of Hand_L or Hand_R, and I can't see it having new bones set in the horse.cpp or horse.h files. This tells me that I don't need to explicitly set the bones for animation to work - is this correct?

It's getting more confusing, not less :(
08-08-2011 05:26 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #9
RE: animation mapping?
horse uses its custom class which doesnt require handL handR

if you're using ERPG2 codes then the chr codes in ERPG2 require handL handR
use debug, and once you have the Exit message, VS will point you to the ERPG2 line where handL handR are required.

just use your custom class for the worm
08-09-2011 12:00 PM
Find all posts by this user Quote this message in a reply
ghreef Offline
Member

Post: #10
RE: animation mapping?
thanks.

I've been pouring through the code to decide if I should adjust the horse files or the Chr files to make a "mob_worm" file. Since it appears that horse is just a vehicle and doesn't manage it's own movement like ERPG2 mobs goblin and skeleton do, it seems I should adjust a copy of the chr files to accomplish this. So, it appears that I need to:
copy character.h from external references to a mob_worm.h file
copy chr.cpp from the game to a mob_worm.cpp file
copy chr.h from the game to a mob_worm.h file

Do all the changes to apply to the worm mob, rename the skeleton, remove the horse and hand specific fighting (since worms don't ride horses or have hands) etc...

Does all this sound right? Did I miss anything?
... <sigh> and the various updates to files like esenthelengine.h and struct.h

- it's fun ... but it's painful! So much better with rum grin
(This post was last modified: 08-09-2011 07:04 PM by ghreef.)
08-09-2011 06:38 PM
Find all posts by this user Quote this message in a reply
ghreef Offline
Member

Post: #11
RE: animation mapping?
All - I'm still stuck on this freaking animation. I can't seem to make this work at all. I tried to leverage just the animation tutorial and that didn't work since it doesn't use obj types to get data from the world manager at all.

I decided to just work with the horse files and modify them into a mob file (again using my worm model as a base).

I update all the header files I could find that needed to be updated. Then I created a mob_test.h and .cpp file. No matter what I try, I can't seem to even get the f*ing mob to show up in the game, even though it's in the world editor, and build all etc...

Any clues?

here's my file data:
Code:
/******************************************************************************/
enum OBJ_TYPE // Game Object Type
{
   OBJ_STATIC      , // static
   OBJ_KINEMATIC   , // kinematic
   OBJ_ITEM        , // item
   OBJ_CHR         , // character
   OBJ_MOB           , // Mob
   OBJ_PLAYER      , // player
   OBJ_HORSE       , // horse
   OBJ_VEHICLE     , // vehicle
   OBJ_DOOR        , // door
   OBJ_LIGHT_POINT , // point light
   OBJ_LIGHT_CONE  , // cone  light
   OBJ_PARTICLES   , // particles
   OBJ_DECAL       , // decal
   OBJ_MESH_OVERLAY, // mesh overlay
   OBJ_LAMP        , // lamp
   OBJ_TORCHIERE   , // torchiere
   OBJ_FIREBALL    , // fireball
};
/******************************************************************************/
from game.cpp
Code:
Game::ObjMemx<Static       > Statics;
Game::ObjMemx<Kinematic    > Kinematics;
Game::ObjMemx<Door         > Doors;
Game::ObjMemx<Item         > Items;
Game::ObjMemx<Torchiere    > Torchieres;
Game::ObjMemx<AI           > AIs;
Game::ObjMemx<Player       > Players;
Game::ObjMemx<Horse        > Horses;
Game::ObjMemx<Mob        > Mobs;
Game::ObjMemx<Fireball     > Fireballs;
Game::ObjMemx<ObjLightPoint> ObjLightPoints;

mob_test.h:

Code:
/******************************************************************************/
STRUCT(Mob , Game::Obj)
//{
   MeshPtr        mesh ;
   CSkeleton      cskel;
   Controller     ctrl ;
   Ragdoll        kinematic_ragdoll;
   Reference<Chr> rider;
   Flt            angle,angle_offset;
  
   Flt  stand_run,turn;
   Vec2 dir;

   // manage
   virtual void create(Game::ObjParams &obj);
           void createKinematicRagdoll();

   // get / set
   virtual Vec    pos   (                );
   virtual Matrix matrix(                );
   virtual void   pos   (C Vec    &pos   );
   virtual void   matrix(C Matrix &matrix) {pos(matrix.pos);}

   // callbacks
   virtual void memoryAddressChanged();
   virtual void linkReferences();

   // update
   virtual Bool update();

   // operations
   virtual void emitSound(Str name, Flt range=1, Flt volume=1);

   // draw
   virtual UInt drawPrepare();
   virtual void drawShadow ();

   // enable / disable
   virtual void disable();
   virtual void  enable();

   // io
   virtual void save(File &f);
   virtual Bool load(File &f);

   Mob();
};
/******************************************************************************/

mob_test.cpp:
Code:
/******************************************************************************/
#include "stdafx.h"
#include "Main.h"
/******************************************************************************/
CSkeleton cskel;
/******************************************************************************/
Mob::Mob()
{
   angle=0;
   angle_offset=0;
   stand_run=0;
   turn=0;
   dir.zero();
}
void Mob::createKinematicRagdoll()
{
   kinematic_ragdoll.create  (cskel,1,true          )  // create the helper ragdoll as kinematic
                    .group   (AG_KINEMATIC_RAGDOLL  )  // set desired actor group
                    .ray     (false                 )  // disable ray-testing
                    .obj     (this                  )  // set game object owner
                    .fromSkel(cskel,cskel.vel(),true); // use 'true' for immediate pose setting at creation time, to ensure that the pose will be set immediately, please read comments on 'fromSkel' method for more information about it
}
void Mob::create(Game::ObjParams &obj)
{
               mesh=obj.mesh   (); //if(!mesh)Exit("Horse doesn't have mesh");
   Skeleton   *skel=obj.skeleton(); //if(!skel)Exit("Horse doesn't have skel");
   PhysBodyPtr phys=obj.phys    ();

   cskel.create(skel,obj.scale(),obj.matrixFinal());
   //cskel.create(Skeletons("../data/obj/chr/critter/worm/worm.skel"));

   createKinematicRagdoll();

   Flt r=1, h=2;
   Vec pos=obj.matrixFinal().pos;
   if(phys && phys->parts.elms()>=1 && phys->parts[0].type()==PHYS_SHAPE)
   {
      r=phys->parts[0].shape.capsule.r;
      h=phys->parts[0].shape.capsule.h;
   }
   ctrl.createCapsule(r,h,pos).actor.obj(this).damping(0.1f).ccd(true);

   angle=Angle(obj.matrixFinal().z.xz())-PI_2;


}
/******************************************************************************/
// GET / SET
/******************************************************************************/
Vec    Mob::pos   (          ) {return cskel.pos   ();}
Matrix Mob::matrix(          ) {return cskel.matrix();}
void   Mob::pos   (C Vec &pos) {Vec delta=pos-T.pos(); cskel.move(delta); ctrl.actor.pos(ctrl.actor.pos()+delta);}
/******************************************************************************/
void Mob::emitSound(Str name, Flt range, Flt volume)
{
   SoundPlay(name,pos(),range*2.5f,volume);
}
/******************************************************************************/
// CALLBACKS
/******************************************************************************/
void Mob::memoryAddressChanged() {ctrl.actor.obj(this); kinematic_ragdoll.obj(this);}
void Mob::linkReferences      () {rider.link();}
/******************************************************************************/
// UPDATE
/******************************************************************************/
Bool Mob::update()
{
   Vec2 move;

   // animate
   Matrix m; m.setRotateY(-angle-angle_offset).move(ctrl.actor.pos());

   cskel.clear();
   //cskel.animate(L"data/obj/chr/critter/worm/walk.anim",                         Time.time(),1-stand_run);
   cskel.animate(L"data/obj/chr/critter/worm/walk.anim",Time.time());
   //cskel.animate(L"data/obj/chr/critter/worm/run.anim"  ,dir.y<0 ? -Time.time() : Time.time(),  stand_run);
   cskel.updateMatrix(m).updateVelocities();

   // step sound
   if(ctrl.onGround() && stand_run>0.25f && Animations("data/obj/chr/critter/worm/walk.anim")->eventOccured("step",Time.time(),Time.d()))
      emitSound(S+"sound/step/material/stone/r"+Random(6)+".wav",1,0.8f);

   kinematic_ragdoll.fromSkel(cskel,cskel.vel(),true);

   return true;
}
/******************************************************************************/
// ENABLE / DISABLE
/******************************************************************************/
void Mob::disable() {__super::disable(); ctrl.actor.kinematic(true );}
void Mob:: enable() {__super:: enable(); ctrl.actor.kinematic(false);}
/******************************************************************************/
// DRAW
/******************************************************************************/
UInt Mob::drawPrepare()
{
   if(mesh)if(Frustum(Ball().setAnimated(mesh->box,cskel)))
   {
      SetHighlight((Cur.obj==this && Cur.highlight) ? Color(34,85,85) : Color(0,0,0)); mesh->draw(cskel);
      SetHighlight(                                                     Color(0,0,0));
   }
   //Meshes("../data/obj/chr/critter/worm/worm.mesh")->draw(cskel);
   return 0;
}
void Mob::drawShadow()
{
   if(mesh)if(Frustum(Ball().setAnimated(mesh->box,cskel)))mesh->drawShadow(cskel);
}
/******************************************************************************/
// IO
/******************************************************************************/
void Mob::save(File &f)
{
   __super::save(f);

   f.putStr(mesh.name());
   cskel.save(f);
   ctrl .save(f);
   f<<angle<<angle_offset<<stand_run<<turn<<dir;
   kinematic_ragdoll.saveState(f,true);
}
Bool Mob::load(File &f)
{
   if(__super::load(f))
   {
      mesh .require(f.getStr());
      cskel.load   (f);
      ctrl .load   (f); ctrl.actor.obj(this);
      f>>angle>>angle_offset>>stand_run>>turn>>dir;
      createKinematicRagdoll(); if(!kinematic_ragdoll.loadState(f))return false;
      return true;
   }
   return false;
}
/******************************************************************************/
//Bool mtInit()
//{
//   cskel.create(Skeletons("../data/obj/chr/critter/worm/worm.skel")); // create controlled skeleton from skel file, with 1.7 meter height
//   return true;
//}
///******************************************************************************/
//Bool mtUpdate()
//{
//   // set animations
//   {  
//      cskel.clear();     // clear controlled skeleton animation
//      cskel.animate(L"../data/obj/chr/critter/worm/walk.anim",Time.time()); // animate with "walk" animation and current time position
//      cskel.updateMatrix    (MatrixIdentity); // update controlled skeleton animation matrixes
//      cskel.updateVelocities(              ); // update controlled skeleton bone velocities (this is needed for Motion Blur effect)
//   }
//
//   return true;
//}
///******************************************************************************/
//void mtRender()
//{
//   switch(Renderer())
//   {
//      case RM_PREPARE:
//      {
//         Meshes("../data/obj/chr/critter/worm/worm.mesh")->draw(cskel); // get mesh from cache and render it with controlled skeleton matrixes
//      }break;
//   }
//}
//void mtDraw()
//{
//   Renderer(mtRender);
//
//   //if(Kb.ctrl()) // when control pressed
//   //{
//   //   if(Renderer.rebuildDepthNeededForDebugDrawing())Renderer.rebuildDepth();
//   //   SetMatrix();     // restore default matrix
//   //   cskel.draw(RED); // draw controlled skeleton
//   //}
//
//   //D.text(0,0.8f,"Hold space to animate");
//}
///******************************************************************************/

... I wish there was a crying smiley ...

Edit: attached is a screenie of the object in the world editor.


update:

It's showing up now, I was missing a reference in Main.h:

Code:
struct Mob;

BUT - now it's floating in the air around 30 feet up??? and, no animations.

Anyone?


Attached File(s) Image(s)
   
(This post was last modified: 08-12-2011 10:09 PM by ghreef.)
08-12-2011 09:14 PM
Find all posts by this user Quote this message in a reply
ghreef Offline
Member

Post: #12
RE: animation mapping?
To assist with this issue, I tried to isolate the problem. I used the tutorial files and replaced the skeleton references with my worm files in the tutorial source, animation.

I found two things, 1) the worm is much larger, but I thought that was the issue, and shouldn't create a real problem. 2) the animation doesn't even work there! It moves once, but doesn't "animate". In the model editor it seems to work fine.

if anyone can help with this, I have attached my model files and some animation files. Please let me know if anyone can see anything that indicated a root problem.

Thanks.


Attached File(s)
.rar  worm.rar (Size: 153.27 KB / Downloads: 3)
08-12-2011 11:46 PM
Find all posts by this user Quote this message in a reply
Post Reply