Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

c:/home/kevn/src/animaniac/ani/KeyFrame/io/KeyFramerExporter.h

Go to the documentation of this file.
00001 
00002 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00003  *
00004  * Animaniac is (C) Copyright 2000,2001 Kevin Meinert
00005  *
00006  * Original Authors:
00007  *   Kevin Meinert
00008  *
00009  *
00010  *
00011  * This library is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Library General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2 of the License, or (at your option) any later version.
00015  *
00016  * This library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Library General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Library General Public
00022  * License along with this library; if not, write to the
00023  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00024  * Boston, MA 02111-1307, USA.
00025  *
00026  * -----------------------------------------------------------------
00027  * File:          $RCSfile: KeyFramerExporter.h,v $
00028  * Date modified: $Date: 2002/05/06 05:21:57 $
00029  * Version:       $Revision: 1.6 $
00030  * -----------------------------------------------------------------
00031  *
00032  *************** <auto-copyright.pl END do not edit this line> ***************/
00033 
00034 #include <fstream>            // for ifstream
00035 #include "ani/KeyFrame/PosQuatKey.h"
00036 #include "ani/KeyFrame/KeyFramer.h"
00037 #include "gmtl/Math.h"
00038 
00039 namespace ani
00040 {
00041    class KeyFramerExporter
00042    {
00043    public:
00044       KeyFramerExporter()
00045       {
00046       }
00047    
00048       void execute( const char* const filename, const ani::KeyFramer<PosQuatKey>& kf )
00049       {
00050          std::ofstream frames_file( filename );
00051 
00052          if (!frames_file.good())
00053          {
00054             std::cout << "WARNING: "
00055                            << clrRESET
00056                            << "couldn't open keyframe file: " 
00057                            << filename <<"\n"
00058                            << std::flush;
00059             return;
00060          }
00061          
00062          std::cout << "Writing keyframe(s) to file: "
00063                 << filename << "\n" << std::flush;
00064          
00065          std::map<float, PosQuatKey >::const_iterator it1 = kf.keys().begin();
00066          for (; it1 != kf.keys().end(); ++it1)
00067          {
00068             const PosQuatKey& key = (*it1).second;
00069             const float& time = key.time();
00070             const gmtl::Vec3f& pos = key.position();
00071             const gmtl::Quatf& quat = key.rotation();
00072             float deg;
00073             gmtl::Vec3f vec;
00074             quat.getRot( deg, vec[0], vec[1], vec[2] );
00075             deg = gmtl::Math::rad2Deg( deg ); 
00076             frames_file<<time<<" "<<pos[0]<<" "<<pos[1]<<" "
00077                        <<pos[2]<<" "<<deg<<" "<<vec[0]<<" "
00078                        <<vec[1]<<" "<<vec[2]<<"\n";
00079          }
00080          frames_file.close();
00081       }   
00082    };
00083 };

Generated on Wed Jun 12 01:54:02 2002 for Animaniac by doxygen1.2.15