[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14967] branches/soc-2008-mxcurioni/source /blender/freestyle: soc-2008-mxcurioni: Big update.

Maxime Curioni maxime.curioni at gmail.com
Sun May 25 19:34:21 CEST 2008


Revision: 14967
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14967
Author:   mxcurioni
Date:     2008-05-25 19:34:21 +0200 (Sun, 25 May 2008)

Log Message:
-----------
soc-2008-mxcurioni: Big update. Finally works (links and compiles). So far, the following steps work:
1. instantiates the config path, the controller and the view
2. sets the controller?\226?\128?\153s view
3. loads a 3ds file (right now a fixed file)
4. inserts a style module (right now, also fixed)
5. computes the view map

The next and final step is running the Python script. A lot of information are fixed and should be changed to test the following code: see source/blender/freestyle/app_blender/*.cpp and search for fixed paths (starting in /Users/).

I am currently evaluating whether it's worth making Python run on its own environment (right now, the program crashes because of PyImport_AddModule) or whether it should use Blender's Python capabilities. Also, I need to figure out how to integrate the SWIG wrapper dynamic library into the current scheme.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppCanvas.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppConfig.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Canvas.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/StringUtils.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp

Added Paths:
-----------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/camera.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/camera.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/config.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/constraint.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/frame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/frame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/manipulatedCameraFrame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/manipulatedCameraFrame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/manipulatedFrame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/manipulatedFrame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/old_camera_vec_quaternion.txt
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/point.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/quaternion.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/quaternion.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/vec.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/vec.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/python/
    branches/soc-2008-mxcurioni/source/blender/freestyle/python/Freestyle.py

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2008-05-25 16:39:57 UTC (rev 14966)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2008-05-25 17:34:21 UTC (rev 14967)
@@ -55,9 +55,14 @@
 prefix = 'intern/app_blender'
 app_sources = env.Glob(prefix + '/*.cpp')
 
+# 	swig wrapper
+#prefix = 'intern/swig'
+#swig_sources = env.Glob(prefix + '/*.cpp')
+swig_sources = []
+
 sources = 	system_sources + image_sources + geometry_sources + scene_graph_sources \
 		  +	winged_edge_sources + view_map_sources + stroke_sources + rendering_sources \
-		  + app_sources
+		  + app_sources + swig_sources
 
 env.BlenderLib (libname="bf_freestyle",
 				sources=sources,
@@ -70,4 +75,21 @@
 ########################################################
 # SWIG
 ########################################################
-#	swig
\ No newline at end of file
+#	swig
+
+# swig -c++ -python -o ModuleWrapper.cpp Freestyle.i
+#
+# g++   -w  -I../geometry -I../image -I../scene_graph -I../stroke -I../system -I../view_map -I../winged_edge -I/usr/include/python2.5 -c ModuleWrapper.cpp -o ModuleWrapper.o
+#
+# install -d ../../build/macosx/release/lib/python
+#
+# g++ -bundle -flat_namespace -undefined suppress  -w  -L/usr/lib/python2.5/config -lpython2.5 -o ../../build/macosx/release/lib/python/_Freestyle.so ModuleWrapper.o
+# 
+# install Freestyle.py ../../build/macosx/release/lib/python
+
+
+#================ MINE
+
+# g++ -w  -I../geometry -I../image -I../scene_graph -I../stroke -I../system -I../view_map -I../winged_edge -I/usr/include/python2.5 -I../../../blenlib -I../../../blenkernel -I../../../imbuf -I../../../makesdna -c ModuleWrapper.cpp -o ModuleWrapper.o
+# 
+# g++ -bundle -flat_namespace -undefined suppress  -w  -L/usr/lib/python2.5/config -lpython2.5 -o ../../python/_Freestyle.so ModuleWrapper.o
\ No newline at end of file

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppCanvas.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppCanvas.cpp	2008-05-25 16:39:57 UTC (rev 14966)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppCanvas.cpp	2008-05-25 17:34:21 UTC (rev 14967)
@@ -29,6 +29,7 @@
 #include "../rendering/GLStrokeRenderer.h"
 #include "../rendering/GLUtils.h"
 #include "AppConfig.h"
+
 #include "../system/StringUtils.h"
 
 #ifdef WIN32

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppConfig.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppConfig.cpp	2008-05-25 16:39:57 UTC (rev 14966)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppConfig.cpp	2008-05-25 17:34:21 UTC (rev 14967)
@@ -31,8 +31,12 @@
     // get the home directory
     _HomeDir = getEnvVar("HOME");
     // get the root directory
-    setRootDir(getEnvVar("FREESTYLE_DIR"));
-    //setRootDir(QString("."));
+	//soc
+	//setRootDir(getEnvVar("FREESTYLE_BLENDER_DIR"));
+	setRootDir("/Users/mx/Documents/work/GSoC_2008/bf-blender/branches/soc-2008-mxcurioni/source/blender/freestyle");
+	cout << _PythonPath << endl;
+
+//setRootDir(QString("."));
     _pInstance = this;
   }
   void Path::setRootDir(const string& iRootDir){
@@ -59,7 +63,7 @@
               "python" + 
               string(PATH_SEP.c_str()) +
               _ProjectDir +
-					    string(DIR_SEP.c_str()) +
+				string(DIR_SEP.c_str()) +
               "style_modules" +
               string(DIR_SEP.c_str()) ;
     if (getenv("PYTHONPATH")) {

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp	2008-05-25 16:39:57 UTC (rev 14966)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp	2008-05-25 17:34:21 UTC (rev 14967)
@@ -36,9 +36,12 @@
 #include "AppConfig.h"
 
 #include "../system/StringUtils.h"
+
+extern "C" {
 #include "BLI_blenlib.h"
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
+}
 
 // glut.h must be included last to avoid a conflict with stdlib.h on vc .net 2003 and 2005
 #ifdef __MACH__
@@ -54,6 +57,9 @@
 
 AppGLWidget::AppGLWidget(const char *iName)
 {
+  //soc
+  _camera = new Camera;	
+
   _Fovy        = 30.f;
   //_SceneDepth = 2.f;
   _RenderStyle = LINE;
@@ -146,8 +152,6 @@
   //  _backBufferFlag = true;
   _record = false;
 
-_camera = new Camera;
-
 }
 
 AppGLWidget::~AppGLWidget()
@@ -609,3 +613,27 @@
 //  delete [] colorPixels;  
 //}
 
+
+//*******************************
+// COPIED FROM LIBQGLVIEWER
+//*******************************
+
+	// inherited 
+	void AppGLWidget::swapBuffers() {}
+	
+	//Updates the display. Do not call draw() directly, use this method instead. 
+	void AppGLWidget::updateGL() {}
+
+	//Makes this widget's rendering context the current OpenGL rendering context. Useful with several viewers
+	void AppGLWidget::makeCurrent() {}
+
+
+	// not-inherited
+
+	//	Convenient way to call setSceneCenter() and setSceneRadius() from a (world axis aligned) bounding box of the scene.
+	void AppGLWidget::setSceneBoundingBox(const Vec& min, const Vec& max) { _camera->setSceneBoundingBox(min,max); }
+		
+	void AppGLWidget::saveSnapshot(bool b) {}
+
+	 void AppGLWidget::setStateFileName(const string& name) { stateFileName_ = name; };
+

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h	2008-05-25 16:39:57 UTC (rev 14966)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h	2008-05-25 17:34:21 UTC (rev 14967)
@@ -47,6 +47,11 @@
 # include "../rendering/GLDebugRenderer.h"
 //# include <QGLViewer/qglviewer.h>
 
+//soc
+#include "camera.h"
+#include "vec.h"
+#include "quaternion.h"
+
 using namespace Geometry;
 
 typedef enum {SURFACIC, LINE, DEPTHBUFFER} RenderStyle;
@@ -58,75 +63,9 @@
 class GLBBoxRenderer;
 class GLMonoColorRenderer;
 class GLDebugRenderer;
-
-class Vec{
-public:
-	Vec() {};
-	Vec(float _x, float _y, float _z): x(_x), y(_y), z(_z) {};
-	~Vec() {}
-	
-	float operator[] (unsigned i) {
-		switch(i){
-		case 0: return x; break;
-		case 1: return y; break;
-		case 2: return z; break;
-		}
-		return 0.0;
-	}
-		
-	
-	float x,y,z;
-};
-
-class Quaternion{
-public:
-	Quaternion( float _x, float _y, float _z, float _s): x(_x), y(_y), z(_z), s(_s){};
-	~Quaternion() {}
-	
-	float operator[] (unsigned i) {
-		switch(i){
-		case 0: return x; break;
-		case 1: return y; break;
-		case 2: return z; break;
-		case 3: return s; break;
-		}
-		return 0.0;
-	}
-	
-	float x,y,z,s;
-};
-
-class Camera {
-	private:
-		float _position[3];
-		float _orientation[3];
-		
-	public:
-		Camera(){};
-	  	~Camera() {};
-		
-		void setZNearCoefficient(float f) {}
-		void playPath(int i) {}
-
-		void loadProjectionMatrix() {}
-		void loadModelViewMatrix() {}
-		real distanceToSceneCenter() { return 0;}
-		void showEntireScene() {} 
-		real zFar() {return 0;}
-		real zNear() {return 0;}
-		void setPosition(Vec v) {}
-		void setOrientation(Quaternion q) {}
-		float* position() { return _position; }
-		float* orientation()  { return _orientation; }
-		void getWorldCoordinatesOf(float *src, float *vp_tmp) {}
-
-};
-
-
-//class AppGLWidget : public QGLViewer
+ 
 class AppGLWidget
 {
-  //Q_OBJECT
 
     
 public:
@@ -136,18 +75,28 @@
   
 public:
 
-	inline void swapBuffers() {}
-  inline void updateGL() {}
-  inline void makeCurrent() {}
-  inline void setSceneBoundingBox(Vec &min_, Vec &max_) {}
-	inline void saveSnapshot(bool b) {}
-	inline real width() { return _width; }
-	inline real height() { return _height; }
-	 void setStateFileName(const string& name) { stateFileName_ = name; };
+	//inherited
+		inline real width() { return _width; }
+		inline real height() { return _height; }
+		void swapBuffers();
+		void updateGL();
+		void makeCurrent();
 	
+	// not-inherited
+		void setSceneBoundingBox(const Vec& min, const Vec& max);
+		void saveSnapshot(bool b);
+		void setStateFileName(const string& name);
 	
-Camera * _camera;
 
+		Camera * _camera;
+
+protected:
+	real _width, _height;
+	Vec _min,_max;
+	string stateFileName_;
+
+public:
+
   // captures a frame animation that was previously registered
   void captureMovie();
 
@@ -452,8 +401,8 @@
   }
 
   void getCameraState(float* position, float* orientation) const {
-    float* pos = _camera->position();
-    float* orient = _camera->orientation();
+	Vec pos = _camera->position();
+	Quaternion orient = _camera->orientation();
     int i;
     for(i=0;i<3;++i){
       position[i] = pos[i];
@@ -585,9 +534,7 @@
   bool _record;
 
 
-real _width, _height;
-Vec _min,_max;
-string stateFileName_;
+
 };
 
 #endif // ARTGLWIDGET_H

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp	2008-05-25 16:39:57 UTC (rev 14966)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/Controller.cpp	2008-05-25 17:34:21 UTC (rev 14967)
@@ -67,9 +67,9 @@
 
 Controller::Controller()
 {
+	
   const string sep(Config::DIR_SEP.c_str());
-  const string filename = Config::Path::getInstance()->getHomeDir() + sep +
-    Config::OPTIONS_DIR + sep + Config::OPTIONS_CURRENT_DIRS_FILE;
+  //const string filename = Config::Path::getInstance()->getHomeDir() + sep + Config::OPTIONS_DIR + sep + Config::OPTIONS_CURRENT_DIRS_FILE;
   //_current_dirs = new ConfigIO(filename, Config::APPLICATION_NAME + "CurrentDirs", true);
 
   _RootNode = new NodeGroup;
@@ -88,6 +88,7 @@
 
   _edgeTesselationNature = (Nature::SILHOUETTE | Nature::BORDER | Nature::CREASE);
 
+  _ProgressBar = new ProgressBar;
   _SceneNumFaces = 0;
   _minEdgeSize = DBL_MAX;
   _bboxDiag = 0;
@@ -180,9 +181,12 @@
   NodeGroup *maxScene = loader3DS.Load();
 
   if (maxScene == NULL) {
+	cout << "Cannot load scene" << endl;
     return 1;
   }
 
+  cout << "Scene loaded\n" << endl;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list