27 #include <vigra/windows.h>
30 #include "hugin_config.h"
31 #if defined HAVE_EPOXY && HAVE_EPOXY
36 #include <OpenGL/gl.h>
58 visualization_state(visualization_state),
65 for (std::vector<MeshInfo*>::iterator it =
meshes.begin() ; it !=
meshes.end() ; ++it) {
73 unsigned int old_size =
meshes.size();
81 for (
unsigned int i = 0; i <
meshes.size(); i++)
93 DEBUG_INFO(
"Making new mesh remapper for image " << i <<
".");
101 meshes[image_number]->CallList();
106 return meshes[image_number]->display_list_number;
116 for (std::vector<MeshInfo*>::iterator it =
meshes.begin() ; it !=
meshes.end() ; ++it) {
129 for(
unsigned int i=0;i<
meshes.size();i++)
130 meshes[i]->SetScaleFactor(scale);
137 bool layout_mode_on_in)
138 : display_list_number(glGenLists(1)),
142 m_visualization_state(visualization_state_in),
145 layout_mode_on(layout_mode_on_in)
151 : display_list_number(glGenLists(1)),
155 m_visualization_state(source.m_visualization_state),
166 glDeleteLists(display_list_number, 1);
177 double scale = m_visualization_state->GetVisibleArea().width() /
188 for (
int x = 0 ; x < 2 ; x++) {
189 for (
int y = 0 ; y < 2 ; y++) {
190 tex_coords[x][y][0] = coords.
tex_c[x][y][0];
191 tex_coords[x][y][1] = coords.
tex_c[x][y][1];
192 vertex_coords[x][y][0] = coords.
vertex_c[x][y][0];
193 vertex_coords[x][y][1] = coords.
vertex_c[x][y][1];
194 vertex_coords[x][y][2] = 0;
207 glCallList(display_list_number);
216 bool multiTexture=m_visualization_state->getViewState()->GetSupportMultiTexture();
217 unsigned int number_of_faces = 0;
221 this->BeforeCompile();
223 glNewList(display_list_number, GL_COMPILE);
225 remap->UpdateAndResetIndex();
226 DEBUG_INFO(
"Specifying faces in display list.");
237 while (remap->GetNextFaceCoordinates(&coords))
239 MeshCoords3D coords3d = m_visualization_state->GetMeshManager()->GetMeshCoords3D(coords);
244 glBegin(GL_LINE_LOOP);
248 glMultiTexCoord2dv(GL_TEXTURE0,coords3d.
tex_coords[0][0]);
249 glMultiTexCoord2dv(GL_TEXTURE1,coords3d.
tex_coords[0][0]);
256 glMultiTexCoord2dv(GL_TEXTURE0,coords3d.
tex_coords[0][1]);
257 glMultiTexCoord2dv(GL_TEXTURE1,coords3d.
tex_coords[0][1]);
264 glMultiTexCoord2dv(GL_TEXTURE0,coords3d.
tex_coords[1][1]);
265 glMultiTexCoord2dv(GL_TEXTURE1,coords3d.
tex_coords[1][1]);
272 glMultiTexCoord2dv(GL_TEXTURE0,coords3d.
tex_coords[1][0]);
273 glMultiTexCoord2dv(GL_TEXTURE1,coords3d.
tex_coords[1][0]);
291 this->AfterCompile();
304 x = r * sin(th) * cos(ph);
306 z = r * cos(th) * cos(ph);
311 yaw = image.getYaw();
312 pitch = image.getPitch();
321 glRotated(yaw, 0,-1,0);
322 glRotated(pitch, -1,0,0);
329 image.setPitch(pitch);
334 double width, height, hfov, vfov;
346 th = ((coord.
x / width) * hfov - hfov / 2.0);
347 ph = ((coord.
y / height) * vfov - vfov / 2.0);
360 double width, height, hfov, vfov;
371 for (
int x = 0 ; x < 2 ; x++) {
372 for (
int y = 0 ; y < 2 ; y++) {
379 th = ((coords.
vertex_c[x][y][0] / width) * hfov - hfov / 2.0);
380 ph = ((coords.
vertex_c[x][y][1] / height) * vfov - vfov / 2.0);
401 double width, height;
407 res.
x = (coord.
x - width / 2.0) * scale / width;
408 res.
y = (coord.
y - height / 2.0) * (-scale) / width;
415 double width, height;
421 for (
int x = 0 ; x < 2 ; x++) {
422 for (
int y = 0 ; y < 2 ; y++) {
a subclass for the panosphere it converts coordinates obtained from an equirectangular projection to ...
An abstract base class for objects that calculate an approximate remap specified by quadrilatrials...
MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on)
void CompileList()
Use the remapper to create the display list.
MeshInfo(HuginBase::Panorama *m_pano, HuginBase::SrcPanoImage *image, VisualizationState *visualization_state, bool layout_mode_on)
Constructor: Creates the mesh for a given image of a panorama.
subclass for the plane overview mode.
void setScale(double scale)
Set the size to draw the images.
A class for exchanging pointers to coordinates.
unsigned int getHeight() const
get panorama height
void SetLayoutScale(double scale)
#define DEBUG_ASSERT(cond)
include file for the hugin project
double(* tex_c)[2][2]
The coordinate in the source image ranging from 0 to 1.
static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState *state)
bool GetLayoutMode() const
return if layout mode is active
double vertex_coords[2][2][3]
Draw undistored images, but with the correct centre position.
MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on)
HuginBase::Panorama * m_pano
virtual HuginBase::SrcPanoImage * GetSrcImage(unsigned int image_nr)
std::size_t getNrOfImages() const
number of images.
std::vector< MeshInfo * > meshes
void Update()
Recreate the mesh when the image or panorama it represents changes.
static void Convert(double &x, double &y, double &z, double th, double ph, double r)
convert from spherical to cartesian coordinates
VisualizationState * visualization_state
static const double scale
unsigned int getWidth() const
double tex_coords[2][2][2]
bool RequireRecalculateMesh(unsigned int image_nr)
Handles the remapper and a display list for a specific image.
virtual MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on)=0
MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on)
static const double scale_diff
scale factor to be used for the layout mode TODO: test this for more scenarios
static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState *state)
virtual HuginBase::PanoramaOptions * GetOptions()
void RenderMesh(unsigned int image_number) const
a class to keep data of a single rectangle with texture coordinates
Define a remapper to use in the layout mode.
A ChoosyRemapper combines the other MeshRemappers and picks which one it deems is best suited for eac...
void SetLayoutMode(bool state)
Turn layout mode on or off.
void SetScaleFactor(double scale)
subclass of MeshInfo for the preview It actually does nothing in addition to the base class ...
double(* vertex_c)[2][2]
The coordinate in the panorama, in its pixel space.
All variables of a source image.
static Coord3D GetCoord3D(hugin_utils::FDiff2D &coord, VisualizationState *state)
void CallList() const
Draw the mesh.
static Coord3D GetCoord3D(hugin_utils::FDiff2D &coord, VisualizationState *state)
a class to handle a 3D point
MeshManager(HuginBase::Panorama *pano, VisualizationState *visualization_state)
unsigned int GetDisplayList(unsigned int image_number) const