2 -----------------------------------------------------------------------------
4 This program is free software; you can redistribute it and/or modify it under
5 the terms of the GNU Lesser General Public License as published by the Free Software
6 Foundation; either version 2 of the License, or (at your option) any later
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
13 You should have received a copy of the GNU Lesser General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
16 http://www.gnu.org/copyleft/lesser.txt.
18 Contributor(s): Dalai Felinto
20 This source uses some of the ideas and code from Paul Bourke.
21 Developed as part of a Research and Development project for SAT - La Société des arts technologiques.
22 -----------------------------------------------------------------------------
25 #if !defined KX_DOME_H
29 #include "KX_Camera.h"
30 #include "DNA_screen_types.h"
31 #include "RAS_ICanvas.h"
32 #include "RAS_IRasterizer.h"
33 #include "RAS_IRenderTools.h"
34 #include "KX_KetsjiEngine.h"
39 #include "MEM_guardedalloc.h"
41 //#include "BLI_blenlib.h"
43 //Dome modes: limit hardcoded in buttons_scene.c
44 #define DOME_FISHEYE 1
45 #define DOME_TRUNCATED 2
46 #define DOME_PANORAM_SPH 3
47 #define DOME_NUM_MODES 4
50 /// class for render 3d scene
56 RAS_ICanvas* m_canvas,
58 RAS_IRasterizer* m_rasterizer,
60 RAS_IRenderTools* m_rendertools,
62 KX_KetsjiEngine* m_engine,
73 virtual ~KX_Dome (void);
79 GLuint domefacesId[7]; // ID of the images -- room for 7 images, using only 4 for 180º x 360º dome, 6 for panoramic and +1 for warp mesh
80 GLuint dlistId; // ID of the Display Lists of the images (used as an offset)
84 MT_Vector3 verts[3]; //three verts
95 int n_width, n_height; //nodes width and height
96 int imagewidth, imageheight;
97 int bufferwidth, bufferheight;
98 vector <vector <WarpMeshNode> > nodes;
101 bool ParseWarpMesh(STR_String text);
103 vector <DomeFace> cubetop, cubebottom, cuberight, cubeleft, cubefront, cubeback; //for fisheye
104 vector <DomeFace> cubeleftback, cuberightback; //for panorama
106 int nfacestop, nfacesbottom, nfacesleft, nfacesright, nfacesfront, nfacesback;
107 int nfacesleftback, nfacesrightback;
109 int GetNumberRenders(){return m_numfaces;};
111 void RenderDome(void);
112 void RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i);
113 void BindImages(int i);
115 void SetViewPort(GLuint viewport[4]);
116 void CalculateFrustum(KX_Camera* cam);
117 void RotateCamera(KX_Camera* cam, int i);
119 //Mesh Creating Functions
120 void CreateMeshDome180(void);
121 void CreateMeshDome250(void);
122 void CreateMeshPanorama(void);
124 void SplitFace(vector <DomeFace>& face, int *nfaces);
126 void FlattenDome(MT_Vector3 verts[3]);
127 void FlattenPanorama(MT_Vector3 verts[3]);
130 void GLDrawTriangles(vector <DomeFace>& face, int nfaces);
131 void GLDrawWarpQuads(void);
133 void DrawDomeFisheye(void);
134 void DrawPanorama(void);
135 void DrawDomeWarped(void);
138 void CreateGLImages(void);
139 void ClearGLImages(void);//called on resize
140 bool CreateDL(void); //create Display Lists
141 void ClearDL(void); //remove Display Lists
143 void CalculateCameraOrientation();
144 void CalculateImageSize(); //set m_imagesize
153 int m_buffersize; // canvas small dimension
154 int m_numfaces; // 4 to 6 depending on the kind of dome image
155 int m_numimages; //numfaces +1 if we have warp mesh
157 float m_size; // size to adjust
158 short m_resolution; //resolution to tesselate the mesh
159 short m_mode; // the mode (truncated, warped, panoramic,...)
160 short m_angle; //the angle of the fisheye
161 float m_radangle; //the angle of the fisheye in radians
162 float m_resbuffer; //the resolution of the buffer
166 MT_Matrix4x4 m_projmat;
168 MT_Matrix3x3 m_locRot [6];// the rotation matrix
174 RAS_ICanvas* m_canvas;
176 RAS_IRasterizer* m_rasterizer;
178 RAS_IRenderTools* m_rendertools;
180 KX_KetsjiEngine* m_engine;