[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32338] trunk/blender: COLLADA exporter: split camera and light export into own files.
Nathan Letwory
nathan at letworyinteractive.com
Wed Oct 6 09:13:43 CEST 2010
Revision: 32338
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32338
Author: jesterking
Date: 2010-10-06 09:13:42 +0200 (Wed, 06 Oct 2010)
Log Message:
-----------
COLLADA exporter: split camera and light export into own files.
Modified Paths:
--------------
trunk/blender/CMakeLists.txt
trunk/blender/source/blender/collada/DocumentExporter.cpp
trunk/blender/source/blender/collada/collada_internal.h
Added Paths:
-----------
trunk/blender/source/blender/collada/CameraExporter.cpp
trunk/blender/source/blender/collada/CameraExporter.h
trunk/blender/source/blender/collada/LightExporter.cpp
trunk/blender/source/blender/collada/LightExporter.h
trunk/blender/source/blender/collada/collada_internal.cpp
Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt 2010-10-06 00:36:12 UTC (rev 32337)
+++ trunk/blender/CMakeLists.txt 2010-10-06 07:13:42 UTC (rev 32338)
@@ -483,7 +483,7 @@
IF(WITH_LCMS)
SET(LCMS ${LIBDIR}/lcms)
- SET(LCMS_INC ${LCMS}/include)
+ SET(LCMS_INCLUDE_DIR ${LCMS}/include)
SET(LCMS_LIBPATH ${LCMS}/lib)
SET(LCMS_LIB lcms)
ENDIF(WITH_LCMS)
Added: trunk/blender/source/blender/collada/CameraExporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/CameraExporter.cpp (rev 0)
+++ trunk/blender/source/blender/collada/CameraExporter.cpp 2010-10-06 07:13:42 UTC (rev 32338)
@@ -0,0 +1,86 @@
+/**
+ * $Id: DocumentExporter.cpp 32309 2010-10-05 00:05:14Z jesterking $
+ *
+ * ***** 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 *****
+ */
+
+#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): COLLADASW::LibraryCameras(sw){}
+
+template<class Functor>
+void forEachCameraObjectInScene(Scene *sce, Functor &f)
+{
+ Base *base= (Base*) sce->base.first;
+ while(base) {
+ Object *ob = base->object;
+
+ if (ob->type == OB_CAMERA && ob->data) {
+ f(ob, sce);
+ }
+ base= base->next;
+ }
+}
+
+void CamerasExporter::exportCameras(Scene *sce)
+{
+ openLibrary();
+
+ forEachCameraObjectInScene(sce, *this);
+
+ 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));
+
+ if (cam->type == CAM_PERSP) {
+ COLLADASW::PerspectiveOptic persp(mSW);
+ 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);
+ addCamera(ccam);
+ }
+ else {
+ COLLADASW::OrthographicOptic ortho(mSW);
+ 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);
+ addCamera(ccam);
+ }
+}
Added: trunk/blender/source/blender/collada/CameraExporter.h
===================================================================
--- trunk/blender/source/blender/collada/CameraExporter.h (rev 0)
+++ trunk/blender/source/blender/collada/CameraExporter.h 2010-10-06 07:13:42 UTC (rev 32338)
@@ -0,0 +1,43 @@
+/**
+ * $Id: DocumentExporter.cpp 32309 2010-10-05 00:05:14Z jesterking $
+ *
+ * ***** 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 *****
+ */
+
+#ifndef __CAMERAEXPORTER_H__
+#define __CAMERAEXPORTER_H__
+
+#include "COLLADASWStreamWriter.h"
+#include "COLLADASWLibraryCameras.h"
+
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+class CamerasExporter: COLLADASW::LibraryCameras
+{
+public:
+ CamerasExporter(COLLADASW::StreamWriter *sw);
+ void exportCameras(Scene *sce);
+ void operator()(Object *ob, Scene *sce);
+};
+
+#endif
Modified: trunk/blender/source/blender/collada/DocumentExporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/DocumentExporter.cpp 2010-10-06 00:36:12 UTC (rev 32337)
+++ trunk/blender/source/blender/collada/DocumentExporter.cpp 2010-10-06 07:13:42 UTC (rev 32338)
@@ -95,11 +95,11 @@
#include "COLLADASWTexture.h"
#include "COLLADASWLibraryMaterials.h"
#include "COLLADASWBindMaterial.h"
-#include "COLLADASWLibraryCameras.h"
+//#include "COLLADASWLibraryCameras.h"
#include "COLLADASWLibraryLights.h"
#include "COLLADASWInstanceCamera.h"
#include "COLLADASWInstanceLight.h"
-#include "COLLADASWCameraOptic.h"
+//#include "COLLADASWCameraOptic.h"
#include "COLLADASWConstants.h"
#include "COLLADASWLibraryControllers.h"
#include "COLLADASWInstanceController.h"
@@ -108,6 +108,9 @@
#include "collada_internal.h"
#include "DocumentExporter.h"
+#include "CameraExporter.h"
+#include "LightExporter.h"
+
#include <vector>
#include <algorithm> // std::find
@@ -128,163 +131,8 @@
return data->layers[layer_index].name;
}
-/**
-Translation map.
-Used to translate every COLLADA id to a valid id, no matter what "wrong" letters may be
-included. Look at the IDREF XSD declaration for more.
-Follows strictly the COLLADA XSD declaration which explicitly allows non-english chars,
-like special chars (e.g. micro sign), umlauts and so on.
-The COLLADA spec also allows additional chars for member access ('.'), these
-must obviously be removed too, otherwise they would be heavily misinterpreted.
-*/
-const unsigned char translate_start_name_map[256] = {
-95, 95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-65, 66, 67, 68, 69, 70, 71, 72,
-73, 74, 75, 76, 77, 78, 79, 80,
-81, 82, 83, 84, 85, 86, 87, 88,
-89, 90, 95, 95, 95, 95, 95, 95,
-97, 98, 99, 100, 101, 102, 103, 104,
-105, 106, 107, 108, 109, 110, 111, 112,
-113, 114, 115, 116, 117, 118, 119, 120,
-121, 122, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 192,
-193, 194, 195, 196, 197, 198, 199, 200,
-201, 202, 203, 204, 205, 206, 207, 208,
-209, 210, 211, 212, 213, 214, 95, 216,
-217, 218, 219, 220, 221, 222, 223, 224,
-225, 226, 227, 228, 229, 230, 231, 232,
-233, 234, 235, 236, 237, 238, 239, 240,
-241, 242, 243, 244, 245, 246, 95, 248,
-249, 250, 251, 252, 253, 254, 255};
-const unsigned char translate_name_map[256] = {
-95, 95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 45, 95, 95, 48,
-49, 50, 51, 52, 53, 54, 55, 56,
-57, 95, 95, 95, 95, 95, 95, 95,
-65, 66, 67, 68, 69, 70, 71, 72,
-73, 74, 75, 76, 77, 78, 79, 80,
-81, 82, 83, 84, 85, 86, 87, 88,
-89, 90, 95, 95, 95, 95, 95, 95,
-97, 98, 99, 100, 101, 102, 103, 104,
-105, 106, 107, 108, 109, 110, 111, 112,
-113, 114, 115, 116, 117, 118, 119, 120,
-121, 122, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 95, 95,
-95, 95, 95, 95, 95, 95, 183, 95,
-95, 95, 95, 95, 95, 95, 95, 192,
-193, 194, 195, 196, 197, 198, 199, 200,
-201, 202, 203, 204, 205, 206, 207, 208,
-209, 210, 211, 212, 213, 214, 95, 216,
-217, 218, 219, 220, 221, 222, 223, 224,
-225, 226, 227, 228, 229, 230, 231, 232,
-233, 234, 235, 236, 237, 238, 239, 240,
-241, 242, 243, 244, 245, 246, 95, 248,
-249, 250, 251, 252, 253, 254, 255};
-typedef std::map< std::string, std::vector<std::string> > map_string_list;
-map_string_list global_id_map;
-
-/** Look at documentation of translate_map */
-static std::string translate_id(const std::string &id)
-{
- if (id.size() == 0)
- { return id; }
- std::string id_translated = id;
- id_translated[0] = translate_start_name_map[(unsigned int)id_translated[0]];
- for (unsigned int i=1; i < id_translated.size(); i++)
- {
- id_translated[i] = translate_name_map[(unsigned int)id_translated[i]];
- }
- // It's so much workload now, the if() should speed up things.
- if (id_translated != id)
- {
- // Search duplicates
- map_string_list::iterator iter = global_id_map.find(id_translated);
- if (iter != global_id_map.end())
- {
- unsigned int i = 0;
- bool found = false;
- for (i=0; i < iter->second.size(); i++)
- {
- if (id == iter->second[i])
- {
- found = true;
- break;
- }
- }
- bool convert = false;
- if (found)
- {
- if (i > 0)
- { convert = true; }
- }
- else
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list