pull/2656/head
Kim Kulling 2019-09-14 09:12:08 +02:00
parent ab3528f726
commit 79056da4be
4 changed files with 30 additions and 8 deletions

View File

@ -1180,8 +1180,12 @@ inline void Light::SetDefaults()
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")) {
this->children.reserve(children->Size());
for (unsigned int i = 0; i < children->Size(); ++i) {

View File

@ -475,14 +475,17 @@ void glTFImporter::ImportCameras(glTF::Asset& r) {
if (cam.type == Camera::Perspective) {
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->mClipPlaneNear = cam.perspective.znear;
} else {
aicam->mClipPlaneFar = cam.ortographic.zfar;
aicam->mClipPlaneNear = cam.ortographic.znear;
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;
}
}
}
}

View File

@ -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")) {
this->children.reserve(children->Size());

View File

@ -702,16 +702,19 @@ void glTF2Importer::ImportCameras(glTF2::Asset& r)
if (cam.type == Camera::Perspective) {
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->mClipPlaneNear = cam.cameraProperties.perspective.znear;
} else {
aicam->mClipPlaneFar = cam.cameraProperties.ortographic.zfar;
aicam->mClipPlaneNear = cam.cameraProperties.ortographic.znear;
aicam->mHorizontalFOV = 0.0;
aicam->mAspect = 1.0f;
if (0.f != cam.cameraProperties.ortographic.ymag ) {
aicam->mAspect = cam.cameraProperties.ortographic.xmag / cam.cameraProperties.ortographic.ymag;
}
}
}
}
void glTF2Importer::ImportLights(glTF2::Asset& r)
@ -905,6 +908,9 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
std::vector<std::vector<aiVertexWeight>> weighting(mesh->mNumBones);
BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
mat4* pbindMatrices = nullptr;
node.skin->inverseBindMatrices->ExtractData(pbindMatrices);
for (uint32_t i = 0; i < mesh->mNumBones; ++i) {
aiBone* bone = new aiBone();
@ -920,6 +926,8 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
}
GetNodeTransform(bone->mOffsetMatrix, *joint);
CopyValue(pbindMatrices[i], bone->mOffsetMatrix);
std::vector<aiVertexWeight>& weights = weighting[i];
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;
}
if (pbindMatrices) {
delete[] pbindMatrices;
}
}
}