For sample images see: http://www.dalaifelinto.com/?p=399 (equisolid) http://www.dalaifelinto.com/?p=389 (equidistant) The 'use_panorama' option is now part of a new Camera type: 'Panorama'. Created two other panorama cameras: - Equisolid: most of lens in the market simulate this lens - e.g. Nikon, Canon, ...) this works as a real lens up to an extent. The final result takes the sensor dimensions into account also. .:. to simulate a Nikon DX2S with a 10.5mm lens do: sensor: 23.7 x 15.7 fisheye lens: 10.5 fisheye fov: 180 render dimensions: 4288 x 2848 - Equidistant: this is not a real lens model. Although the old equidistant lens simulate this lens. The result is always as a circular fisheye that takes the whole sensor (in other words, it doesn't take the sensor into consideration). This is perfect for fulldomes ;) For the UI we have 10 to 360 as soft values and 10 to 3600 as hard values (because we can). Reference material: http://www.hdrlabs.com/tutorials/downloads_files/HDRI%20for%20CGI.pdf http://www.bobatkins.com/photography/technical/field_of_view.html Note, this is not a real simulation of the light path through the lens. The ideal solution would be this: https://graphics.stanford.edu/wikis/cs348b-11/Assignment3 http://www.graphics.stanford.edu/papers/camera/ Thanks Brecht for the fix, suggestions and code review. Kudos for the dome community for keeping me stimulated on the topic since 2009 ;) Patch partly implemented during lab time at VisGraf, IMPA - Rio de Janeiro.
96 lines
2.8 KiB
C++
96 lines
2.8 KiB
C++
/*
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
* Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed,
|
|
* Nathan Letwory
|
|
*
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
*/
|
|
|
|
/** \file blender/collada/CameraExporter.cpp
|
|
* \ingroup collada
|
|
*/
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "COLLADASWCamera.h"
|
|
#include "COLLADASWCameraOptic.h"
|
|
|
|
#include "DNA_camera_types.h"
|
|
|
|
#include "CameraExporter.h"
|
|
|
|
#include "collada_internal.h"
|
|
|
|
CamerasExporter::CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryCameras(sw), export_settings(export_settings) {}
|
|
|
|
template<class Functor>
|
|
void forEachCameraObjectInScene(Scene *sce, Functor &f, bool export_selected)
|
|
{
|
|
Base *base = (Base*) sce->base.first;
|
|
while (base) {
|
|
Object *ob = base->object;
|
|
|
|
if (ob->type == OB_CAMERA && ob->data && !(export_selected && !(ob->flag & SELECT))) {
|
|
f(ob, sce);
|
|
}
|
|
base = base->next;
|
|
}
|
|
}
|
|
|
|
void CamerasExporter::exportCameras(Scene *sce)
|
|
{
|
|
openLibrary();
|
|
|
|
forEachCameraObjectInScene(sce, *this, this->export_settings->selected);
|
|
|
|
closeLibrary();
|
|
}
|
|
void CamerasExporter::operator()(Object *ob, Scene *sce)
|
|
{
|
|
// 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));
|
|
|
|
switch (cam->type) {
|
|
case CAM_PANO:
|
|
case CAM_PERSP: {
|
|
COLLADASW::PerspectiveOptic persp(mSW);
|
|
persp.setXFov(RAD2DEGF(focallength_to_fov(cam->lens, cam->sensor_x)), "xfov");
|
|
persp.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch), false, "aspect_ratio");
|
|
persp.setZFar(cam->clipend, false, "zfar");
|
|
persp.setZNear(cam->clipsta, false, "znear");
|
|
COLLADASW::Camera ccam(mSW, &persp, cam_id, cam_name);
|
|
addCamera(ccam);
|
|
break;
|
|
}
|
|
case CAM_ORTHO:
|
|
default:
|
|
{
|
|
COLLADASW::OrthographicOptic ortho(mSW);
|
|
ortho.setXMag(cam->ortho_scale, "xmag");
|
|
ortho.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch), false, "aspect_ratio");
|
|
ortho.setZFar(cam->clipend, false, "zfar");
|
|
ortho.setZNear(cam->clipsta, false, "znear");
|
|
COLLADASW::Camera ccam(mSW, &ortho, cam_id, cam_name);
|
|
addCamera(ccam);
|
|
break;
|
|
}}
|
|
}
|