FIX: IrrMesh lightmap scale factor is imported correctly now.

FIX: aiProcess_TransformUVCoords tried to transform untransformed channels, and 'he' changed their order from time to time.
FIX: Viewer displays lightmap with scaling factor correctly now.
Further work on documentation, material doc is WIP for the moment.
Some improvements to fast_atof.
Updating makeifle.mingw to reflect my new boost location (arg, too lazy to make it better ...). 

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@413 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2009-05-03 21:49:34 +00:00
parent afcfdf27ea
commit 25088fd7da
11 changed files with 511 additions and 653 deletions

View File

@ -50,42 +50,35 @@ inline void SetGenericProperty(std::map< unsigned int, T >& list,
const char* szName, const T& value, bool* bWasExisting = NULL)
{
ai_assert(NULL != szName);
const uint32_t hash = SuperFastHash(szName);
typedef std::map< unsigned int, T > GenericPropertyMap;
typedef std::pair< unsigned int, T > GenericPair;
uint32_t hash = SuperFastHash(szName);
typename GenericPropertyMap::iterator it = list.find(hash);
if (it == list.end())
{
if (bWasExisting)*bWasExisting = false;
list.insert(GenericPair( hash, value ));
typename std::map<unsigned int, T>::iterator it = list.find(hash);
if (it == list.end()) {
if (bWasExisting)
*bWasExisting = false;
list.insert(std::pair<unsigned int, T>( hash, value ));
return;
}
(*it).second = value;
if (bWasExisting)*bWasExisting = true;
if (bWasExisting)
*bWasExisting = true;
}
// ------------------------------------------------------------------------------------------------
template <class T>
inline const T& GetGenericProperty(const std::map< unsigned int, T >& list,
const char* szName, const T& errorReturn)
{
ai_assert(NULL != szName);
const uint32_t hash = SuperFastHash(szName);
typedef std::map< unsigned int, T > GenericPropertyMap;
typedef std::pair< unsigned int, T > GenericPair;
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
if (it == list.end())
return errorReturn;
uint32_t hash = SuperFastHash(szName);
typename GenericPropertyMap::const_iterator it = list.find(hash);
if (it == list.end())return errorReturn;
return (*it).second;
}
// ------------------------------------------------------------------------------------------------
// Special version for pointer types - they will be deleted when replaced with another value
// passing NULL removes the whole property
@ -94,29 +87,25 @@ inline void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
const char* szName, T* value, bool* bWasExisting = NULL)
{
ai_assert(NULL != szName);
const uint32_t hash = SuperFastHash(szName);
typedef std::map< unsigned int, T* > GenericPropertyMap;
typedef std::pair< unsigned int, T* > GenericPair;
typename std::map<unsigned int, T*>::iterator it = list.find(hash);
if (it == list.end()) {
if (bWasExisting)
*bWasExisting = false;
uint32_t hash = SuperFastHash(szName);
typename GenericPropertyMap::iterator it = list.find(hash);
if (it == list.end())
{
if (bWasExisting)*bWasExisting = false;
list.insert(GenericPair( hash, value ));
list.insert(std::pair<unsigned int,T*>( hash, value ));
return;
}
if ((*it).second != value)
{
if ((*it).second != value) {
delete (*it).second;
(*it).second = value;
}
if (!value)
{
if (!value) {
list.erase(it);
}
if (bWasExisting)*bWasExisting = true;
if (bWasExisting)
*bWasExisting = true;
}

View File

@ -210,6 +210,7 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags)
matFlags = 0; // zero output flags
int cnt = 0; // number of used texture channels
unsigned int nd = 0;
// Continue reading from the file
while (reader->read())
@ -363,7 +364,7 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags)
s.Set(prop.value);
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(0));
}
else if (prop.name == "Texture2")
else if (prop.name == "Texture2" && cnt == 1)
{
// 2-layer material lightmapped?
if (matFlags & AI_IRRMESH_MAT_lightmap) {
@ -388,25 +389,27 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags)
++cnt;
s.Set(prop.value);
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(1));
++nd;
// set the corresponding material flag
matFlags |= AI_IRRMESH_EXTRA_2ND_TEXTURE;
}
else DefaultLogger::get()->warn("IRRmat: Skipping second texture");
}
else if (prop.name == "Texture3")
else if (prop.name == "Texture3" && cnt == 2)
{
// Irrlicht does not seem to use these channels.
++cnt;
s.Set(prop.value);
mat->AddProperty(&s,AI_MATKEY_TEXTURE_UNKNOWN(0));
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(nd+1));
}
else if (prop.name == "Texture4" )
else if (prop.name == "Texture4" && cnt == 3)
{
// Irrlicht does not seem to use these channels.
++cnt;
s.Set(prop.value);
mat->AddProperty(&s,AI_MATKEY_TEXTURE_UNKNOWN(1));
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(nd+2));
}
// Texture mapping options
@ -435,14 +438,14 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags)
else if (prop.name == "TextureWrap3" && cnt >= 3)
{
int map = ConvertMappingMode(prop.value);
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_UNKNOWN(0));
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_UNKNOWN(0));
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_DIFFUSE(nd+1));
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_DIFFUSE(nd+1));
}
else if (prop.name == "TextureWrap4" && cnt >= 4)
{
int map = ConvertMappingMode(prop.value);
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_UNKNOWN(1));
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_UNKNOWN(1));
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_DIFFUSE(nd+2));
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_DIFFUSE(nd+2));
}
}
}
@ -455,25 +458,24 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags)
/* IRR */ !ASSIMP_stricmp(reader->getNodeName(),"attributes"))
{
// Now process lightmapping flags
// We should have at least one texture, however
// if there are multiple textures we assign the
// lightmap settings to the last texture.
// We should have at least one textur to do that ..
if (cnt && matFlags & AI_IRRMESH_MAT_lightmap)
{
float f = 1.f;
unsigned int unmasked = matFlags&~AI_IRRMESH_MAT_lightmap;
// Additive lightmap?
int op = (matFlags & AI_IRRMESH_MAT_lightmap_add
int op = (unmasked & AI_IRRMESH_MAT_lightmap_add
? aiTextureOp_Add : aiTextureOp_Multiply);
// Handle Irrlicht's lightmapping scaling factor
if (matFlags & AI_IRRMESH_MAT_lightmap_m2 ||
matFlags & AI_IRRMESH_MAT_lightmap_light_m2)
if (unmasked & AI_IRRMESH_MAT_lightmap_m2 ||
unmasked & AI_IRRMESH_MAT_lightmap_light_m2)
{
f = 2.f;
}
else if (matFlags & AI_IRRMESH_MAT_lightmap_m4 ||
matFlags & AI_IRRMESH_MAT_lightmap_light_m4)
else if (unmasked & AI_IRRMESH_MAT_lightmap_m4 ||
unmasked & AI_IRRMESH_MAT_lightmap_light_m4)
{
f = 4.f;
}

View File

@ -101,8 +101,7 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
{
out -= rounded*(float)AI_MATH_PI;
sprintf(szTemp,"Texture coordinate rotation %f can "
"be simplified to %f",info.mRotation,out);
sprintf(szTemp,"Texture coordinate rotation %f can be simplified to %f",info.mRotation,out);
DefaultLogger::get()->info(szTemp);
}
@ -120,36 +119,29 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
* type (e.g. if mirroring is active there IS a difference between
* offset 2 and 3)
*/
if ((rounded = (int)info.mTranslation.x))
{
if ((rounded = (int)info.mTranslation.x)) {
float out;
szTemp[0] = 0;
if (aiTextureMapMode_Wrap == info.mapU)
{
if (aiTextureMapMode_Wrap == info.mapU) {
// Wrap - simple take the fraction of the field
out = info.mTranslation.x-(float)rounded;
sprintf(szTemp,"[w] UV U offset %f can "
"be simplified to %f",info.mTranslation.x,out);
sprintf(szTemp,"[w] UV U offset %f can be simplified to %f",info.mTranslation.x,out);
}
else if (aiTextureMapMode_Mirror == info.mapU && 1 != rounded)
{
else if (aiTextureMapMode_Mirror == info.mapU && 1 != rounded) {
// Mirror
if (rounded % 2)rounded--;
if (rounded % 2)
rounded--;
out = info.mTranslation.x-(float)rounded;
sprintf(szTemp,"[m/d] UV U offset %f can "
"be simplified to %f",info.mTranslation.x,out);
sprintf(szTemp,"[m/d] UV U offset %f can be simplified to %f",info.mTranslation.x,out);
}
else if (aiTextureMapMode_Clamp == info.mapU || aiTextureMapMode_Decal == info.mapU)
{
else if (aiTextureMapMode_Clamp == info.mapU || aiTextureMapMode_Decal == info.mapU) {
// Clamp - translations beyond 1,1 are senseless
sprintf(szTemp,"[c] UV U offset %f can "
"be clamped to 1.0f",info.mTranslation.x);
sprintf(szTemp,"[c] UV U offset %f can be clamped to 1.0f",info.mTranslation.x);
out = 1.f;
}
if (szTemp[0])
{
if (szTemp[0]) {
DefaultLogger::get()->info(szTemp);
info.mTranslation.x = out;
}
@ -160,36 +152,29 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
* type (e.g. if mirroring is active there IS a difference between
* offset 2 and 3)
*/
if ((rounded = (int)info.mTranslation.y))
{
if ((rounded = (int)info.mTranslation.y)) {
float out;
szTemp[0] = 0;
if (aiTextureMapMode_Wrap == info.mapV)
{
if (aiTextureMapMode_Wrap == info.mapV) {
// Wrap - simple take the fraction of the field
out = info.mTranslation.y-(float)rounded;
sprintf(szTemp,"[w] UV V offset %f can "
"be simplified to %f",info.mTranslation.y,out);
sprintf(szTemp,"[w] UV V offset %f can be simplified to %f",info.mTranslation.y,out);
}
else if (aiTextureMapMode_Mirror == info.mapV && 1 != rounded)
{
else if (aiTextureMapMode_Mirror == info.mapV && 1 != rounded) {
// Mirror
if (rounded % 2)rounded--;
if (rounded % 2)
rounded--;
out = info.mTranslation.x-(float)rounded;
sprintf(szTemp,"[m/d] UV V offset %f can "
"be simplified to %f",info.mTranslation.y,out);
sprintf(szTemp,"[m/d] UV V offset %f can be simplified to %f",info.mTranslation.y,out);
}
else if (aiTextureMapMode_Clamp == info.mapV || aiTextureMapMode_Decal == info.mapV)
{
else if (aiTextureMapMode_Clamp == info.mapV || aiTextureMapMode_Decal == info.mapV) {
// Clamp - translations beyond 1,1 are senseless
sprintf(szTemp,"[c] UV V offset %f can"
"be clamped to 1.0f",info.mTranslation.y);
sprintf(szTemp,"[c] UV V offset %f canbe clamped to 1.0f",info.mTranslation.y);
out = 1.f;
}
if (szTemp[0])
{
if (szTemp[0]) {
DefaultLogger::get()->info(szTemp);
info.mTranslation.y = out;
}
@ -201,9 +186,7 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
void UpdateUVIndex(const std::list<TTUpdateInfo>& l, unsigned int n)
{
// Don't set if == 0 && wasn't set before
for (std::list<TTUpdateInfo>::const_iterator it = l.begin();
it != l.end(); ++it)
{
for (std::list<TTUpdateInfo>::const_iterator it = l.begin();it != l.end(); ++it) {
const TTUpdateInfo& info = *it;
if (info.directShortcut)
@ -241,14 +224,13 @@ void TextureTransformStep::Execute( aiScene* pScene)
typedef std::list<STransformVecInfo> MeshTrafoList;
std::vector<MeshTrafoList> meshLists(pScene->mNumMeshes);
for (unsigned int i = 0; i < pScene->mNumMaterials;++i)
{
for (unsigned int i = 0; i < pScene->mNumMaterials;++i) {
aiMaterial* mat = pScene->mMaterials[i];
for (unsigned int a = 0; a < mat->mNumProperties;++a)
{
for (unsigned int a = 0; a < mat->mNumProperties;++a) {
aiMaterialProperty* prop = mat->mProperties[a];
if (!::strcmp( prop->mKey.data, "$tex.file"))
{
if (!::strcmp( prop->mKey.data, "$tex.file")) {
STransformVecInfo info;
// Setup a shortcut structure to allow for a fast updating
@ -313,15 +295,14 @@ void TextureTransformStep::Execute( aiScene* pScene)
// Find out whether this material is used by more than
// one mesh. This will make our task much, much more difficult!
unsigned int cnt = 0;
for (unsigned int n = 0; n < pScene->mNumMeshes;++n)
{
for (unsigned int n = 0; n < pScene->mNumMeshes;++n) {
if (pScene->mMeshes[n]->mMaterialIndex == i)
++cnt;
}
if (!cnt)continue;
else if (1 != cnt)
{
if (!cnt)
continue;
else if (1 != cnt) {
// This material is referenced by more than one mesh!
// So we need to make sure the UV index for the texture
// is identical for each of it ...
@ -329,16 +310,14 @@ void TextureTransformStep::Execute( aiScene* pScene)
}
// Get all coresponding meshes
for (unsigned int n = 0; n < pScene->mNumMeshes;++n)
{
for (unsigned int n = 0; n < pScene->mNumMeshes;++n) {
aiMesh* mesh = pScene->mMeshes[n];
if (mesh->mMaterialIndex != i || !mesh->mTextureCoords[0]) continue;
if (mesh->mMaterialIndex != i || !mesh->mTextureCoords[0])
continue;
unsigned int uv = info.uvIndex;
if (!mesh->mTextureCoords[uv])
{
// If the requested UV index is not available,
// take the first one instead.
if (!mesh->mTextureCoords[uv]) {
// If the requested UV index is not available, take the first one instead.
uv = 0;
}
@ -350,15 +329,15 @@ void TextureTransformStep::Execute( aiScene* pScene)
MeshTrafoList::iterator it;
// Check whether we have this transform setup already
for (it = meshLists[n].begin();it != meshLists[n].end(); ++it)
{
for (it = meshLists[n].begin();it != meshLists[n].end(); ++it) {
if ((*it) == info && (*it).uvIndex == uv) {
(*it).updateList.push_back(update);
break;
}
}
if (it == meshLists[n].end())
{
if (it == meshLists[n].end()) {
meshLists[n].push_back(info);
meshLists[n].back().uvIndex = uv;
meshLists[n].back().updateList.push_back(update);
@ -373,66 +352,67 @@ void TextureTransformStep::Execute( aiScene* pScene)
// Now process all meshes. Important: we don't remove unreferenced UV channels.
// This is a job for the RemoveUnreferencedData-Step.
for (unsigned int q = 0; q < pScene->mNumMeshes;++q)
{
for (unsigned int q = 0; q < pScene->mNumMeshes;++q) {
aiMesh* mesh = pScene->mMeshes[q];
MeshTrafoList& trafo = meshLists[q];
inChannels += mesh->GetNumUVChannels();
if (!mesh->mTextureCoords[0] || trafo.empty() ||
trafo.size() == 1 && trafo.begin()->IsUntransformed())
{
if (!mesh->mTextureCoords[0] || trafo.empty() || trafo.size() == 1 && trafo.begin()->IsUntransformed()) {
outChannels += mesh->GetNumUVChannels();
continue;
}
// Move untransformed UV channels to the first
// position in the list .... except if we need
// a new locked index which should be as small as possible
bool veto = false;
// Move untransformed UV channels to the first position in the list ....
// except if we need a new locked index which should be as small as possible
bool veto = false, need = false;
unsigned int cnt = 0;
unsigned int untransformed = 0;
MeshTrafoList::iterator it,it2;
for (it = trafo.begin();it != trafo.end(); ++it,++cnt)
{
if ((*it).lockedPos == AI_TT_UV_IDX_LOCK_TBD)
{
for (it = trafo.begin(), it2;it != trafo.end(); ++it,++cnt) {
if (!(*it).IsUntransformed())
need = true;
if ((*it).lockedPos == AI_TT_UV_IDX_LOCK_TBD) {
// Lock this index and make sure it won't be changed
(*it).lockedPos = cnt;
veto = true;
continue;
}
if (!veto && it != trafo.begin() && (*it).IsUntransformed())
{
trafo.push_front((*it));
if (!veto && it != trafo.begin() && (*it).IsUntransformed()) {
for (it2 = trafo.begin();it2 != it; ++it2) {
if (!(*it2).IsUntransformed())
break;
}
trafo.insert(it2,*it);
trafo.erase(it);
break;
}
}
if (!need)
continue;
// Find all that are not at their 'locked' position
// and move them to it. Conflicts are possible but
// quite unlikely.
// Find all that are not at their 'locked' position and move them to it.
// Conflicts are possible but quite unlikely.
cnt = 0;
for (it = trafo.begin();it != trafo.end(); ++it,++cnt)
{
if ((*it).lockedPos != AI_TT_UV_IDX_LOCK_NONE && (*it).lockedPos != cnt)
{
for (it = trafo.begin();it != trafo.end(); ++it,++cnt) {
if ((*it).lockedPos != AI_TT_UV_IDX_LOCK_NONE && (*it).lockedPos != cnt) {
it2 = trafo.begin();unsigned int t = 0;
while (t != (*it).lockedPos)++it2;
while (t != (*it).lockedPos)
++it2;
if ((*it2).lockedPos != AI_TT_UV_IDX_LOCK_NONE)
{
DefaultLogger::get()->error("Channel mismatch, can't compute all transformations properly");
if ((*it2).lockedPos != AI_TT_UV_IDX_LOCK_NONE) {
DefaultLogger::get()->error("Channel mismatch, can't compute all transformations properly [design bug]");
continue;
}
std::swap(*it2,*it);
if ((*it).lockedPos == untransformed)untransformed = cnt;
if ((*it).lockedPos == untransformed)
untransformed = cnt;
}
}
@ -445,9 +425,9 @@ void TextureTransformStep::Execute( aiScene* pScene)
for (it = trafo.begin();it != trafo.end(); ++it)
ref[(*it).uvIndex] = true;
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n)
{
if (ref[n])continue;
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
if (ref[n])
continue;
trafo.push_back(STransformVecInfo());
trafo.back().uvIndex = n;
}
@ -456,10 +436,9 @@ void TextureTransformStep::Execute( aiScene* pScene)
// The unimportant ones are at the end of the list, so
// it shouldn't be too worse if we remove them.
unsigned int size = (unsigned int)trafo.size();
if (size > AI_MAX_NUMBER_OF_TEXTURECOORDS)
{
if (!DefaultLogger::isNullLogger())
{
if (size > AI_MAX_NUMBER_OF_TEXTURECOORDS) {
if (!DefaultLogger::isNullLogger()) {
::sprintf(buffer,"%i UV channels required but just %i available",
trafo.size(),AI_MAX_NUMBER_OF_TEXTURECOORDS);
@ -476,10 +455,9 @@ void TextureTransformStep::Execute( aiScene* pScene)
// Now continue and generate the output channels. Channels
// that we're not going to need later can be overridden.
it = trafo.begin();
for (unsigned int n = 0; n < trafo.size();++n,++it)
{
if (n >= size)
{
for (unsigned int n = 0; n < trafo.size();++n,++it) {
if (n >= size) {
// Try to use an untransformed channel for all channels we threw over board
UpdateUVIndex((*it).updateList,untransformed);
continue;
@ -488,8 +466,7 @@ void TextureTransformStep::Execute( aiScene* pScene)
outChannels++;
// Write to the log
if (!DefaultLogger::isNullLogger())
{
if (!DefaultLogger::isNullLogger()) {
sprintf(buffer,"Mesh %i, channel %i: t(%.3f,%.3f), s(%.3f,%.3f), r(%.3f), %s%s",
q,n,
(*it).mTranslation.x,
@ -504,11 +481,11 @@ void TextureTransformStep::Execute( aiScene* pScene)
}
// Check whether we need a new buffer here
if (mesh->mTextureCoords[n])
{
if (mesh->mTextureCoords[n]) {
it2 = it;++it2;
for (unsigned int m = n+1; m < size;++m, ++it2)
{
for (unsigned int m = n+1; m < size;++m, ++it2) {
if ((*it2).uvIndex == n){
it2 = trafo.begin();
break;
@ -533,11 +510,11 @@ void TextureTransformStep::Execute( aiScene* pScene)
end = dest + mesh->mNumVertices;
// Build a transformation matrix and transform all UV coords with it
if (!(*it).IsUntransformed())
{
if (!(*it).IsUntransformed()) {
const aiVector2D& trl = (*it).mTranslation;
const aiVector2D& scl = (*it).mScaling;
// fixme: simplify ..
++transformedChannels;
aiMatrix3x3 matrix;
@ -555,7 +532,7 @@ void TextureTransformStep::Execute( aiScene* pScene)
m5.a3 += trl.x; m5.b3 += trl.y;
matrix = m2 * m4 * matrix * m3 * m5;
for (src = dest; src != end; ++src) {
for (src = dest; src != end; ++src) { /* manual homogenious divide */
src->z = 1.f;
*src = matrix * *src;
src->x /= src->z;
@ -570,10 +547,9 @@ void TextureTransformStep::Execute( aiScene* pScene)
}
// Print some detailled statistics into the log
if (!DefaultLogger::isNullLogger())
{
if (transformedChannels)
{
if (!DefaultLogger::isNullLogger()) {
if (transformedChannels) {
::sprintf(buffer,"TransformUVCoordsProcess end: %i output channels (in: %i, modified: %i)",
outChannels,inChannels,transformedChannels);

View File

@ -141,11 +141,14 @@ inline uint8_t HexOctetToDecimal(const char* in)
// ------------------------------------------------------------------------------------
inline int strtol10s( const char* in, const char** out=0)
{
bool bNeg = false;
if ('-' == *in){++in;bNeg = true;}
if ('+' == *in)++in;
bool inv = (*in=='-');
if (inv || *in=='+')
++in;
int value = strtol10(in,out);
if (bNeg)value = -value;
if (inv) {
value = -value;
}
return value;
}
@ -218,14 +221,13 @@ inline uint64_t strtol10_64( const char* in, const char** out=0, unsigned int* m
// ------------------------------------------------------------------------------------
inline const char* fast_atof_move( const char* c, float& out)
{
const char *t;
float f;
bool inv = (*c=='-');
if (inv || *c=='+')
++c;
f = (float) strtol10_64 ( c, &c );
f = (float) strtol10_64 ( c, &c);
if (*c == '.' || (c[0] == ',' && (c[1] >= '0' || c[1] <= '9'))) // allow for commas, too
{
++c;
@ -239,12 +241,10 @@ inline const char* fast_atof_move( const char* c, float& out)
// number of digits to be read. AI_FAST_ATOF_RELAVANT_DECIMALS can be a value between
// 1 and 15.
unsigned int diff = AI_FAST_ATOF_RELAVANT_DECIMALS;
double pl = (double) strtol10_64 ( c, &t, &diff );
double pl = (double) strtol10_64 ( c, &c, &diff );
pl *= fast_atof_table[diff];
f += (float)pl;
c = t;
}
// A major 'E' must be allowed. Necessary for proper reading of some DXF files.
@ -256,7 +256,7 @@ inline const char* fast_atof_move( const char* c, float& out)
if (einv || *c=='+')
++c;
float exp = (float)strtol10(c, &c);
float exp = (float)strtol10_64(c, &c);
if (einv)
exp *= -1.0f;

View File

@ -48,7 +48,8 @@ ifeq ($(NOBOOST),1)
DEFINEFLAGS += -DASSIMP_BUILD_BOOST_WORKAROUND
# NAMESUFFIX += -noboost
else
INCLUDEFLAGS += -I"C:/Program Files/boost/boost_1_35_0"
# adjust this manually if your boost is stored elsewhere
INCLUDEFLAGS += -I"C:/Program Files/boost/boost_1_38"
endif
# Setup environment for st build

Binary file not shown.

519
doc/dox.h
View File

@ -664,173 +664,7 @@ the bone information is described later on.
@section material Materials
All materials are stored in an array of aiMaterial inside the aiScene. Each aiMesh refers to one
material by its index in the array. Due to the vastly diverging definitions and usages of material
parameters there is no hard definition of a material structure. Instead a material is defined by
a set of properties accessible by their names. Have a look at aiMaterial.h to see what types of
properties are defined. In this file there are also various functions defined to test for the
presence of certain properties in a material and retrieve their values.
Example to convert from an ASSIMP material to a Direct3D 9 material for use with the fixed
function pipeline. Textures are not handled, only colors and the specular power, sometimes
also refered to as "shininess":
@code
void ConvertColor ( const aiColor4D& clrIn, D3DCOLORVALUE& clrOut )
{
clrOut.r = clrIn.r;
clrOut.g = clrIn.g;
clrOut.b = clrIn.b;
clrOut.a = clrIn.a;
}
void ConvertMaterial( aiMaterial* matIn, D3DMATERIAL9* matOut )
{
// ***** DIFFUSE MATERIAL COLOR
aiColor4D clr(0.0f,0.0f,0.0f,1.0f);
// if the material property is not existing, the passed color pointer
// won't be modified, therefore the diffuse color would be BLACK in this case
aiGetMaterialColor(matIn,AI_MATKEY_COLOR_DIFFUSE,&clr);
ConvertColor ( clr, matOut.Diffuse );
// ***** SPECULAR MATERIAL COLOR
clr = aiColor4D(1.0f,1.0f,1.0f,1.0f);
aiGetMaterialColor(matIn,AI_MATKEY_COLOR_SPECULAR,&clr);
ConvertColor ( clr, matOut.Specular );
// ***** AMBIENT MATERIAL COLOR
clr = aiColor4D(0.0f,0.0f,0.0f,1.0f);
aiGetMaterialColor(matIn,AI_MATKEY_COLOR_AMBIENT,&clr);
ConvertColor ( clr, matOut.Ambient );
// ***** EMISIVE MATERIAL COLOR (Self illumination)
clr = aiColor4D(0.0f,0.0f,0.0f,1.0f);
aiGetMaterialColor(matIn,AI_MATKEY_COLOR_EMISSIVE,&clr);
ConvertColor ( clr, matOut.Emissive );
// ***** SHININESS (Phong power)
matOut.Power = 0.0f;
aiGetMaterialFloat(matIn,AI_MATKEY_COLOR_EMISSIVE,&matOut.Power);
}
@endcode
Textures:
Textures can have various types and intended purposes. Sometimes ASSIMP is not able to
determine the exact designated use of a texture. Normally it will assume a texture to be
a diffuse color map by default. Texture types:
<b>1. Diffuse textures.</b> Diffuse textures are combined with the result of the diffuse lighting term.
<br>
<b>2. Specular textures.</b> Specular textures are combined with the result of the specular lighting term.
Generally speaking, they can be used to map a texture onto specular highlights.
<br>
<b>3. Ambient textures.</b> Ambient textures are combined with the result of the ambient lighting term.
<br>
<b>4. Emissive textures.</b> Emissive textures are combined with the emissive base color of the material.
The result is then added to the final pixel color. Emissive textures are sometimes called
"Self ilumination maps".
<br>
<b>5. Opacity textures.</b> Opacity textures specify the opacity of a texel. They are
normally grayscale images, black stands for fully transparent, white for fully opaque.
<br>
<b>6. Height maps.</b> Height maps specify the relative height of a point on a triangle on a
per-texel base. Normally height maps (sometimes called "Bump maps") are converted to normal
maps before rendering. Height maps are normally grayscale textures. Height maps could also
be used as displacement maps on highly tesselated surfaces.
<br>
<b>7. Normal maps.</b> Normal maps contain normal vectors for a single texel, in tangent space.
They are not bound to an object. However, all lighting computations must be done in tangent space.
There are many resources on Normal Mapping on the internet.
<br>
<b>8. Shininess maps</b> Shininess maps (sometimes called "Gloss" or "SpecularMap") specify
the shininess of a texel mapped on a surface. They are normally used together with normal maps
to make flat surfaces look as if they were real 3d objects.
<br>
Textures are generally defined by a set of parameters including
<br>
<b>1. The path to the texture.</b> This property is always set. If it is not set, a texture
is not existing. This can either be a valid path (beware, sometimes
it could be a 8.3 file name!) or an asterisk (*) suceeded by a zero-based index, the latter being
a reference to an embedded texture (see the "Textures" section for more details). I suggest using code
like this to find out whether a texture is embedded or not:
@code
aiString path; // contains the path obtained via aiGetMaterialString()
const aiScene* scene; // valid aiScene instance
const char* szData = path.data;
if ('*' == *szData)
{
int index = atoi(szData+1);
ai_assert(index < scene->mNumTextures);
// your loading code for loading from aiTexture's ...
}
else // your loading code to load from a path ...
@endcode
<br>
<b>2. An UV coordinate index.</b> This is an index into the UV coordinate set list of the
corresponding mesh. Note: Some formats don't define this, so beware, it could be that
a second diffuse texture in a mesh was originally intended to use a second UV channel although
ASSIMP says it uses the first one. UV coordinate source indices are defined by the
<i>AI_MATKEY_UVWSRC_&lt;textype&gt;(&lt;texindex&gt;)</i> material property. Assume 0 as default value if
this property is not set.
<br>
<b>3. A blend factor.</b> This is used if multiple textures are assigned to a slot, e.g. two
or more textures on the diffuse channel. A texture's color value is multiplied with its
blend factor before it is combined with the previous color value (from the last texture or the
diffuse/specular/ambient/emissive base color) using
a blend operation (see 4.). Blend factor are defined by the
<i>AI_MATKEY_TEXBLEND_&lt;textype&gt;(&lt;texindex&gt;)</i> material property. Assume 1.0f as default value
if this property is not set.
<br>
<b>4. A blend operation.</b> This is used if multiple textures are assigned to a slot, e.g. two
or more textures on the diffuse channel. After a texture's color value has been multiplied
with its blend factor, the blend operation is used to combine it with the previous color value
(from the last texture or the diffuse/specular/ambient/emissive base color).
Blend operations are stored as integer property, however their type is aiTextureOp.
Blend factor are defined by the <i>AI_TEXOP_BLEND_&lt;textype&gt;(&lt;texindex&gt;)</i> material property. Assume
aiTextureOp_Multiply as default value if this property is not set.
<br>
<b>5. Mapping modes for all axes </b> The mapping mode for an axis specifies how the rendering
system should deal with UV coordinates beyond the 0-1 range. Mapping modes are
defined by the <i>AI_MATKEY_MAPPINGMODE_&lt;axis&gt;_&lt;textype&gt;(&lt;texindex&gt;)</i> material property.
&lt;axis&gt; is either U,V or W. The data type is int, however the real type is aiTextureMapMode.
The default value is aiTextureMapMode_Wrap.
You can use the aiGetMaterialTexture() function to read all texture parameters at once (maybe
if you're too lazy to read 4 or 5 values manually if there's a smart helper function
doing all the work for you ...).
@code
if (AI_SUCCESS != aiGetMaterialTexture(
pcMat, // aiMaterial structure
0, // we want the first diffuse texture
AI_TEXTYPE_DIFFUSE, // we want the first diffuse texture
&path, // receives the path of the texture
&uv, // receives the UV index of the texture
&blend, // receives the blend factor of the texture
&op, // receives the blend operation of the texture
&mmodes, // receives an array of three aiMappingMode's, each specifying
// the mapping mode for a particular axis. Order: UV(W)
// (you may also specify 0 for a parameter if you don't need it)
))
{
// cry, jump out of the window, but don't take drugs if this occurs!
}
@endcode
<br>
As you can see, there's much undefined and subject to speculations. When implementing
ASSIMP's material system the most important point was to keep it as flexible as possible.
The first step you should do when you implement ASSIMP materials into your application is
to make a list of all material properties your rendering engine supports, too. Then I suggest
you to take a look at the remaining material properties: many of them can be simplified and replaced
with other properties, e.g. a diffuse texture blend factor can often be premultiplied
with the diffuse base color! At last a few properties you do not support will remain. Forget them.
Most models won't look worse if only small details of its material cannot be rendered as it was intended
by the artist.
See the @link materials Material System Page. @endlink
@section bones Bones
@ -895,7 +729,6 @@ If you need hints on how to convert to or from quaternions, have a look at the
using logarithmic interpolation for the scaling keys if you happen to need them - usually you don't
need them at all.
@section textures Textures
Normally textures used by assets are stored in separate files, however,
@ -922,6 +755,356 @@ containing the file extension of the format of the embedded texture. This is onl
set if ASSIMP is able to determine the file format.
*/
/**
@page materials Material System
@section General Overview
THIS SECTION IS NOT YET COMPLETE AND WIP!<br>
All materials are stored in an array of aiMaterial inside the aiScene.
Each aiMesh refers to one
material by its index in the array. Due to the vastly diverging definitions and usages of material
parameters there is no hard definition of a material structure. Instead a material is defined by
a set of properties accessible by their names. Have a look at aiMaterial.h to see what types of
properties are defined. In this file there are also various functions defined to test for the
presence of certain properties in a material and retrieve their values.
@section keys Constants
All material key constants start with 'AI_MATKEY' (it's an ugly macro for historical reasons, don't ask).
<table border="1">
<tr>
<th>Name</th>
<th>Data Type</th>
<th>Default Value</th>
<th>Meaning</th>
<th>Notes</th>
</tr>
<tr>
<td><tt>NAME</tt></td>
<td>aiString</td>
<td>n/a</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>
</tr>
<tr>
<td><tt>COLOR_DIFFUSE</tt></td>
<td>aiColor3D</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>---</td>
</tr>
<tr>
<td><tt>COLOR_SPECULAR</tt></td>
<td>aiColor3D</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>---</td>
</tr>
<tr>
<td><tt>COLOR_AMBIENT</tt></td>
<td>aiColor3D</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>---</td>
</tr>
<tr>
<td><tt>COLOR_EMISSIVE</tt></td>
<td>aiColor3D</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>---</tt></td>
</tr>
<tr>
<td><tt>COLOR_TRANSPARENT</tt></td>
<td>aiColor3D</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
translucent light to construct the final 'destination color' for a particular position in the screen buffer. T </td>
<td>---</tt></td>
</tr>
<tr>
<td><tt>WIREFRAME</tt></td>
<td>int</td>
<td>false</td>
<td>Specifies whether wireframe rendering must be turned on for the material. 0 for false, !0 for true. </td>
<td>---</tt></td>
</tr>
<tr>
<td><tt>TWOSIDED</tt></td>
<td>int</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>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>
<td><tt>SHADING_MODEL</tt></td>
<td>int</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>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>
<td><tt>BLEND_FUNC</tt></td>
<td>int</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>-</td>
</tr>
<tr>
<td><tt>OPACITY</tt></td>
<td>float</td>
<td>1.0</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>
</tr>
<tr>
<td><tt>SHININESS</tt></td>
<td>float</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><tt>SHININESS</tt>=0 is equivalent to <tt>SHADING_MODEL</tt>=<tt>aiShadingMode_Gouraud</tt>.</td>
</tr>
<tr>
<td><tt>SHININESS_STRENGTH</tt></td>
<td>float</td>
<td>1.0</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>
</tr>
<tr>
<td><tt>REFRACTI</tt></td>
<td>float</td>
<td>1.0</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>
</tr>
<tr>
<td><tt>TEXTURE(t,n)</tt></td>
<td>aiString</td>
<td>n/a</td>
<td>Defines the path to the n'th texture on the stack 't', where 'n' is any value >= 0 and 't' is one of the #aiTextureType enumerated values.</td>
<td>See the 'Textures' section below.</td>
</tr>
</table>
@section cpp C++-API
Retrieving a property from a material is done using various utility functions. For C++ it's simply calling aiMaterial::Get()
@code
aiMaterial* mat = .....
// The generic way
if(AI_SUCCESS != mat->Get(<material-key>,<where-to-store>)) {
// handle epic failure here
}
@endcode
Simple, isn't it? To get the name of a material you would use
@code
aiString name;
mat->Get(AI_MATKEY_NAME,name);
@endcode
Or for the diffuse color ('color' won't be modified if the property is not set)
@code
aiColor3D color (0.f,0.f,0.f);
mat->Get(AI_MATKEY_COLOR_DIFFUSE,color);
@endcode
<b>Note:</b> Get() is actually a template with explicit specializations for aiColor3D, aiColor4D, aiString, float, int and some others.
Make sure that the type of the second parameter is matching the expected data type of the material property (no compile-time check yet!).
Don't follow this advice if you wish to encounter very strange results.
@section C C-API
For good old C it's slightly different. Take a look at the aiGetMaterialGet<data-type> functions.
@code
aiMaterial* mat = .....
if(AI_SUCCESS != aiGetMaterialFloat(mat,<material-key>,<where-to-store>)) {
// handle epic failure here
}
@endcode
To get the name of a material you would use
@code
aiString name;
aiGetMaterialString(mat,AI_MATKEY_NAME,&name);
@endcode
Or for the diffuse color ('color' won't be modified if the property is not set)
@code
aiColor3D color (0.f,0.f,0.f);
aiGetMaterialColor(mat,AI_MATKEY_COLOR_DIFFUSE,&color);
@endcode
@section pseudo Pseudo Code Listing
For completeness, the following is a very rough pseudo-code sample showing how to evaluate Assimp materials in your
shading pipeline. You'll probably want to limit your handling of all those material keys to a reasonable subset suitable for your purposes
(for example most 3d engines won't support highly complex multi-layer materials, but many 3d modellers do).
Also note that this sample is targeted at a (shader-based) rendering pipeline for real time graphics.
INCOMPLETE! WIP!
@code
// ---------------------------------------------------------------------------------------
// Evaluate multiple textures stacked on top of each other
float3 EvaluateStack(stack)
{
// For the 'diffuse' stack stack.base_color would be COLOR_DIFFUSE
// and TEXTURE(aiTextureType_DIFFUSE,n) the n'th texture.
float3 base = stack.base_color;
for (every texture in stack)
{
// assuming we have explicit & pretransformed UVs for this texture
float3 color = SampleTexture(texture,uv);
// scale by texture blend factor
color *= texture.blend;
if (texture.op == add)
base += color;
else if (texture.op == multiply)
base *= color;
else // other blend ops go here
}
return base;
}
// ---------------------------------------------------------------------------------------
// Compute the diffuse contribution for a pixel
float3 ComputeDiffuseContribution()
{
if (shading == none)
return float3(1,1,1);
float3 intensity (0,0,0);
for (all lights in range)
{
float fac = 1.f;
if (shading == gouraud)
fac = lambert-term ..
else // other shading modes go here
// handling of different types of lights, such as point or spot lights
// ...
// and finally sum the contribution of this single light ...
intensity += light.diffuse_color * fac;
}
// ... and combine the final incoming light with the diffuse color
return EvaluateStack(diffuse) * intensity;
}
// ---------------------------------------------------------------------------------------
// Compute the specular contribution for a pixel
float3 ComputeSpecularContribution()
{
if (shading == gouraud || specular_strength == 0 || specular_exponent == 0)
return float3(0,0,0);
float3 intensity (0,0,0);
for (all lights in range)
{
float fac = 1.f;
if (shading == phong)
fac = phong-term ..
else // other specular shading modes go here
// handling of different types of lights, such as point or spot lights
// ...
// and finally sum the specular contribution of this single light ...
intensity += light.specular_color * fac;
}
// ... and combine the final specular light with the specular color
return EvaluateStack(specular) * intensity * specular_strength;
}
// ---------------------------------------------------------------------------------------
// Compute the ambient contribution for a pixel
float3 ComputeAmbientContribution()
{
if (shading == none)
return float3(0,0,0);
float3 intensity (0,0,0);
for (all lights in range)
{
float fac = 1.f;
// handling of different types of lights, such as point or spot lights
// ...
// and finally sum the ambient contribution of this single light ...
intensity += light.ambient_color * fac;
}
// ... and combine the final ambient light with the ambient color
return EvaluateStack(ambient) * intensity;
}
// ---------------------------------------------------------------------------------------
// Compute the final color value for a pixel
// @param prev Previous color at that position in the framebuffer
float4 PimpMyPixel (float4 prev)
{
// .. handle displacement mapping per vertex
// .. handle bump/normal mapping
// Get all single light contribution terms
float3 diff = ComputeDiffuseContribution();
float3 spec = ComputeSpecularContribution();
float3 ambi = ComputeAmbientContribution();
// .. and compute the final color value for this pixel
float3 color = diff + spec + ambi;
float3 opac = EvaluateStack(opacity);
if (blend_func == multiply)
return prev
}
@endcode
*/
/**
@page viewer The Viewer
Sinn: StandAlone-Test fĂĽr die Importlib

View File

@ -669,9 +669,8 @@ public:
* from the material
*
* @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
* @param type Specifies the type of the texture to be retrieved (
* e.g. diffuse, specular, height map ...)
* @param idx Index of the texture to be retrieved.
* @param type .. set by AI_MATKEY_XXX
* @param idx .. set by AI_MATKEY_XXX
* @param pOut Pointer to a buffer to receive the result.
* @param pMax Specifies the size of the given buffer, in Type's.
* Receives the number of values (not bytes!) read.
@ -747,171 +746,23 @@ extern "C" {
#endif
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_NAME
* Defines the name of the material. <br>
* <b>Type:</b> string (aiString)<br>
* <b>Default value:</b> <tt>none</tt> <br>
*/
#define AI_MATKEY_NAME "?mat.name",0,0
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_TWOSIDED
* Indicates that the material must be rendered two-sided (means: no
* backface culling). <br>
* <b>Type:</b> int <br>
* <b>Default value:</b> <tt>0</tt> <br>
*/
#define AI_MATKEY_TWOSIDED "$mat.twosided",0,0
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_SHADING_MODEL
* Defines the shading model to be used for this material. See the doc for
* #aiShadingMode for a complete list of all predefined values.
* <br>
* <b>Type:</b> int (aiShadingMode)<br>
* <b>Default value:</b> <tt>aiShadingMode_Gouraud</tt>
*/
#define AI_MATKEY_SHADING_MODEL "$mat.shadingm",0,0
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_ENABLE_WIREFRAME
* Integer property. 1 to enable wireframe mode for rendering.
* A material with this property set to 1 should appear as wireframe, even
* if the scene is rendered solid.
* <br>
* <b>Type:</b> int <br>
* <b>Default value:</b> <tt>0</tt>
*/
#define AI_MATKEY_ENABLE_WIREFRAME "$mat.wireframe",0,0
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_BLEND_FUNC
* Integer property (one of the #aiBlendMode enumerated values). Defines
* the blend function to be used to combine the material color for a specific
* pixel with the previous framebuffer color at this position. This
* corresponds to the #AI_MATKEY_OPACITY and #AI_MATKEY_COLOR_TRANSPARENT
* property. No alpha-blending needs to be turned on if the opacity for all
* color channels is 1.0 and the blend mode is set to #aiBlendMode_Default.
* <br>
* <b>Type:</b> int (#aiBlendMode)<br>
* <b>Default value:</b> <tt>#aiBlendMode_Default</tt>
*/
#define AI_MATKEY_BLEND_FUNC "$mat.blend",0,0
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_OPACITY
* Defines the base opacity of the material. To get the opacity value for
* a particular channel, this value is multiplied with the corresponding
* channel of the #AI_MATKEY_COLOR_TRANSPARENT property. The final value
* is fed in the blend function defined by the #AI_MATKEY_BLEND_FUNC
* property.
* <br>
* <b>Type:</b> float<br>
* <b>Default value:</b> <tt>1.0f</tt><br>
*/
#define AI_MATKEY_OPACITY "$mat.opacity",0,0
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_BUMPSCALING
* Defines the height scaling of a bump map (for stuff like Parallax
* Occlusion Mapping). The actual interpretation/range depends on the
* 3D applications which wrote a particular model. <br>
*
* <b>Type:</b> float<br>
* <b>Default value:</b> <tt>1.0f</tt>
*/
#define AI_MATKEY_BUMPSCALING "$mat.bumpscaling",0,0
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_SHININESS
* Defines the base shininess of the material
* This is the exponent of the Phong and Phong-Blinn shading equations.
* The range is undefined and depends on the shader being used. The
* value will not be negative, though. <br>
*
* <b>Type:</b> float<br>
* <b>Default value:</b> <tt>0.0f</tt>
*/
#define AI_MATKEY_SHININESS "$mat.shininess",0,0
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_SHININESS_STRENGTH
* Defines the strength of the specular highlight.
* This simply scales the specular lighting coefficient. <br>
*
* <b>Type:</b> float <br>
* <b>Default value:</b> <tt>1.0f</tt>
* @note The same effect could be achieved by scaling the specular material
* color. However, most 3D modelers keep this property separate and so
* do we. OK!?
*/
#define AI_MATKEY_SHININESS_STRENGTH "$mat.shinpercent",0,0
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_REFRACTI
* Index of refraction of the material. This is used by some shading models,
* e.g. Cook-Torrance. The value is the ratio of the speed of light in a
* vacuum to the speed of light in the material. <br>
*
* <b>Type:</b> float <br>
* <b>Default value:</b> <tt>1.0f </tt>
*/
#define AI_MATKEY_REFRACTI "$mat.refracti",0,0
// ---------------------------------------------------------------------------
/** @def AI_MATKEY_COLOR_DIFFUSE
* Defines the diffuse base color of the material.
* If stored as 4-component color, the alpha channel is ignored.<br>
* <b>Type:</b> color (#aiColor4D or #aiColor3D) <br>
* <b>Default value:</b> <tt>0.0f|0.0f|0.0f|1.0f </tt>
*/
#define AI_MATKEY_COLOR_DIFFUSE "$clr.diffuse",0,0
/** @def AI_MATKEY_COLOR_AMBIENT
* Declares the amount of ambient light emitted from
* the surface of this object. If stored as 4-component color,
* the alpha channel is ignored.<br><br>
* <b>Type:</b> color (#aiColor4D or #aiColor3D) <br>
* <b>Default value:</b> <tt>0.0f|0.0f|0.0f|1.0f </tt>
*/
#define AI_MATKEY_COLOR_AMBIENT "$clr.ambient",0,0
/** @def AI_MATKEY_COLOR_SPECULAR
* Declares the color of light specularly reflected from
* the surface of this object. If stored as 4-component color, the
* alpha channel is ignored.<br><br>
* <b>Type:</b> color (#aiColor4D or #aiColor3D) <br>
* <b>Default value:</b> <tt>0.0f|0.0f|0.0f|1.0f </tt>
*/
#define AI_MATKEY_COLOR_SPECULAR "$clr.specular",0,0
/** @def AI_MATKEY_COLOR_EMISSIVE
* Declares the amount of light emitted from the
* surface of this object. If stored as 4-component color, the alpha
* channel is ignored.<br><br>
* <b>Type:</b> color (#aiColor4D or #aiColor3D) <br>
* <b>Default value:</b> <tt>0.0f|0.0f|0.0f|1.0f </tt>
*/
#define AI_MATKEY_COLOR_EMISSIVE "$clr.emissive",0,0
/** @def AI_MATKEY_COLOR_TRANSPARENT
* Defines the transparent base color of the material. If stored as
* 4-component color, the alpha channel is ignored. This
* corresponds to the #AI_MATKEY_OPACITY and #AI_MATKEY_BLEND_FUNC
* material properties.<br> <br>
* <b>Type:</b> color (#aiColor4D or #aiColor3D) <br>
* <b>Default value:</b> <tt>0.0f|0.0f|0.0f|1.0f </tt>
*/
#define AI_MATKEY_COLOR_TRANSPARENT "$clr.transparent",0,0
/** @def AI_MATKEY_COLOR_REFLECTIVE
* Declares the color of a perfect mirror reflection. If stored as
* 4-component color, the alpha channel is ignored.<br> <br>
* <b>Type:</b> color (#aiColor4D or #aiColor3D) <br>
* <b>Default value:</b> <tt>0.0f|0.0f|0.0f|1.0f </tt>
*/
#define AI_MATKEY_COLOR_REFLECTIVE "$clr.reflective",0,0
#define AI_MATKEY_GLOBAL_BACKGROUND_IMAGE "?bg.global",0,0
// ---------------------------------------------------------------------------
// Pure key names for all texture-related properties
@ -928,17 +779,6 @@ extern "C" {
#define _AI_MATKEY_TEXFLAGS_BASE "$tex.flags"
//! @endcond
// ---------------------------------------------------------------------------
/**
* @def AI_MATKEY_TEXTURE
* Specifies the path to the Nth texture of type "type".
* This can either be a path to the texture or a string of the form '*i'
* where i is an index into the array of embedded textures that has been
* imported along with the scene. See #aiTexture for more details.
* <br>
* <b>Type:</b> #aiString<br>
* <b>Default value if key is not defined:</b> <tt>n/a</tt><br>
*/
// ---------------------------------------------------------------------------
#define AI_MATKEY_TEXTURE(type, N) _AI_MATKEY_TEXTURE_BASE,type,N
@ -977,25 +817,8 @@ extern "C" {
#define AI_MATKEY_TEXTURE_REFLECTION(N) \
AI_MATKEY_TEXTURE(aiTextureType_REFLECTION,N)
#define AI_MATKEY_TEXTURE_UNKNOWN(N) \
AI_MATKEY_TEXTURE(aiTextureType_UNKNOWN,N)
//! @endcond
// ---------------------------------------------------------------------------
/**
* @def AI_MATKEY_UVWSRC
* Specifies which UV channel is used as source for the mapping coordinates
* of the Nth texture of type "type". If the requested mapping channel does
* not exist in a mesh associated with the material, decrement the index by
* one until you find a working UV channel. Please note that this property
* is mutually exlusive with AI_MATKEY_MAPPING(type,N) set to 'UV'.
* <br>
* <b>Type:</b> int<br>
* <b>Default value if key is not defined:</b><tt>0</tt><br>
* <b>Requires:</b> AI_MATKEY_TEXTURE(type,N)
* and AI_MATKEY_MAPPING(type,N) == UV<br>
*/
// ---------------------------------------------------------------------------
#define AI_MATKEY_UVWSRC(type, N) _AI_MATKEY_UVWSRC_BASE,type,N
@ -1034,21 +857,8 @@ extern "C" {
#define AI_MATKEY_UVWSRC_REFLECTION(N) \
AI_MATKEY_UVWSRC(aiTextureType_REFLECTION,N)
#define AI_MATKEY_UVWSRC_UNKNOWN(N) \
AI_MATKEY_UVWSRC(aiTextureType_UNKNOWN,N)
//! @endcond
// ---------------------------------------------------------------------------
/**
* @def AI_MATKEY_TEXOP
* Specifies how the Nth texture of type "type" is combined with
* the result of all color values from all previous texture layers combined.
* <br>
* <b>Type:</b> int (#aiTextureOp)<br>
* <b>Default value if key is not defined:</b> <tt>#aiTextureOp_Multiply</tt><br>
* <b>Requires:</b> AI_MATKEY_TEXTURE(type,N)<br>
*/
// ---------------------------------------------------------------------------
#define AI_MATKEY_TEXOP(type, N) _AI_MATKEY_TEXOP_BASE,type,N
// For backward compatibility and simplicity
@ -1086,20 +896,8 @@ extern "C" {
#define AI_MATKEY_TEXOP_REFLECTION(N) \
AI_MATKEY_TEXOP(aiTextureType_REFLECTION,N)
#define AI_MATKEY_TEXOP_UNKNOWN(N) \
AI_MATKEY_TEXOP(aiTextureType_UNKNOWN,N)
//! @endcond
// ---------------------------------------------------------------------------
/**
* @def AI_MATKEY_MAPPING
* Specifies how the Nth texture of type "type" is mapped.
* <br>
* <b>Type:</b> int (#aiTextureMapping)<br>
* <b>Default value if key is not defined:</b> <tt>#aiTextureMapping_UV</tt><br>
* <b>Requires:</b>#AI_MATKEY_TEXTURE(type,N)<br>
*/
// ---------------------------------------------------------------------------
#define AI_MATKEY_MAPPING(type, N) _AI_MATKEY_MAPPING_BASE,type,N
// For backward compatibility and simplicity
@ -1137,22 +935,8 @@ extern "C" {
#define AI_MATKEY_MAPPING_REFLECTION(N) \
AI_MATKEY_MAPPING(aiTextureType_REFLECTION,N)
#define AI_MATKEY_MAPPING_UNKNOWN(N) \
AI_MATKEY_MAPPING(aiTextureType_UNKNOWN,N)
//! @endcond
// ---------------------------------------------------------------------------
/**
* @def AI_MATKEY_TEXBLEND
* Specifies the strength of the <N>th texture of type <type>. This is just
* a multiplier for the texture's color values. It may have any value, even
* outside [0..1].
* <br>
* <b>Type:</b> float<br>
* <b>Default value if this key is not defined:</b><tt>1.f</tt><br>
* <b>Requires:</b> #AI_MATKEY_TEXTURE(type,N)<br>
*/
// ---------------------------------------------------------------------------
#define AI_MATKEY_TEXBLEND(type, N) _AI_MATKEY_TEXBLEND_BASE,type,N
// For backward compatibility and simplicity
@ -1190,23 +974,8 @@ extern "C" {
#define AI_MATKEY_TEXBLEND_REFLECTION(N) \
AI_MATKEY_TEXBLEND(aiTextureType_REFLECTION,N)
#define AI_MATKEY_TEXBLEND_UNKNOWN(N) \
AI_MATKEY_TEXBLEND(aiTextureType_UNKNOWN,N)
//! @endcond
// ---------------------------------------------------------------------------
/**
* @def AI_MATKEY_MAPPINGMODE_U
* Specifies the texture mapping mode for the <N>th texture of type <type> in
* the u (x) direction.
* <br>
* <b>Type:</b> int (#aiTextureMapMode)<br>
* <b>Default value if key is not defined:</b><tt>#aiTextureMapMode_Wrap</tt><br>
* <b>Requires:</b> AI_MATKEY_TEXTURE(type,N)<br>
* @note There's no equivalent property for the 'w' axis of volume textures,
* just because no formats exports this information.
*/
// ---------------------------------------------------------------------------
#define AI_MATKEY_MAPPINGMODE_U(type, N) _AI_MATKEY_MAPPINGMODE_U_BASE,type,N
// For backward compatibility and simplicity
@ -1244,23 +1013,8 @@ extern "C" {
#define AI_MATKEY_MAPPINGMODE_U_REFLECTION(N) \
AI_MATKEY_MAPPINGMODE_U(aiTextureType_REFLECTION,N)
#define AI_MATKEY_MAPPINGMODE_U_UNKNOWN(N) \
AI_MATKEY_MAPPINGMODE_U(aiTextureType_UNKNOWN,N)
//! @endcond
// ---------------------------------------------------------------------------
/**
* @def AI_MATKEY_MAPPINGMODE_V
* Specifies the texture mapping mode for the <N>th texture of type <type> in
* the w (z) direction.
* <br>
* <b>Type:</b> int (#aiTextureMapMode)<br>
* <b>Default value if key is not defined:</b><tt>#aiTextureMapMode_Wrap</tt><br>
* <b>Requires:</b> AI_MATKEY_TEXTURE(type,N)<br>
* @note There's no equivalent property for the 'w' axis of volume textures,
* just because no formats exports this information.
*/
// ---------------------------------------------------------------------------
#define AI_MATKEY_MAPPINGMODE_V(type, N) _AI_MATKEY_MAPPINGMODE_V_BASE,type,N
// For backward compatibility and simplicity
@ -1298,23 +1052,8 @@ extern "C" {
#define AI_MATKEY_MAPPINGMODE_V_REFLECTION(N) \
AI_MATKEY_MAPPINGMODE_V(aiTextureType_REFLECTION,N)
#define AI_MATKEY_MAPPINGMODE_V_UNKNOWN(N) \
AI_MATKEY_MAPPINGMODE_V(aiTextureType_UNKNOWN,N)
//! @endcond
// ---------------------------------------------------------------------------
/**
* @def AI_MATKEY_TEXMAP_AXIS
* Specifies the main mapping axis of the Nth texture of type "type".
* This applies to non-UV mapped textures. For spherical, cylindrical and
* planar this is the main axis of the corresponding geometric shape.
* <br>
* <b>Type:</b> float[3] (#aiVector3D)<br>
* <b>Default value if key is not defined:</b> <tt>aiVector3D(0.f,1.f,0.f)</tt> <br>
* <b>Requires:</b> AI_MATKEY_TEXTURE(type,N) and
* AI_MATKEY_MAPPING(type,N) != UV<br>
*/
// ---------------------------------------------------------------------------
#define AI_MATKEY_TEXMAP_AXIS(type, N) _AI_MATKEY_TEXMAP_AXIS_BASE,type,N
// For backward compatibility and simplicity
@ -1352,25 +1091,8 @@ extern "C" {
#define AI_MATKEY_TEXMAP_AXIS_REFLECTION(N) \
AI_MATKEY_TEXMAP_AXIS(aiTextureType_REFLECTION,N)
#define AI_MATKEY_TEXMAP_AXIS_UNKNOWN(N) \
AI_MATKEY_TEXMAP_AXIS(aiTextureType_UNKNOWN,N)
//! @endcond
// ---------------------------------------------------------------------------
/**
* @def AI_MATKEY_UVTRANSFORM
* Specifies how the UV mapping coordinates for the Nth texture of type
* "type" are transformed before they're used for mapping. This is an array
* of five floats - use the aiUVTransform structure for simplicity.
* <br>
* <b>Type:</b> Array of 5 floats<br>
* <b>Default value if key is not defined:</b><tt>0.f,0.f,1.f,1.f,0.f</tt><br>
* <b>Requires:</b> AI_MATKEY_TEXTURE(type,N) and
* AI_MATKEY_MAPPING(type,N) == UV<br>
* <b>Note:</b>Transformed 3D texture coordinates are not *yet* supported.
* And they'll probably never be, no format exports such rubbish.
*/
// ---------------------------------------------------------------------------
#define AI_MATKEY_UVTRANSFORM(type, N) _AI_MATKEY_UVTRANSFORM_BASE,type,N
// For backward compatibility and simplicity
@ -1413,16 +1135,6 @@ extern "C" {
//! @endcond
// ---------------------------------------------------------------------------
/**
* @def AI_MATKEY_TEXFLAGS
* Specifies flags for the Nth texture of type 'type'. The key is a bitwise
* combination of the #aiTextureFlags enumerated values.
* <br>
* <b>Type:</b> int (#aiTextureFlags)<br>
* <b>Default value if key is not defined:</b> <tt>0</tt><br>
* <b>Requires:</b>#AI_MATKEY_TEXTURE(type,N)<br>
*/
// ---------------------------------------------------------------------------
#define AI_MATKEY_TEXFLAGS(type, N) _AI_MATKEY_TEXFLAGS_BASE,type,N
// For backward compatibility and simplicity
@ -1463,19 +1175,6 @@ extern "C" {
#define AI_MATKEY_TEXFLAGS_UNKNOWN(N) \
AI_MATKEY_TEXFLAGS(aiTextureType_UNKNOWN,N)
#define AI_MATKEY_ORENNAYAR_ROUGHNESS "$shading.orennayar.roughness",0,0
#define AI_MATKEY_MINNAERT_DARKNESS "$shading.minnaert.darkness",0,0
#define AI_MATKEY_COOK_TORRANCE_PARAM "$shading.cookt.param",0,0
/** @def AI_MATKEY_GLOBAL_BACKGROUND_IMAGE
* Global property defined by some loaders. Contains the path to
* the image file to be used as background image.
*
* @deprecated
*/
#define AI_MATKEY_GLOBAL_BACKGROUND_IMAGE "$global.bg.image2d",0,0
// ---------------------------------------------------------------------------
/** @brief Retrieve a material property with a specific key from the material
*

View File

@ -1 +1 @@
#define SVNRevision 402
#define SVNRevision 412

View File

@ -1020,6 +1020,7 @@ int CMaterialManager::CreateMaterial(
sMacro[iCurrent].Definition = "1";
++iCurrent;
}
char buff[32];
if (pcMesh->piLightmapTexture)
{
sMacro[iCurrent].Name = "AV_LIGHTMAP_TEXTURE";
@ -1036,6 +1037,13 @@ int CMaterialManager::CreateMaterial(
}
else sMacro[iCurrent].Definition = "IN.TexCoord0";
sMacro[iCurrent].Name = "AV_LIGHTMAP_TEXTURE_UV_COORD";
++iCurrent;float f= 1.f;
aiGetMaterialFloat(pcMat,AI_MATKEY_TEXBLEND_LIGHTMAP(0),&f);
sprintf(buff,"%f",f);
sMacro[iCurrent].Name = "LM_STRENGTH";
sMacro[iCurrent].Definition = buff;
++iCurrent;
}
if (pcMesh->piNormalTexture && !bib)

View File

@ -874,7 +874,7 @@ std::string g_szMaterialShader = std::string(
"OUT.a = TRANSPARENCY;\n"
"#endif\n"
"#ifdef AV_LIGHTMAP_TEXTURE\n"
"OUT.rgb *= tex2D(LIGHTMAP_SAMPLER,AV_LIGHTMAP_TEXTURE_UV_COORD).rgb;\n"
"OUT.rgb *= tex2D(LIGHTMAP_SAMPLER,AV_LIGHTMAP_TEXTURE_UV_COORD).rgb*LM_STRENGTH;\n"
"#endif\n"
"#ifdef AV_OPACITY_TEXTURE\n"
"OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
@ -989,7 +989,7 @@ std::string g_szMaterialShader = std::string(
"OUT.a = TRANSPARENCY;\n"
"#endif\n"
"#ifdef AV_LIGHTMAP_TEXTURE\n"
"OUT.rgb *= tex2D(LIGHTMAP_SAMPLER,AV_LIGHTMAP_TEXTURE_UV_COORD).rgb;\n"
"OUT.rgb *= tex2D(LIGHTMAP_SAMPLER,AV_LIGHTMAP_TEXTURE_UV_COORD).rgb*LM_STRENGTH;\n"
"#endif\n"
"#ifdef AV_OPACITY_TEXTURE\n"
"OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"