浏览代码

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

aramis_acg 16 年之前
父节点
当前提交
0c762117b8
共有 4 个文件被更改,包括 17 次插入29 次删除
  1. 0 13
      code/ColladaHelper.h
  2. 11 15
      code/ColladaLoader.cpp
  3. 2 1
      code/ColladaParser.cpp
  4. 4 0
      workspaces/vc8/assimp.vcproj

+ 0 - 13
code/ColladaHelper.h

@@ -470,15 +470,6 @@ struct Sampler
 	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,
     but we limit our version to a reasonable subset. */
 struct Effect
@@ -486,9 +477,6 @@ struct Effect
 	// Shading mode
 	ShadeType mShadeType;
 
-	// Alpha mode
-	AlphaMode mAlphaMode;
-
 	// Colors
 	aiColor4D mEmissive, mAmbient, mDiffuse, mSpecular,
 		mTransparent, mReflective;
@@ -512,7 +500,6 @@ struct Effect
 	
 	Effect()
 		: mShadeType    (Shade_Phong)
-		, mAlphaMode	(AM_ALPHA_ZERO)
 		, mEmissive		( 0, 0, 0, 1)
 		, mAmbient		( 0.1f, 0.1f, 0.1f, 1)
 		, mDiffuse		( 0.6f, 0.6f, 0.6f, 1)

+ 11 - 15
code/ColladaLoader.cpp

@@ -315,18 +315,6 @@ void ColladaLoader::BuildLightsForNode( const ColladaParser& pParser, const Coll
 				if (srcLight->mPenumbraAngle == 10e10f) 
 				{
 					// 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
 					out->mAngleOuterCone = AI_DEG_TO_RAD (acos(pow(0.1f,1.f/srcLight->mFalloffExponent))+
 						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
 			std::map<ColladaMeshIndex, size_t>::const_iterator dstMeshIt = mMeshIndexByID.find( index);
-			if( dstMeshIt != mMeshIndexByID.end())
-			{
+			if( dstMeshIt != mMeshIndexByID.end())	{
 				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
 				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.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
 		if( !effect.mTexAmbient.mName.empty()) 
 			 /* It is merely a lightmap */

+ 2 - 1
code/ColladaParser.cpp

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

+ 4 - 0
workspaces/vc8/assimp.vcproj

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