[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15405] branches/soc-2008-mxcurioni/source /blender/freestyle/intern/app_blender: soc-2008-mxcurioni: renamed libQGLWidget's Camera class to AppGLWidget_Camera to use Blender' s Camera struct, integrated the camera parameters from Blender.

Maxime Curioni maxime.curioni at gmail.com
Wed Jul 2 14:17:51 CEST 2008


Revision: 15405
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15405
Author:   mxcurioni
Date:     2008-07-02 14:16:36 +0200 (Wed, 02 Jul 2008)

Log Message:
-----------
soc-2008-mxcurioni: renamed libQGLWidget's Camera class to AppGLWidget_Camera to use Blender's Camera struct, integrated the camera parameters from Blender. Perspective projection (precisely field of view) is now correct. Orthographic projection still having issues.

Modified Paths:
--------------
    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/AppGLWidget_camera.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_camera.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_constraint.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_manipulatedCameraFrame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_manipulatedCameraFrame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_manipulatedFrame.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_manipulatedFrame.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp

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-07-02 11:45:37 UTC (rev 15404)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp	2008-07-02 12:16:36 UTC (rev 15405)
@@ -58,7 +58,7 @@
 AppGLWidget::AppGLWidget(const char *iName)
 {
   //soc
-  _camera = new Camera;	
+  _camera = new AppGLWidget_Camera;	
 
   _Fovy        = 30.f;
   //_SceneDepth = 2.f;

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-07-02 11:45:37 UTC (rev 15404)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h	2008-07-02 12:16:36 UTC (rev 15405)
@@ -90,7 +90,7 @@
 		void setStateFileName(const string& name);
 	
 
-		Camera * _camera;
+		AppGLWidget_Camera * _camera;
 
 protected:
 	unsigned int _width, _height;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_camera.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_camera.cpp	2008-07-02 11:45:37 UTC (rev 15404)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget_camera.cpp	2008-07-02 12:16:36 UTC (rev 15405)
@@ -36,7 +36,7 @@
 
  See IODistance(), physicalDistanceToScreen(), physicalScreenWidth() and focusDistance()
  documentations for default stereo parameter values. */
-Camera::Camera()
+AppGLWidget_Camera::AppGLWidget_Camera()
   : fieldOfView_(M_PI/4.0f)
 {
   // #CONNECTION# Camera copy constructor
@@ -85,7 +85,7 @@
 
  The frame() is deleted, but the different keyFrameInterpolator() are \e not deleted (in case they
  are shared). */
-Camera::~Camera()
+AppGLWidget_Camera::~AppGLWidget_Camera()
 {
   delete frame_;
   //delete interpolationKfi_;
@@ -93,7 +93,7 @@
 
 
 /*! Copy constructor. Performs a deep copy using operator=(). */
-Camera::Camera(const Camera& camera)
+AppGLWidget_Camera::AppGLWidget_Camera(const AppGLWidget_Camera& camera)
 {
   // #CONNECTION# Camera constructor
   //interpolationKfi_ = new KeyFrameInterpolator;
@@ -122,7 +122,7 @@
  camera()->setScreenWidthAndHeight(width(), height());
  \endcode
  The same applies to sceneCenter() and sceneRadius(), if needed. */
-Camera& Camera::operator=(const Camera& camera)
+AppGLWidget_Camera& AppGLWidget_Camera::operator=(const AppGLWidget_Camera& camera)
 {
   setScreenWidthAndHeight(camera.screenWidth(), camera.screenHeight());
   setFieldOfView(camera.fieldOfView());
@@ -164,7 +164,7 @@
 
 If your Camera is used without a QGLViewer (offscreen rendering, shadow maps), use setAspectRatio()
 instead to define the projection matrix. */
-void Camera::setScreenWidthAndHeight(int width, int height)
+void AppGLWidget_Camera::setScreenWidthAndHeight(int width, int height)
 {
   // Prevent negative and zero dimensions that would cause divisions by zero.
 	screenWidth_  = width > 0 ? width : 1;
@@ -208,7 +208,7 @@
 
  \attention The value is always positive although the clipping plane is positioned at a negative z
  value in the Camera coordinate system. This follows the \c gluPerspective standard. */
-float Camera::zNear() const
+float AppGLWidget_Camera::zNear() const
 {
   float z = distanceToSceneCenter() - zClippingCoefficient()*sceneRadius();
 
@@ -217,8 +217,8 @@
   if (z < zMin)
     switch (type())
       {
-      case Camera::PERSPECTIVE  : z = zMin; break;
-      case Camera::ORTHOGRAPHIC : z = 0.0;  break;
+      case AppGLWidget_Camera::PERSPECTIVE  : z = zMin; break;
+      case AppGLWidget_Camera::ORTHOGRAPHIC : z = 0.0;  break;
       }
   return z;
 }
@@ -232,7 +232,7 @@
 \endcode
 
 See the zNear() documentation for details. */
-float Camera::zFar() const
+float AppGLWidget_Camera::zFar() const
 {
   return distanceToSceneCenter() + zClippingCoefficient()*sceneRadius();
 }
@@ -241,12 +241,12 @@
 
 Prefix the type with Camera, as in: \code camera()->setType(Camera::ORTHOGRAPHIC); // or even
 qglviewer::Camera::ORTHOGRAPHIC if you do not use namespace \endcode */
-void Camera::setType(Type type)
+void AppGLWidget_Camera::setType(Type type)
 {
   // make ORTHOGRAPHIC frustum fit PERSPECTIVE (at least in plane normal to viewDirection(), passing
   // through RAP) Done only when CHANGING type since orthoCoef_ may have been changed with a
   // setRevolveAroundPoint() in the meantime.
-  if ( (type == Camera::ORTHOGRAPHIC) && (type_ == Camera::PERSPECTIVE) )
+  if ( (type == AppGLWidget_Camera::ORTHOGRAPHIC) && (type_ == AppGLWidget_Camera::PERSPECTIVE) )
     orthoCoef_ = tan(fieldOfView()/2.0);
   type_ = type;
 }
@@ -264,7 +264,7 @@
 
 A \c NULL \p mcf pointer will silently be ignored. The calling method is responsible for
 deleting the previous frame() pointer if needed in order to prevent memory leaks. */
-void Camera::setFrame(ManipulatedCameraFrame* const mcf)
+void AppGLWidget_Camera::setFrame(ManipulatedCameraFrame* const mcf)
 {
   if (!mcf)
     return;
@@ -275,7 +275,7 @@
 
 /*! Returns the distance from the Camera center to sceneCenter(), projected along the Camera Z axis.
   Used by zNear() and zFar() to optimize the Z range. */
-float Camera::distanceToSceneCenter() const
+float AppGLWidget_Camera::distanceToSceneCenter() const
 {
   return fabs((frame()->coordinatesOf(sceneCenter())).z);
 }
@@ -296,7 +296,7 @@
 
  Overload this method to change this behavior if desired, as is done in the 
  <a href="../examples/standardCamera.html">standardCamera example</a>. */
-void Camera::getOrthoWidthHeight(GLdouble& halfWidth, GLdouble& halfHeight) const
+void AppGLWidget_Camera::getOrthoWidthHeight(GLdouble& halfWidth, GLdouble& halfHeight) const
 {
   const float dist = orthoCoef_ * fabs(cameraCoordinatesOf(revolveAroundPoint()).z);
   //#CONNECTION# fitScreenRegion
@@ -322,14 +322,14 @@
  \note You must call this method if your Camera is not associated with a QGLViewer and is used for
  offscreen computations (using (un)projectedCoordinatesOf() for instance). loadProjectionMatrix()
  does it otherwise. */
-void Camera::computeProjectionMatrix() const
+void AppGLWidget_Camera::computeProjectionMatrix() const
 {
   const float ZNear = zNear();
   const float ZFar  = zFar();
 
   switch (type())
     {
-    case Camera::PERSPECTIVE:
+    case AppGLWidget_Camera::PERSPECTIVE:
       {
 	// #CONNECTION# all non null coefficients were set to 0.0 in constructor.
 	const float f = 1.0/tan(fieldOfView()/2.0);
@@ -342,7 +342,7 @@
 	// same as gluPerspective( 180.0*fieldOfView()/M_PI, aspectRatio(), zNear(), zFar() );
 	break;
       }
-    case Camera::ORTHOGRAPHIC:
+    case AppGLWidget_Camera::ORTHOGRAPHIC:
       {
 	GLdouble w, h;
 	getOrthoWidthHeight(w,h);
@@ -368,7 +368,7 @@
  \note You must call this method if your Camera is not associated with a QGLViewer and is used for
  offscreen computations (using (un)projectedCoordinatesOf() for instance). loadModelViewMatrix()
  does it otherwise. */
-void Camera::computeModelViewMatrix() const
+void AppGLWidget_Camera::computeModelViewMatrix() const
 {
   const Quaternion q = frame()->orientation();
 
@@ -427,7 +427,7 @@
 
  \attention If you use several OpenGL contexts and bypass the Qt main refresh loop, you should call
  QGLWidget::makeCurrent() before this method in order to activate the right OpenGL context. */
-void Camera::loadProjectionMatrix(bool reset) const
+void AppGLWidget_Camera::loadProjectionMatrix(bool reset) const
 {
   // WARNING: makeCurrent must be called by every calling method
   glMatrixMode(GL_PROJECTION);
@@ -464,7 +464,7 @@
 
  \attention If you use several OpenGL contexts and bypass the Qt main refresh loop, you should call
  QGLWidget::makeCurrent() before this method in order to activate the right OpenGL context. */
-void Camera::loadModelViewMatrix(bool reset) const
+void AppGLWidget_Camera::loadModelViewMatrix(bool reset) const
 {
   // WARNING: makeCurrent must be called by every calling method
   glMatrixMode(GL_MODELVIEW);
@@ -500,7 +500,7 @@
  Note that getProjectionMatrix() always returns the mono-vision matrix.
 
  \attention glMatrixMode is set to \c GL_PROJECTION. */
-void Camera::loadProjectionMatrixStereo(bool leftBuffer) const
+void AppGLWidget_Camera::loadProjectionMatrixStereo(bool leftBuffer) const
 {
   float left, right, bottom, top;
   float screenHalfWidth, halfWidth, side, shift, delta;
@@ -510,7 +510,7 @@
 
   switch (type())
     {
-    case Camera::PERSPECTIVE:
+    case AppGLWidget_Camera::PERSPECTIVE:
       // compute half width of screen,
       // corresponding to zero parallax plane to deduce decay of cameras
       screenHalfWidth = focusDistance() * tan(horizontalFieldOfView() / 2.0);
@@ -531,8 +531,8 @@
       glFrustum(left, right, bottom, top, zNear(), zFar() );
       break;
 
-    case Camera::ORTHOGRAPHIC:
-      cout << "Camera::setProjectionMatrixStereo: Stereo not available with Ortho mode";
+    case AppGLWidget_Camera::ORTHOGRAPHIC:
+      cout << "AppGLWidget_Camera::setProjectionMatrixStereo: Stereo not available with Ortho mode";
       break;
     }
 }
@@ -555,7 +555,7 @@
  href="../examples/contribs.html#anaglyph">anaglyph</a> examples for an illustration.
 
  \attention glMatrixMode is set to \c GL_MODELVIEW. */
-void Camera::loadModelViewMatrixStereo(bool leftBuffer) const
+void AppGLWidget_Camera::loadModelViewMatrixStereo(bool leftBuffer) const
 {
   // WARNING: makeCurrent must be called by every calling method
   glMatrixMode(GL_MODELVIEW);
@@ -585,7 +585,7 @@
  man page for details).
 
  See also getModelViewMatrix() and setFromProjectionMatrix(). */
-void Camera::getProjectionMatrix(GLdouble m[16]) const
+void AppGLWidget_Camera::getProjectionMatrix(GLdouble m[16]) const
 {
   // May not be needed, but easier and more robust like this.
   computeProjectionMatrix();
@@ -607,7 +607,7 @@
  man page for details).
 
  See also getProjectionMatrix() and setFromModelViewMatrix(). */
-void Camera::getModelViewMatrix(GLdouble m[16]) const
+void AppGLWidget_Camera::getModelViewMatrix(GLdouble m[16]) const
 {
   // May not be needed, but easier like this.

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list