- Main Page
- Namespaces
- Classes
- Files

# VCRA-SZCZERBACKI-PointBasedRendering/splatting.h

    00001
    00018 #ifndef __SPLATTING_H
    00019 #define __SPLATTING_H
    00020
    00021 #include "ssVector.hpp"
    00022 #include "ssMatrix.hpp"
    00023 #include "ssAdditional.hpp"
    00024 #include "Timer.h"
    00025 #include "Mesh.h"
    00026 #include "ABuffer.h"
    00027 #include <glut.h>   /* includes glut and OpenGL */
    00028 #include <fstream>
    00029
    00030 static char lwoFileName[200];
    00032 const int   maxResolution = 609; /*256*/
    00033 const int   maxSubpixels = 16;
    00034 const float maxPrefiltersize = 0.0f;    //1.0f
    00035
    00036 static int sizex = 609,sizey = 609; /*256*/
    00037 static int subpixels = 1;
    00038 static float prefiltersize = 0.0f;      //1.0f
    00039
    00040 const float  defaultWidth = 609;
    00041 const float  defaultHeight = 609;
    00042 static float pixelScale = defaultWidth/(float)sizex;
    00043 static float figsx,figsy;
    00044
    00045 const int  jitterPatterns = 64;
    00046 const int  gausssamples = 1024;/*256*/
    00047 static Vector2 *prefilterJitter = NULL;
    00048 static Vector2 *lensJitter = NULL;
    00049
    00050 const float F = 2.0f;
    00051
    00052 const float prefiltercutoff = 2.0f;     //2.0f
    00053
    00054 const float conditionThreshold = 100.0f;
    00055
    00056 const int subdivision = 3;
    00057
    00058 const float focus = 10.0f;
    00059 const float aperture = 2.8f;
    00060 const float imagePlane = 1.0f;  //do not change
    00061 const float focalLength = imagePlane*focus/(imagePlane+focus);
    00062 const float lensRadius = focalLength*0.5f/aperture;
    00063
    00064 static bool rasterization = true;
    00065 static bool pointvisualization = false;
    00066 static bool reconstructionvisualization = false;
    00067
    00068
    00069 struct Splat
    00070 {
    00071         Vector3   m_position;
    00072         Vector3   m_normal;
    00073         Vector4   m_color;
    00074         float     m_size;
    00075 };
    00076
    00077 class CameraControls
    00078 {
    00079 public:
    00080         CameraControls( float rotationScale = 1.0f, float translationScale = 1.0f, float inertia = 0.0f, bool framerateDependent = true )
    00081         {
    00082                 m_rotationScale = rotationScale;
    00083                 m_translationScale = translationScale;
    00084                 m_inertia = inertia;
    00085                 m_framerateDependent = framerateDependent;
    00086
    00087                 m_angles.set(0,0,0);
    00088                 m_angleAdds.set(0,0,0);
    00089                 m_position.set(0,0,0);
    00090                 m_positionAdd.set(0,0,0);
    00091                 m_objectAngles.set(0,0,0);
    00092                 m_cameraMatrix.ident();
    00093         }
    00094         ~CameraControls()
    00095         {
    00096         }
    00097
    00098         const Matrix4x4 &getCameraMatrix()
    00099         {
    00100                 float s,r;
    00101                 m_timer.sample();
    00102                 float dt = m_timer.getDelta();
    00103
    00104         //camera movement
    00105                 if( m_framerateDependent )
    00106                 {
    00107                         s = 5.0f * m_translationScale * dt;
    00108                         r = m_rotationScale * 3.1415f / 4.0f * dt;
    00109                 }
    00110                 else
    00111                 {
    00112                         s = 0.5f * m_translationScale;
    00113                         r = m_rotationScale * 3.1415f / 64.0f;
    00114                 }
    00115
    00116                 m_angles += m_angleAdds;
    00117                 m_position += m_positionAdd;
    00118                 if( m_framerateDependent )
    00119                 {
    00120                         m_angleAdds *= float(pow(m_inertia,dt*30.0f));
    00121                         m_positionAdd *= float(pow(m_inertia,dt*30.0f));
    00122                 }
    00123                 else
    00124                 {
    00125                         m_angleAdds *= m_inertia;
    00126                         m_positionAdd *= m_inertia;
    00127                 }
    00128
    00129
    00130                 m_cameraMatrix.ident();
    00131                 m_cameraMatrix *= MatrixFactory::rotateZ( -m_angles.z );
    00132                 m_cameraMatrix *= MatrixFactory::rotateX( -m_angles.x );
    00133                 m_cameraMatrix *= MatrixFactory::rotateY( -m_angles.y );
    00134                 m_cameraMatrix.setColumn(3,Vector4(m_position.x,m_position.y,m_position.z,1.0f));
    00135                 return m_cameraMatrix;
    00136         }
    00137 private:
    00138         bool                    m_framerateDependent;
    00139         float                   m_inertia;
    00140         float                   m_rotationScale;
    00141         float                   m_translationScale;
    00142         Vector3                 m_angles;
    00143         Vector3                 m_angleAdds;
    00144         Vector3                 m_position;
    00145         Vector3                 m_positionAdd;
    00146         Matrix4x4               m_cameraMatrix;
    00147         Timer                   m_timer;
    00148
    00149         Vector3         m_objectAngles;
    00150 };
    00151
    00152
    00153 #define PROJECTION_PERSPECTIVE
    00154
    00155
    00156 void loadLwoFile(char *filename);
    00157
    00158 void makeJitter(int subpixels);
    00159
    00160 #endif