1
1
forked from 0ad/0ad
0ad/source/dcdt/se/sr_sa_model_export.cpp
janwas 5bf9bca9ef fix/disable warnings.
there are too many W4 and "potentially uninitialized", so those are
disabled by 0ad_warning_disable.h.

the silly "int x = strlen" and very dangerous "int x = (void*)p" (and
vice versa) problems are fixed.

This was SVN commit r5526.
2007-12-23 12:18:57 +00:00

67 lines
1.6 KiB
C++

#include "precompiled.h"
#include "0ad_warning_disable.h"
# include "sr_sa_model_export.h"
# include "sr_model.h"
# include "sr_sn_shape.h"
//# define SR_USE_TRACE1 // Const / Dest
//# define SR_USE_TRACE2 //
# include "sr_trace.h"
//=============================== SrSaModelExport ====================================
SrSaModelExport::SrSaModelExport ( const SrString& dir )
{
SR_TRACE1 ( "Constructor" );
directory ( dir );
_num = 0;
_prefix = "model";
}
SrSaModelExport::~SrSaModelExport ()
{
SR_TRACE1 ( "Destructor" );
}
void SrSaModelExport::directory ( const SrString& dir )
{
_dir = dir;
char c = _dir.last_char();
if ( c==0 || c=='/' || c=='\\' ) return;
_dir << '/';
}
bool SrSaModelExport::apply ( SrSn* n )
{
_num = 0;
bool result = SrSa::apply ( n );
return result;
}
//==================================== virtuals ====================================
bool SrSaModelExport::shape_apply ( SrSnShapeBase* s )
{
if ( sr_compare(s->inst_class_name(),"model")!=0 ) return true;
if ( !s->visible() ) return true;
SrMat mat;
get_top_matrix ( mat );
SrModel model;
model = ((SrSnModel*)s)->shape();
model.apply_transformation ( mat );
SrString fname;
fname.setf ( "%s%s%04d.srm", (const char*)_dir,(const char*)_prefix, _num++ );
SrOutput out ( fopen(fname,"wt") );
if ( !out.valid() ) return false;
model.save ( out );
return true;
}
//======================================= EOF ====================================