Merge branch 'master' into master

pull/1683/head
Christian Meurin 2018-01-15 19:10:14 -08:00 committed by GitHub
commit 86fa0f4524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 12621 additions and 101 deletions

View File

@ -702,6 +702,7 @@ ADD_ASSIMP_IMPORTER( MMD
) )
SET( Step_SRCS SET( Step_SRCS
STEPFile.h
StepExporter.h StepExporter.h
StepExporter.cpp StepExporter.cpp
) )

View File

@ -241,6 +241,10 @@ private:
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
aiColor3D GetColorPropertyFromMaterial( const PropertyTable& props, const std::string& baseName, aiColor3D GetColorPropertyFromMaterial( const PropertyTable& props, const std::string& baseName,
bool& result ); bool& result );
aiColor3D GetColorPropertyFactored( const PropertyTable& props, const std::string& colorName,
const std::string& factorName, bool& result, bool useTemplate=true );
aiColor3D GetColorProperty( const PropertyTable& props, const std::string& colorName,
bool& result, bool useTemplate=true );
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void SetShadingPropertiesCommon( aiMaterial* out_mat, const PropertyTable& props ); void SetShadingPropertiesCommon( aiMaterial* out_mat, const PropertyTable& props );
@ -1716,7 +1720,7 @@ unsigned int Converter::ConvertMaterial( const Material& material, const MeshGeo
aiString str; aiString str;
// stip Material:: prefix // strip Material:: prefix
std::string name = material.Name(); std::string name = material.Name();
if ( name.substr( 0, 10 ) == "Material::" ) { if ( name.substr( 0, 10 ) == "Material::" ) {
name = name.substr( 10 ); name = name.substr( 10 );
@ -2077,40 +2081,62 @@ void Converter::SetTextureProperties( aiMaterial* out_mat, const LayeredTextureM
TrySetTextureProperties( out_mat, layeredTextures, "ShininessExponent", aiTextureType_SHININESS, mesh ); TrySetTextureProperties( out_mat, layeredTextures, "ShininessExponent", aiTextureType_SHININESS, mesh );
} }
aiColor3D Converter::GetColorPropertyFromMaterial( const PropertyTable& props, const std::string& baseName, aiColor3D Converter::GetColorPropertyFactored( const PropertyTable& props, const std::string& colorName,
bool& result ) const std::string& factorName, bool& result, bool useTemplate )
{ {
result = true; result = true;
bool ok; bool ok;
const aiVector3D& Diffuse = PropertyGet<aiVector3D>( props, baseName, ok ); aiVector3D BaseColor = PropertyGet<aiVector3D>( props, colorName, ok, useTemplate );
if ( ok ) { if ( ! ok ) {
return aiColor3D( Diffuse.x, Diffuse.y, Diffuse.z ); result = false;
return aiColor3D( 0.0f, 0.0f, 0.0f );
} }
else {
aiVector3D DiffuseColor = PropertyGet<aiVector3D>( props, baseName + "Color", ok );
if ( ok ) {
float DiffuseFactor = PropertyGet<float>( props, baseName + "Factor", ok );
if ( ok ) {
DiffuseColor *= DiffuseFactor;
}
return aiColor3D( DiffuseColor.x, DiffuseColor.y, DiffuseColor.z ); // if no factor name, return the colour as is
} if ( factorName.empty() ) {
return aiColor3D( BaseColor.x, BaseColor.y, BaseColor.z );
} }
result = false;
return aiColor3D( 0.0f, 0.0f, 0.0f ); // otherwise it should be multiplied by the factor, if found.
float factor = PropertyGet<float>( props, factorName, ok, useTemplate );
if ( ok ) {
BaseColor *= factor;
}
return aiColor3D( BaseColor.x, BaseColor.y, BaseColor.z );
} }
aiColor3D Converter::GetColorPropertyFromMaterial( const PropertyTable& props, const std::string& baseName,
bool& result )
{
return GetColorPropertyFactored( props, baseName + "Color", baseName + "Factor", result, true );
}
aiColor3D Converter::GetColorProperty( const PropertyTable& props, const std::string& colorName,
bool& result, bool useTemplate )
{
result = true;
bool ok;
const aiVector3D& ColorVec = PropertyGet<aiVector3D>( props, colorName, ok, useTemplate );
if ( ! ok ) {
result = false;
return aiColor3D( 0.0f, 0.0f, 0.0f );
}
return aiColor3D( ColorVec.x, ColorVec.y, ColorVec.z );
}
void Converter::SetShadingPropertiesCommon( aiMaterial* out_mat, const PropertyTable& props ) void Converter::SetShadingPropertiesCommon( aiMaterial* out_mat, const PropertyTable& props )
{ {
// set shading properties. There are various, redundant ways in which FBX materials // Set shading properties.
// specify their shading settings (depending on shading models, prop // Modern FBX Files have two separate systems for defining these,
// template etc.). No idea which one is right in a particular context. // with only the more comprehensive one described in the property template.
// Just try to make sense of it - there's no spec to verify this against, // Likely the other values are a legacy system,
// so why should we. // which is still always exported by the official FBX SDK.
//
// Blender's FBX import and export mostly ignore this legacy system,
// and as we only support recent versions of FBX anyway, we can do the same.
bool ok; bool ok;
const aiColor3D& Diffuse = GetColorPropertyFromMaterial( props, "Diffuse", ok ); const aiColor3D& Diffuse = GetColorPropertyFromMaterial( props, "Diffuse", ok );
if ( ok ) { if ( ok ) {
out_mat->AddProperty( &Diffuse, 1, AI_MATKEY_COLOR_DIFFUSE ); out_mat->AddProperty( &Diffuse, 1, AI_MATKEY_COLOR_DIFFUSE );
@ -2126,29 +2152,64 @@ void Converter::SetShadingPropertiesCommon( aiMaterial* out_mat, const PropertyT
out_mat->AddProperty( &Ambient, 1, AI_MATKEY_COLOR_AMBIENT ); out_mat->AddProperty( &Ambient, 1, AI_MATKEY_COLOR_AMBIENT );
} }
const aiColor3D& Specular = GetColorPropertyFromMaterial( props, "Specular", ok ); // we store specular factor as SHININESS_STRENGTH, so just get the color
const aiColor3D& Specular = GetColorProperty( props, "SpecularColor", ok, true );
if ( ok ) { if ( ok ) {
out_mat->AddProperty( &Specular, 1, AI_MATKEY_COLOR_SPECULAR ); out_mat->AddProperty( &Specular, 1, AI_MATKEY_COLOR_SPECULAR );
} }
// and also try to get SHININESS_STRENGTH
const float SpecularFactor = PropertyGet<float>( props, "SpecularFactor", ok, true );
if ( ok ) {
out_mat->AddProperty( &SpecularFactor, 1, AI_MATKEY_SHININESS_STRENGTH );
}
// and the specular exponent
const float ShininessExponent = PropertyGet<float>( props, "ShininessExponent", ok );
if ( ok ) {
out_mat->AddProperty( &ShininessExponent, 1, AI_MATKEY_SHININESS );
}
// TransparentColor / TransparencyFactor... gee thanks FBX :rolleyes:
const aiColor3D& Transparent = GetColorPropertyFactored( props, "TransparentColor", "TransparencyFactor", ok );
float CalculatedOpacity = 1.0;
if ( ok ) {
out_mat->AddProperty( &Transparent, 1, AI_MATKEY_COLOR_TRANSPARENT );
// as calculated by FBX SDK 2017:
CalculatedOpacity = 1.0 - ((Transparent.r + Transparent.g + Transparent.b) / 3.0);
}
// use of TransparencyFactor is inconsistent.
// Maya always stores it as 1.0,
// so we can't use it to set AI_MATKEY_OPACITY.
// Blender is more sensible and stores it as the alpha value.
// However both the FBX SDK and Blender always write an additional
// legacy "Opacity" field, so we can try to use that.
//
// If we can't find it,
// we can fall back to the value which the FBX SDK calculates
// from transparency colour (RGB) and factor (F) as
// 1.0 - F*((R+G+B)/3).
//
// There's no consistent way to interpret this opacity value,
// so it's up to clients to do the correct thing.
const float Opacity = PropertyGet<float>( props, "Opacity", ok ); const float Opacity = PropertyGet<float>( props, "Opacity", ok );
if ( ok ) { if ( ok ) {
out_mat->AddProperty( &Opacity, 1, AI_MATKEY_OPACITY ); out_mat->AddProperty( &Opacity, 1, AI_MATKEY_OPACITY );
} }
else if ( CalculatedOpacity != 1.0 ) {
const float Reflectivity = PropertyGet<float>( props, "Reflectivity", ok ); out_mat->AddProperty( &CalculatedOpacity, 1, AI_MATKEY_OPACITY );
if ( ok ) {
out_mat->AddProperty( &Reflectivity, 1, AI_MATKEY_REFLECTIVITY );
} }
const float Shininess = PropertyGet<float>( props, "Shininess", ok ); // reflection color and factor are stored separately
const aiColor3D& Reflection = GetColorProperty( props, "ReflectionColor", ok, true );
if ( ok ) { if ( ok ) {
out_mat->AddProperty( &Shininess, 1, AI_MATKEY_SHININESS_STRENGTH ); out_mat->AddProperty( &Reflection, 1, AI_MATKEY_COLOR_REFLECTIVE );
} }
const float ShininessExponent = PropertyGet<float>( props, "ShininessExponent", ok ); float ReflectionFactor = PropertyGet<float>( props, "ReflectionFactor", ok, true );
if ( ok ) { if ( ok ) {
out_mat->AddProperty( &ShininessExponent, 1, AI_MATKEY_SHININESS ); out_mat->AddProperty( &ReflectionFactor, 1, AI_MATKEY_REFLECTIVITY );
} }
const float BumpFactor = PropertyGet<float>(props, "BumpFactor", ok); const float BumpFactor = PropertyGet<float>(props, "BumpFactor", ok);

View File

@ -148,11 +148,23 @@ T PropertyGet(const PropertyTable& in, const std::string& name, const T& default
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename T> template <typename T>
inline inline
T PropertyGet(const PropertyTable& in, const std::string& name, bool& result) { T PropertyGet(const PropertyTable& in, const std::string& name, bool& result, bool useTemplate=false ) {
const Property* const prop = in.Get(name); const Property* prop = in.Get(name);
if( nullptr == prop) { if( nullptr == prop) {
result = false; if ( ! useTemplate ) {
return T(); result = false;
return T();
}
const PropertyTable* templ = in.TemplateProps();
if ( nullptr == templ ) {
result = false;
return T();
}
prop = templ->Get(name);
if ( nullptr == prop ) {
result = false;
return T();
}
} }
// strong typing, no need to be lenient // strong typing, no need to be lenient

View File

@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "IFCUtil.h" #include "IFCUtil.h"
#include <assimp/MemoryIOWrapper.h> #include "code/MemoryIOWrapper.h"
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include <assimp/importerdesc.h> #include <assimp/importerdesc.h>
@ -931,7 +931,7 @@ void ProcessSpatialStructures(ConversionData& conv)
conv.out->mRootNode->mParent = NULL; conv.out->mRootNode->mParent = NULL;
conv.out->mRootNode->mNumChildren = static_cast<unsigned int>(nb_nodes); conv.out->mRootNode->mNumChildren = static_cast<unsigned int>(nb_nodes);
conv.out->mRootNode->mChildren = new aiNode*[conv.out->mRootNode->mNumChildren]; conv.out->mRootNode->mChildren = new aiNode*[conv.out->mRootNode->mNumChildren];
for (size_t i = 0; i < nb_nodes; ++i) { for (size_t i = 0; i < nb_nodes; ++i) {
aiNode* node = nodes[i]; aiNode* node = nodes[i];

View File

@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief STEP character handling, string un-escaping * @brief STEP character handling, string un-escaping
*/ */
#include "STEPFileEncoding.h" #include "STEPFileEncoding.h"
#include <assimp/fast_atof.h> #include "code/fast_atof.h"
#include <contrib/utf8cpp/source/utf8.h> #include <contrib/utf8cpp/source/utf8.h>
#include <memory> #include <memory>

View File

@ -46,8 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "STEPFileReader.h" #include "STEPFileReader.h"
#include "STEPFileEncoding.h" #include "STEPFileEncoding.h"
#include <assimp/TinyFormatter.h> #include "code/TinyFormatter.h"
#include <assimp/fast_atof.h> #include "code/fast_atof.h"
#include <memory> #include <memory>

View File

@ -169,7 +169,7 @@ corresponding preprocessor flag to selectively disable formats.
# include "NDOLoader.h" # include "NDOLoader.h"
#endif #endif
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER #ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
# include "IFCLoader.h" # include "Importer/IFC/IFCLoader.h"
#endif #endif
#ifndef ASSIMP_BUILD_NO_XGL_IMPORTER #ifndef ASSIMP_BUILD_NO_XGL_IMPORTER
# include "XGLLoader.h" # include "XGLLoader.h"

View File

@ -364,17 +364,16 @@ namespace STEP {
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
class ConversionSchema class ConversionSchema
{ {
public: public:
struct SchemaEntry { struct SchemaEntry {
SchemaEntry(const char* name,ConvertObjectProc func) SchemaEntry( const char *name, ConvertObjectProc func )
: name(name) : mName( name )
, func(func) , mFunc(func) {
{} // empty
}
const char* name; const char* mName;
ConvertObjectProc func; ConvertObjectProc mFunc;
}; };
typedef std::map<std::string,ConvertObjectProc> ConverterMap; typedef std::map<std::string,ConvertObjectProc> ConverterMap;
@ -410,7 +409,7 @@ namespace STEP {
const ConversionSchema& operator=( const SchemaEntry (& schemas)[N]) { const ConversionSchema& operator=( const SchemaEntry (& schemas)[N]) {
for(size_t i = 0; i < N; ++i ) { for(size_t i = 0; i < N; ++i ) {
const SchemaEntry& schema = schemas[i]; const SchemaEntry& schema = schemas[i];
converters[schema.name] = schema.func; converters[schema.mName] = schema.mFunc;
} }
return *this; return *this;
} }

115
doc/dox.h
View File

@ -813,188 +813,203 @@ All material key constants start with 'AI_MATKEY' (it's an ugly macro for histor
<th>Name</th> <th>Name</th>
<th>Data Type</th> <th>Data Type</th>
<th>Default Value</th> <th>Default Value</th>
<th>Meaning</th> <th>Meaning</th>
<th>Notes</th> <th>Notes</th>
</tr> </tr>
<tr> <tr>
<td><tt>NAME</tt></td> <td><tt>NAME</tt></td>
<td>aiString</td> <td>aiString</td>
<td>n/a</td> <td>n/a</td>
<td>The name of the material, if available. </td> <td>The name of the material, if available. </td>
<td>Ignored by <tt>aiProcess_RemoveRedundantMaterials</tt>. Materials are considered equal even if their names are different.</td> <td>Ignored by <tt>aiProcess_RemoveRedundantMaterials</tt>. Materials are considered equal even if their names are different.</td>
</tr> </tr>
<tr> <tr>
<td><tt>COLOR_DIFFUSE</tt></td> <td><tt>COLOR_DIFFUSE</tt></td>
<td>aiColor3D</td> <td>aiColor3D</td>
<td>black (0,0,0)</td> <td>black (0,0,0)</td>
<td>Diffuse color of the material. This is typically scaled by the amount of incoming diffuse light (e.g. using gouraud shading) </td> <td>Diffuse color of the material. This is typically scaled by the amount of incoming diffuse light (e.g. using gouraud shading) </td>
<td>---</td> <td>---</td>
</tr> </tr>
<tr> <tr>
<td><tt>COLOR_SPECULAR</tt></td> <td><tt>COLOR_SPECULAR</tt></td>
<td>aiColor3D</td> <td>aiColor3D</td>
<td>black (0,0,0)</td> <td>black (0,0,0)</td>
<td>Specular color of the material. This is typically scaled by the amount of incoming specular light (e.g. using phong shading) </td> <td>Specular color of the material. This is typically scaled by the amount of incoming specular light (e.g. using phong shading) </td>
<td>---</td> <td>---</td>
</tr> </tr>
<tr> <tr>
<td><tt>COLOR_AMBIENT</tt></td> <td><tt>COLOR_AMBIENT</tt></td>
<td>aiColor3D</td> <td>aiColor3D</td>
<td>black (0,0,0)</td> <td>black (0,0,0)</td>
<td>Ambient color of the material. This is typically scaled by the amount of ambient light </td> <td>Ambient color of the material. This is typically scaled by the amount of ambient light </td>
<td>---</td> <td>---</td>
</tr> </tr>
<tr> <tr>
<td><tt>COLOR_EMISSIVE</tt></td> <td><tt>COLOR_EMISSIVE</tt></td>
<td>aiColor3D</td> <td>aiColor3D</td>
<td>black (0,0,0)</td> <td>black (0,0,0)</td>
<td>Emissive color of the material. This is the amount of light emitted by the object. In real time applications it will usually not affect surrounding objects, but raytracing applications may wish to treat emissive objects as light sources. </td> <td>Emissive color of the material. This is the amount of light emitted by the object. In real time applications it will usually not affect surrounding objects, but raytracing applications may wish to treat emissive objects as light sources. </td>
<td>---</tt></td> <td>---</td>
</tr> </tr>
<tr> <tr>
<td><tt>COLOR_TRANSPARENT</tt></td> <td><tt>COLOR_TRANSPARENT</tt></td>
<td>aiColor3D</td> <td>aiColor3D</td>
<td>black (0,0,0)</td> <td>black (0,0,0)</td>
<td>Defines the transparent color of the material, this is the color to be multiplied with the color of <td>Defines the transparent color of the material, this is the color to be multiplied with the color of translucent light to construct the final 'destination color' for a particular position in the screen buffer.</td>
translucent light to construct the final 'destination color' for a particular position in the screen buffer. T </td> <td>---</td>
<td>---</tt></td> </tr>
<tr>
<td><tt>COLOR_REFLECTIVE</tt></td>
<td>aiColor3D</td>
<td>black (0,0,0)</td>
<td>Defines the reflective color of the material. This is typically scaled by the amount of incoming light from the direction of mirror reflection. Usually combined with an enviroment lightmap of some kind for real-time applications.</td>
<td>---</td>
</tr>
<tr>
<td><tt>REFLECTIVITY</tt></td>
<td>float</td>
<td>0.0</td>
<td>Scales the reflective color of the material.</td>
<td>---</td>
</tr> </tr>
<tr> <tr>
<td><tt>WIREFRAME</tt></td> <td><tt>WIREFRAME</tt></td>
<td>int</td> <td>int</td>
<td>false</td> <td>false</td>
<td>Specifies whether wireframe rendering must be turned on for the material. 0 for false, !0 for true. </td> <td>Specifies whether wireframe rendering must be turned on for the material. 0 for false, !0 for true. </td>
<td>---</tt></td> <td>---</td>
</tr> </tr>
<tr> <tr>
<td><tt>TWOSIDED</tt></td> <td><tt>TWOSIDED</tt></td>
<td>int</td> <td>int</td>
<td>false</td> <td>false</td>
<td>Specifies whether meshes using this material must be rendered without backface culling. 0 for false, !0 for true. </td> <td>Specifies whether meshes using this material must be rendered without backface culling. 0 for false, !0 for true. </td>
<td>Some importers set this property if they don't know whether the output face oder is right. As long as it is not set, you may safely enable backface culling.</tt></td> <td>Some importers set this property if they don't know whether the output face oder is right. As long as it is not set, you may safely enable backface culling.</tt></td>
</tr> </tr>
<tr> <tr>
<td><tt>SHADING_MODEL</tt></td> <td><tt>SHADING_MODEL</tt></td>
<td>int</td> <td>int</td>
<td>gouraud</td> <td>gouraud</td>
<td>One of the #aiShadingMode enumerated values. Defines the library shading model to use for (real time) rendering to approximate the original look of the material as closely as possible. </td> <td>One of the #aiShadingMode enumerated values. Defines the library shading model to use for (real time) rendering to approximate the original look of the material as closely as possible. </td>
<td>The presence of this key might indicate a more complex material. If absent, assume phong shading only if a specular exponent is given.</tt></td> <td>The presence of this key might indicate a more complex material. If absent, assume phong shading only if a specular exponent is given.</tt></td>
</tr> </tr>
<tr> <tr>
<td><tt>BLEND_FUNC</tt></td> <td><tt>BLEND_FUNC</tt></td>
<td>int</td> <td>int</td>
<td>false</td> <td>false</td>
<td>One of the #aiBlendMode enumerated values. Defines how the final color value in the screen buffer is computed from the given color at that position and the newly computed color from the material. Simply said, alpha blending settings.</td> <td>One of the #aiBlendMode enumerated values. Defines how the final color value in the screen buffer is computed from the given color at that position and the newly computed color from the material. Simply said, alpha blending settings.</td>
<td>-</td> <td>-</td>
</tr> </tr>
<tr> <tr>
<td><tt>OPACITY</tt></td> <td><tt>OPACITY</tt></td>
<td>float</td> <td>float</td>
<td>1.0</td> <td>1.0</td>
<td>Defines the opacity of the material in a range between 0..1.</td> <td>Defines the opacity of the material in a range between 0..1.</td>
<td>Use this value to decide whether you have to activate alpha blending for rendering. <tt>OPACITY</tt> != 1 usually also implies TWOSIDED=1 to avoid cull artifacts.</td> <td>Use this value to decide whether you have to activate alpha blending for rendering. <tt>OPACITY</tt> != 1 usually also implies TWOSIDED=1 to avoid cull artifacts.</td>
</tr> </tr>
<tr> <tr>
<td><tt>SHININESS</tt></td> <td><tt>SHININESS</tt></td>
<td>float</td> <td>float</td>
<td>0.f</td> <td>0.f</td>
<td>Defines the shininess of a phong-shaded material. This is actually the exponent of the phong specular equation</td> <td>Defines the shininess of a phong-shaded material. This is actually the exponent of the phong specular equation</td>
<td><tt>SHININESS</tt>=0 is equivalent to <tt>SHADING_MODEL</tt>=<tt>aiShadingMode_Gouraud</tt>.</td> <td><tt>SHININESS</tt>=0 is equivalent to <tt>SHADING_MODEL</tt>=<tt>aiShadingMode_Gouraud</tt>.</td>
</tr> </tr>
<tr> <tr>
<td><tt>SHININESS_STRENGTH</tt></td> <td><tt>SHININESS_STRENGTH</tt></td>
<td>float</td> <td>float</td>
<td>1.0</td> <td>1.0</td>
<td>Scales the specular color of the material.</td> <td>Scales the specular color of the material.</td>
<td>This value is kept separate from the specular color by most modelers, and so do we.</td> <td>This value is kept separate from the specular color by most modelers, and so do we.</td>
</tr> </tr>
<tr> <tr>
<td><tt>REFRACTI</tt></td> <td><tt>REFRACTI</tt></td>
<td>float</td> <td>float</td>
<td>1.0</td> <td>1.0</td>
<td>Defines the Index Of Refraction for the material. That's not supported by most file formats.</td> <td>Defines the Index Of Refraction for the material. That's not supported by most file formats.</td>
<td>Might be of interest for raytracing.</td> <td>Might be of interest for raytracing.</td>
</tr> </tr>
<tr> <tr>
<td><tt>TEXTURE(t,n)</tt></td> <td><tt>TEXTURE(t,n)</tt></td>
<td>aiString</td> <td>aiString</td>
<td>n/a</td> <td>n/a</td>
<td>Defines the path of the n'th texture on the stack 't', where 'n' is any value >= 0 and 't' is one of the #aiTextureType enumerated values. Either a filepath or `*<index>`, where `<index>` is the index of an embedded texture in aiScene::mTextures.</td> <td>Defines the path of the n'th texture on the stack 't', where 'n' is any value >= 0 and 't' is one of the #aiTextureType enumerated values. Either a filepath or `*<index>`, where `<index>` is the index of an embedded texture in aiScene::mTextures.</td>
<td>See the 'Textures' section above.</td> <td>See the 'Textures' section above.</td>
</tr> </tr>
<tr> <tr>
<td><tt>TEXBLEND(t,n)</tt></td> <td><tt>TEXBLEND(t,n)</tt></td>
<td>float</td> <td>float</td>
<td>n/a</td> <td>n/a</td>
<td>Defines the strength the n'th texture on the stack 't'. All color components (rgb) are multiplied with this factor *before* any further processing is done.</td> <td>Defines the strength the n'th texture on the stack 't'. All color components (rgb) are multiplied with this factor *before* any further processing is done.</td>
<td>-</td> <td>-</td>
</tr> </tr>
<tr> <tr>
<td><tt>TEXOP(t,n)</tt></td> <td><tt>TEXOP(t,n)</tt></td>
<td>int</td> <td>int</td>
<td>n/a</td> <td>n/a</td>
<td>One of the #aiTextureOp enumerated values. Defines the arithmetic operation to be used to combine the n'th texture on the stack 't' with the n-1'th. <tt>TEXOP(t,0)</tt> refers to the blend operation between the base color for this stack (e.g. <tt>COLOR_DIFFUSE</tt> for the diffuse stack) and the first texture.</td> <td>One of the #aiTextureOp enumerated values. Defines the arithmetic operation to be used to combine the n'th texture on the stack 't' with the n-1'th. <tt>TEXOP(t,0)</tt> refers to the blend operation between the base color for this stack (e.g. <tt>COLOR_DIFFUSE</tt> for the diffuse stack) and the first texture.</td>
<td>-</td> <td>-</td>
</tr> </tr>
<tr> <tr>
<td><tt>MAPPING(t,n)</tt></td> <td><tt>MAPPING(t,n)</tt></td>
<td>int</td> <td>int</td>
<td>n/a</td> <td>n/a</td>
<td>Defines how the input mapping coordinates for sampling the n'th texture on the stack 't' are computed. Usually explicit UV coordinates are provided, but some model file formats might also be using basic shapes, such as spheres or cylinders, to project textures onto meshes.</td> <td>Defines how the input mapping coordinates for sampling the n'th texture on the stack 't' are computed. Usually explicit UV coordinates are provided, but some model file formats might also be using basic shapes, such as spheres or cylinders, to project textures onto meshes.</td>
<td>See the 'Textures' section below. #aiProcess_GenUVCoords can be used to let Assimp compute proper UV coordinates from projective mappings.</td> <td>See the 'Textures' section below. #aiProcess_GenUVCoords can be used to let Assimp compute proper UV coordinates from projective mappings.</td>
</tr> </tr>
<tr> <tr>
<td><tt>UVWSRC(t,n)</tt></td> <td><tt>UVWSRC(t,n)</tt></td>
<td>int</td> <td>int</td>
<td>n/a</td> <td>n/a</td>
<td>Defines the UV channel to be used as input mapping coordinates for sampling the n'th texture on the stack 't'. All meshes assigned to this material share the same UV channel setup</td> <td>Defines the UV channel to be used as input mapping coordinates for sampling the n'th texture on the stack 't'. All meshes assigned to this material share the same UV channel setup</td>
<td>Presence of this key implies <tt>MAPPING(t,n)</tt> to be #aiTextureMapping_UV. See @ref uvwsrc for more details. </td> <td>Presence of this key implies <tt>MAPPING(t,n)</tt> to be #aiTextureMapping_UV. See @ref uvwsrc for more details. </td>
</tr> </tr>
<tr> <tr>
<td><tt>MAPPINGMODE_U(t,n)</tt></td> <td><tt>MAPPINGMODE_U(t,n)</tt></td>
<td>int</td> <td>int</td>
<td>n/a</td> <td>n/a</td>
<td>Any of the #aiTextureMapMode enumerated values. Defines the texture wrapping mode on the x axis for sampling the n'th texture on the stack 't'. 'Wrapping' occurs whenever UVs lie outside the 0..1 range. </td> <td>Any of the #aiTextureMapMode enumerated values. Defines the texture wrapping mode on the x axis for sampling the n'th texture on the stack 't'. 'Wrapping' occurs whenever UVs lie outside the 0..1 range. </td>
<td>-</td> <td>-</td>
</tr> </tr>
<tr> <tr>
<td><tt>MAPPINGMODE_V(t,n)</tt></td> <td><tt>MAPPINGMODE_V(t,n)</tt></td>
<td>int</td> <td>int</td>
<td>n/a</td> <td>n/a</td>
<td>Wrap mode on the v axis. See <tt>MAPPINGMODE_U</tt>. </td> <td>Wrap mode on the v axis. See <tt>MAPPINGMODE_U</tt>. </td>
<td>-</td> <td>-</td>
</tr> </tr>
<tr> <tr>
<td><tt>TEXMAP_AXIS(t,n)</tt></td> <td><tt>TEXMAP_AXIS(t,n)</tt></td>
<td>aiVector3D</td> <td>aiVector3D</td>
<td>n/a</td> <td>n/a</td>
<td></tt> Defines the base axis to to compute the mapping coordinates for the n'th texture on the stack 't' from. This is not required for UV-mapped textures. For instance, if <tt>MAPPING(t,n)</tt> is #aiTextureMapping_SPHERE, U and V would map to longitude and latitude of a sphere around the given axis. The axis is given in local mesh space.</td> <td></tt> Defines the base axis to to compute the mapping coordinates for the n'th texture on the stack 't' from. This is not required for UV-mapped textures. For instance, if <tt>MAPPING(t,n)</tt> is #aiTextureMapping_SPHERE, U and V would map to longitude and latitude of a sphere around the given axis. The axis is given in local mesh space.</td>
<td>-</td> <td>-</td>
</tr> </tr>
<tr> <tr>
<td><tt>TEXFLAGS(t,n)</tt></td> <td><tt>TEXFLAGS(t,n)</tt></td>
<td>int</td> <td>int</td>
<td>n/a</td> <td>n/a</td>
<td></tt> Defines miscellaneous flag for the n'th texture on the stack 't'. This is a bitwise combination of the #aiTextureFlags enumerated values.</td> <td></tt> Defines miscellaneous flag for the n'th texture on the stack 't'. This is a bitwise combination of the #aiTextureFlags enumerated values.</td>
<td>-</td> <td>-</td>
</tr> </tr>
</table> </table>
@ -1085,7 +1100,7 @@ for all textures
assign channel specified in uvwsrc assign channel specified in uvwsrc
else else
assign channels in ascending order for all texture stacks, assign channels in ascending order for all texture stacks,
i.e. diffuse1 gets channel 1, opacity0 gets channel 0. i.e. diffuse1 gets channel 1, opacity0 gets channel 0.
@endverbatim @endverbatim

View File

@ -94,8 +94,9 @@ class Type:
self.enums = enums self.enums = enums
def read(filename,silent=False): def read(filename, silent=False):
schema = Schema() schema = Schema()
print( "Try to read EXPRESS schema file" + filename)
with open(filename,'rt') as inp: with open(filename,'rt') as inp:
contents = inp.read() contents = inp.read()
types = re.findall(re_match_type,contents) types = re.findall(re_match_type,contents)

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -46,6 +46,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#include <assimp/material.h>
#include <assimp/scene.h>
#include <assimp/types.h>
using namespace Assimp; using namespace Assimp;
@ -67,3 +70,30 @@ TEST_F( utFBXImporterExporter, importBareBoxWithoutColorsAndTextureCoords ) {
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/box.fbx", aiProcess_ValidateDataStructure ); const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/box.fbx", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene ); EXPECT_NE( nullptr, scene );
} }
TEST_F( utFBXImporterExporter, importPhongMaterial ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/phong_cube.fbx", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
EXPECT_EQ( (unsigned int)1, scene->mNumMaterials );
const aiMaterial *mat = scene->mMaterials[0];
EXPECT_NE( nullptr, mat );
float f; aiColor3D c;
// phong_cube.fbx has all properties defined
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_DIFFUSE, c), aiReturn_SUCCESS );
EXPECT_EQ( c, aiColor3D(0.5, 0.25, 0.25) );
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_SPECULAR, c), aiReturn_SUCCESS );
EXPECT_EQ( c, aiColor3D(0.25, 0.25, 0.5) );
EXPECT_EQ( mat->Get(AI_MATKEY_SHININESS_STRENGTH, f), aiReturn_SUCCESS );
EXPECT_EQ( f, 0.5 );
EXPECT_EQ( mat->Get(AI_MATKEY_SHININESS, f), aiReturn_SUCCESS );
EXPECT_EQ( f, 10.0 );
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_AMBIENT, c), aiReturn_SUCCESS );
EXPECT_EQ( c, aiColor3D(0.125, 0.25, 0.25) );
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_EMISSIVE, c), aiReturn_SUCCESS );
EXPECT_EQ( c, aiColor3D(0.25, 0.125, 0.25) );
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_TRANSPARENT, c), aiReturn_SUCCESS );
EXPECT_EQ( c, aiColor3D(0.75, 0.5, 0.25) );
EXPECT_EQ( mat->Get(AI_MATKEY_OPACITY, f), aiReturn_SUCCESS );
EXPECT_EQ( f, 0.5 );
}