Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Letwory <nathan@letworyinteractive.com>2010-09-28 12:01:20 +0400
committerNathan Letwory <nathan@letworyinteractive.com>2010-09-28 12:01:20 +0400
commit8a68326f8151ea28b1fd559c92eba1847b3330b4 (patch)
tree04b2c16523bdf728c901007abe1786270b66c0b1 /source/blender/collada/DocumentImporter.cpp
parent690397efb2ab7b18de88a299cb3d08b8646caa25 (diff)
COLLADA: Better import and export of cameras.
Diffstat (limited to 'source/blender/collada/DocumentImporter.cpp')
-rw-r--r--source/blender/collada/DocumentImporter.cpp72
1 files changed, 71 insertions, 1 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 2a3df69f0db..0e895741fae 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -3526,11 +3526,12 @@ public:
// XXX empty node may not mean it is empty object, not sure about this
else {
ob = add_object(sce, OB_EMPTY);
- rename_id(&ob->id, (char*)node->getOriginalId().c_str());
}
// check if object is not NULL
if (!ob) return;
+
+ rename_id(&ob->id, (char*)node->getOriginalId().c_str());
object_map[node->getUniqueId()] = ob;
node_map[node->getUniqueId()] = node;
@@ -3836,6 +3837,75 @@ public:
}
break;
}
+
+ switch(camera->getDescriptionType()) {
+ case COLLADAFW::Camera::ASPECTRATIO_AND_Y:
+ {
+ switch(cam->type) {
+ case CAM_ORTHO:
+ {
+ double ymag = camera->getYMag().getValue();
+ double aspect = camera->getAspectRatio().getValue();
+ double xmag = aspect*ymag;
+ cam->ortho_scale = (float)xmag;
+ }
+ break;
+ case CAM_PERSP:
+ default:
+ {
+ double yfov = camera->getYFov().getValue();
+ double aspect = camera->getAspectRatio().getValue();
+ double xfov = aspect*yfov;
+ // xfov is in degrees, cam->lens is in millimiters
+ cam->lens = angle_to_lens((float)xfov*(M_PI/180.0f));
+ }
+ break;
+ }
+ }
+ break;
+ /* XXX correct way to do following four is probably to get also render
+ size and determine proper settings from that somehow */
+ case COLLADAFW::Camera::ASPECTRATIO_AND_X:
+ case COLLADAFW::Camera::SINGLE_X:
+ case COLLADAFW::Camera::X_AND_Y:
+ {
+ switch(cam->type) {
+ case CAM_ORTHO:
+ cam->ortho_scale = (float)camera->getXMag().getValue();
+ break;
+ case CAM_PERSP:
+ default:
+ {
+ double x = camera->getXFov().getValue();
+ // x is in degrees, cam->lens is in millimiters
+ cam->lens = angle_to_lens((float)x*(M_PI/180.0f));
+ }
+ break;
+ }
+ }
+ break;
+ case COLLADAFW::Camera::SINGLE_Y:
+ {
+ switch(cam->type) {
+ case CAM_ORTHO:
+ cam->ortho_scale = (float)camera->getYMag().getValue();
+ break;
+ case CAM_PERSP:
+ default:
+ {
+ double yfov = camera->getYFov().getValue();
+ // yfov is in degrees, cam->lens is in millimiters
+ cam->lens = angle_to_lens((float)yfov*(M_PI/180.0f));
+ }
+ break;
+ }
+ }
+ break;
+ case COLLADAFW::Camera::UNDEFINED:
+ // read nothing, use blender defaults.
+ break;
+ }
+
this->uid_camera_map[camera->getUniqueId()] = cam;
// XXX import camera options
return true;