Fix camera rotation from FBX, fix illegal memory access of binary data
This commit is contained in:
parent
6e527563cd
commit
efd404764d
|
@ -293,15 +293,18 @@ int main(int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned char *binaryData = &(*data_render_model->binary)[0];
|
if (data_render_model->binary->empty() == false)
|
||||||
unsigned long binarySize = data_render_model->binary->size();
|
{
|
||||||
if (fwrite(binaryData, binarySize, 1, fp) != 1) {
|
const unsigned char *binaryData = &(*data_render_model->binary)[0];
|
||||||
fmt::fprintf(stderr, "ERROR: Failed to write %lu bytes to file '%s'.\n", binarySize, binaryPath);
|
unsigned long binarySize = data_render_model->binary->size();
|
||||||
|
if (fwrite(binaryData, binarySize, 1, fp) != 1) {
|
||||||
|
fmt::fprintf(stderr, "ERROR: Failed to write %lu bytes to file '%s'.\n", binarySize, binaryPath);
|
||||||
|
fclose(fp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 1;
|
fmt::printf("Wrote %lu bytes of binary data to %s.\n", binarySize, binaryPath);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
|
||||||
fmt::printf("Wrote %lu bytes of binary data to %s.\n", binarySize, binaryPath);
|
|
||||||
|
|
||||||
delete data_render_model;
|
delete data_render_model;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -381,6 +381,14 @@ static void ReadCamera(RawModel &raw, FbxScene *pScene, FbxNode *pNode)
|
||||||
(float) pCamera->OrthoZoom, (float) pCamera->OrthoZoom,
|
(float) pCamera->OrthoZoom, (float) pCamera->OrthoZoom,
|
||||||
(float) pCamera->FarPlane, (float) pCamera->NearPlane);
|
(float) pCamera->FarPlane, (float) pCamera->NearPlane);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cameras in FBX coordinate space face +X when rotation is (0,0,0)
|
||||||
|
// We need to adjust this to face glTF specified -Z
|
||||||
|
auto nodeIdx = raw.GetNodeById(pNode->GetUniqueID());
|
||||||
|
auto& rawNode = raw.GetNode(nodeIdx);
|
||||||
|
|
||||||
|
auto r = Quatf::FromAngleAxis(-90 * ((float) M_PI / 180.0f), {0.0, 1.0, 0.0});
|
||||||
|
rawNode.rotation = rawNode.rotation * r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReadNodeProperty(RawModel &raw, FbxNode *pNode, FbxProperty &prop)
|
static void ReadNodeProperty(RawModel &raw, FbxNode *pNode, FbxProperty &prop)
|
||||||
|
|
Loading…
Reference in New Issue