ColladaLoader does now load transparency. hacky, but it could work.

Cleaned up Collada material importing. No changes to other loader parts.
Adding missing FileSystemFilter.h to vc8 build config.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@383 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2009-04-10 22:51:12 +00:00
parent f3324da6ea
commit 0c762117b8
4 changed files with 17 additions and 29 deletions

View File

@ -470,15 +470,6 @@ struct Sampler
float mMixWithPrevious; float mMixWithPrevious;
}; };
/** Describes different alpha blending modes. */
enum AlphaMode
{
AM_RGB_ZERO,
AM_RGB_ONE,
AM_ALPHA_ONE,
AM_ALPHA_ZERO
};
/** A collada effect. Can contain about anything according to the Collada spec, /** A collada effect. Can contain about anything according to the Collada spec,
but we limit our version to a reasonable subset. */ but we limit our version to a reasonable subset. */
struct Effect struct Effect
@ -486,9 +477,6 @@ struct Effect
// Shading mode // Shading mode
ShadeType mShadeType; ShadeType mShadeType;
// Alpha mode
AlphaMode mAlphaMode;
// Colors // Colors
aiColor4D mEmissive, mAmbient, mDiffuse, mSpecular, aiColor4D mEmissive, mAmbient, mDiffuse, mSpecular,
mTransparent, mReflective; mTransparent, mReflective;
@ -512,7 +500,6 @@ struct Effect
Effect() Effect()
: mShadeType (Shade_Phong) : mShadeType (Shade_Phong)
, mAlphaMode (AM_ALPHA_ZERO)
, mEmissive ( 0, 0, 0, 1) , mEmissive ( 0, 0, 0, 1)
, mAmbient ( 0.1f, 0.1f, 0.1f, 1) , mAmbient ( 0.1f, 0.1f, 0.1f, 1)
, mDiffuse ( 0.6f, 0.6f, 0.6f, 1) , mDiffuse ( 0.6f, 0.6f, 0.6f, 1)

View File

@ -315,18 +315,6 @@ void ColladaLoader::BuildLightsForNode( const ColladaParser& pParser, const Coll
if (srcLight->mPenumbraAngle == 10e10f) if (srcLight->mPenumbraAngle == 10e10f)
{ {
// Need to rely on falloff_exponent. I don't know how to interpret it, so I need to guess .... // Need to rely on falloff_exponent. I don't know how to interpret it, so I need to guess ....
// ci - inner cone angle
// co - outer cone angle
// fe - falloff exponent
// ld - spot direction - normalized
// rd - ray direction - normalized
//
// Formula is:
// 1. (cos(acos (ld dot rd) - ci))^fe == epsilon
// 2. (ld dot rd) == cos(acos(epsilon^(1/fe)) + ci)
// 3. co == acos (ld dot rd)
// 4. co == acos(epsilon^(1/fe)) + ci)
// epsilon chosen to be 0.1 // epsilon chosen to be 0.1
out->mAngleOuterCone = AI_DEG_TO_RAD (acos(pow(0.1f,1.f/srcLight->mFalloffExponent))+ out->mAngleOuterCone = AI_DEG_TO_RAD (acos(pow(0.1f,1.f/srcLight->mFalloffExponent))+
srcLight->mFalloffAngle); srcLight->mFalloffAngle);
@ -486,10 +474,10 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll
// if we already have the mesh at the library, just add its index to the node's array // if we already have the mesh at the library, just add its index to the node's array
std::map<ColladaMeshIndex, size_t>::const_iterator dstMeshIt = mMeshIndexByID.find( index); std::map<ColladaMeshIndex, size_t>::const_iterator dstMeshIt = mMeshIndexByID.find( index);
if( dstMeshIt != mMeshIndexByID.end()) if( dstMeshIt != mMeshIndexByID.end()) {
{
newMeshRefs.push_back( dstMeshIt->second); newMeshRefs.push_back( dstMeshIt->second);
} else }
else
{ {
// else we have to add the mesh to the collection and store its newly assigned index at the node // else we have to add the mesh to the collection and store its newly assigned index at the node
aiMesh* dstMesh = CreateMesh( pParser, srcMesh, submesh, srcController, vertexStart, faceStart); aiMesh* dstMesh = CreateMesh( pParser, srcMesh, submesh, srcController, vertexStart, faceStart);
@ -1166,6 +1154,14 @@ void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* pScene
mat.AddProperty( &effect.mShininess, 1, AI_MATKEY_SHININESS); mat.AddProperty( &effect.mShininess, 1, AI_MATKEY_SHININESS);
mat.AddProperty( &effect.mRefractIndex, 1, AI_MATKEY_REFRACTI); mat.AddProperty( &effect.mRefractIndex, 1, AI_MATKEY_REFRACTI);
// transparency, a very hard one. seemingly not all files are following the
// specification here .. but we can trick.
if (effect.mTransparency > 0.f && effect.mTransparency < 1.f) {
effect.mTransparency = 1.f- effect.mTransparency;
mat.AddProperty( &effect.mTransparency, 1, AI_MATKEY_OPACITY );
mat.AddProperty( &effect.mTransparent, 1, AI_MATKEY_COLOR_TRANSPARENT );
}
// add textures, if given // add textures, if given
if( !effect.mTexAmbient.mName.empty()) if( !effect.mTexAmbient.mName.empty())
/* It is merely a lightmap */ /* It is merely a lightmap */

View File

@ -1070,8 +1070,9 @@ void ColladaParser::ReadEffect( Collada::Effect& pEffect)
else if( IsElement( "reflective")) { else if( IsElement( "reflective")) {
ReadEffectColor( pEffect.mReflective, pEffect.mTexReflective); ReadEffectColor( pEffect.mReflective, pEffect.mTexReflective);
} }
else if( IsElement( "transparent")) else if( IsElement( "transparent")) {
ReadEffectColor( pEffect.mTransparent,pEffect.mTexTransparent); ReadEffectColor( pEffect.mTransparent,pEffect.mTexTransparent);
}
else if( IsElement( "shininess")) else if( IsElement( "shininess"))
ReadEffectFloat( pEffect.mShininess); ReadEffectFloat( pEffect.mShininess);

View File

@ -1352,6 +1352,10 @@
RelativePath="..\..\code\BaseProcess.h" RelativePath="..\..\code\BaseProcess.h"
> >
</File> </File>
<File
RelativePath="..\..\code\FileSystemFilter.h"
>
</File>
<File <File
RelativePath="..\..\code\IFF.h" RelativePath="..\..\code\IFF.h"
> >