About Store Forum Documentation Contact



Post Reply 
Unexpected tilt to character
Author Message
gamecreator Offline
Member

Post: #1
Unexpected tilt to character
I experienced the following in the World Editor when I hit Update Visible and Play.
[Image: skeltilt.th.jpg]
The skeleton tilts and continues to stay tilted as I move it around. It stands and animates correctly in the Mesh Editor and it also stands fine (but of course doesn't move) if I set the type to OBJ_STATIC. In comparing the skeleton of my skeleton to that of Esenthel's human, I noticed that my Body bone takes up the whole body whereas the human's has a lower one called Body and then an upper one called BodyU. Could this be the problem?

I exported my mesh from 3DS Max 2009 via the Collada DAE exporter. Thank you for any help.
11-22-2009 01:42 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Unexpected tilt to character
could you make a video of the problem?

and show on screens how the mesh looks like in Mesh Editor (with its animation skeleton visible)

if you're using custom animations, then you need to setup them in your own codes (Chr::sac, please check bloody massacre tutorial)
11-22-2009 01:54 AM
Find all posts by this user Quote this message in a reply
gamecreator Offline
Member

Post: #3
RE: Unexpected tilt to character
I think I could make a video but what would you like to see? It would be just me in the World Editor as you see on the left of the original image and then me hitting Update Visible and Play and then the skeleton looking like it does on the right as you move (float) it around. Record that?

In the meantime, here is the image of the skeleton in the viewer, with the animation option selected.
[Image: skelinviewer.th.jpg]

And thanks for the final advice but I haven't coded anything yet. Just learning the tools at the moment.
11-22-2009 03:00 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Unexpected tilt to character
you're using custom skeleton and animations, so yes, you'd need to setup the codes to load custom animations
11-22-2009 03:06 AM
Find all posts by this user Quote this message in a reply
gamecreator Offline
Member

Post: #5
RE: Unexpected tilt to character
I'm sorry for seeming so dense but how do I "setup the codes to load custom animations" in the World Editor?

In the meantime, I downloaded the Bloody Massacre files and on trying to run Bloody Massacre.exe, it showed me two screens and then exited with the following Error:
"Can't load "D:\Esenthel\Data\obj\building\Chinese\detail\Impenetrable Iron.gfx"
Additional path "obj\building\House""

I'm not sure why it's trying to look on my D:\ drive. Both the EsenthelEngineSDK and the Bloody Massacre files are extracted to my desktop. And there is no Impenetrable Iron.gfx in either folder (nor is there a Chinese folder). There is just an iron.gfx file though. It may be trying to load the wrong file.

I will continue to look through the Bloody Massacre tutorials for a solution for the World Editor problem though. Thank you.
(This post was last modified: 11-22-2009 04:13 AM by gamecreator.)
11-22-2009 04:05 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Unexpected tilt to character
oh, sorry, thats an error, I'm uploading fixed BM demo, it will be ready in 20 minutes, please check the updated version

as for the custom animations, you can't set them in the World Editor, you can set them only in your game codes.

there is also tutorial in game basics folder which operates on character animations (the one in which human and skeleton characters walk in circles, and the skeleton has a custom animation defined "scary walk.anim")
11-22-2009 04:25 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Unexpected tilt to character
updated BM demo is ready
11-22-2009 05:05 AM
Find all posts by this user Quote this message in a reply
gamecreator Offline
Member

Post: #8
RE: Unexpected tilt to character
Ok. I think I understand. The World Editor doesn't support custom animations so that's why my skeleton is tilted in it. No problem. I'm sure it'll work fine in my code, once I start programming. Thanks once more, Esenthel! Your help is really appreciated.
11-22-2009 05:06 AM
Find all posts by this user Quote this message in a reply
gamecreator Offline
Member

Post: #9
RE: Unexpected tilt to character
Hello again. I've now tried to import an animated model into code (the Character and Skeleton tutorial examples) and random tilting problems are still happening. It seems to me to be influenced by the skeleton/bones and maybe also by turning looping on and off. For example, the mesh is turned a different direction depending on which bone I name as Body (I have three or four spine bones in the body). Also, for the exact same mesh, skeleton and animation files, the Character and Skeleton examples tilt the model differently (the Skeleton example seems to be better at showing it standing correctly).

I will attempt to make a video trying to illustrate all of this tonight.
11-24-2009 06:57 PM
Find all posts by this user Quote this message in a reply
gamecreator Offline
Member

Post: #10
RE: Unexpected tilt to character
Here are all of the files, videos included (5MB):

http://www.mediafire.com/?nrzyzfgmmgy

If anyone can help me understand why the character tilts in seemingly such a random way (and also, how to fix it) I would appreciate it.
11-25-2009 08:12 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
RE: Unexpected tilt to character
Hi,

please load your mesh, skeleton, and then load default animations (like stand, walk, run), you'll see that the character is animated incorrectly.

this is because your skeleton isn't a skeleton similar to the one needed for animations (most importantly "Body" bone in your skeleton has additional parent "bip01", and the "Body" has rotated orientation than the default, please notice the tiny line going out from bone position, perpendicular to the bone direction)

when you load a character mesh to the game, using Game::Chr, it uses those default animations, stand, walk run..

you need either to change your skeleton to be exactly the same as the sample skeletons,

or

as I mentioned above, in the codes, character object creation, setup custom animations.
please check Chr::sac.*
there are tutorials for that (Bloody Massacre and Game Basics\where skeleton and human walk in circles)
11-25-2009 02:56 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #12
RE: Unexpected tilt to character
Ok i check your code to and you must make your own animation for character and overwrite it. I change a bit your code and made some animations. But to make it 100% corectly you have to change more and try add character in WE and play it. When i try use world make in WE i have error with skeleton so maybe you have to chenge char skeleton.
You have to change your code like here:
Quote:struct Player : Game::Chr // extend character class by defining a player class based on the character
{
void setAnim();
virtual Bool update(); // here we'll update the player (please note that this is a virtual method)
};
/******************************************************************************/
void Player::setAnim()
{
sac.stand=&cskel.getSkelAnim("obj/chr/test/stand.anim");
sac.run=&cskel.getSkelAnim("obj/chr/test/walk.anim");
}
And Init:
Quote:Bool Init()
{
Physics.create();
ground .create(Box(15,1,15,Vec(0,-2,0)),0);

// Matrix matrix; matrix.setScalePos(5.8,Vec(0,0,0));
Matrix matrix; matrix.setScalePos(5.8,Vec(0,0,0));
player.create(0.45, 1.8, matrix, *Meshs("obj/chr/test/man.mesh"), *Skeletons("obj/chr/test/man.skel")); // create player by radius, height, matrix, mesh and skeleton
player.setAnim();
return true;
}
Code with world create in WE:
Code:
/******************************************************************************/
#include "stdafx.h"
#include "../../../../../data/enum/_enums.h"
/******************************************************************************

   Here we'll present how to properly use different camera modes

/******************************************************************************/
// Define viewing modes:
enum VIEW_MODE // Viewing Mode
{
   VIEW_FPP, // First Person
   VIEW_TPP, // Third Person
   VIEW_ISO, // Isometric
   VIEW_NUM, // number of view modes
};
UInt View; // current VIEW_MODE
/******************************************************************************/
struct Player : Game::Chr
{
   Vec ctrl_pos;
   void create(Game::ObjParams &obj);
   virtual Bool update();
  
   virtual void draw(); // extend drawing to disable head rendering in FPP mode

   virtual void save(File &f);
   virtual Bool load(File &f);
};
/******************************************************************************/
Game::ObjMemx<Game::Static> Statics; // container for static objects
Game::ObjMemx<Game::Item  > Items  ; // container for item   objects
Game::ObjMemx<      Player> Players; // container for player objects
/******************************************************************************/
void Player::create(Game::ObjParams &obj)
{
    __super::create(obj); // call default creation
    sac.walk=&cskel.getSkelAnim("obj/chr/test/walk.anim");
    sac.stand=&cskel.getSkelAnim("obj/chr/test/stand.anim");
}
Bool Player::update()
{
   if(action)
   {
      if(Kb.b(KB_W) || Kb.b(KB_S) || Kb.b(KB_A) || Kb.b(KB_D) || Kb.b(KB_Q) || Kb.b(KB_E))actionBreak();
   }

   if(!action)
   {
      // turn & move
      input.anglei.x=Kb.b(KB_Q)-Kb.b(KB_E);
      input.anglei.y=Kb.b(KB_T)-Kb.b(KB_G);
      input.diri  .x=Kb.b(KB_D)-Kb.b(KB_A);
      input.diri  .z=Kb.b(KB_W)-Kb.b(KB_S);
      input.diri  .y=Kb.b(KB_SPACE)-Kb.b(KB_LSHIFT);

      // dodge, crouch, walk, jump
      input.dodge = Kb.bd(KB_D)-Kb.bd(KB_A);
      input.crouch= Kb.b (KB_LSHIFT);
      input.walk  = Kb.b (KB_LCTRL );
      input.jump  =(Kb.bp(KB_SPACE ) ? 3.5 : 0);

      // mouse turn
      if(View!=VIEW_ISO) // don't use mouse turning when in Isometric mode
      {
         Flt  max=DegToRad(900)*Tm.d(),
              dx =Ms.dir_ds.x*1.7,
              dy =Ms.dir_ds.y*1.7*Ms.inv();
         angle.x-=Mid(dx,-max,max);
         angle.y+=Mid(dy,-max,max);
      }

      // ready stance change
      ready^=Kb.bp(KB_R);
   }

   ctrl_pos=ctrl.actor.pos();

   return __super::update();
}

void Player::draw()
{
   Bool disable_head_draw=(View==VIEW_FPP && Renderer()!=RM_SHD_MAP && mesh); // disable drawing head when we're in FPP mode and we're not in shadowing mode (if this isn't included player will cast head-less shadows)

   if(disable_head_draw)mesh->hide("head"); // hide "head" mesh part in 'mesh'

   __super::draw(); // call default drawing

   if(disable_head_draw)mesh->show("head"); // un-hide "head" mesh part, so other objects which use the same mesh will have the head rendered properly
}

void Player::save(File &f)
{
   __super::save(f);
   f<<ctrl_pos;
}
Bool Player::load(File &f)
{
   if(__super::load(f))
   {
      f>>ctrl_pos;
      return true;
   }
   return false;
}
/******************************************************************************/
void InitPre()
{
   App.name("Camera Modes");
   App.flag=APP_MS_EXCLUSIVE|APP_FULL_TOGGLE;
   IOPath("../data");
   Paks.add("engine.pak");

   D.full(true).sync(true).ambPower(0.3).hpRt(true);
}
/******************************************************************************/
Bool Init()
{
   Physics.create();
   Sky    .set   ();
   Sun &sun=Suns.New(); sun.set(*Images("gfx/sky/sun.gfx")).light_color=1-D.ambColor(); sun.rays.mode=SUN_RAYS_HIGH;

   // create the world
   Game::World.init()
              .setObjType(Statics,OBJ_STATIC)
              .setObjType(Players,OBJ_PLAYER)
              .setObjItem(Items  ,OBJ_ITEM  )
              .New("world/sample.world");

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   Game::World.update(Cam.at);

   // set next camera mode when Tab pressed
   if(Kb.bp(KB_TAB))
   {
      View=(View+1)%VIEW_NUM;

      if(View==VIEW_ISO) // when set to isometric view
      {
         Cam.dist =   10; // set bigger camera distance at start
         Cam.pitch=-PI_4; // set starting camera pitch angle
      }
   }

   // setup the camera
   if(Players.elms()) // if we have at least one player
   {
      // set camera depending on current view mode
      switch(View)
      {
         case VIEW_FPP:
         {
            OrientP &head=Players[0].cskel.getPoint("head"); // obtain player "head" skeleton point (this was created in Mesh Editor)
            Cam.setPosDir(head.pos,head.dir,head.perp); // set camera from 'head' position, direction and perpendicular to direction
         }break;

         case VIEW_TPP:
         {
            Cam.dist=Max(1.0f,Cam.dist*ScaleFactor(Ms.wheel()*-0.1)); // update camera distance according to mouse wheel
            Cam.setSpherical(Players[0].ctrl_pos+Vec(0,0.5,0), Players[0].angle.x, Players[0].angle.y, 0, Cam.dist); // set spherical camera looking at player position with given player angles
         }break;

         default: // VIEW_ISO
         {
            Cam.yaw  -=Ms.ds.x; // update camera yaw   angle according to mouse smooth delta x
            Cam.pitch+=Ms.ds.y; // update camera pitch angle according to mouse smooth delta y
            Clamp(Cam.pitch,-PI_2,0); // clamp to possible camera pitch angle
            Cam.dist  =Max(1.0f,Cam.dist*ScaleFactor(Ms.wheel()*-0.1)); // update camera distance according to mouse wheel
            Cam.setSpherical(Players[0].pos(), Cam.yaw, Cam.pitch, 0, Cam.dist); // set spherical camera looking at player using camera angles
         }break;
      }

      // after setting camera position and angles:
      Cam.updateVelocities().set(); // update camera velocities and activate it
   }
   else // when no player on the scene
   {
      CamHandle(0.1,100,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT)); // default camera handling actions
   }

   return true;
}
/******************************************************************************/
void Render()
{
   Game::World.draw();
}
void Draw()
{
   Renderer(Render);
   D.text  (0,0.9,"Press Tab to switch camera modes");
}
/******************************************************************************/
And my animation but anim walk is make wrong you have to change, also obj file to add char to WE. Add this to chr in data->obj:
http://www.speedyshare.com/files/19468964/Test.rar
(This post was last modified: 11-25-2009 03:29 PM by Seba.)
11-25-2009 03:23 PM
Find all posts by this user Quote this message in a reply
gamecreator Offline
Member

Post: #13
RE: Unexpected tilt to character
Thank you both very much for your help. I understand the problem. Is there a way to import the Esenthel skeleton into Max?
11-25-2009 04:56 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #14
RE: Unexpected tilt to character
hello, unfortunately at the moment there is no way to export skeleton to max from EE
11-25-2009 05:11 PM
Find all posts by this user Quote this message in a reply
gamecreator Offline
Member

Post: #15
RE: Unexpected tilt to character
I finally had a chance to try Seba's code addition (just the first two, not the WE one). The character now stands correctly while you don't press anything but when you press W to move forward, it instantly tilts to the side again (but it shows the correct animation frame). Maybe Esenthel can support the standard 3DS Max biped in the future? For now, I think I'll have to make custom bones.

Maybe this could warrant having its own tutorial. I can't be the only one who's tried to export an animated mesh from 3DS Max to use his own character.
(This post was last modified: 11-28-2009 01:44 AM by gamecreator.)
11-28-2009 01:38 AM
Find all posts by this user Quote this message in a reply
Post Reply