Problem involving LEXIexporter& Generic Pose Loader

Problems building or running the engine, queries about how to use features etc.
Post Reply
Yanko
Kobold
Posts: 32
Joined: Thu Apr 26, 2007 7:13 pm

Problem involving LEXIexporter& Generic Pose Loader

Post by Yanko »

So, hey there, my first help request, and it involves 2 things that have their own topics :oops:

but anyway, i didn't post in any of them because i don't really know who to blame.

It works like this, me and another dude are working for this university project that involves emoting heads controlled by fuzzy state machines. We're currently just testing some stuff around Ogre, using the Example Framework.

So, we hacked together a quick code that uses a slightly modified version of the http://www.ogre3d.org/wiki/index.php/Ge ... se_Loading .

Problem is, currently, on our first test, we used facial.mesh (Dr Bunsen), and it worked just fine. When we try to use our own head, it crashes on loading.

here's our load code:

Code: Select all

void loadHead(std::string meshFile){
     // const char  *poseAnimationStateName = "PoseAnimationState";
      //try{
         // Pre-load the mesh so that we can tweak it with a manual animation
         mesh = MeshManager::getSingleton().load(meshFile, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
         //we'll read through this list while loading
         PoseList poseList = mesh->getPoseList();
         //used to loop through each submesh
         //int numSubMeshes = mesh->getNumSubMeshes();
         //int curPoseIndex = 0;
         //create the animation on the mesh
         Animation* anim = mesh->createAnimation(poseAnimationStateName, 0);
         //skip submesh 0 since it is the shared geometry, and we have no poses on that
         //for(int curSubMesh = 1; curSubMesh <= numSubMeshes; curSubMesh++){
            //create the VertexTrack on this animation
           // Ogre::VertexAnimationTrack *vt = anim->createVertexTrack(curSubMesh, VAT_POSE);
           Ogre::VertexAnimationTrack *vt = anim->createVertexTrack(4, VAT_POSE);
            //create the keyframe we will use to update this vertex track
            //keep all our keyframes in a map for later updating
            //vertexPoseKeyFrameMap[curSubMesh] = vt->createVertexPoseKeyFrame(0);
            vertexPoseKeyFrameMap = vt->createVertexPoseKeyFrame(0);
            //add the references to each pose that applies to this subMesh
            //while(poseList[curPoseIndex]->getTarget() == curSubMesh-1){
               //create a pose reference for each pose
               //vertexPoseKeyFrameMap[curSubMesh]->addPoseReference(curPoseIndex, 0.0f);
              for (int i = 0; i < 3; ++i)
                {
                vertexPoseKeyFrameMap->addPoseReference(i, 0.0f);
                }

               // curPoseIndex++;
            //}
         //}
         //create the head
         head = mSceneMgr->createEntity("Head", meshFile);
         //head->getAnimationState(poseAnimationStateName)->setTimePosition(0);
         //head->getAnimationState(poseAnimationStateName)->setEnabled(true);
         //put entity in scene
         /*SceneNode* */ headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
         headNode->attachObject(head);
    /*  }
      catch(runtime_error err){
         std::string error = "ERROR: ";
         error.append(__FILE__);
         error.append(err.what());
         LogManager::getSingleton().logMessage(error);
      }
      */
   }
notice there are a lot of commented lines, i just left them because maybe someone could spot something that we're doing wrong.


the error is on

Code: Select all

mesh = MeshManager::getSingleton().load(meshFile, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

Here's a cleaner version of the code (removing the commented lines):

Code: Select all

void loadHead(std::string meshFile){

         mesh = MeshManager::getSingleton().load(meshFile, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

         PoseList poseList = mesh->getPoseList();

         Animation* anim = mesh->createAnimation(poseAnimationStateName, 0);
         Ogre::VertexAnimationTrack *vt = anim->createVertexTrack(4, VAT_POSE);
         vertexPoseKeyFrameMap = vt->createVertexPoseKeyFrame(0);
         for (int i = 0; i < 3; ++i)
         {
             vertexPoseKeyFrameMap->addPoseReference(i, 0.0f);
         }

         head = mSceneMgr->createEntity("Head", meshFile);
         headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
         headNode->attachObject(head);

   }
i think i should also point out some global vars we're using (when i said quickly hacked together, i mean it :lol: )

Code: Select all

   Ogre::Entity* head;
   Ogre::MeshPtr mesh;
   SceneNode* headNode;
   Ogre::VertexPoseKeyFrame* vertexPoseKeyFrameMap;
   const char  *poseAnimationStateName = "PoseAnimationState";
   float k=0.0;
I don't really know if it's a problem on the CODE itself, or if i screwed something up while exporting on LEXI. I'm using Max8, and the version that was on Ogre's page till 2 days ago (aparently they just released a new one that has max 9 support)

so, i know it's a lot of information, but... any thoughts?
Last edited by Yanko on Fri Jun 29, 2007 6:42 pm, edited 1 time in total.
Yanko
Kobold
Posts: 32
Joined: Thu Apr 26, 2007 7:13 pm

Post by Yanko »

btw

here is a pack with what was exported by LEXI

http://download.yousendit.com/DE73E5AB05E3A9D8
Yanko
Kobold
Posts: 32
Joined: Thu Apr 26, 2007 7:13 pm

Post by Yanko »

i really really hate to do this, but unfortunately we´re totally stuck here =/
and since it´s gone to the 2nd page...


sorry :oops:
*bump*
Sethos
Goblin
Posts: 212
Joined: Mon Nov 14, 2005 9:00 am
Location: Copenhagen, Denmark
x 1

Post by Sethos »

This isn't a LEXIExporter problem. It's your pose loader that really isn't generic at all:

Code: Select all

Ogre::VertexAnimationTrack *vt = anim->createVertexTrack(4, VAT_POSE); 
All your vertex tracks are targeted submesh 4! This will work for facial.mesh, since submesh 4 is the head. But for any other mesh you cannot be sure! You should take a closer look at the generic loader, which targets the vertex tracks to the current submesh.

Alternatively, you can open your custom mesh in LEXIViewer and see what index the submesh you want to target has.

Hope it helps you.
Yanko
Kobold
Posts: 32
Joined: Thu Apr 26, 2007 7:13 pm

Post by Yanko »

Man, thanks a lot =D
Impressively, we figured that out just before the reply, but thanks still =)

The other programmer actually re-did part of the code so it wouldn´t be so generic, and we eventually missed that part. Now that part is sorted out, but thanks a lot anyway man!

I wont put it as [SOLVED] cause we might just get some problems in that part of the coding still, so if we get it fixed, i promise the mods i´ll put it there =)

If any of the mods wants to put it as solved already just to sort out stuff, feel free to do so, though.
Post Reply