Calculating values for orthonormal camera on Collada export. Note that I have found no tool yet which can load them, so I have no test so far (CColladaFileLoader also ignores existence of orthographic cameras so far). But the old export was definitely wrong while the new solution should at least work in theory.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4409 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2012-12-19 12:11:52 +00:00
parent e0952a9c3f
commit 7afcfbd12c
2 changed files with 14 additions and 7 deletions

View File

@ -1,6 +1,7 @@
--------------------------
Changes in 1.9 (not yet released)
- Collada exporter calculates values for orthographic camera now on export
- Collada exporter now exports the camera up-vector correctly.
- Add IColladaMeshWriter::findGeometryNameForNode
- Add getters IGUIButton::isDrawBorderEnabled and IGUIButton::isDrawBackgroundEnabled

View File

@ -661,14 +661,20 @@ void CColladaMeshWriter::writeNodeCameras(irr::scene::ISceneNode * node)
Writer->writeElement(L"orthographic", false);
Writer->writeLineBreak();
// TODO: Those values are not affected by the matrix set for the ortographic projection.
// We do not have those values so far in Irrlicht for orthogonal cameras.
irr::core::matrix4 projMat( cameraNode->getProjectionMatrix() );
irr::f32 xmag = 2.f/projMat[0];
irr::f32 ymag = 2.f/projMat[5];
// writeNode(L"xmag", core::stringw("1.0").c_str()); // TODO: do we need xmag, ymag?
// writeNode(L"ymag", core::stringw("1.0").c_str());
writeNode(L"aspect_ratio", core::stringw(cameraNode->getAspectRatio()).c_str());
writeNode(L"znear", core::stringw(cameraNode->getNearValue()).c_str());
writeNode(L"zfar", core::stringw(cameraNode->getFarValue()).c_str());
// Note that Irrlicht camera does not update near/far when setting the projection matrix,
// so we have to calculate that here (at least currently - maybe camera code will be updated at some time).
irr::f32 nearMinusFar = -1.f/projMat[10];
irr::f32 zNear = projMat[14]*nearMinusFar;
irr::f32 zFar = 1.f/projMat[10] + zNear;
writeNode(L"xmag", core::stringw(xmag).c_str());
writeNode(L"ymag", core::stringw(ymag).c_str());
writeNode(L"znear", core::stringw(zNear).c_str());
writeNode(L"zfar", core::stringw(zFar).c_str());
Writer->writeClosingTag(L"orthographic");
Writer->writeLineBreak();