Merge branch 'master' into fix-fov-doc
commit
7258441153
|
@ -598,8 +598,11 @@ static void WriteDump(const char *pFile, const char *cmd, const aiScene *scene,
|
|||
if (!mesh->mTextureCoords[a])
|
||||
break;
|
||||
|
||||
ioprintf(io, "\t\t<TextureCoords num=\"%u\" set=\"%u\" num_components=\"%u\"> \n", mesh->mNumVertices,
|
||||
a, mesh->mNumUVComponents[a]);
|
||||
ioprintf(io, "\t\t<TextureCoords num=\"%u\" set=\"%u\" name=\"%s\" num_components=\"%u\"> \n",
|
||||
mesh->mNumVertices,
|
||||
a,
|
||||
mesh->mTextureCoordsNames[a].C_Str(),
|
||||
mesh->mNumUVComponents[a]);
|
||||
|
||||
if (!shortened) {
|
||||
if (mesh->mNumUVComponents[a] == 3) {
|
||||
|
|
|
@ -63,11 +63,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
using namespace Assimp;
|
||||
|
||||
// AutoCAD Binary DXF<CR><LF><SUB><NULL>
|
||||
const std::string AI_DXF_BINARY_IDENT = std::string("AutoCAD Binary DXF\r\n\x1a\0");
|
||||
const size_t AI_DXF_BINARY_IDENT_LEN = 24u;
|
||||
static constexpr char AI_DXF_BINARY_IDENT[] = "AutoCAD Binary DXF\r\n\x1a";
|
||||
static constexpr size_t AI_DXF_BINARY_IDENT_LEN = sizeof AI_DXF_BINARY_IDENT;
|
||||
|
||||
// default vertex color that all uncolored vertices will receive
|
||||
const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
|
||||
static const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
|
||||
|
||||
// color indices for DXF - 16 are supported, the table is
|
||||
// taken directly from the DXF spec.
|
||||
|
@ -156,10 +156,10 @@ void DXFImporter::InternReadFile( const std::string& filename, aiScene* pScene,
|
|||
}
|
||||
|
||||
// Check whether this is a binary DXF file - we can't read binary DXF files :-(
|
||||
char buff[AI_DXF_BINARY_IDENT_LEN+1] = {0};
|
||||
char buff[AI_DXF_BINARY_IDENT_LEN] = {0};
|
||||
file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1);
|
||||
|
||||
if (0 == strncmp(AI_DXF_BINARY_IDENT.c_str(),buff,AI_DXF_BINARY_IDENT_LEN)) {
|
||||
if (0 == memcmp(AI_DXF_BINARY_IDENT,buff,AI_DXF_BINARY_IDENT_LEN)) {
|
||||
throw DeadlyImportError("DXF: Binary files are not supported at the moment");
|
||||
}
|
||||
|
||||
|
|
|
@ -1126,6 +1126,8 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c
|
|||
*out_uv++ = aiVector3D(v.x, v.y, 0.0f);
|
||||
}
|
||||
|
||||
out_mesh->mTextureCoordsNames[i] = mesh.GetTextureCoordChannelName(i);
|
||||
|
||||
out_mesh->mNumUVComponents[i] = 2;
|
||||
}
|
||||
|
||||
|
@ -2126,7 +2128,12 @@ void FBXConverter::SetShadingPropertiesCommon(aiMaterial *out_mat, const Propert
|
|||
const aiColor3D &Emissive = GetColorPropertyFromMaterial(props, "Emissive", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&Emissive, 1, AI_MATKEY_COLOR_EMISSIVE);
|
||||
}
|
||||
} else {
|
||||
const aiColor3D &emissiveColor = GetColorPropertyFromMaterial(props, "Maya|emissive", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&emissiveColor, 1, AI_MATKEY_COLOR_EMISSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
const aiColor3D &Ambient = GetColorPropertyFromMaterial(props, "Ambient", ok);
|
||||
if (ok) {
|
||||
|
@ -2207,6 +2214,52 @@ void FBXConverter::SetShadingPropertiesCommon(aiMaterial *out_mat, const Propert
|
|||
if (ok) {
|
||||
out_mat->AddProperty(&DispFactor, 1, "$mat.displacementscaling", 0, 0);
|
||||
}
|
||||
|
||||
// PBR material information
|
||||
const aiColor3D &baseColor = GetColorPropertyFromMaterial(props, "Maya|base_color", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&baseColor, 1, AI_MATKEY_BASE_COLOR);
|
||||
}
|
||||
|
||||
const float useColorMap = PropertyGet<float>(props, "Maya|use_color_map", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&useColorMap, 1, AI_MATKEY_USE_COLOR_MAP);
|
||||
}
|
||||
|
||||
const float useMetallicMap = PropertyGet<float>(props, "Maya|use_metallic_map", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&useMetallicMap, 1, AI_MATKEY_USE_METALLIC_MAP);
|
||||
}
|
||||
|
||||
const float metallicFactor = PropertyGet<float>(props, "Maya|metallic", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&metallicFactor, 1, AI_MATKEY_METALLIC_FACTOR);
|
||||
}
|
||||
|
||||
const float useRoughnessMap = PropertyGet<float>(props, "Maya|use_roughness_map", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&useRoughnessMap, 1, AI_MATKEY_USE_ROUGHNESS_MAP);
|
||||
}
|
||||
|
||||
const float roughnessFactor = PropertyGet<float>(props, "Maya|roughness", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&roughnessFactor, 1, AI_MATKEY_ROUGHNESS_FACTOR);
|
||||
}
|
||||
|
||||
const float useEmissiveMap = PropertyGet<float>(props, "Maya|use_emissive_map", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&useEmissiveMap, 1, AI_MATKEY_USE_EMISSIVE_MAP);
|
||||
}
|
||||
|
||||
const float emissiveIntensity = PropertyGet<float>(props, "Maya|emissive_intensity", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&emissiveIntensity, 1, AI_MATKEY_EMISSIVE_INTENSITY);
|
||||
}
|
||||
|
||||
const float useAOMap = PropertyGet<float>(props, "Maya|use_ao_map", ok);
|
||||
if (ok) {
|
||||
out_mat->AddProperty(&useAOMap, 1, AI_MATKEY_USE_AO_MAP);
|
||||
}
|
||||
}
|
||||
|
||||
void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTable &props, const TextureMap &_textures, const MeshGeometry *const mesh) {
|
||||
|
|
|
@ -604,15 +604,15 @@ void MeshGeometry::ReadVertexDataTangents(std::vector<aiVector3D>& tangents_out,
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const std::string BinormalIndexToken = "BinormalIndex";
|
||||
static const std::string BinormalsIndexToken = "BinormalsIndex";
|
||||
static const char * BinormalIndexToken = "BinormalIndex";
|
||||
static const char * BinormalsIndexToken = "BinormalsIndex";
|
||||
|
||||
void MeshGeometry::ReadVertexDataBinormals(std::vector<aiVector3D>& binormals_out, const Scope& source,
|
||||
const std::string& MappingInformationType,
|
||||
const std::string& ReferenceInformationType)
|
||||
{
|
||||
const char * str = source.Elements().count( "Binormals" ) > 0 ? "Binormals" : "Binormal";
|
||||
const char * strIdx = source.Elements().count( "Binormals" ) > 0 ? BinormalsIndexToken.c_str() : BinormalIndexToken.c_str();
|
||||
const char * strIdx = source.Elements().count( "Binormals" ) > 0 ? BinormalsIndexToken : BinormalIndexToken;
|
||||
ResolveVertexDataArray(binormals_out,source,MappingInformationType,ReferenceInformationType,
|
||||
str,
|
||||
strIdx,
|
||||
|
|
|
@ -131,7 +131,7 @@ Property* ReadTypedProperty(const Element& element)
|
|||
ParseTokenAsFloat(*tok[6]))
|
||||
);
|
||||
}
|
||||
else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
|
||||
else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"float") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
|
||||
checkTokenCount(tok, 5);
|
||||
return new TypedProperty<float>(ParseTokenAsFloat(*tok[4]));
|
||||
}
|
||||
|
|
|
@ -55,9 +55,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
namespace Assimp {
|
||||
namespace Ogre {
|
||||
|
||||
const std::string MESH_VERSION_1_8 = "[MeshSerializer_v1.8]";
|
||||
const std::string SKELETON_VERSION_1_8 = "[Serializer_v1.80]";
|
||||
const std::string SKELETON_VERSION_1_1 = "[Serializer_v1.10]";
|
||||
static constexpr auto MESH_VERSION_1_8 = "[MeshSerializer_v1.8]";
|
||||
static constexpr auto SKELETON_VERSION_1_8 = "[Serializer_v1.80]";
|
||||
static constexpr auto SKELETON_VERSION_1_1 = "[Serializer_v1.10]";
|
||||
|
||||
const unsigned short HEADER_CHUNK_ID = 0x1000;
|
||||
|
||||
|
|
|
@ -749,22 +749,22 @@ enum MeshAttribute {
|
|||
TexCoord
|
||||
};
|
||||
|
||||
static const std::string PosToken = "position";
|
||||
static const std::string ColToken = "color";
|
||||
static const std::string NormalToken = "normal";
|
||||
static const std::string TexCoordToken = "texcoord";
|
||||
constexpr auto PosToken = "position";
|
||||
constexpr auto ColToken = "color";
|
||||
constexpr auto NormalToken = "normal";
|
||||
constexpr auto TexCoordToken = "texcoord";
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
static MeshAttribute getAttributeByName(const char *attribName) {
|
||||
ai_assert(nullptr != attribName);
|
||||
|
||||
if (0 == strncmp(PosToken.c_str(), attribName, PosToken.size())) {
|
||||
if (0 == strcmp(PosToken, attribName)) {
|
||||
return Position;
|
||||
} else if (0 == strncmp(ColToken.c_str(), attribName, ColToken.size())) {
|
||||
} else if (0 == strcmp(ColToken, attribName)) {
|
||||
return Color;
|
||||
} else if (0 == strncmp(NormalToken.c_str(), attribName, NormalToken.size())) {
|
||||
} else if (0 == strcmp(NormalToken, attribName)) {
|
||||
return Normal;
|
||||
} else if (0 == strncmp(TexCoordToken.c_str(), attribName, TexCoordToken.size())) {
|
||||
} else if (0 == strcmp(TexCoordToken, attribName)) {
|
||||
return TexCoord;
|
||||
}
|
||||
|
||||
|
|
|
@ -1118,11 +1118,13 @@ public:
|
|||
bool KHR_materials_transmission;
|
||||
bool KHR_draco_mesh_compression;
|
||||
bool FB_ngon_encoding;
|
||||
bool KHR_texture_basisu;
|
||||
} extensionsUsed;
|
||||
|
||||
//! Keeps info about the required extensions
|
||||
struct RequiredExtensions {
|
||||
bool KHR_draco_mesh_compression;
|
||||
bool KHR_texture_basisu;
|
||||
} extensionsRequired;
|
||||
|
||||
AssetMetadata asset;
|
||||
|
|
|
@ -1144,6 +1144,7 @@ inline Image::Image() :
|
|||
}
|
||||
|
||||
inline void Image::Read(Value &obj, Asset &r) {
|
||||
//basisu: no need to handle .ktx2, .basis, load as is
|
||||
if (!mDataLength) {
|
||||
Value *curUri = FindString(obj, "uri");
|
||||
if (nullptr != curUri) {
|
||||
|
@ -2124,6 +2125,7 @@ inline void Asset::ReadExtensionsUsed(Document &doc) {
|
|||
CHECK_EXT(KHR_materials_clearcoat);
|
||||
CHECK_EXT(KHR_materials_transmission);
|
||||
CHECK_EXT(KHR_draco_mesh_compression);
|
||||
CHECK_EXT(KHR_texture_basisu);
|
||||
|
||||
#undef CHECK_EXT
|
||||
}
|
||||
|
|
|
@ -250,6 +250,7 @@ namespace glTF2 {
|
|||
|
||||
inline void Write(Value& obj, Image& img, AssetWriter& w)
|
||||
{
|
||||
//basisu: no need to handle .ktx2, .basis, write as is
|
||||
if (img.bufferView) {
|
||||
obj.AddMember("bufferView", img.bufferView->index, w.mAl);
|
||||
obj.AddMember("mimeType", Value(img.mimeType, w.mAl).Move(), w.mAl);
|
||||
|
@ -892,10 +893,22 @@ namespace glTF2 {
|
|||
if (this->mAsset.extensionsUsed.FB_ngon_encoding) {
|
||||
exts.PushBack(StringRef("FB_ngon_encoding"), mAl);
|
||||
}
|
||||
|
||||
if (this->mAsset.extensionsUsed.KHR_texture_basisu) {
|
||||
exts.PushBack(StringRef("KHR_texture_basisu"), mAl);
|
||||
}
|
||||
}
|
||||
|
||||
if (!exts.Empty())
|
||||
mDoc.AddMember("extensionsUsed", exts, mAl);
|
||||
|
||||
//basisu extensionRequired
|
||||
Value extsReq;
|
||||
extsReq.SetArray();
|
||||
if (this->mAsset.extensionsUsed.KHR_texture_basisu) {
|
||||
extsReq.PushBack(StringRef("KHR_texture_basisu"), mAl);
|
||||
mDoc.AddMember("extensionsRequired", extsReq, mAl);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
|
|
@ -494,7 +494,6 @@ void glTF2Exporter::GetMatTexProp(const aiMaterial* mat, float& prop, const char
|
|||
|
||||
void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref<Texture>& texture, aiTextureType tt, unsigned int slot = 0)
|
||||
{
|
||||
|
||||
if (mat->GetTextureCount(tt) > 0) {
|
||||
aiString tex;
|
||||
|
||||
|
@ -507,6 +506,7 @@ void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref<Texture>& texture, aiTe
|
|||
texture = mAsset->textures.Get(it->second);
|
||||
}
|
||||
|
||||
bool useBasisUniversal = false;
|
||||
if (!texture) {
|
||||
std::string texId = mAsset->FindUniqueID("", "texture");
|
||||
texture = mAsset->textures.Create(texId);
|
||||
|
@ -519,18 +519,46 @@ void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref<Texture>& texture, aiTe
|
|||
aiTexture* curTex = mScene->mTextures[atoi(&path[1])];
|
||||
|
||||
texture->source->name = curTex->mFilename.C_Str();
|
||||
|
||||
// The asset has its own buffer, see Image::SetData
|
||||
texture->source->SetData(reinterpret_cast<uint8_t *>(curTex->pcData), curTex->mWidth, *mAsset);
|
||||
|
||||
|
||||
//basisu: embedded ktx2, bu
|
||||
if (curTex->achFormatHint[0]) {
|
||||
std::string mimeType = "image/";
|
||||
mimeType += (memcmp(curTex->achFormatHint, "jpg", 3) == 0) ? "jpeg" : curTex->achFormatHint;
|
||||
if(memcmp(curTex->achFormatHint, "jpg", 3) == 0)
|
||||
mimeType += "jpeg";
|
||||
else if(memcmp(curTex->achFormatHint, "ktx", 3) == 0) {
|
||||
useBasisUniversal = true;
|
||||
mimeType += "ktx";
|
||||
}
|
||||
else if(memcmp(curTex->achFormatHint, "kx2", 3) == 0) {
|
||||
useBasisUniversal = true;
|
||||
mimeType += "ktx2";
|
||||
}
|
||||
else if(memcmp(curTex->achFormatHint, "bu", 2) == 0) {
|
||||
useBasisUniversal = true;
|
||||
mimeType += "basis";
|
||||
}
|
||||
else
|
||||
mimeType += curTex->achFormatHint;
|
||||
texture->source->mimeType = mimeType;
|
||||
}
|
||||
|
||||
// The asset has its own buffer, see Image::SetData
|
||||
//basisu: "image/ktx2", "image/basis" as is
|
||||
texture->source->SetData(reinterpret_cast<uint8_t *>(curTex->pcData), curTex->mWidth, *mAsset);
|
||||
}
|
||||
else {
|
||||
texture->source->uri = path;
|
||||
if(texture->source->uri.find(".ktx")!=std::string::npos ||
|
||||
texture->source->uri.find(".basis")!=std::string::npos)
|
||||
{
|
||||
useBasisUniversal = true;
|
||||
}
|
||||
}
|
||||
|
||||
//basisu
|
||||
if(useBasisUniversal) {
|
||||
mAsset->extensionsUsed.KHR_texture_basisu = true;
|
||||
mAsset->extensionsRequired.KHR_texture_basisu = true;
|
||||
}
|
||||
|
||||
GetTexSampler(mat, texture, tt, slot);
|
||||
|
|
|
@ -1263,7 +1263,7 @@ aiMeshMorphAnim *CreateMeshMorphAnim(glTF2::Asset&, Node &node, AnimationSampler
|
|||
|
||||
static const float kMillisecondsFromSeconds = 1000.f;
|
||||
|
||||
if (nullptr != samplers.weight) {
|
||||
if (samplers.weight && samplers.weight->input && samplers.weight->output) {
|
||||
float *times = nullptr;
|
||||
samplers.weight->input->ExtractData(times);
|
||||
float *values = nullptr;
|
||||
|
@ -1476,6 +1476,12 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
|
|||
if (strcmp(ext, "jpeg") == 0) {
|
||||
ext = "jpg";
|
||||
}
|
||||
else if(strcmp(ext, "ktx2") == 0) { //basisu: ktx remains
|
||||
ext = "kx2";
|
||||
}
|
||||
else if(strcmp(ext, "basis") == 0) { //basisu
|
||||
ext = "bu";
|
||||
}
|
||||
|
||||
size_t len = strlen(ext);
|
||||
if (len <= 3) {
|
||||
|
|
|
@ -169,7 +169,7 @@ void Logger::debug(const char *message) {
|
|||
// sometimes importers will include data from the input file
|
||||
// (i.e. node names) in their messages.
|
||||
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
|
||||
return;
|
||||
return OnDebug("<fixme: long message discarded>");
|
||||
}
|
||||
return OnDebug(message);
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ void Logger::verboseDebug(const char *message) {
|
|||
|
||||
// SECURITY FIX: see above
|
||||
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
|
||||
return;
|
||||
return OnVerboseDebug("<fixme: long message discarded>");
|
||||
}
|
||||
return OnVerboseDebug(message);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ void Logger::info(const char *message) {
|
|||
|
||||
// SECURITY FIX: see above
|
||||
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
|
||||
return;
|
||||
return OnInfo("<fixme: long message discarded>");
|
||||
}
|
||||
return OnInfo(message);
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ void Logger::warn(const char *message) {
|
|||
|
||||
// SECURITY FIX: see above
|
||||
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
|
||||
return;
|
||||
return OnWarn("<fixme: long message discarded>");
|
||||
}
|
||||
return OnWarn(message);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ void Logger::warn(const char *message) {
|
|||
void Logger::error(const char *message) {
|
||||
// SECURITY FIX: see above
|
||||
if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) {
|
||||
return;
|
||||
return OnError("<fixme: long message discarded>");
|
||||
}
|
||||
return OnError(message);
|
||||
}
|
||||
|
|
|
@ -920,6 +920,18 @@ extern "C" {
|
|||
#define AI_MATKEY_SHADER_PRIMITIVE "?sh.ps", 0, 0
|
||||
#define AI_MATKEY_SHADER_COMPUTE "?sh.cs", 0, 0
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// PBR material support
|
||||
#define AI_MATKEY_USE_COLOR_MAP "$mat.useColorMap", 0, 0
|
||||
#define AI_MATKEY_BASE_COLOR "$clr.base", 0, 0
|
||||
#define AI_MATKEY_USE_METALLIC_MAP "$mat.useMetallicMap", 0, 0
|
||||
#define AI_MATKEY_METALLIC_FACTOR "$mat.metallicFactor", 0, 0
|
||||
#define AI_MATKEY_USE_ROUGHNESS_MAP "$mat.useRoughnessMap", 0, 0
|
||||
#define AI_MATKEY_ROUGHNESS_FACTOR "$mat.roughnessFactor", 0, 0
|
||||
#define AI_MATKEY_USE_EMISSIVE_MAP "$mat.useEmissiveMap", 0, 0
|
||||
#define AI_MATKEY_EMISSIVE_INTENSITY "$mat.emissiveIntensity", 0, 0
|
||||
#define AI_MATKEY_USE_AO_MAP "$mat.useAOMap", 0, 0
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Pure key names for all texture-related properties
|
||||
//! @cond MATS_DOC_FULL
|
||||
|
|
|
@ -674,6 +674,10 @@ struct aiMesh {
|
|||
*/
|
||||
C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||
|
||||
/** Vertex stream names.
|
||||
*/
|
||||
C_STRUCT aiString mTextureCoordsNames[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||
|
||||
/** Specifies the number of components for a given UV channel.
|
||||
* Up to three channels are supported (UVW, for accessing volume
|
||||
* or cube maps). If the value is 2 for a given channel n, the
|
||||
|
|
Loading…
Reference in New Issue