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
parent690397efb2ab7b18de88a299cb3d08b8646caa25 (diff)
COLLADA: Better import and export of cameras.
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/DocumentExporter.cpp10
-rw-r--r--source/blender/collada/DocumentImporter.cpp72
2 files changed, 76 insertions, 6 deletions
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index 9fdc07f391b..deddd8f8cba 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -1905,15 +1905,15 @@ public:
}
void operator()(Object *ob, Scene *sce)
{
- // XXX add other params later
+ // TODO: shiftx, shifty, YF_dofdist
Camera *cam = (Camera*)ob->data;
std::string cam_id(get_camera_id(ob));
std::string cam_name(id_name(cam));
if (cam->type == CAM_PERSP) {
COLLADASW::PerspectiveOptic persp(mSW);
- persp.setXFov(1.0);
- persp.setAspectRatio(0.1);
+ persp.setXFov(lens_to_angle(cam->lens)*(180.0f/M_PI));
+ persp.setAspectRatio(1.0);
persp.setZFar(cam->clipend);
persp.setZNear(cam->clipsta);
COLLADASW::Camera ccam(mSW, &persp, cam_id, cam_name);
@@ -1921,8 +1921,8 @@ public:
}
else {
COLLADASW::OrthographicOptic ortho(mSW);
- ortho.setXMag(1.0);
- ortho.setAspectRatio(0.1);
+ ortho.setXMag(cam->ortho_scale);
+ ortho.setAspectRatio(1.0);
ortho.setZFar(cam->clipend);
ortho.setZNear(cam->clipsta);
COLLADASW::Camera ccam(mSW, &ortho, cam_id, cam_name);
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;