Adding double precision import support for formats that can be exported
parent
fa1d6d8c55
commit
05a6ee6473
|
@ -149,7 +149,7 @@ void ColladaExporter::WriteFile()
|
||||||
// Writes the asset header
|
// Writes the asset header
|
||||||
void ColladaExporter::WriteHeader()
|
void ColladaExporter::WriteHeader()
|
||||||
{
|
{
|
||||||
static const float epsilon = 0.00001f;
|
static const ai_real epsilon = 0.00001;
|
||||||
static const aiQuaternion x_rot(aiMatrix3x3(
|
static const aiQuaternion x_rot(aiMatrix3x3(
|
||||||
0, -1, 0,
|
0, -1, 0,
|
||||||
1, 0, 0,
|
1, 0, 0,
|
||||||
|
@ -176,9 +176,9 @@ void ColladaExporter::WriteHeader()
|
||||||
|
|
||||||
bool add_root_node = false;
|
bool add_root_node = false;
|
||||||
|
|
||||||
float scale = 1.0;
|
ai_real scale = 1.0;
|
||||||
if(std::abs(scaling.x - scaling.y) <= epsilon && std::abs(scaling.x - scaling.z) <= epsilon && std::abs(scaling.y - scaling.z) <= epsilon) {
|
if(std::abs(scaling.x - scaling.y) <= epsilon && std::abs(scaling.x - scaling.z) <= epsilon && std::abs(scaling.y - scaling.z) <= epsilon) {
|
||||||
scale = (float) ((((double) scaling.x) + ((double) scaling.y) + ((double) scaling.z)) / 3.0);
|
scale = (ai_real) ((((double) scaling.x) + ((double) scaling.y) + ((double) scaling.z)) / 3.0);
|
||||||
} else {
|
} else {
|
||||||
add_root_node = true;
|
add_root_node = true;
|
||||||
}
|
}
|
||||||
|
@ -450,7 +450,7 @@ void ColladaExporter::WriteSpotLight(const aiLight *const light){
|
||||||
srcLight->mFalloffAngle);
|
srcLight->mFalloffAngle);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const float fallOffAngle = AI_RAD_TO_DEG(light->mAngleInnerCone);
|
const ai_real fallOffAngle = AI_RAD_TO_DEG(light->mAngleInnerCone);
|
||||||
mOutput << startstr <<"<falloff_angle sid=\"fall_off_angle\">"
|
mOutput << startstr <<"<falloff_angle sid=\"fall_off_angle\">"
|
||||||
<< fallOffAngle
|
<< fallOffAngle
|
||||||
<<"</falloff_angle>" << endstr;
|
<<"</falloff_angle>" << endstr;
|
||||||
|
@ -803,10 +803,10 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||||
PushTag();
|
PushTag();
|
||||||
|
|
||||||
// Positions
|
// Positions
|
||||||
WriteFloatArray( idstr + "-positions", FloatType_Vector, (float*) mesh->mVertices, mesh->mNumVertices);
|
WriteFloatArray( idstr + "-positions", FloatType_Vector, (ai_real*) mesh->mVertices, mesh->mNumVertices);
|
||||||
// Normals, if any
|
// Normals, if any
|
||||||
if( mesh->HasNormals() )
|
if( mesh->HasNormals() )
|
||||||
WriteFloatArray( idstr + "-normals", FloatType_Vector, (float*) mesh->mNormals, mesh->mNumVertices);
|
WriteFloatArray( idstr + "-normals", FloatType_Vector, (ai_real*) mesh->mNormals, mesh->mNumVertices);
|
||||||
|
|
||||||
// texture coords
|
// texture coords
|
||||||
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a)
|
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a)
|
||||||
|
@ -814,7 +814,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||||
if( mesh->HasTextureCoords( a) )
|
if( mesh->HasTextureCoords( a) )
|
||||||
{
|
{
|
||||||
WriteFloatArray( idstr + "-tex" + std::to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2,
|
WriteFloatArray( idstr + "-tex" + std::to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2,
|
||||||
(float*) mesh->mTextureCoords[a], mesh->mNumVertices);
|
(ai_real*) mesh->mTextureCoords[a], mesh->mNumVertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,7 +822,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||||
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a)
|
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a)
|
||||||
{
|
{
|
||||||
if( mesh->HasVertexColors( a) )
|
if( mesh->HasVertexColors( a) )
|
||||||
WriteFloatArray( idstr + "-color" + std::to_string(a), FloatType_Color, (float*) mesh->mColors[a], mesh->mNumVertices);
|
WriteFloatArray( idstr + "-color" + std::to_string(a), FloatType_Color, (ai_real*) mesh->mColors[a], mesh->mNumVertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
// assemble vertex structure
|
// assemble vertex structure
|
||||||
|
@ -917,7 +917,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Writes a float array of the given type
|
// Writes a float array of the given type
|
||||||
void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataType pType, const float* pData, size_t pElementCount)
|
void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataType pType, const ai_real* pData, size_t pElementCount)
|
||||||
{
|
{
|
||||||
size_t floatsPerElement = 0;
|
size_t floatsPerElement = 0;
|
||||||
switch( pType )
|
switch( pType )
|
||||||
|
|
|
@ -108,7 +108,7 @@ protected:
|
||||||
enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color };
|
enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color };
|
||||||
|
|
||||||
/// Writes a float array of the given type
|
/// Writes a float array of the given type
|
||||||
void WriteFloatArray( const std::string& pIdString, FloatDataType pType, const float* pData, size_t pElementCount);
|
void WriteFloatArray( const std::string& pIdString, FloatDataType pType, const ai_real* pData, size_t pElementCount);
|
||||||
|
|
||||||
/// Writes the scene library
|
/// Writes the scene library
|
||||||
void WriteSceneLibrary();
|
void WriteSceneLibrary();
|
||||||
|
@ -160,10 +160,10 @@ protected:
|
||||||
struct Property
|
struct Property
|
||||||
{
|
{
|
||||||
bool exist;
|
bool exist;
|
||||||
float value;
|
ai_real value;
|
||||||
Property()
|
Property()
|
||||||
: exist(false)
|
: exist(false)
|
||||||
, value(0.0f)
|
, value(0.0)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ struct Transform
|
||||||
{
|
{
|
||||||
std::string mID; ///< SID of the transform step, by which anim channels address their target node
|
std::string mID; ///< SID of the transform step, by which anim channels address their target node
|
||||||
TransformType mType;
|
TransformType mType;
|
||||||
float f[16]; ///< Interpretation of data depends on the type of the transformation
|
ai_real f[16]; ///< Interpretation of data depends on the type of the transformation
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A collada camera. */
|
/** A collada camera. */
|
||||||
|
@ -116,16 +116,16 @@ struct Camera
|
||||||
bool mOrtho;
|
bool mOrtho;
|
||||||
|
|
||||||
//! Horizontal field of view in degrees
|
//! Horizontal field of view in degrees
|
||||||
float mHorFov;
|
ai_real mHorFov;
|
||||||
|
|
||||||
//! Vertical field of view in degrees
|
//! Vertical field of view in degrees
|
||||||
float mVerFov;
|
ai_real mVerFov;
|
||||||
|
|
||||||
//! Screen aspect
|
//! Screen aspect
|
||||||
float mAspect;
|
ai_real mAspect;
|
||||||
|
|
||||||
//! Near& far z
|
//! Near& far z
|
||||||
float mZNear, mZFar;
|
ai_real mZNear, mZFar;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET 1e9f
|
#define ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET 1e9f
|
||||||
|
@ -152,21 +152,21 @@ struct Light
|
||||||
aiColor3D mColor;
|
aiColor3D mColor;
|
||||||
|
|
||||||
//! Light attenuation
|
//! Light attenuation
|
||||||
float mAttConstant,mAttLinear,mAttQuadratic;
|
ai_real mAttConstant,mAttLinear,mAttQuadratic;
|
||||||
|
|
||||||
//! Spot light falloff
|
//! Spot light falloff
|
||||||
float mFalloffAngle;
|
ai_real mFalloffAngle;
|
||||||
float mFalloffExponent;
|
ai_real mFalloffExponent;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// FCOLLADA extension from here
|
// FCOLLADA extension from here
|
||||||
|
|
||||||
//! ... related stuff from maja and max extensions
|
//! ... related stuff from maja and max extensions
|
||||||
float mPenumbraAngle;
|
ai_real mPenumbraAngle;
|
||||||
float mOuterAngle;
|
ai_real mOuterAngle;
|
||||||
|
|
||||||
//! Common light intensity
|
//! Common light intensity
|
||||||
float mIntensity;
|
ai_real mIntensity;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Short vertex index description */
|
/** Short vertex index description */
|
||||||
|
@ -275,7 +275,7 @@ struct Node
|
||||||
struct Data
|
struct Data
|
||||||
{
|
{
|
||||||
bool mIsStringArray;
|
bool mIsStringArray;
|
||||||
std::vector<float> mValues;
|
std::vector<ai_real> mValues;
|
||||||
std::vector<std::string> mStrings;
|
std::vector<std::string> mStrings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ struct Controller
|
||||||
std::string mJointNameSource;
|
std::string mJointNameSource;
|
||||||
|
|
||||||
///< The bind shape matrix, as array of floats. I'm not sure what this matrix actually describes, but it can't be ignored in all cases
|
///< The bind shape matrix, as array of floats. I'm not sure what this matrix actually describes, but it can't be ignored in all cases
|
||||||
float mBindShapeMatrix[16];
|
ai_real mBindShapeMatrix[16];
|
||||||
|
|
||||||
// accessor URL of the joint inverse bind matrices
|
// accessor URL of the joint inverse bind matrices
|
||||||
std::string mJointOffsetMatrixSource;
|
std::string mJointOffsetMatrixSource;
|
||||||
|
@ -490,11 +490,11 @@ struct Sampler
|
||||||
|
|
||||||
/** Weighting factor
|
/** Weighting factor
|
||||||
*/
|
*/
|
||||||
float mWeighting;
|
ai_real mWeighting;
|
||||||
|
|
||||||
/** Mixing factor from OKINO
|
/** Mixing factor from OKINO
|
||||||
*/
|
*/
|
||||||
float mMixWithPrevious;
|
ai_real mMixWithPrevious;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A collada effect. Can contain about anything according to the Collada spec,
|
/** A collada effect. Can contain about anything according to the Collada spec,
|
||||||
|
@ -513,8 +513,8 @@ struct Effect
|
||||||
mTexTransparent, mTexBump, mTexReflective;
|
mTexTransparent, mTexBump, mTexReflective;
|
||||||
|
|
||||||
// Scalar factory
|
// Scalar factory
|
||||||
float mShininess, mRefractIndex, mReflectivity;
|
ai_real mShininess, mRefractIndex, mReflectivity;
|
||||||
float mTransparency;
|
ai_real mTransparency;
|
||||||
bool mHasTransparency;
|
bool mHasTransparency;
|
||||||
bool mRGBTransparency;
|
bool mRGBTransparency;
|
||||||
bool mInvertTransparency;
|
bool mInvertTransparency;
|
||||||
|
|
|
@ -704,7 +704,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
|
||||||
size_t jointIndex = iit->first;
|
size_t jointIndex = iit->first;
|
||||||
size_t vertexIndex = iit->second;
|
size_t vertexIndex = iit->second;
|
||||||
|
|
||||||
float weight = ReadFloat( weightsAcc, weights, vertexIndex, 0);
|
ai_real weight = ReadFloat( weightsAcc, weights, vertexIndex, 0);
|
||||||
|
|
||||||
// one day I gonna kill that XSI Collada exporter
|
// one day I gonna kill that XSI Collada exporter
|
||||||
if( weight > 0.0f)
|
if( weight > 0.0f)
|
||||||
|
@ -1071,7 +1071,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// resolve the data pointers for all anim channels. Find the minimum time while we're at it
|
// resolve the data pointers for all anim channels. Find the minimum time while we're at it
|
||||||
float startTime = 1e20f, endTime = -1e20f;
|
ai_real startTime = 1e20, endTime = -1e20;
|
||||||
for( std::vector<Collada::ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
for( std::vector<Collada::ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
||||||
{
|
{
|
||||||
Collada::ChannelEntry& e = *it;
|
Collada::ChannelEntry& e = *it;
|
||||||
|
@ -1100,7 +1100,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
|
|
||||||
// now for every unique point in time, find or interpolate the key values for that time
|
// now for every unique point in time, find or interpolate the key values for that time
|
||||||
// and apply them to the transform chain. Then the node's present transformation can be calculated.
|
// and apply them to the transform chain. Then the node's present transformation can be calculated.
|
||||||
float time = startTime;
|
ai_real time = startTime;
|
||||||
while( 1)
|
while( 1)
|
||||||
{
|
{
|
||||||
for( std::vector<Collada::ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
for( std::vector<Collada::ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
||||||
|
@ -1109,7 +1109,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
|
|
||||||
// find the keyframe behind the current point in time
|
// find the keyframe behind the current point in time
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
float postTime = 0.f;
|
ai_real postTime = 0.0;
|
||||||
while( 1)
|
while( 1)
|
||||||
{
|
{
|
||||||
if( pos >= e.mTimeAccessor->mCount)
|
if( pos >= e.mTimeAccessor->mCount)
|
||||||
|
@ -1123,19 +1123,19 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
pos = std::min( pos, e.mTimeAccessor->mCount-1);
|
pos = std::min( pos, e.mTimeAccessor->mCount-1);
|
||||||
|
|
||||||
// read values from there
|
// read values from there
|
||||||
float temp[16];
|
ai_real temp[16];
|
||||||
for( size_t c = 0; c < e.mValueAccessor->mSize; ++c)
|
for( size_t c = 0; c < e.mValueAccessor->mSize; ++c)
|
||||||
temp[c] = ReadFloat( *e.mValueAccessor, *e.mValueData, pos, c);
|
temp[c] = ReadFloat( *e.mValueAccessor, *e.mValueData, pos, c);
|
||||||
|
|
||||||
// if not exactly at the key time, interpolate with previous value set
|
// if not exactly at the key time, interpolate with previous value set
|
||||||
if( postTime > time && pos > 0)
|
if( postTime > time && pos > 0)
|
||||||
{
|
{
|
||||||
float preTime = ReadFloat( *e.mTimeAccessor, *e.mTimeData, pos-1, 0);
|
ai_real preTime = ReadFloat( *e.mTimeAccessor, *e.mTimeData, pos-1, 0);
|
||||||
float factor = (time - postTime) / (preTime - postTime);
|
ai_real factor = (time - postTime) / (preTime - postTime);
|
||||||
|
|
||||||
for( size_t c = 0; c < e.mValueAccessor->mSize; ++c)
|
for( size_t c = 0; c < e.mValueAccessor->mSize; ++c)
|
||||||
{
|
{
|
||||||
float v = ReadFloat( *e.mValueAccessor, *e.mValueData, pos-1, c);
|
ai_real v = ReadFloat( *e.mValueAccessor, *e.mValueData, pos-1, c);
|
||||||
temp[c] += (v - temp[c]) * factor;
|
temp[c] += (v - temp[c]) * factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1152,7 +1152,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
resultTrafos.push_back( mat);
|
resultTrafos.push_back( mat);
|
||||||
|
|
||||||
// find next point in time to evaluate. That's the closest frame larger than the current in any channel
|
// find next point in time to evaluate. That's the closest frame larger than the current in any channel
|
||||||
float nextTime = 1e20f;
|
ai_real nextTime = 1e20;
|
||||||
for( std::vector<Collada::ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
for( std::vector<Collada::ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
||||||
{
|
{
|
||||||
Collada::ChannelEntry& channelElement = *it;
|
Collada::ChannelEntry& channelElement = *it;
|
||||||
|
@ -1161,7 +1161,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
while( pos < channelElement.mTimeAccessor->mCount)
|
while( pos < channelElement.mTimeAccessor->mCount)
|
||||||
{
|
{
|
||||||
const float t = ReadFloat( *channelElement.mTimeAccessor, *channelElement.mTimeData, pos, 0);
|
const ai_real t = ReadFloat( *channelElement.mTimeAccessor, *channelElement.mTimeData, pos, 0);
|
||||||
if( t > time)
|
if( t > time)
|
||||||
{
|
{
|
||||||
nextTime = std::min( nextTime, t);
|
nextTime = std::min( nextTime, t);
|
||||||
|
@ -1174,16 +1174,16 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
// Sub-sample axis-angle channels if the delta between two consecutive
|
// Sub-sample axis-angle channels if the delta between two consecutive
|
||||||
// key-frame angles is >= 180 degrees.
|
// key-frame angles is >= 180 degrees.
|
||||||
if (transforms[channelElement.mTransformIndex].mType == Collada::TF_ROTATE && channelElement.mSubElement == 3 && pos > 0 && pos < channelElement.mTimeAccessor->mCount) {
|
if (transforms[channelElement.mTransformIndex].mType == Collada::TF_ROTATE && channelElement.mSubElement == 3 && pos > 0 && pos < channelElement.mTimeAccessor->mCount) {
|
||||||
const float cur_key_angle = ReadFloat(*channelElement.mValueAccessor, *channelElement.mValueData, pos, 0);
|
const ai_real cur_key_angle = ReadFloat(*channelElement.mValueAccessor, *channelElement.mValueData, pos, 0);
|
||||||
const float last_key_angle = ReadFloat(*channelElement.mValueAccessor, *channelElement.mValueData, pos - 1, 0);
|
const ai_real last_key_angle = ReadFloat(*channelElement.mValueAccessor, *channelElement.mValueData, pos - 1, 0);
|
||||||
const float cur_key_time = ReadFloat(*channelElement.mTimeAccessor, *channelElement.mTimeData, pos, 0);
|
const ai_real cur_key_time = ReadFloat(*channelElement.mTimeAccessor, *channelElement.mTimeData, pos, 0);
|
||||||
const float last_key_time = ReadFloat(*channelElement.mTimeAccessor, *channelElement.mTimeData, pos - 1, 0);
|
const ai_real last_key_time = ReadFloat(*channelElement.mTimeAccessor, *channelElement.mTimeData, pos - 1, 0);
|
||||||
const float last_eval_angle = last_key_angle + (cur_key_angle - last_key_angle) * (time - last_key_time) / (cur_key_time - last_key_time);
|
const ai_real last_eval_angle = last_key_angle + (cur_key_angle - last_key_angle) * (time - last_key_time) / (cur_key_time - last_key_time);
|
||||||
const float delta = std::fabs(cur_key_angle - last_eval_angle);
|
const ai_real delta = std::abs(cur_key_angle - last_eval_angle);
|
||||||
if (delta >= 180.0f) {
|
if (delta >= 180.0) {
|
||||||
const int subSampleCount = static_cast<int>(floorf(delta / 90.0f));
|
const int subSampleCount = static_cast<int>(floorf(delta / 90.0));
|
||||||
if (cur_key_time != time) {
|
if (cur_key_time != time) {
|
||||||
const float nextSampleTime = time + (cur_key_time - time) / subSampleCount;
|
const ai_real nextSampleTime = time + (cur_key_time - time) / subSampleCount;
|
||||||
nextTime = std::min(nextTime, nextSampleTime);
|
nextTime = std::min(nextTime, nextSampleTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1289,7 +1289,7 @@ void ColladaLoader::AddTexture ( aiMaterial& mat, const ColladaParser& pParser,
|
||||||
_AI_MATKEY_TEXBLEND_BASE, type, idx);
|
_AI_MATKEY_TEXBLEND_BASE, type, idx);
|
||||||
|
|
||||||
// Blend factor
|
// Blend factor
|
||||||
mat.AddProperty((float*)&sampler.mWeighting , 1,
|
mat.AddProperty((ai_real*)&sampler.mWeighting , 1,
|
||||||
_AI_MATKEY_TEXBLEND_BASE, type, idx);
|
_AI_MATKEY_TEXBLEND_BASE, type, idx);
|
||||||
|
|
||||||
// UV source index ... if we didn't resolve the mapping, it is actually just
|
// UV source index ... if we didn't resolve the mapping, it is actually just
|
||||||
|
@ -1464,11 +1464,11 @@ void ColladaLoader::BuildMaterials( ColladaParser& pParser, aiScene* /*pScene*/)
|
||||||
|
|
||||||
const int shadeMode = aiShadingMode_Phong;
|
const int shadeMode = aiShadingMode_Phong;
|
||||||
mat->AddProperty<int>( &shadeMode, 1, AI_MATKEY_SHADING_MODEL);
|
mat->AddProperty<int>( &shadeMode, 1, AI_MATKEY_SHADING_MODEL);
|
||||||
aiColor4D colAmbient( 0.2f, 0.2f, 0.2f, 1.0f), colDiffuse( 0.8f, 0.8f, 0.8f, 1.0f), colSpecular( 0.5f, 0.5f, 0.5f, 0.5f);
|
aiColor4D colAmbient( 0.2, 0.2, 0.2, 1.0), colDiffuse( 0.8, 0.8, 0.8, 1.0), colSpecular( 0.5, 0.5, 0.5, 0.5);
|
||||||
mat->AddProperty( &colAmbient, 1, AI_MATKEY_COLOR_AMBIENT);
|
mat->AddProperty( &colAmbient, 1, AI_MATKEY_COLOR_AMBIENT);
|
||||||
mat->AddProperty( &colDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
|
mat->AddProperty( &colDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||||
mat->AddProperty( &colSpecular, 1, AI_MATKEY_COLOR_SPECULAR);
|
mat->AddProperty( &colSpecular, 1, AI_MATKEY_COLOR_SPECULAR);
|
||||||
const float specExp = 5.0f;
|
const ai_real specExp = 5.0;
|
||||||
mat->AddProperty( &specExp, 1, AI_MATKEY_SHININESS);
|
mat->AddProperty( &specExp, 1, AI_MATKEY_SHININESS);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1587,7 +1587,7 @@ void ColladaLoader::ConvertPath (aiString& ss)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Reads a float value from an accessor and its data array.
|
// Reads a float value from an accessor and its data array.
|
||||||
float ColladaLoader::ReadFloat( const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const
|
ai_real ColladaLoader::ReadFloat( const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const
|
||||||
{
|
{
|
||||||
// FIXME: (thom) Test for data type here in every access? For the moment, I leave this to the caller
|
// FIXME: (thom) Test for data type here in every access? For the moment, I leave this to the caller
|
||||||
size_t pos = pAccessor.mStride * pIndex + pAccessor.mOffset + pOffset;
|
size_t pos = pAccessor.mStride * pIndex + pAccessor.mOffset + pOffset;
|
||||||
|
|
|
@ -190,7 +190,7 @@ protected:
|
||||||
* @param pOffset Offset into the element, for multipart elements such as vectors or matrices
|
* @param pOffset Offset into the element, for multipart elements such as vectors or matrices
|
||||||
* @return the specified value
|
* @return the specified value
|
||||||
*/
|
*/
|
||||||
float ReadFloat( const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const;
|
ai_real ReadFloat( const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const;
|
||||||
|
|
||||||
/** Reads a string value from an accessor and its data array.
|
/** Reads a string value from an accessor and its data array.
|
||||||
* @param pAccessor The accessor to use for reading
|
* @param pAccessor The accessor to use for reading
|
||||||
|
|
|
@ -128,7 +128,7 @@ bool ColladaParser::ReadBoolFromTextContent()
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Read float from text contents of current element
|
// Read float from text contents of current element
|
||||||
float ColladaParser::ReadFloatFromTextContent()
|
ai_real ColladaParser::ReadFloatFromTextContent()
|
||||||
{
|
{
|
||||||
const char* cur = GetTextContent();
|
const char* cur = GetTextContent();
|
||||||
return fast_atof(cur);
|
return fast_atof(cur);
|
||||||
|
@ -674,7 +674,7 @@ void ColladaParser::ReadController( Collada::Controller& pController)
|
||||||
for( unsigned int a = 0; a < 16; a++)
|
for( unsigned int a = 0; a < 16; a++)
|
||||||
{
|
{
|
||||||
// read a number
|
// read a number
|
||||||
content = fast_atoreal_move<float>( content, pController.mBindShapeMatrix[a]);
|
content = fast_atoreal_move<ai_real>( content, pController.mBindShapeMatrix[a]);
|
||||||
// skip whitespace after it
|
// skip whitespace after it
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
}
|
}
|
||||||
|
@ -1179,13 +1179,13 @@ void ColladaParser::ReadLight( Collada::Light& pLight)
|
||||||
// text content contains 3 floats
|
// text content contains 3 floats
|
||||||
const char* content = GetTextContent();
|
const char* content = GetTextContent();
|
||||||
|
|
||||||
content = fast_atoreal_move<float>( content, (float&)pLight.mColor.r);
|
content = fast_atoreal_move<ai_real>( content, (ai_real&)pLight.mColor.r);
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
|
|
||||||
content = fast_atoreal_move<float>( content, (float&)pLight.mColor.g);
|
content = fast_atoreal_move<ai_real>( content, (ai_real&)pLight.mColor.g);
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
|
|
||||||
content = fast_atoreal_move<float>( content, (float&)pLight.mColor.b);
|
content = fast_atoreal_move<ai_real>( content, (ai_real&)pLight.mColor.b);
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
|
|
||||||
TestClosing( "color");
|
TestClosing( "color");
|
||||||
|
@ -1578,16 +1578,16 @@ void ColladaParser::ReadEffectColor( aiColor4D& pColor, Sampler& pSampler)
|
||||||
// text content contains 4 floats
|
// text content contains 4 floats
|
||||||
const char* content = GetTextContent();
|
const char* content = GetTextContent();
|
||||||
|
|
||||||
content = fast_atoreal_move<float>( content, (float&)pColor.r);
|
content = fast_atoreal_move<ai_real>( content, (ai_real&)pColor.r);
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
|
|
||||||
content = fast_atoreal_move<float>( content, (float&)pColor.g);
|
content = fast_atoreal_move<ai_real>( content, (ai_real&)pColor.g);
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
|
|
||||||
content = fast_atoreal_move<float>( content, (float&)pColor.b);
|
content = fast_atoreal_move<ai_real>( content, (ai_real&)pColor.b);
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
|
|
||||||
content = fast_atoreal_move<float>( content, (float&)pColor.a);
|
content = fast_atoreal_move<ai_real>( content, (ai_real&)pColor.a);
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
TestClosing( "color");
|
TestClosing( "color");
|
||||||
}
|
}
|
||||||
|
@ -1636,7 +1636,7 @@ void ColladaParser::ReadEffectColor( aiColor4D& pColor, Sampler& pSampler)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Reads an effect entry containing a float
|
// Reads an effect entry containing a float
|
||||||
void ColladaParser::ReadEffectFloat( float& pFloat)
|
void ColladaParser::ReadEffectFloat( ai_real& pFloat)
|
||||||
{
|
{
|
||||||
while( mReader->read())
|
while( mReader->read())
|
||||||
{
|
{
|
||||||
|
@ -1645,7 +1645,7 @@ void ColladaParser::ReadEffectFloat( float& pFloat)
|
||||||
{
|
{
|
||||||
// text content contains a single floats
|
// text content contains a single floats
|
||||||
const char* content = GetTextContent();
|
const char* content = GetTextContent();
|
||||||
content = fast_atoreal_move<float>( content, pFloat);
|
content = fast_atoreal_move<ai_real>( content, pFloat);
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
|
|
||||||
TestClosing( "float");
|
TestClosing( "float");
|
||||||
|
@ -1943,9 +1943,9 @@ void ColladaParser::ReadDataArray()
|
||||||
if( *content == 0)
|
if( *content == 0)
|
||||||
ThrowException( "Expected more values while reading float_array contents.");
|
ThrowException( "Expected more values while reading float_array contents.");
|
||||||
|
|
||||||
float value;
|
ai_real value;
|
||||||
// read a number
|
// read a number
|
||||||
content = fast_atoreal_move<float>( content, value);
|
content = fast_atoreal_move<ai_real>( content, value);
|
||||||
data.mValues.push_back( value);
|
data.mValues.push_back( value);
|
||||||
// skip whitespace after it
|
// skip whitespace after it
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
|
@ -2456,11 +2456,11 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
|
||||||
ThrowException( format() << "Invalid data index (" << pLocalIndex << "/" << acc.mCount << ") in primitive specification" );
|
ThrowException( format() << "Invalid data index (" << pLocalIndex << "/" << acc.mCount << ") in primitive specification" );
|
||||||
|
|
||||||
// get a pointer to the start of the data object referred to by the accessor and the local index
|
// get a pointer to the start of the data object referred to by the accessor and the local index
|
||||||
const float* dataObject = &(acc.mData->mValues[0]) + acc.mOffset + pLocalIndex* acc.mStride;
|
const ai_real* dataObject = &(acc.mData->mValues[0]) + acc.mOffset + pLocalIndex* acc.mStride;
|
||||||
|
|
||||||
// assemble according to the accessors component sub-offset list. We don't care, yet,
|
// assemble according to the accessors component sub-offset list. We don't care, yet,
|
||||||
// what kind of object exactly we're extracting here
|
// what kind of object exactly we're extracting here
|
||||||
float obj[4];
|
ai_real obj[4];
|
||||||
for( size_t c = 0; c < 4; ++c)
|
for( size_t c = 0; c < 4; ++c)
|
||||||
obj[c] = dataObject[acc.mSubOffset[c]];
|
obj[c] = dataObject[acc.mSubOffset[c]];
|
||||||
|
|
||||||
|
@ -2764,7 +2764,7 @@ void ColladaParser::ReadNodeTransformation( Node* pNode, TransformType pType)
|
||||||
for( unsigned int a = 0; a < sNumParameters[pType]; a++)
|
for( unsigned int a = 0; a < sNumParameters[pType]; a++)
|
||||||
{
|
{
|
||||||
// read a number
|
// read a number
|
||||||
content = fast_atoreal_move<float>( content, tf.f[a]);
|
content = fast_atoreal_move<ai_real>( content, tf.f[a]);
|
||||||
// skip whitespace after it
|
// skip whitespace after it
|
||||||
SkipSpacesAndLineEnd( &content);
|
SkipSpacesAndLineEnd( &content);
|
||||||
}
|
}
|
||||||
|
@ -3075,7 +3075,7 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform( const std::vector<Transform
|
||||||
case TF_ROTATE:
|
case TF_ROTATE:
|
||||||
{
|
{
|
||||||
aiMatrix4x4 rot;
|
aiMatrix4x4 rot;
|
||||||
float angle = tf.f[3] * float( AI_MATH_PI) / 180.0f;
|
ai_real angle = tf.f[3] * ai_real( AI_MATH_PI) / 180.0;
|
||||||
aiVector3D axis( tf.f[0], tf.f[1], tf.f[2]);
|
aiVector3D axis( tf.f[0], tf.f[1], tf.f[2]);
|
||||||
aiMatrix4x4::Rotation( angle, axis, rot);
|
aiMatrix4x4::Rotation( angle, axis, rot);
|
||||||
res *= rot;
|
res *= rot;
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace Assimp
|
||||||
void ReadEffectColor( aiColor4D& pColor, Collada::Sampler& pSampler);
|
void ReadEffectColor( aiColor4D& pColor, Collada::Sampler& pSampler);
|
||||||
|
|
||||||
/** Reads an effect entry containing a float */
|
/** Reads an effect entry containing a float */
|
||||||
void ReadEffectFloat( float& pFloat);
|
void ReadEffectFloat( ai_real& pFloat);
|
||||||
|
|
||||||
/** Reads an effect parameter specification of any kind */
|
/** Reads an effect parameter specification of any kind */
|
||||||
void ReadEffectParam( Collada::EffectParam& pParam);
|
void ReadEffectParam( Collada::EffectParam& pParam);
|
||||||
|
@ -259,7 +259,7 @@ namespace Assimp
|
||||||
bool ReadBoolFromTextContent();
|
bool ReadBoolFromTextContent();
|
||||||
|
|
||||||
/** Reads a single float from current text content */
|
/** Reads a single float from current text content */
|
||||||
float ReadFloatFromTextContent();
|
ai_real ReadFloatFromTextContent();
|
||||||
|
|
||||||
/** Calculates the resulting transformation from all the given transform steps */
|
/** Calculates the resulting transformation from all the given transform steps */
|
||||||
aiMatrix4x4 CalculateResultTransform( const std::vector<Collada::Transform>& pTransforms) const;
|
aiMatrix4x4 CalculateResultTransform( const std::vector<Collada::Transform>& pTransforms) const;
|
||||||
|
@ -335,7 +335,7 @@ namespace Assimp
|
||||||
Collada::Animation mAnims;
|
Collada::Animation mAnims;
|
||||||
|
|
||||||
/** Size unit: how large compared to a meter */
|
/** Size unit: how large compared to a meter */
|
||||||
float mUnitSize;
|
ai_real mUnitSize;
|
||||||
|
|
||||||
/** Which is the up vector */
|
/** Which is the up vector */
|
||||||
enum { UP_X, UP_Y, UP_Z } mUpDirection;
|
enum { UP_X, UP_Y, UP_Z } mUpDirection;
|
||||||
|
|
|
@ -161,9 +161,9 @@ void OFFImporter::InternReadFile( const std::string& pFile,
|
||||||
aiVector3D& v = tempPositions[i];
|
aiVector3D& v = tempPositions[i];
|
||||||
|
|
||||||
sz = line; SkipSpaces(&sz);
|
sz = line; SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<float>(sz,(float&)v.x); SkipSpaces(&sz);
|
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)v.x); SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<float>(sz,(float&)v.y); SkipSpaces(&sz);
|
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)v.y); SkipSpaces(&sz);
|
||||||
fast_atoreal_move<float>(sz,(float&)v.z);
|
fast_atoreal_move<ai_real>(sz,(ai_real&)v.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ void OFFImporter::InternReadFile( const std::string& pFile,
|
||||||
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
|
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
|
||||||
aiMaterial* pcMat = new aiMaterial();
|
aiMaterial* pcMat = new aiMaterial();
|
||||||
|
|
||||||
aiColor4D clr(0.6f,0.6f,0.6f,1.0f);
|
aiColor4D clr(0.6,0.6,0.6,1.0);
|
||||||
pcMat->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE);
|
pcMat->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE);
|
||||||
pScene->mMaterials[0] = pcMat;
|
pScene->mMaterials[0] = pcMat;
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ void ObjExporter::WriteMaterialFile()
|
||||||
mOutputMat << "Ke " << c.r << " " << c.g << " " << c.b << endl;
|
mOutputMat << "Ke " << c.r << " " << c.g << " " << c.b << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
float o;
|
ai_real o;
|
||||||
if(AI_SUCCESS == mat->Get(AI_MATKEY_OPACITY,o)) {
|
if(AI_SUCCESS == mat->Get(AI_MATKEY_OPACITY,o)) {
|
||||||
mOutputMat << "d " << o << endl;
|
mOutputMat << "d " << o << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,21 +191,21 @@ struct Material
|
||||||
//! Emissive color
|
//! Emissive color
|
||||||
aiColor3D emissive;
|
aiColor3D emissive;
|
||||||
//! Alpha value
|
//! Alpha value
|
||||||
float alpha;
|
ai_real alpha;
|
||||||
//! Shineness factor
|
//! Shineness factor
|
||||||
float shineness;
|
ai_real shineness;
|
||||||
//! Illumination model
|
//! Illumination model
|
||||||
int illumination_model;
|
int illumination_model;
|
||||||
//! Index of refraction
|
//! Index of refraction
|
||||||
float ior;
|
ai_real ior;
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
Material()
|
Material()
|
||||||
: diffuse (0.6f,0.6f,0.6f)
|
: diffuse (0.6,0.6,0.6)
|
||||||
, alpha (1.f)
|
, alpha (1.0)
|
||||||
, shineness (0.0f)
|
, shineness (0.0)
|
||||||
, illumination_model (1)
|
, illumination_model (1)
|
||||||
, ior (1.f)
|
, ior (1.0)
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
for (size_t i = 0; i < TextureTypeCount; ++i)
|
for (size_t i = 0; i < TextureTypeCount; ++i)
|
||||||
|
|
|
@ -232,7 +232,7 @@ void ObjFileMtlImporter::getColorRGBA( aiColor3D *pColor )
|
||||||
{
|
{
|
||||||
ai_assert( NULL != pColor );
|
ai_assert( NULL != pColor );
|
||||||
|
|
||||||
float r( 0.0f ), g( 0.0f ), b( 0.0f );
|
ai_real r( 0.0 ), g( 0.0 ), b( 0.0 );
|
||||||
m_DataIt = getFloat<DataArrayIt>( m_DataIt, m_DataItEnd, r );
|
m_DataIt = getFloat<DataArrayIt>( m_DataIt, m_DataItEnd, r );
|
||||||
pColor->r = r;
|
pColor->r = r;
|
||||||
|
|
||||||
|
@ -255,10 +255,10 @@ void ObjFileMtlImporter::getIlluminationModel( int &illum_model )
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Loads a single float value.
|
// Loads a single float value.
|
||||||
void ObjFileMtlImporter::getFloatValue( float &value )
|
void ObjFileMtlImporter::getFloatValue( ai_real &value )
|
||||||
{
|
{
|
||||||
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
||||||
value = (float) fast_atof(m_buffer);
|
value = (ai_real) fast_atof(m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
|
@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <assimp/defs.h>
|
||||||
|
|
||||||
struct aiColor3D;
|
struct aiColor3D;
|
||||||
struct aiString;
|
struct aiString;
|
||||||
|
@ -85,7 +86,7 @@ private:
|
||||||
/// Get illumination model from loaded data
|
/// Get illumination model from loaded data
|
||||||
void getIlluminationModel( int &illum_model );
|
void getIlluminationModel( int &illum_model );
|
||||||
/// Gets a float value from data.
|
/// Gets a float value from data.
|
||||||
void getFloatValue( float &value );
|
void getFloatValue( ai_real &value );
|
||||||
/// Creates a new material from loaded data.
|
/// Creates a new material from loaded data.
|
||||||
void createMaterial();
|
void createMaterial();
|
||||||
/// Get texture name from loaded data.
|
/// Get texture name from loaded data.
|
||||||
|
|
|
@ -279,23 +279,23 @@ size_t ObjFileParser::getNumComponentsInLine() {
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void ObjFileParser::getVector( std::vector<aiVector3D> &point3d_array ) {
|
void ObjFileParser::getVector( std::vector<aiVector3D> &point3d_array ) {
|
||||||
size_t numComponents = getNumComponentsInLine();
|
size_t numComponents = getNumComponentsInLine();
|
||||||
float x, y, z;
|
ai_real x, y, z;
|
||||||
if( 2 == numComponents ) {
|
if( 2 == numComponents ) {
|
||||||
copyNextWord( m_buffer, Buffersize );
|
copyNextWord( m_buffer, Buffersize );
|
||||||
x = ( float ) fast_atof( m_buffer );
|
x = ( ai_real ) fast_atof( m_buffer );
|
||||||
|
|
||||||
copyNextWord( m_buffer, Buffersize );
|
copyNextWord( m_buffer, Buffersize );
|
||||||
y = ( float ) fast_atof( m_buffer );
|
y = ( ai_real ) fast_atof( m_buffer );
|
||||||
z = 0.0;
|
z = 0.0;
|
||||||
} else if( 3 == numComponents ) {
|
} else if( 3 == numComponents ) {
|
||||||
copyNextWord( m_buffer, Buffersize );
|
copyNextWord( m_buffer, Buffersize );
|
||||||
x = ( float ) fast_atof( m_buffer );
|
x = ( ai_real ) fast_atof( m_buffer );
|
||||||
|
|
||||||
copyNextWord( m_buffer, Buffersize );
|
copyNextWord( m_buffer, Buffersize );
|
||||||
y = ( float ) fast_atof( m_buffer );
|
y = ( ai_real ) fast_atof( m_buffer );
|
||||||
|
|
||||||
copyNextWord( m_buffer, Buffersize );
|
copyNextWord( m_buffer, Buffersize );
|
||||||
z = ( float ) fast_atof( m_buffer );
|
z = ( ai_real ) fast_atof( m_buffer );
|
||||||
} else {
|
} else {
|
||||||
throw DeadlyImportError( "OBJ: Invalid number of components" );
|
throw DeadlyImportError( "OBJ: Invalid number of components" );
|
||||||
}
|
}
|
||||||
|
@ -306,15 +306,15 @@ void ObjFileParser::getVector( std::vector<aiVector3D> &point3d_array ) {
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Get values for a new 3D vector instance
|
// Get values for a new 3D vector instance
|
||||||
void ObjFileParser::getVector3( std::vector<aiVector3D> &point3d_array ) {
|
void ObjFileParser::getVector3( std::vector<aiVector3D> &point3d_array ) {
|
||||||
float x, y, z;
|
ai_real x, y, z;
|
||||||
copyNextWord(m_buffer, Buffersize);
|
copyNextWord(m_buffer, Buffersize);
|
||||||
x = (float) fast_atof(m_buffer);
|
x = (ai_real) fast_atof(m_buffer);
|
||||||
|
|
||||||
copyNextWord(m_buffer, Buffersize);
|
copyNextWord(m_buffer, Buffersize);
|
||||||
y = (float) fast_atof(m_buffer);
|
y = (ai_real) fast_atof(m_buffer);
|
||||||
|
|
||||||
copyNextWord( m_buffer, Buffersize );
|
copyNextWord( m_buffer, Buffersize );
|
||||||
z = ( float ) fast_atof( m_buffer );
|
z = ( ai_real ) fast_atof( m_buffer );
|
||||||
|
|
||||||
point3d_array.push_back( aiVector3D( x, y, z ) );
|
point3d_array.push_back( aiVector3D( x, y, z ) );
|
||||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
|
@ -323,26 +323,26 @@ void ObjFileParser::getVector3( std::vector<aiVector3D> &point3d_array ) {
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Get values for two 3D vectors on the same line
|
// Get values for two 3D vectors on the same line
|
||||||
void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, std::vector<aiVector3D> &point3d_array_b ) {
|
void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, std::vector<aiVector3D> &point3d_array_b ) {
|
||||||
float x, y, z;
|
ai_real x, y, z;
|
||||||
copyNextWord(m_buffer, Buffersize);
|
copyNextWord(m_buffer, Buffersize);
|
||||||
x = (float) fast_atof(m_buffer);
|
x = (ai_real) fast_atof(m_buffer);
|
||||||
|
|
||||||
copyNextWord(m_buffer, Buffersize);
|
copyNextWord(m_buffer, Buffersize);
|
||||||
y = (float) fast_atof(m_buffer);
|
y = (ai_real) fast_atof(m_buffer);
|
||||||
|
|
||||||
copyNextWord( m_buffer, Buffersize );
|
copyNextWord( m_buffer, Buffersize );
|
||||||
z = ( float ) fast_atof( m_buffer );
|
z = ( ai_real ) fast_atof( m_buffer );
|
||||||
|
|
||||||
point3d_array_a.push_back( aiVector3D( x, y, z ) );
|
point3d_array_a.push_back( aiVector3D( x, y, z ) );
|
||||||
|
|
||||||
copyNextWord(m_buffer, Buffersize);
|
copyNextWord(m_buffer, Buffersize);
|
||||||
x = (float) fast_atof(m_buffer);
|
x = (ai_real) fast_atof(m_buffer);
|
||||||
|
|
||||||
copyNextWord(m_buffer, Buffersize);
|
copyNextWord(m_buffer, Buffersize);
|
||||||
y = (float) fast_atof(m_buffer);
|
y = (ai_real) fast_atof(m_buffer);
|
||||||
|
|
||||||
copyNextWord( m_buffer, Buffersize );
|
copyNextWord( m_buffer, Buffersize );
|
||||||
z = ( float ) fast_atof( m_buffer );
|
z = ( ai_real ) fast_atof( m_buffer );
|
||||||
|
|
||||||
point3d_array_b.push_back( aiVector3D( x, y, z ) );
|
point3d_array_b.push_back( aiVector3D( x, y, z ) );
|
||||||
|
|
||||||
|
@ -352,12 +352,12 @@ void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, st
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Get values for a new 2D vector instance
|
// Get values for a new 2D vector instance
|
||||||
void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
|
void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
|
||||||
float x, y;
|
ai_real x, y;
|
||||||
copyNextWord(m_buffer, Buffersize);
|
copyNextWord(m_buffer, Buffersize);
|
||||||
x = (float) fast_atof(m_buffer);
|
x = (ai_real) fast_atof(m_buffer);
|
||||||
|
|
||||||
copyNextWord(m_buffer, Buffersize);
|
copyNextWord(m_buffer, Buffersize);
|
||||||
y = (float) fast_atof(m_buffer);
|
y = (ai_real) fast_atof(m_buffer);
|
||||||
|
|
||||||
point2d_array.push_back(aiVector2D(x, y));
|
point2d_array.push_back(aiVector2D(x, y));
|
||||||
|
|
||||||
|
|
|
@ -196,12 +196,12 @@ inline char_t CopyNextWord( char_t it, char_t end, char *pBuffer, size_t length
|
||||||
* @return Current-iterator with new position
|
* @return Current-iterator with new position
|
||||||
*/
|
*/
|
||||||
template<class char_t>
|
template<class char_t>
|
||||||
inline char_t getFloat( char_t it, char_t end, float &value )
|
inline char_t getFloat( char_t it, char_t end, ai_real &value )
|
||||||
{
|
{
|
||||||
static const size_t BUFFERSIZE = 1024;
|
static const size_t BUFFERSIZE = 1024;
|
||||||
char buffer[ BUFFERSIZE ];
|
char buffer[ BUFFERSIZE ];
|
||||||
it = CopyNextWord<char_t>( it, end, buffer, BUFFERSIZE );
|
it = CopyNextWord<char_t>( it, end, buffer, BUFFERSIZE );
|
||||||
value = (float) fast_atof( buffer );
|
value = (ai_real) fast_atof( buffer );
|
||||||
|
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,13 +481,13 @@ void PLYImporter::LoadTextureCoordinates(std::vector<aiVector2D>* pvOut)
|
||||||
|
|
||||||
if (0xFFFFFFFF != aiPositions[0])
|
if (0xFFFFFFFF != aiPositions[0])
|
||||||
{
|
{
|
||||||
vOut.x = PLY::PropertyInstance::ConvertTo<float>(
|
vOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||||
GetProperty((*i).alProperties, aiPositions[0]).avList.front(),aiTypes[0]);
|
GetProperty((*i).alProperties, aiPositions[0]).avList.front(),aiTypes[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0xFFFFFFFF != aiPositions[1])
|
if (0xFFFFFFFF != aiPositions[1])
|
||||||
{
|
{
|
||||||
vOut.y = PLY::PropertyInstance::ConvertTo<float>(
|
vOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||||
GetProperty((*i).alProperties, aiPositions[1]).avList.front(),aiTypes[1]);
|
GetProperty((*i).alProperties, aiPositions[1]).avList.front(),aiTypes[1]);
|
||||||
}
|
}
|
||||||
// and add them to our nice list
|
// and add them to our nice list
|
||||||
|
@ -502,7 +502,7 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != pvOut);
|
ai_assert(NULL != pvOut);
|
||||||
|
|
||||||
unsigned int aiPositions[3] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
|
ai_uint aiPositions[3] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
|
||||||
PLY::EDataType aiTypes[3] = {EDT_Char,EDT_Char,EDT_Char};
|
PLY::EDataType aiTypes[3] = {EDT_Char,EDT_Char,EDT_Char};
|
||||||
PLY::ElementInstanceList* pcList = NULL;
|
PLY::ElementInstanceList* pcList = NULL;
|
||||||
unsigned int cnt = 0;
|
unsigned int cnt = 0;
|
||||||
|
@ -591,19 +591,19 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
||||||
|
|
||||||
if (0xFFFFFFFF != aiPositions[0])
|
if (0xFFFFFFFF != aiPositions[0])
|
||||||
{
|
{
|
||||||
vOut.x = PLY::PropertyInstance::ConvertTo<float>(
|
vOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||||
GetProperty((*i).alProperties, aiPositions[0]).avList.front(),aiTypes[0]);
|
GetProperty((*i).alProperties, aiPositions[0]).avList.front(),aiTypes[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0xFFFFFFFF != aiPositions[1])
|
if (0xFFFFFFFF != aiPositions[1])
|
||||||
{
|
{
|
||||||
vOut.y = PLY::PropertyInstance::ConvertTo<float>(
|
vOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||||
GetProperty((*i).alProperties, aiPositions[1]).avList.front(),aiTypes[1]);
|
GetProperty((*i).alProperties, aiPositions[1]).avList.front(),aiTypes[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0xFFFFFFFF != aiPositions[2])
|
if (0xFFFFFFFF != aiPositions[2])
|
||||||
{
|
{
|
||||||
vOut.z = PLY::PropertyInstance::ConvertTo<float>(
|
vOut.z = PLY::PropertyInstance::ConvertTo<ai_real>(
|
||||||
GetProperty((*i).alProperties, aiPositions[2]).avList.front(),aiTypes[2]);
|
GetProperty((*i).alProperties, aiPositions[2]).avList.front(),aiTypes[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +615,7 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Convert a color component to [0...1]
|
// Convert a color component to [0...1]
|
||||||
float PLYImporter::NormalizeColorValue (PLY::PropertyInstance::ValueUnion val,
|
ai_real PLYImporter::NormalizeColorValue (PLY::PropertyInstance::ValueUnion val,
|
||||||
PLY::EDataType eType)
|
PLY::EDataType eType)
|
||||||
{
|
{
|
||||||
switch (eType)
|
switch (eType)
|
||||||
|
@ -623,20 +623,20 @@ float PLYImporter::NormalizeColorValue (PLY::PropertyInstance::ValueUnion val,
|
||||||
case EDT_Float:
|
case EDT_Float:
|
||||||
return val.fFloat;
|
return val.fFloat;
|
||||||
case EDT_Double:
|
case EDT_Double:
|
||||||
return (float)val.fDouble;
|
return (ai_real)val.fDouble;
|
||||||
|
|
||||||
case EDT_UChar:
|
case EDT_UChar:
|
||||||
return (float)val.iUInt / (float)0xFF;
|
return (ai_real)val.iUInt / (ai_real)0xFF;
|
||||||
case EDT_Char:
|
case EDT_Char:
|
||||||
return (float)(val.iInt+(0xFF/2)) / (float)0xFF;
|
return (ai_real)(val.iInt+(0xFF/2)) / (ai_real)0xFF;
|
||||||
case EDT_UShort:
|
case EDT_UShort:
|
||||||
return (float)val.iUInt / (float)0xFFFF;
|
return (ai_real)val.iUInt / (ai_real)0xFFFF;
|
||||||
case EDT_Short:
|
case EDT_Short:
|
||||||
return (float)(val.iInt+(0xFFFF/2)) / (float)0xFFFF;
|
return (ai_real)(val.iInt+(0xFFFF/2)) / (ai_real)0xFFFF;
|
||||||
case EDT_UInt:
|
case EDT_UInt:
|
||||||
return (float)val.iUInt / (float)0xFFFF;
|
return (ai_real)val.iUInt / (ai_real)0xFFFF;
|
||||||
case EDT_Int:
|
case EDT_Int:
|
||||||
return ((float)val.iInt / (float)0xFF) + 0.5f;
|
return ((ai_real)val.iInt / (ai_real)0xFF) + 0.5f;
|
||||||
default: ;
|
default: ;
|
||||||
};
|
};
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
@ -727,7 +727,7 @@ void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
||||||
}
|
}
|
||||||
|
|
||||||
// assume 1.0 for the alpha channel ifit is not set
|
// assume 1.0 for the alpha channel ifit is not set
|
||||||
if (0xFFFFFFFF == aiPositions[3])vOut.a = 1.0f;
|
if (0xFFFFFFFF == aiPositions[3])vOut.a = 1.0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vOut.a = NormalizeColorValue(GetProperty((*i).alProperties,
|
vOut.a = NormalizeColorValue(GetProperty((*i).alProperties,
|
||||||
|
@ -1076,14 +1076,14 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial*>* pvOut)
|
||||||
// handle phong power and shading mode
|
// handle phong power and shading mode
|
||||||
int iMode;
|
int iMode;
|
||||||
if (0xFFFFFFFF != iPhong) {
|
if (0xFFFFFFFF != iPhong) {
|
||||||
float fSpec = PLY::PropertyInstance::ConvertTo<float>(GetProperty((*i).alProperties, iPhong).avList.front(),ePhong);
|
ai_real fSpec = PLY::PropertyInstance::ConvertTo<ai_real>(GetProperty((*i).alProperties, iPhong).avList.front(),ePhong);
|
||||||
|
|
||||||
// if shininess is 0 (and the pow() calculation would therefore always
|
// if shininess is 0 (and the pow() calculation would therefore always
|
||||||
// become 1, not depending on the angle), use gouraud lighting
|
// become 1, not depending on the angle), use gouraud lighting
|
||||||
if (fSpec) {
|
if (fSpec) {
|
||||||
// scale this with 15 ... hopefully this is correct
|
// scale this with 15 ... hopefully this is correct
|
||||||
fSpec *= 15;
|
fSpec *= 15;
|
||||||
pcHelper->AddProperty<float>(&fSpec, 1, AI_MATKEY_SHININESS);
|
pcHelper->AddProperty<ai_real>(&fSpec, 1, AI_MATKEY_SHININESS);
|
||||||
|
|
||||||
iMode = (int)aiShadingMode_Phong;
|
iMode = (int)aiShadingMode_Phong;
|
||||||
}
|
}
|
||||||
|
@ -1094,8 +1094,8 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial*>* pvOut)
|
||||||
|
|
||||||
// handle opacity
|
// handle opacity
|
||||||
if (0xFFFFFFFF != iOpacity) {
|
if (0xFFFFFFFF != iOpacity) {
|
||||||
float fOpacity = PLY::PropertyInstance::ConvertTo<float>(GetProperty((*i).alProperties, iPhong).avList.front(),eOpacity);
|
ai_real fOpacity = PLY::PropertyInstance::ConvertTo<ai_real>(GetProperty((*i).alProperties, iPhong).avList.front(),eOpacity);
|
||||||
pcHelper->AddProperty<float>(&fOpacity, 1, AI_MATKEY_OPACITY);
|
pcHelper->AddProperty<ai_real>(&fOpacity, 1, AI_MATKEY_OPACITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The face order is absolutely undefined for PLY, so we have to
|
// The face order is absolutely undefined for PLY, so we have to
|
||||||
|
|
|
@ -155,7 +155,7 @@ protected:
|
||||||
/** Static helper to parse a color channel value. The input value
|
/** Static helper to parse a color channel value. The input value
|
||||||
* is normalized to 0-1.
|
* is normalized to 0-1.
|
||||||
*/
|
*/
|
||||||
static float NormalizeColorValue (
|
static ai_real NormalizeColorValue (
|
||||||
PLY::PropertyInstance::ValueUnion val,
|
PLY::PropertyInstance::ValueUnion val,
|
||||||
PLY::EDataType eType);
|
PLY::EDataType eType);
|
||||||
|
|
||||||
|
|
|
@ -825,8 +825,8 @@ bool PLY::PropertyInstance::ParseValue(
|
||||||
|
|
||||||
case EDT_Double:
|
case EDT_Double:
|
||||||
|
|
||||||
float f;
|
double f;
|
||||||
pCur = fast_atoreal_move<float>(pCur,f);
|
pCur = fast_atoreal_move<double>(pCur,f);
|
||||||
out->fDouble = (double)f;
|
out->fDouble = (double)f;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -162,12 +162,12 @@ void STLExporter :: WriteMeshBinary(const aiMesh* m)
|
||||||
}
|
}
|
||||||
nor.Normalize();
|
nor.Normalize();
|
||||||
}
|
}
|
||||||
float nx = nor.x, ny = nor.y, nz = nor.z;
|
ai_real nx = nor.x, ny = nor.y, nz = nor.z;
|
||||||
AI_SWAP4(nx); AI_SWAP4(ny); AI_SWAP4(nz);
|
AI_SWAP4(nx); AI_SWAP4(ny); AI_SWAP4(nz);
|
||||||
mOutput.write((char *)&nx, 4); mOutput.write((char *)&ny, 4); mOutput.write((char *)&nz, 4);
|
mOutput.write((char *)&nx, 4); mOutput.write((char *)&ny, 4); mOutput.write((char *)&nz, 4);
|
||||||
for(unsigned int a = 0; a < f.mNumIndices; ++a) {
|
for(unsigned int a = 0; a < f.mNumIndices; ++a) {
|
||||||
const aiVector3D& v = m->mVertices[f.mIndices[a]];
|
const aiVector3D& v = m->mVertices[f.mIndices[a]];
|
||||||
float vx = v.x, vy = v.y, vz = v.z;
|
ai_real vx = v.x, vy = v.y, vz = v.z;
|
||||||
AI_SWAP4(vx); AI_SWAP4(vy); AI_SWAP4(vz);
|
AI_SWAP4(vx); AI_SWAP4(vy); AI_SWAP4(vz);
|
||||||
mOutput.write((char *)&vx, 4); mOutput.write((char *)&vy, 4); mOutput.write((char *)&vz, 4);
|
mOutput.write((char *)&vx, 4); mOutput.write((char *)&vy, 4); mOutput.write((char *)&vz, 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ void STLImporter::InternReadFile( const std::string& pFile,
|
||||||
this->mBuffer = &mBuffer2[0];
|
this->mBuffer = &mBuffer2[0];
|
||||||
|
|
||||||
// the default vertex color is light gray.
|
// the default vertex color is light gray.
|
||||||
clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = 0.6f;
|
clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = 0.6;
|
||||||
|
|
||||||
// allocate a single node
|
// allocate a single node
|
||||||
pScene->mRootNode = new aiNode();
|
pScene->mRootNode = new aiNode();
|
||||||
|
@ -217,13 +217,13 @@ void STLImporter::InternReadFile( const std::string& pFile,
|
||||||
s.Set(AI_DEFAULT_MATERIAL_NAME);
|
s.Set(AI_DEFAULT_MATERIAL_NAME);
|
||||||
pcMat->AddProperty(&s, AI_MATKEY_NAME);
|
pcMat->AddProperty(&s, AI_MATKEY_NAME);
|
||||||
|
|
||||||
aiColor4D clrDiffuse(0.6f,0.6f,0.6f,1.0f);
|
aiColor4D clrDiffuse(0.6,0.6,0.6,1.0);
|
||||||
if (bMatClr) {
|
if (bMatClr) {
|
||||||
clrDiffuse = clrColorDefault;
|
clrDiffuse = clrColorDefault;
|
||||||
}
|
}
|
||||||
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_DIFFUSE);
|
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_DIFFUSE);
|
||||||
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_SPECULAR);
|
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_SPECULAR);
|
||||||
clrDiffuse = aiColor4D(0.05f,0.05f,0.05f,1.0f);
|
clrDiffuse = aiColor4D(0.05,0.05,0.05,1.0);
|
||||||
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_AMBIENT);
|
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_AMBIENT);
|
||||||
|
|
||||||
pScene->mNumMaterials = 1;
|
pScene->mNumMaterials = 1;
|
||||||
|
@ -307,11 +307,11 @@ void STLImporter::LoadASCIIFile()
|
||||||
}
|
}
|
||||||
sz += 7;
|
sz += 7;
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<float>(sz, (float&)vn->x );
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->x );
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->y );
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->z );
|
||||||
normalBuffer.push_back(*vn);
|
normalBuffer.push_back(*vn);
|
||||||
normalBuffer.push_back(*vn);
|
normalBuffer.push_back(*vn);
|
||||||
}
|
}
|
||||||
|
@ -332,11 +332,11 @@ void STLImporter::LoadASCIIFile()
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
positionBuffer.push_back(aiVector3D());
|
positionBuffer.push_back(aiVector3D());
|
||||||
aiVector3D* vn = &positionBuffer.back();
|
aiVector3D* vn = &positionBuffer.back();
|
||||||
sz = fast_atoreal_move<float>(sz, (float&)vn->x );
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->x );
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->y );
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->z );
|
||||||
faceVertexCounter++;
|
faceVertexCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,10 +416,10 @@ bool STLImporter::LoadBinaryFile()
|
||||||
// read the default vertex color for facets
|
// read the default vertex color for facets
|
||||||
bIsMaterialise = true;
|
bIsMaterialise = true;
|
||||||
DefaultLogger::get()->info("STL: Taking code path for Materialise files");
|
DefaultLogger::get()->info("STL: Taking code path for Materialise files");
|
||||||
clrColorDefault.r = (*sz2++) / 255.0f;
|
clrColorDefault.r = (*sz2++) / 255.0;
|
||||||
clrColorDefault.g = (*sz2++) / 255.0f;
|
clrColorDefault.g = (*sz2++) / 255.0;
|
||||||
clrColorDefault.b = (*sz2++) / 255.0f;
|
clrColorDefault.b = (*sz2++) / 255.0;
|
||||||
clrColorDefault.a = (*sz2++) / 255.0f;
|
clrColorDefault.a = (*sz2++) / 255.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -480,18 +480,18 @@ bool STLImporter::LoadBinaryFile()
|
||||||
DefaultLogger::get()->info("STL: Mesh has vertex colors");
|
DefaultLogger::get()->info("STL: Mesh has vertex colors");
|
||||||
}
|
}
|
||||||
aiColor4D* clr = &pMesh->mColors[0][i*3];
|
aiColor4D* clr = &pMesh->mColors[0][i*3];
|
||||||
clr->a = 1.0f;
|
clr->a = 1.0;
|
||||||
if (bIsMaterialise) // this is reversed
|
if (bIsMaterialise) // this is reversed
|
||||||
{
|
{
|
||||||
clr->r = (color & 0x31u) / 31.0f;
|
clr->r = (color & 0x31u) / 31.0;
|
||||||
clr->g = ((color & (0x31u<<5))>>5u) / 31.0f;
|
clr->g = ((color & (0x31u<<5))>>5u) / 31.0;
|
||||||
clr->b = ((color & (0x31u<<10))>>10u) / 31.0f;
|
clr->b = ((color & (0x31u<<10))>>10u) / 31.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
clr->b = (color & 0x31u) / 31.0f;
|
clr->b = (color & 0x31u) / 31.0;
|
||||||
clr->g = ((color & (0x31u<<5))>>5u) / 31.0f;
|
clr->g = ((color & (0x31u<<5))>>5u) / 31.0;
|
||||||
clr->r = ((color & (0x31u<<10))>>10u) / 31.0f;
|
clr->r = ((color & (0x31u<<10))>>10u) / 31.0;
|
||||||
}
|
}
|
||||||
// assign the color to all vertices of the face
|
// assign the color to all vertices of the face
|
||||||
*(clr+1) = *clr;
|
*(clr+1) = *clr;
|
||||||
|
|
|
@ -82,7 +82,7 @@ struct Material
|
||||||
std::string mName;
|
std::string mName;
|
||||||
bool mIsReference; // if true, mName holds a name by which the actual material can be found in the material list
|
bool mIsReference; // if true, mName holds a name by which the actual material can be found in the material list
|
||||||
aiColor4D mDiffuse;
|
aiColor4D mDiffuse;
|
||||||
float mSpecularExponent;
|
ai_real mSpecularExponent;
|
||||||
aiColor3D mSpecular;
|
aiColor3D mSpecular;
|
||||||
aiColor3D mEmissive;
|
aiColor3D mEmissive;
|
||||||
std::vector<TexEntry> mTextures;
|
std::vector<TexEntry> mTextures;
|
||||||
|
@ -100,7 +100,7 @@ struct Material
|
||||||
struct BoneWeight
|
struct BoneWeight
|
||||||
{
|
{
|
||||||
unsigned int mVertex;
|
unsigned int mVertex;
|
||||||
float mWeight;
|
ai_real mWeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Helper structure to represent a bone in a mesh */
|
/** Helper structure to represent a bone in a mesh */
|
||||||
|
|
|
@ -373,7 +373,7 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
|
||||||
{
|
{
|
||||||
const XFile::Bone& obone = bones[c];
|
const XFile::Bone& obone = bones[c];
|
||||||
// set up a vertex-linear array of the weights for quick searching if a bone influences a vertex
|
// set up a vertex-linear array of the weights for quick searching if a bone influences a vertex
|
||||||
std::vector<float> oldWeights( sourceMesh->mPositions.size(), 0.0f);
|
std::vector<ai_real> oldWeights( sourceMesh->mPositions.size(), 0.0);
|
||||||
for( unsigned int d = 0; d < obone.mWeights.size(); d++)
|
for( unsigned int d = 0; d < obone.mWeights.size(); d++)
|
||||||
oldWeights[obone.mWeights[d].mVertex] = obone.mWeights[d].mWeight;
|
oldWeights[obone.mWeights[d].mVertex] = obone.mWeights[d].mWeight;
|
||||||
|
|
||||||
|
@ -383,8 +383,8 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
|
||||||
for( unsigned int d = 0; d < orgPoints.size(); d++)
|
for( unsigned int d = 0; d < orgPoints.size(); d++)
|
||||||
{
|
{
|
||||||
// does the new vertex stem from an old vertex which was influenced by this bone?
|
// does the new vertex stem from an old vertex which was influenced by this bone?
|
||||||
float w = oldWeights[orgPoints[d]];
|
ai_real w = oldWeights[orgPoints[d]];
|
||||||
if( w > 0.0f)
|
if( w > 0.0)
|
||||||
newWeights.push_back( aiVertexWeight( d, w));
|
newWeights.push_back( aiVertexWeight( d, w));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,4 +713,3 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_X_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_X_IMPORTER
|
||||||
|
|
||||||
|
|
|
@ -1326,7 +1326,7 @@ unsigned int XFileParser::ReadInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
float XFileParser::ReadFloat()
|
ai_real XFileParser::ReadFloat()
|
||||||
{
|
{
|
||||||
if( mIsBinaryFormat)
|
if( mIsBinaryFormat)
|
||||||
{
|
{
|
||||||
|
@ -1343,7 +1343,7 @@ float XFileParser::ReadFloat()
|
||||||
if( mBinaryFloatSize == 8)
|
if( mBinaryFloatSize == 8)
|
||||||
{
|
{
|
||||||
if( End - P >= 8) {
|
if( End - P >= 8) {
|
||||||
float result = (float) (*(double*) P);
|
ai_real result = (ai_real) (*(double*) P);
|
||||||
P += 8;
|
P += 8;
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1353,7 +1353,7 @@ float XFileParser::ReadFloat()
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if( End - P >= 4) {
|
if( End - P >= 4) {
|
||||||
float result = *(float*) P;
|
ai_real result = *(ai_real*) P;
|
||||||
P += 4;
|
P += 4;
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1372,17 +1372,17 @@ float XFileParser::ReadFloat()
|
||||||
{
|
{
|
||||||
P += 9;
|
P += 9;
|
||||||
CheckForSeparator();
|
CheckForSeparator();
|
||||||
return 0.0f;
|
return 0.0;
|
||||||
} else
|
} else
|
||||||
if( strncmp( P, "1.#QNAN0", 8) == 0)
|
if( strncmp( P, "1.#QNAN0", 8) == 0)
|
||||||
{
|
{
|
||||||
P += 8;
|
P += 8;
|
||||||
CheckForSeparator();
|
CheckForSeparator();
|
||||||
return 0.0f;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float result = 0.0f;
|
ai_real result = 0.0;
|
||||||
P = fast_atoreal_move<float>( P, result);
|
P = fast_atoreal_move<ai_real>( P, result);
|
||||||
|
|
||||||
CheckForSeparator();
|
CheckForSeparator();
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ protected:
|
||||||
unsigned short ReadBinWord();
|
unsigned short ReadBinWord();
|
||||||
unsigned int ReadBinDWord();
|
unsigned int ReadBinDWord();
|
||||||
unsigned int ReadInt();
|
unsigned int ReadInt();
|
||||||
float ReadFloat();
|
ai_real ReadFloat();
|
||||||
aiVector2D ReadVector2();
|
aiVector2D ReadVector2();
|
||||||
aiVector3D ReadVector3();
|
aiVector3D ReadVector3();
|
||||||
aiColor3D ReadRGB();
|
aiColor3D ReadRGB();
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <assimp/defs.h>
|
||||||
|
|
||||||
#include "StringComparison.h"
|
#include "StringComparison.h"
|
||||||
|
|
||||||
|
@ -350,51 +351,26 @@ inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
// The same but more human.
|
// The same but more human.
|
||||||
inline float fast_atof(const char* c)
|
inline ai_real fast_atof(const char* c)
|
||||||
{
|
{
|
||||||
float ret;
|
ai_real ret;
|
||||||
fast_atoreal_move<float>(c, ret);
|
fast_atoreal_move<ai_real>(c, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float fast_atof( const char* c, const char** cout)
|
inline ai_real fast_atof( const char* c, const char** cout)
|
||||||
{
|
{
|
||||||
float ret;
|
ai_real ret;
|
||||||
*cout = fast_atoreal_move<float>(c, ret);
|
*cout = fast_atoreal_move<ai_real>(c, ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float fast_atof( const char** inout)
|
inline ai_real fast_atof( const char** inout)
|
||||||
{
|
{
|
||||||
float ret;
|
ai_real ret;
|
||||||
*inout = fast_atoreal_move<float>(*inout, ret);
|
*inout = fast_atoreal_move<ai_real>(*inout, ret);
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline double fast_atod(const char* c)
|
|
||||||
{
|
|
||||||
double ret;
|
|
||||||
fast_atoreal_move<double>(c, ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline double fast_atod( const char* c, const char** cout)
|
|
||||||
{
|
|
||||||
double ret;
|
|
||||||
*cout = fast_atoreal_move<double>(c, ret);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double fast_atod( const char** inout)
|
|
||||||
{
|
|
||||||
double ret;
|
|
||||||
*inout = fast_atoreal_move<double>(*inout, ret);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -402,4 +378,3 @@ inline double fast_atod( const char** inout)
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -228,6 +228,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
# define ASSIMP_BUILD_DEBUG
|
# define ASSIMP_BUILD_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
/* Define AI_DOUBLE_PRECISION to compile assimp
|
||||||
|
* with double precision support (64-bit). */
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef AI_DOUBLE_PRECISION
|
||||||
|
typedef double ai_real;
|
||||||
|
typedef signed long long int ai_int;
|
||||||
|
typedef unsigned long long int ai_uint;
|
||||||
|
#else // AI_DOUBLE_PRECISION
|
||||||
|
typedef float ai_real;
|
||||||
|
typedef signed int ai_int;
|
||||||
|
typedef unsigned int ai_uint;
|
||||||
|
#endif // AI_DOUBLE_PRECISION
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/* Useful constants */
|
/* Useful constants */
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -242,6 +257,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_MATH_TWO_PI_F (AI_MATH_PI_F * 2.0f)
|
#define AI_MATH_TWO_PI_F (AI_MATH_PI_F * 2.0f)
|
||||||
#define AI_MATH_HALF_PI_F (AI_MATH_PI_F * 0.5f)
|
#define AI_MATH_HALF_PI_F (AI_MATH_PI_F * 0.5f)
|
||||||
|
|
||||||
|
/* Tiny macro to convert from radians to degrees and back */
|
||||||
|
#define AI_DEG_TO_RAD(x) ((x)*(ai_real)0.0174532925)
|
||||||
|
#define AI_RAD_TO_DEG(x) ((x)*(ai_real)57.2957795)
|
||||||
|
|
||||||
/* Support for big-endian builds */
|
/* Support for big-endian builds */
|
||||||
#if defined(__BYTE_ORDER__)
|
#if defined(__BYTE_ORDER__)
|
||||||
# if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
# if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||||
|
@ -265,18 +284,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
|
#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
|
||||||
|
|
||||||
#ifdef AI_DOUBLE_PRECISION
|
|
||||||
typedef double ai_real;
|
|
||||||
typedef signed long long int ai_int;
|
|
||||||
/* Tiny macro to convert from radians to degrees and back */
|
|
||||||
#define AI_DEG_TO_RAD(x) ((x)*0.0174532925)
|
|
||||||
#define AI_RAD_TO_DEG(x) ((x)*57.2957795)
|
|
||||||
#else
|
|
||||||
typedef float ai_real;
|
|
||||||
typedef signed int ai_int;
|
|
||||||
/* Tiny macro to convert from radians to degrees and back */
|
|
||||||
#define AI_DEG_TO_RAD(x) ((x)*0.0174532925f)
|
|
||||||
#define AI_RAD_TO_DEG(x) ((x)*57.2957795f)
|
|
||||||
#endif // AI_SINGLEPRECISION
|
|
||||||
|
|
||||||
#endif // !! AI_DEFINES_H_INC
|
#endif // !! AI_DEFINES_H_INC
|
||||||
|
|
|
@ -179,19 +179,10 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FastAtofWrapper {
|
struct FastAtofWrapper {
|
||||||
float operator()(const char* str) { return Assimp::fast_atof(str); }
|
ai_real operator()(const char* str) { return Assimp::fast_atof(str); }
|
||||||
};
|
|
||||||
|
|
||||||
struct FastAtodWrapper {
|
|
||||||
double operator()(const char* str) { return Assimp::fast_atod(str); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(FastAtofTest, FastAtof)
|
TEST_F(FastAtofTest, FastAtof)
|
||||||
{
|
{
|
||||||
RunTest<float>(FastAtofWrapper());
|
RunTest<ai_real>(FastAtofWrapper());
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(FastAtofTest, FastAtod)
|
|
||||||
{
|
|
||||||
RunTest<double>(FastAtodWrapper());
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue