Horde3D
http://horde3d.org/forums/

Animation
http://horde3d.org/forums/viewtopic.php?f=2&t=335
Page 1 of 1

Author:  roarflolo [ 16.05.2008, 18:05 ]
Post subject:  Animation

I have a rather large scene where a few objects have animation. I export using FCollada with sampled animation. The converted animation file is 25MB so I guess every node has animation stored even if the node doesn't actually move.

I changed the code in Converter::processNode to check the node actually animates and clear the frame vector if not. The anim file is then 70KB.

Code:
   // Animation (assume sampled data)
   DaeSampler *sampler = doc.libAnimations.findAnimForTarget( node.id, node.transMat.sid );
   
   std::vector< Matrix4f > frame_matrices;
   if( sampler != 0x0 && sampler->output->floatArray.size() == _frameCount * 16 )
   {
      // create all the matrices adn see if they actually animate
      for( unsigned int i = 0; i < _frameCount; ++i )
      {
         Matrix4f mat = animTransAccum[i] * makeMatrix4f( &sampler->output->floatArray[i * 16], doc.y_up );
         if( oNode != 0x0 )
         {
            frame_matrices.push_back( mat );
            animTransAccum[i] = Matrix4f();
         }
         else animTransAccum[i] = mat;
      }
   }
   else
   {
      for( unsigned int i = 0; i < _frameCount; ++i )
      {
         if( oNode != 0x0 )
         {
            frame_matrices.push_back( relMat );
            animTransAccum[i] = Matrix4f();
         }
         else animTransAccum[i] = relMat;
      }
      if( sampler != 0x0 && sampler->output->floatArray.size() != _frameCount * 16 )
         log( "Warning: Use animation sampling for export!" );
   }

   // see if the frame matrices are actually animating, if not, clear the frame matrix array
   if( frame_matrices.size()>0 )
   {
      bool is_animating = false;
      Matrix4f ref_tm = frame_matrices[0];
      for( size_t i=1; i<frame_matrices.size(); ++i )
      {
         if( memcmp(ref_tm.x,frame_matrices[i].x,sizeof(ref_tm.x))!=0 )
         {
            is_animating = true;
            break;
         }
      }
      if( !is_animating )
      {
         frame_matrices.clear();
      }
   }

   // copy the frame matrices to the node
   for( size_t i=0; i<frame_matrices.size(); ++i )
   {
      oNode->frames.push_back(frame_matrices[i]);
   }

   // Process children

Author:  DarkAngel [ 17.05.2008, 11:15 ]
Post subject:  Re: Animation

roarflolo wrote:
I have a rather large scene ... The converted animation file is 25MB ... I changed the code in Converter::processNode ... [now] The anim file is then 70KB.

:shock: Nice find!

AFAIK, so far the focus of the Horde project so far has been on adding all of the required features. Now that v1.0 is almost final, hopefully we should see a few more optimisations like this :)

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/