*** empty log message ***
This commit is contained in:
parent
9150fdfb37
commit
033ed78dcd
|
@ -1,72 +0,0 @@
|
|||
#ifndef CAMERA_H
|
||||
#define CAMERA_H
|
||||
|
||||
#include <vcg/space/point3.h>
|
||||
#include <vcg/math/Matrix44.h>
|
||||
|
||||
namespace vcg {
|
||||
|
||||
template <class T> class ViewGL {
|
||||
public:
|
||||
void GetView();
|
||||
void SetView();
|
||||
Point3<T> Project(const Point3<T> &p) const;
|
||||
Point3<T> UnProject(const Point3<T> &p) const;
|
||||
Point3<T> ViewPoint();
|
||||
|
||||
Matrix44<T> proj;
|
||||
Matrix44<T> model;
|
||||
Matrix44<T> matrix;
|
||||
Matrix44<T> inverse;
|
||||
int viewport[4];
|
||||
};
|
||||
|
||||
template <class T> void Camera<T>::GetView() {
|
||||
glGetDoublev(GL_PROJECTION_MATRIX, (double *)&proj);
|
||||
glGetDoublev(GL_MODELVIEW_MATRIX, (double *)&model);
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
|
||||
proj.Transpose();
|
||||
model.Transpose();
|
||||
|
||||
matrix.Import(proj * model);
|
||||
inverse = matrix;
|
||||
Invert(inverse);
|
||||
}
|
||||
|
||||
template <class T> Point3<T> Camera<T>::ViewPoint() {
|
||||
return inverse * Point3<T>(0, 0, 0);
|
||||
/*Matrix44d model(model_matrix);
|
||||
model.Invert();
|
||||
Point3d view = model * Point3d(0, 0, 0);
|
||||
return Point3<T>(view[0], view[1], view[2]); */
|
||||
}
|
||||
|
||||
template <class T> Point3<T> Camera<T>::Project(const Point3<T> &p) const {
|
||||
Point3<T> r;
|
||||
r = matrix * p;
|
||||
r[0] = (r[0]+1)*(viewport[2]/2.0)+viewport[0];
|
||||
r[1] =(r[1]+1)*(viewport[3]/2.0)+viewport[1];
|
||||
return r;
|
||||
/*double r[3];
|
||||
gluProject(p[0], p[1], p[2], model_matrix, proj_matrix, viewport, &r[0], &r[1], &r[2]);
|
||||
return Point3<T>((T)r[0], (T)r[1], (T)r[2]);*/
|
||||
}
|
||||
|
||||
template <class T> Point3<T> Camera<T>::UnProject(const Point3<T> &p) const {
|
||||
Point3<T> s;
|
||||
s[0] = (p[0]- viewport[0])/ (viewport[2]/2.0) - 1;
|
||||
s[1] = (p[1]- viewport[1])/ (viewport[3]/2.0) - 1;
|
||||
s[2] = p[2];
|
||||
s[1] = -s[1]; // pezza aggiunta per il tan2.... ?????????????
|
||||
s = inverse * s;
|
||||
return s;
|
||||
/*double r[3];
|
||||
gluUnProject(p[0], p[1], p[2], model_matrix, proj_matrix, viewport, &r[0], &r[1], &r[2]);
|
||||
return Point3<T>((T)r[0], (T)r[1], (T)r[2]);*/
|
||||
}
|
||||
|
||||
|
||||
}//namespace
|
||||
|
||||
#endif
|
|
@ -1,94 +0,0 @@
|
|||
#ifndef FRUSTUM_H
|
||||
#define FRUSTUM_H
|
||||
|
||||
#include <wrap/gui/camera.h>
|
||||
#include <vcg/space/plane3.h>
|
||||
#include <vcg/space/line3.h>
|
||||
|
||||
|
||||
namespace vcg {
|
||||
|
||||
template <class T> class Frustum: public Camera {
|
||||
public:
|
||||
void GetView();
|
||||
bool IsOutside(Point3<T> &point);
|
||||
bool IsOutside(Point3<T> &point, T radius);
|
||||
T Distance(Point3<T> &point, int plane);
|
||||
Point3<T> ViewPoint();
|
||||
|
||||
protected:
|
||||
T resolution;
|
||||
Plane3<T> planes[6];
|
||||
Point3<T> view_point;
|
||||
};
|
||||
|
||||
|
||||
//Implementation
|
||||
template <class T> Point3<T> Frustum<T>::ViewPoint() {
|
||||
return view_point;
|
||||
}
|
||||
|
||||
template <class T> bool Frustum<T>::IsOutside(Point3<T> &point) {
|
||||
Point3<T> r = Project(point);
|
||||
if(r[0] < viewport[0] || r[0] > viewport[0]+viewport[2] ||
|
||||
r[1] < viewport[1] || r[1] > viewport[1]+viewport[3])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T> bool Frustum<T>::IsOutside(Point3<T> &point, T radius) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
T dist = Distance(point, i);
|
||||
if(dist < -radius)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T> T Frustum<T>::Distance(Point3<T> &point, int plane) {
|
||||
return Distance<T>(point, planes[plane]);
|
||||
}
|
||||
|
||||
template <class T> void Frustum<T>::GetView() {
|
||||
Camera::GetView();
|
||||
|
||||
Point3d NE, SE, SW, NW, ne, se, sw, nw;
|
||||
int t = viewport[1] + viewport[3];
|
||||
int b = viewport[1];
|
||||
int r = viewport[0] + viewport[2];
|
||||
int l = viewport[0];
|
||||
|
||||
Point3d NE, SE, SW, NW, ne, se, sw, nw;
|
||||
gluUnProject(l, b, 0, model_matrix, proj_matrix, viewport, &nw[0], &nw[1], &nw[2]);
|
||||
gluUnProject(l, t, 0, model_matrix, proj_matrix, viewport, &sw[0], &sw[1], &sw[2]);
|
||||
gluUnProject(r, b, 0, model_matrix, proj_matrix, viewport, &ne[0], &ne[1], &ne[2]);
|
||||
gluUnProject(r, t, 0, model_matrix, proj_matrix, viewport, &se[0], &se[1], &se[2]);
|
||||
gluUnProject(l, b, 1, model_matrix, proj_matrix, viewport, &NW[0], &NW[1], &NW[2]);
|
||||
gluUnProject(l, t, 1, model_matrix, proj_matrix, viewport, &SW[0], &SW[1], &SW[2]);
|
||||
gluUnProject(r, b, 1, model_matrix, proj_matrix, viewport, &NE[0], &NE[1], &NE[2]);
|
||||
gluUnProject(r, t, 1, model_matrix, proj_matrix, viewport, &SE[0], &SE[1], &SE[2]);
|
||||
|
||||
view_point = Camera::ViewPoint();
|
||||
|
||||
planes[0].init(view_point, Point3<T>().Import(nw), Point3<T>().Import(ne));
|
||||
planes[1].init(view_point, Point3<T>().Import(ne), Point3<T>().Import(se));
|
||||
planes[2].init(view_point, Point3<T>().Import(se), Point3<T>().Import(sw));
|
||||
planes[3].init(view_point, Point3<T>().Import(sw), Point3<T>().Import(nw));
|
||||
planes[4].init(Point3<T>().Import(se), Point3<T>().Import(sw), Point3<T>().Import(nw));
|
||||
planes[5].init(Point3<T>().Import(SW), Point3<T>().Import(SE), Point3<T>().Import(NE));
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
planes[i].Normalize();
|
||||
|
||||
//calcoliamo la risoluzione: dimenzione di un pixel a distanza 1 dal view_point
|
||||
resolution = (T)((ne + NE) - (nw + NW)).Norm() /( viewport[2] * ((ne + NE) - (nw + NW)).Norm());
|
||||
}
|
||||
|
||||
}//namespace
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
#ifndef TRACKBALL_H
|
||||
#define TRACKBALL_H
|
||||
|
||||
#include <vcg/math/similar.h>
|
||||
|
||||
namespace vcg {
|
||||
|
||||
class Trackball {
|
||||
public:
|
||||
Similarf track;
|
||||
Similarf local;
|
||||
|
||||
Trackball();
|
||||
void SetIdentity();
|
||||
void SetPosition(const Similarf &local, int millisec = 0);
|
||||
|
||||
//operating
|
||||
void GetView();
|
||||
void Apply();
|
||||
void Draw();
|
||||
void Reset();
|
||||
|
||||
//interface
|
||||
void MouseDown(int x, int y, Button button);
|
||||
void MouseMove(int x, int y);
|
||||
void MouseUp(int x, int y, Button button);
|
||||
void MouseWheel(Button notch);
|
||||
void ButtonUp(Button button);
|
||||
void ButtonDown(Button button);
|
||||
|
||||
//spinning interface
|
||||
void SetSpinnable(bool on);
|
||||
bool IsSpinnable();
|
||||
bool SetSpinning(Quaternionf &spin);
|
||||
void StopSpinning();
|
||||
bool IsSpinning();
|
||||
|
||||
//interfaccia navigation:
|
||||
void Back();
|
||||
void Forward();
|
||||
void Home();
|
||||
void HistorySize(int lenght);
|
||||
|
||||
enum { LOCAL, VIEW, SCREEN };
|
||||
|
||||
enum {
|
||||
ROTATE = 0, ROTATE_G = 1, //really makes sense only in VIEW system
|
||||
ROTATE_X = 2, ROTATE_Y = 3, ROTATE_Z = 4, // Axis Constrained Rotation
|
||||
DRAG_X = 5, DRAG_Y = 6, DRAG_Z = 7, // Drag constrained to an axis (trackball axis)
|
||||
DRAG_XY = 8, DRAG_YZ = 9, DRAG_XZ = 10, // Drag constrained to a plane
|
||||
SCALE = 11, //scale respect to center of trackball
|
||||
NONE = 12 //disable trackball
|
||||
};
|
||||
enum Button { BUTTON_LEFT = 1, BUTTON_MIDDLE = 2, BUTTON_RIGHT = 4, WHEEL = 8,
|
||||
KEY_SHIFT = 16, KEY_CTRL = 32, KEY_ALT = 64, HANDLE = 128 };
|
||||
protected:
|
||||
Camera camera;
|
||||
|
||||
TrackMode *current;
|
||||
|
||||
Similarf &last();
|
||||
int last_x, last_y;
|
||||
bool dragging;
|
||||
int button_mask;
|
||||
|
||||
Quaternionf spin;
|
||||
bool spinnable;
|
||||
bool spinning;
|
||||
|
||||
std::list<Similarf> history;
|
||||
};
|
||||
|
||||
}//namespace
|
||||
|
||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef TRACKMODE_H
|
||||
#define TRACKMODE_H
|
||||
|
||||
namespace vcg {
|
||||
|
||||
class TrackMode {
|
||||
public:
|
||||
};
|
||||
|
||||
class SphereMode: public TrackMode {
|
||||
public:
|
||||
};
|
||||
|
||||
class GravityMode: public TrackMode {
|
||||
public:
|
||||
};
|
||||
|
||||
class CylinderMode: public TrackMode {
|
||||
public:
|
||||
};
|
||||
|
||||
class PlaneMode: public TrackMode {
|
||||
public:
|
||||
};
|
||||
|
||||
class LineMode: public TrackMode {
|
||||
public:
|
||||
};
|
||||
|
||||
class ScaleMode: public TrackMode {
|
||||
public:
|
||||
};
|
||||
|
||||
}//namespace
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue