This commit is contained in:
Rishabh Battulwar 2018-08-03 00:13:12 +00:00 committed by GitHub
commit ce98ac816f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 3 deletions

View File

@ -192,6 +192,9 @@ if (NOT MSVC)
target_compile_options(FBX2glTF PRIVATE
"-Wno-null-dereference"
"-Wunused"
# need to add this to stop cppcodec, a dependency here, from failing to build
# @ref: https://stackoverflow.com/questions/20302595/how-to-disable-narrowing-conversion-warnings
"-Wno-narrowing"
)
endif()

View File

@ -790,6 +790,7 @@ static void ReadMesh(RawModel &raw, FbxScene *pScene, FbxNode *pNode, const std:
static_cast<float>(blendShapes.GetBlendChannel(channelIx).deformPercent),
shape.normals.LayerPresent(),
shape.tangents.LayerPresent(),
shape.shape->GetName()
});
}
}

View File

@ -940,7 +940,7 @@ ModelData *Raw2Gltf(
GLT_VEC4F, tangents);
}
primitive->AddTarget(pAcc.get(), nAcc.get(), tAcc.get());
primitive->AddTarget(pAcc.get(), nAcc.get(), tAcc.get(), channel.name);
}
}
if (options.draco.enabled) {

View File

@ -330,6 +330,7 @@ struct RawBlendChannel
float defaultDeform;
bool hasNormals;
bool hasTangents;
std::string name;
};
struct RawSurface

View File

@ -39,13 +39,16 @@ void PrimitiveData::NoteDracoBuffer(const BufferViewData &data)
dracoBufferView = data.ix;
}
void PrimitiveData::AddTarget(const AccessorData *positions, const AccessorData *normals, const AccessorData *tangents)
void PrimitiveData::AddTarget(const AccessorData *positions, const AccessorData *normals, const AccessorData *tangents,
const std::string &shape_name)
{
targetAccessors.push_back(std::make_tuple(
positions->ix,
normals ? normals->ix : -1,
tangents ? tangents ->ix : -1
));
targetNames.push_back(shape_name);
}
void to_json(json &j, const PrimitiveData &d) {
@ -70,6 +73,15 @@ void to_json(json &j, const PrimitiveData &d) {
}
j["targets"] = targets;
}
if (!d.targetNames.empty()) {
json extras {};
json names {};
for (const auto &name : d.targetNames) {
names.push_back(name);
}
extras["target_names"] = names;
j["extras"] = extras;
}
if (!d.dracoAttributes.empty()) {
j["extensions"] = {
{ KHR_DRACO_MESH_COMPRESSION, {

View File

@ -31,7 +31,8 @@ struct PrimitiveData
void AddAttrib(std::string name, const AccessorData &accessor);
void AddTarget(const AccessorData *positions, const AccessorData *normals, const AccessorData *tangents);
void AddTarget(const AccessorData *positions, const AccessorData *normals, const AccessorData *tangents,
const std::string &name);
template<class T>
void AddDracoAttrib(const AttributeDefinition<T> attribute, const std::vector<T> &attribArr)
@ -62,6 +63,7 @@ struct PrimitiveData
const MeshMode mode;
std::vector<std::tuple<int, int, int>> targetAccessors {};
std::vector<std::string> targetNames {};
std::map<std::string, int> attributes;
std::map<std::string, int> dracoAttributes;