[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20955] branches/soc-2009-chingachgook: Importer base for Chingiz.
Arystanbek Dyussenov
arystan.d at gmail.com
Wed Jun 17 13:16:18 CEST 2009
Revision: 20955
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20955
Author: kazanbas
Date: 2009-06-17 13:16:18 +0200 (Wed, 17 Jun 2009)
Log Message:
-----------
Importer base for Chingiz.
Modified Paths:
--------------
branches/soc-2009-chingachgook/config/linux2-config.py
branches/soc-2009-chingachgook/source/blender/collada/DocumentExporter.h
branches/soc-2009-chingachgook/source/blender/collada/SConscript
branches/soc-2009-chingachgook/source/blender/collada/collada.cpp
branches/soc-2009-chingachgook/source/blender/collada/collada.h
branches/soc-2009-chingachgook/source/blender/editors/include/ED_object.h
branches/soc-2009-chingachgook/source/blender/editors/object/object_edit.c
branches/soc-2009-chingachgook/source/blender/editors/space_info/info_header.c
branches/soc-2009-chingachgook/source/blender/windowmanager/intern/wm_operators.c
branches/soc-2009-chingachgook/tools/Blender.py
branches/soc-2009-chingachgook/tools/btools.py
Added Paths:
-----------
branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp
branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.h
Modified: branches/soc-2009-chingachgook/config/linux2-config.py
===================================================================
--- branches/soc-2009-chingachgook/config/linux2-config.py 2009-06-17 11:01:05 UTC (rev 20954)
+++ branches/soc-2009-chingachgook/config/linux2-config.py 2009-06-17 11:16:18 UTC (rev 20955)
@@ -170,6 +170,9 @@
BF_PCRE = ''
BF_PCRE_LIB = 'pcre'
BF_PCRE_LIBPATH = '/usr/lib'
+BF_EXPAT = '/usr'
+BF_EXPAT_LIB = 'expat'
+BF_EXPAT_LIBPATH = '/usr/lib'
##
CC = 'gcc'
Modified: branches/soc-2009-chingachgook/source/blender/collada/DocumentExporter.h
===================================================================
--- branches/soc-2009-chingachgook/source/blender/collada/DocumentExporter.h 2009-06-17 11:01:05 UTC (rev 20954)
+++ branches/soc-2009-chingachgook/source/blender/collada/DocumentExporter.h 2009-06-17 11:16:18 UTC (rev 20955)
@@ -1,3 +1,4 @@
+struct Scene;
class DocumentExporter
{
Added: branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp
===================================================================
--- branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp (rev 0)
+++ branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp 2009-06-17 11:16:18 UTC (rev 20955)
@@ -0,0 +1,238 @@
+#include "COLLADAFWStableHeaders.h"
+#include "COLLADAFWIWriter.h"
+#include "COLLADAFWRoot.h"
+#include "COLLADAFWNode.h"
+#include "COLLADAFWVisualScene.h"
+#include "COLLADAFWInstanceGeometry.h"
+#include "COLLADAFWFileInfo.h"
+#include "COLLADAFWRoot.h"
+#include "COLLADAFWLight.h"
+#include "COLLADAFWImage.h"
+#include "COLLADAFWMaterial.h"
+#include "COLLADAFWGeometry.h"
+#include "COLLADAFWMesh.h"
+
+#include "COLLADASaxFWLLoader.h"
+
+extern "C"
+{
+#include "BKE_main.h"
+#include "BKE_mesh.h"
+#include "BKE_context.h"
+
+#include "DNA_object_types.h"
+
+#include "ED_object.h"
+
+#include "DocumentImporter.h"
+}
+
+
+/** Class that needs to be implemented by a writer.
+ IMPORTANT: The write functions are called in arbitrary order.*/
+class Writer: public COLLADAFW::IWriter
+{
+private:
+ std::string mFilename;
+
+ std::vector<COLLADAFW::VisualScene> mVisualScenes;
+
+ bContext *mContext;
+
+ class UnitConverter
+ {
+ private:
+ COLLADAFW::FileInfo::Unit mUnit;
+ COLLADAFW::FileInfo::UpAxisType mUpAxis;
+ public:
+ UnitConverter(COLLADAFW::FileInfo::UpAxisType upAxis, COLLADAFW::FileInfo::Unit& unit) :
+ mUpAxis(upAxis), mUnit(unit)
+ {
+ }
+
+ // TODO
+ // convert vector vec from COLLADA format to Blender
+ void convertVec3(float *vec)
+ {
+ }
+
+ // TODO need also for angle conversion, time conversion...
+ };
+
+public:
+
+ /** Constructor. */
+ Writer(bContext *C, const char *filename) : mContext(C), mFilename(filename) {};
+
+ /** Destructor. */
+ ~Writer() {};
+
+ bool write()
+ {
+ COLLADASaxFWL::Loader loader;
+ COLLADAFW::Root root(&loader, this);
+
+ // XXX report error
+ if (!root.loadDocument(mFilename))
+ return false;
+ }
+
+ /** This method will be called if an error in the loading process occurred and the loader cannot
+ continue to to load. The writer should undo all operations that have been performed.
+ @param errorMessage A message containing informations about the error that occurred.
+ */
+ virtual void cancel(const COLLADAFW::String& errorMessage)
+ {
+ }
+
+ /** This is the method called. The writer hast to prepare to receive data.*/
+ virtual void start()
+ {
+ }
+
+ /** This method is called after the last write* method. No other methods will be called after this.*/
+ virtual void finish()
+ {
+ // using mVisualScenes, do:
+ // - write <node> data to Objects: materials, transforms, etc.
+ }
+
+ /** When this method is called, the writer must write the global document asset.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeGlobalAsset ( const COLLADAFW::FileInfo* asset )
+ {
+ // XXX take up_axis, unit into account
+ // COLLADAFW::FileInfo::Unit unit = asset->getUnit();
+ // COLLADAFW::FileInfo::UpAxisType upAxis = asset->getUpAxisType();
+
+ return true;
+ }
+
+ /** When this method is called, the writer must write the scene.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeScene ( const COLLADAFW::Scene* scene )
+ {
+ // XXX could store the scene id, but do nothing for now
+ return true;
+ }
+
+ /** When this method is called, the writer must write the entire visual scene.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeVisualScene ( const COLLADAFW::VisualScene* visualScene )
+ {
+ // for the sake of clarity link nodes to geometries at a later stage
+ mVisualScenes.push_back(*visualScene);
+ return true;
+ }
+
+ /** When this method is called, the writer must handle all nodes contained in the
+ library nodes.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeLibraryNodes ( const COLLADAFW::LibraryNodes* libraryNodes )
+ {
+ return true;
+ }
+
+ /** When this method is called, the writer must write the geometry.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeGeometry ( const COLLADAFW::Geometry* geometry )
+ {
+ // - create a mesh object
+ // - enter editmode getting editmesh
+ // - write geometry
+ // - exit editmode
+
+ // check geometry->getType() first
+ COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh*)geometry;
+
+ // create a mesh object
+ Object *ob = ED_object_add_type(mContext, OB_MESH);
+ Mesh *me = (Mesh*)ob->data;
+
+ // enter editmode
+ ED_object_enter_editmode(mContext, 0);
+
+ EditMesh *em = BKE_mesh_get_editmesh(me);
+
+ // write geometry
+ // currently only support <triangles>
+
+ BKE_mesh_end_editmesh(me, em);
+
+ // exit editmode
+ ED_object_exit_editmode(mContext, EM_FREEDATA);
+
+ return true;
+ }
+
+ /** When this method is called, the writer must write the material.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeMaterial( const COLLADAFW::Material* material )
+ {
+ // TODO: create and store a material.
+ // Let it have 0 users for now.
+ return true;
+ }
+
+ /** When this method is called, the writer must write the effect.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeEffect( const COLLADAFW::Effect* effect )
+ {
+ return true;
+ }
+
+ /** When this method is called, the writer must write the camera.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeCamera( const COLLADAFW::Camera* camera )
+ {
+ return true;
+ }
+
+ /** When this method is called, the writer must write the image.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeImage( const COLLADAFW::Image* image )
+ {
+ return true;
+ }
+
+ /** When this method is called, the writer must write the light.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeLight( const COLLADAFW::Light* light )
+ {
+ return true;
+ }
+
+ /** When this method is called, the writer must write the Animation.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeAnimation( const COLLADAFW::Animation* animation )
+ {
+ return true;
+ }
+
+ /** When this method is called, the writer must write the AnimationList.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeAnimationList( const COLLADAFW::AnimationList* animationList )
+ {
+ return true;
+ }
+
+ /** When this method is called, the writer must write the skin controller data.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeSkinControllerData( const COLLADAFW::SkinControllerData* skinControllerData )
+ {
+ return true;
+ }
+
+ /** When this method is called, the writer must write the controller.
+ @return The writer should return true, if writing succeeded, false otherwise.*/
+ virtual bool writeController( const COLLADAFW::Controller* Controller )
+ {
+ return true;
+ }
+};
+
+void DocumentImporter::import(bContext *C, const char *filename)
+{
+ Writer w(C, filename);
+ w.write();
+}
Added: branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.h
===================================================================
--- branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.h (rev 0)
+++ branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.h 2009-06-17 11:16:18 UTC (rev 20955)
@@ -0,0 +1,8 @@
+struct Main;
+struct bContext;
+
+class DocumentImporter
+{
+ public:
+ void import(bContext *C, const char *filename);
+};
Modified: branches/soc-2009-chingachgook/source/blender/collada/SConscript
===================================================================
--- branches/soc-2009-chingachgook/source/blender/collada/SConscript 2009-06-17 11:01:05 UTC (rev 20954)
+++ branches/soc-2009-chingachgook/source/blender/collada/SConscript 2009-06-17 11:16:18 UTC (rev 20955)
@@ -4,7 +4,7 @@
sources = env.Glob('*.cpp')
# relative paths to include dirs, space-separated, string
-incs = '../blenlib ../blenkernel %s/COLLADAStreamWriter/include %s/COLLADABaseUtils/include' % (env['BF_OPENCOLLADA'], env['BF_OPENCOLLADA']) + ' ../makesdna'
+incs = '../blenlib ../blenkernel ../makesdna ../makesrna ../editors/include [OPENCOLLADA]/COLLADAStreamWriter/include [OPENCOLLADA]/COLLADABaseUtils/include [OPENCOLLADA]/COLLADAFramework/include [OPENCOLLADA]/COLLADASaxFrameworkLoader/include '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA'])
env.BlenderLib ('bf_collada', sources, Split(incs), [], libtype='core', priority=200 )
Modified: branches/soc-2009-chingachgook/source/blender/collada/collada.cpp
===================================================================
--- branches/soc-2009-chingachgook/source/blender/collada/collada.cpp 2009-06-17 11:01:05 UTC (rev 20954)
+++ branches/soc-2009-chingachgook/source/blender/collada/collada.cpp 2009-06-17 11:16:18 UTC (rev 20955)
@@ -1,11 +1,17 @@
-#include <stdio.h>
+#include "BKE_main.h"
#include "BKE_scene.h"
+#include "BKE_context.h"
+
#include "DocumentExporter.h"
+#include "DocumentImporter.h"
extern "C"
{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list