closes https://github.com/assimp/assimp/issues/2613 : merge glTF2 patch.
parent
ab3528f726
commit
79056da4be
|
@ -1180,8 +1180,12 @@ inline void Light::SetDefaults()
|
||||||
falloffExponent = 0.f;
|
falloffExponent = 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Node::Read(Value& obj, Asset& r)
|
inline
|
||||||
{
|
void Node::Read(Value& obj, Asset& r) {
|
||||||
|
if (name.empty()) {
|
||||||
|
name = id;
|
||||||
|
}
|
||||||
|
|
||||||
if (Value* children = FindArray(obj, "children")) {
|
if (Value* children = FindArray(obj, "children")) {
|
||||||
this->children.reserve(children->Size());
|
this->children.reserve(children->Size());
|
||||||
for (unsigned int i = 0; i < children->Size(); ++i) {
|
for (unsigned int i = 0; i < children->Size(); ++i) {
|
||||||
|
|
|
@ -475,14 +475,17 @@ void glTFImporter::ImportCameras(glTF::Asset& r) {
|
||||||
|
|
||||||
if (cam.type == Camera::Perspective) {
|
if (cam.type == Camera::Perspective) {
|
||||||
aicam->mAspect = cam.perspective.aspectRatio;
|
aicam->mAspect = cam.perspective.aspectRatio;
|
||||||
aicam->mHorizontalFOV = cam.perspective.yfov * aicam->mAspect;
|
aicam->mHorizontalFOV = cam.cameraProperties.perspective.yfov * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect);
|
||||||
aicam->mClipPlaneFar = cam.perspective.zfar;
|
aicam->mClipPlaneFar = cam.perspective.zfar;
|
||||||
aicam->mClipPlaneNear = cam.perspective.znear;
|
aicam->mClipPlaneNear = cam.perspective.znear;
|
||||||
} else {
|
} else {
|
||||||
aicam->mClipPlaneFar = cam.ortographic.zfar;
|
aicam->mClipPlaneFar = cam.ortographic.zfar;
|
||||||
aicam->mClipPlaneNear = cam.ortographic.znear;
|
aicam->mClipPlaneNear = cam.ortographic.znear;
|
||||||
aicam->mHorizontalFOV = 0.0;
|
aicam->mHorizontalFOV = 0.0;
|
||||||
aicam->mAspect = cam.ortographic.xmag / cam.ortographic.ymag;
|
aicam->mAspect = 1.0f;
|
||||||
|
if (0.f != cam.cameraProperties.ortographic.ymag) {
|
||||||
|
aicam->mAspect = cam.cameraProperties.ortographic.xmag / cam.cameraProperties.ortographic.ymag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1098,8 +1098,11 @@ inline void Light::Read(Value& obj, Asset& /*r*/)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Node::Read(Value& obj, Asset& r)
|
inline
|
||||||
{
|
void Node::Read(Value& obj, Asset& r) {
|
||||||
|
if (name.empty()) {
|
||||||
|
name = id;
|
||||||
|
}
|
||||||
|
|
||||||
if (Value* children = FindArray(obj, "children")) {
|
if (Value* children = FindArray(obj, "children")) {
|
||||||
this->children.reserve(children->Size());
|
this->children.reserve(children->Size());
|
||||||
|
|
|
@ -702,14 +702,17 @@ void glTF2Importer::ImportCameras(glTF2::Asset& r)
|
||||||
if (cam.type == Camera::Perspective) {
|
if (cam.type == Camera::Perspective) {
|
||||||
|
|
||||||
aicam->mAspect = cam.cameraProperties.perspective.aspectRatio;
|
aicam->mAspect = cam.cameraProperties.perspective.aspectRatio;
|
||||||
aicam->mHorizontalFOV = cam.cameraProperties.perspective.yfov * aicam->mAspect;
|
aicam->mHorizontalFOV = cam.cameraProperties.perspective.yfov * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect);
|
||||||
aicam->mClipPlaneFar = cam.cameraProperties.perspective.zfar;
|
aicam->mClipPlaneFar = cam.cameraProperties.perspective.zfar;
|
||||||
aicam->mClipPlaneNear = cam.cameraProperties.perspective.znear;
|
aicam->mClipPlaneNear = cam.cameraProperties.perspective.znear;
|
||||||
} else {
|
} else {
|
||||||
aicam->mClipPlaneFar = cam.cameraProperties.ortographic.zfar;
|
aicam->mClipPlaneFar = cam.cameraProperties.ortographic.zfar;
|
||||||
aicam->mClipPlaneNear = cam.cameraProperties.ortographic.znear;
|
aicam->mClipPlaneNear = cam.cameraProperties.ortographic.znear;
|
||||||
aicam->mHorizontalFOV = 0.0;
|
aicam->mHorizontalFOV = 0.0;
|
||||||
aicam->mAspect = cam.cameraProperties.ortographic.xmag / cam.cameraProperties.ortographic.ymag;
|
aicam->mAspect = 1.0f;
|
||||||
|
if (0.f != cam.cameraProperties.ortographic.ymag ) {
|
||||||
|
aicam->mAspect = cam.cameraProperties.ortographic.xmag / cam.cameraProperties.ortographic.ymag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -905,6 +908,9 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
|
||||||
std::vector<std::vector<aiVertexWeight>> weighting(mesh->mNumBones);
|
std::vector<std::vector<aiVertexWeight>> weighting(mesh->mNumBones);
|
||||||
BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
|
BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
|
||||||
|
|
||||||
|
mat4* pbindMatrices = nullptr;
|
||||||
|
node.skin->inverseBindMatrices->ExtractData(pbindMatrices);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < mesh->mNumBones; ++i) {
|
for (uint32_t i = 0; i < mesh->mNumBones; ++i) {
|
||||||
aiBone* bone = new aiBone();
|
aiBone* bone = new aiBone();
|
||||||
|
|
||||||
|
@ -920,6 +926,8 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
|
||||||
}
|
}
|
||||||
GetNodeTransform(bone->mOffsetMatrix, *joint);
|
GetNodeTransform(bone->mOffsetMatrix, *joint);
|
||||||
|
|
||||||
|
CopyValue(pbindMatrices[i], bone->mOffsetMatrix);
|
||||||
|
|
||||||
std::vector<aiVertexWeight>& weights = weighting[i];
|
std::vector<aiVertexWeight>& weights = weighting[i];
|
||||||
|
|
||||||
bone->mNumWeights = static_cast<uint32_t>(weights.size());
|
bone->mNumWeights = static_cast<uint32_t>(weights.size());
|
||||||
|
@ -935,6 +943,10 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
|
||||||
}
|
}
|
||||||
mesh->mBones[i] = bone;
|
mesh->mBones[i] = bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pbindMatrices) {
|
||||||
|
delete[] pbindMatrices;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue