2
Copyright (c) 2008-2009 NetAllied Systems GmbH
4
This file is part of COLLADAMax.
6
Portions of the code are:
7
Copyright (c) 2005-2007 Feeling Software Inc.
8
Copyright (c) 2005-2007 Sony Computer Entertainment America
10
Based on the 3dsMax COLLADASW Tools:
11
Copyright (c) 2005-2006 Autodesk Media Entertainment
13
Licensed under the MIT Open Source License,
14
for details please see LICENSE file or the website
15
http://www.opensource.org/licenses/mit-license.php
19
#include "COLLADAMaxStableHeaders.h"
20
#include "COLLADAMaxAnimationExporter.h"
22
#include "COLLADAMaxExtra.h"
30
const String Extra::TECHNIQUE_PROFILE_3DSMAX = "OpenCOLLADA3dsMax";
32
const String Extra::TECHNIQUE_PROFILE_OPENCOLLADA = "OpenCOLLADA";
34
const String Extra::USERDEFINED_PROPERTIES = "user_properties";
36
const String Extra::CAST_SHADOWS_PROPERTY = "cast_shadows";
37
const String Extra::RECEIVE_SHADOWS_PROPERTY = "receive_shadows";
38
const String Extra::PRIMARY_VISIBILITY_PROPERTY = "primary_visibility";
39
const String Extra::SECONDARY_VISIBILITY_PROPERTY = "secondary_visibility";
41
//---------------------------------------------------------------
42
Extra::Extra ( COLLADASW::StreamWriter * streamWriter, DocumentExporter * documentExporter )
44
mAnimationExporter(documentExporter->getAnimationExporter()),
45
mOptions(documentExporter->getOptions()),
50
//---------------------------------------------------------------
51
void Extra::addAnimatedExtraParameter(const String & parameterName, const String& childName, IParamBlock2* parameters, int parameterIndex, const String& baseId)
53
//check if the parameterIndex is a valid index for this param block
54
if ( parameters->IDtoIndex(parameterIndex) < 0 )
57
ParamType2 parameterType = parameters->GetParameterType(parameterIndex);
59
TimeValue animationStart = mOptions.getAnimationStart();
62
switch (parameterType)
65
mExtraTechnique->addExtraTechniqueChildParameter(Extra::TECHNIQUE_PROFILE_3DSMAX, childName, parameterName, parameters->GetInt(parameterIndex, animationStart)!= false);
66
// NO ANIMATION ON BOOLEANS
69
if ( AnimationExporter::isAnimated(parameters, parameterIndex) )
71
mExtraTechnique->addExtraTechniqueChildParameter(Extra::TECHNIQUE_PROFILE_3DSMAX, childName, parameterName, parameters->GetInt(parameterIndex, animationStart) , parameterName);
72
mAnimationExporter->addAnimatedParameter(parameters, parameterIndex, baseId, parameterName, 0);
76
mExtraTechnique->addExtraTechniqueChildParameter(Extra::TECHNIQUE_PROFILE_3DSMAX, childName, parameterName, parameters->GetInt(parameterIndex, animationStart));
80
if ( AnimationExporter::isAnimated(parameters, parameterIndex) )
82
mExtraTechnique->addExtraTechniqueChildParameter(Extra::TECHNIQUE_PROFILE_3DSMAX, childName, parameterName, parameters->GetFloat(parameterIndex, animationStart), parameterName);
83
mAnimationExporter->addAnimatedParameter(parameters, parameterIndex, baseId, parameterName, 0);
87
mExtraTechnique->addExtraTechniqueChildParameter(Extra::TECHNIQUE_PROFILE_3DSMAX, childName, parameterName, parameters->GetFloat(parameterIndex, animationStart));
96
//---------------------------------------------------------------
97
void Extra::addAnimatedExtraParameter(const String & parameterName, const String& childName, IParamBlock* parameters, int parameterIndex, const String& baseId)
99
if ( parameterIndex >= parameters->NumParams() )
102
ParamType parameterType = parameters->GetParameterType(parameterIndex);
104
TimeValue animationStart = mOptions.getAnimationStart();
106
// use the animation number with the GetController method
107
// since the parameters enumeration doesn't reflect the param
109
Control *controller = parameters->GetController(parameterIndex);
111
switch (parameterType)
114
mExtraTechnique->addExtraTechniqueChildParameter(Extra::TECHNIQUE_PROFILE_3DSMAX, childName, parameterName, parameters->GetInt(parameterIndex, animationStart)!= false);
115
// NO ANIMATION ON BOOLEANS
118
if ( AnimationExporter::isAnimated(parameters, parameterIndex) )
120
mExtraTechnique->addExtraTechniqueChildParameter(Extra::TECHNIQUE_PROFILE_3DSMAX, childName, parameterName, parameters->GetInt(parameterIndex, animationStart) , parameterName);
121
mAnimationExporter->addAnimatedParameter(parameters, parameterIndex, baseId, parameterName, 0);
125
mExtraTechnique->addExtraTechniqueChildParameter(Extra::TECHNIQUE_PROFILE_3DSMAX, childName, parameterName, parameters->GetInt(parameterIndex, animationStart));
129
if ( AnimationExporter::isAnimated(parameters, parameterIndex) )
131
mExtraTechnique->addExtraTechniqueChildParameter(Extra::TECHNIQUE_PROFILE_3DSMAX, childName, parameterName, parameters->GetFloat(parameterIndex, animationStart), parameterName);
132
mAnimationExporter->addAnimatedParameter(parameters, parameterIndex, baseId, parameterName, 0);
136
mExtraTechnique->addExtraTechniqueChildParameter(Extra::TECHNIQUE_PROFILE_3DSMAX, childName, parameterName, parameters->GetFloat(parameterIndex, animationStart));
146
//---------------------------------------------------------------
147
void Extra::addParamBlockAnimatedExtraParameters ( const String & elementName, const ExtraParameter extraParameters[], int extraParametersCount, IParamBlock * paramBlock, const String& baseId )
149
for ( int i = 0; i < extraParametersCount; ++i )
151
const ExtraParameter & parameter = extraParameters[ i ];
152
addAnimatedExtraParameter ( parameter.paramName, elementName, paramBlock, parameter.paramId, baseId );
156
//---------------------------------------------------------------
157
void Extra::addParamBlockAnimatedExtraParameters ( const String & elementName, const ExtraParameter extraParameters[], int extraParametersCount, IParamBlock2 * paramBlock, const String& baseId )
159
for ( int i = 0; i < extraParametersCount; ++i )
161
const ExtraParameter & parameter = extraParameters[ i ];
162
addAnimatedExtraParameter ( parameter.paramName, elementName, paramBlock, parameter.paramId, baseId );
166
void Extra::writeParameterBlockInfo( const String& fileName, IParamBlock* parameters )
171
fb.open ( fileName.c_str(), std::ios::app );
173
std::ostream os ( &fb );
176
int count = parameters->NumParams();
179
for (int i = 0; i<count; ++i)
181
ParamType type = parameters->GetParameterType(i);
189
os << "TYPE_BOOL " << parameters->GetInt ( i ) << " ";
193
os << "TYPE_FLOAT " << parameters->GetFloat ( i ) << " ";
197
os << "TYPE_INT " << parameters->GetInt ( i ) << " ";
200
Color color = parameters->GetColor(i);
201
os << "TYPE_RGBA " << color.r << " " << color.g << " " << color.b << " " ;
207
os << std::endl << std::endl;
214
void Extra::writeParameterBlockInfo( const String& fileName, IParamBlock2* parameters )
219
fb.open ( fileName.c_str(), std::ios::app );
221
std::ostream os ( &fb );
224
int count = parameters->NumParams();
227
for (int i = 0; i<count; ++i)
230
int parameterID = parameters->IndextoID(i);
232
ParamType2 type = parameters->GetParameterType(parameterID);
233
bool printName = true;
235
os << i << " " << parameterID << " ";
241
os << "TYPE_BOOL " << parameters->GetInt ( parameterID ) << " ";
245
os << "TYPE_FLOAT " << parameters->GetFloat ( parameterID ) << " ";
248
os << "TYPE_PCNT_FRAC " << parameters->GetFloat ( parameterID ) << " ";
252
os << "TYPE_INT " << parameters->GetInt ( parameterID ) << " ";
256
Color color = parameters->GetColor(i);
257
os << "TYPE_RGBA " << color.r << " " << color.g << " " << color.b << " " ;
262
Texmap* texmap = parameters->GetTexmap(i);
263
os << "TYPE_TEXMAP ";
265
os << texmap->GetName();
276
os << parameters->GetLocalName ( parameterID );
278
os << std::endl << std::endl;