Horde3D

Next-Generation Graphics Engine
It is currently 30.11.2024, 11:33

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Animation
PostPosted: 16.05.2008, 18:05 
Offline

Joined: 15.05.2008, 05:32
Posts: 46
Location: California
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Animation
PostPosted: 17.05.2008, 11:15 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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 :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group