aggiunto:
- l' enum dei tipi PERSPECTIVE, ORTHO, ISOMETRIC, CAVALIERI - inline void SetCavalieri(...) - inline void SetIsometric(...) - modificato - void SetOrtho( .. )
This commit is contained in:
parent
42831cd32b
commit
494f6ccff7
|
|
@ -23,6 +23,9 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
History
|
History
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.19 2005/02/22 10:57:58 tommyfranken
|
||||||
|
Corrected declaration and some syntax errors in GetFrustum
|
||||||
|
|
||||||
Revision 1.18 2005/02/21 18:11:07 ganovelli
|
Revision 1.18 2005/02/21 18:11:07 ganovelli
|
||||||
GetFrustum moved from gl/camera to math/camera.h
|
GetFrustum moved from gl/camera to math/camera.h
|
||||||
|
|
||||||
|
|
@ -93,6 +96,15 @@ creation
|
||||||
|
|
||||||
namespace vcg{
|
namespace vcg{
|
||||||
|
|
||||||
|
enum {
|
||||||
|
|
||||||
|
PERSPECTIVE = 0,
|
||||||
|
ORTHO = 1,
|
||||||
|
ISOMETRIC = 2,
|
||||||
|
CAVALIERI = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template<class S>
|
template<class S>
|
||||||
class Camera
|
class Camera
|
||||||
{
|
{
|
||||||
|
|
@ -102,7 +114,7 @@ public:
|
||||||
f(0.f),s(vcg::Point2<S>(0.0,0.0)),
|
f(0.f),s(vcg::Point2<S>(0.0,0.0)),
|
||||||
c(vcg::Point2<S>(0.0,0.0)),
|
c(vcg::Point2<S>(0.0,0.0)),
|
||||||
viewport(vcg::Point2<int>(0,0)),
|
viewport(vcg::Point2<int>(0,0)),
|
||||||
_flags(0),viewportM(1)
|
_flags(0),viewportM(1), cameraType(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
S f; // Focal Distance (cioe' la distanza del piano immagine dal centro di proiezione
|
S f; // Focal Distance (cioe' la distanza del piano immagine dal centro di proiezione
|
||||||
|
|
@ -117,13 +129,20 @@ public:
|
||||||
S viewportM; // ratio between viewport in pixel and size (useful to avoid chancing s or viewport when
|
S viewportM; // ratio between viewport in pixel and size (useful to avoid chancing s or viewport when
|
||||||
// zooming a ortho camera (for a perspective camera it is 1)
|
// zooming a ortho camera (for a perspective camera it is 1)
|
||||||
|
|
||||||
enum{
|
/*enum{
|
||||||
ORTHO_BIT = 0x01 // true if the camera is orthogonal
|
ORTHO_BIT = 0x01 // true if the camera is orthogonal
|
||||||
};
|
};*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char _flags;
|
char _flags;
|
||||||
bool IsOrtho(){ return (_flags & ORTHO_BIT);}
|
|
||||||
void SetOrtho(bool v, S dist )
|
int cameraType;
|
||||||
|
//bool IsOrtho(){ return (_flags & ORTHO_BIT);}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*void SetOrtho(bool v, S dist )
|
||||||
{
|
{
|
||||||
if(v)
|
if(v)
|
||||||
{
|
{
|
||||||
|
|
@ -132,12 +151,30 @@ public:
|
||||||
}
|
}
|
||||||
else _flags &= ~ORTHO_BIT;
|
else _flags &= ~ORTHO_BIT;
|
||||||
|
|
||||||
};
|
};*/
|
||||||
|
|
||||||
char & UberFlags() {return _flags;}
|
char & UberFlags() {return _flags;}
|
||||||
|
|
||||||
|
void SetOrtho(S dist )
|
||||||
|
{
|
||||||
|
|
||||||
|
cameraType = ORTHO;
|
||||||
|
viewportM = ( ((viewport[0] * s[0]) * (viewport[1] * s[1])) / f ) * dist;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/// set the camera specifying the perspecive view
|
/// set the camera specifying the perspecive view
|
||||||
inline void SetPerspective(S angle, S ratio, S nearend, S farend,vcg::Point2<S> viewport=vcg::Point2<S>(500,-1) );
|
inline void SetPerspective(S angle, S ratio, S nearend, S farend,vcg::Point2<S> viewport=vcg::Point2<S>(500,-1) );
|
||||||
|
|
||||||
|
|
||||||
|
/// set the camera specifying the cavalieri view
|
||||||
|
inline void SetCavalieri(S sx, S dx, S bt, S tp, S nearend, S farend, vcg::Point2<S> viewport=vcg::Point2<S>(500,-1) );
|
||||||
|
|
||||||
|
|
||||||
|
/// set the camera specifying the isometric view
|
||||||
|
inline void SetIsometric(S sx, S dx, S bt, S tp, S nearend, S farend, vcg::Point2<S> viewport=vcg::Point2<S>(500,-1) );
|
||||||
|
|
||||||
/// set the camera specifying the frustum view
|
/// set the camera specifying the frustum view
|
||||||
inline void SetFrustum(S dx, S sx, S bt, S tp, S nearend, S farend,vcg::Point2<S> viewport=vcg::Point2<S>(500,-1));
|
inline void SetFrustum(S dx, S sx, S bt, S tp, S nearend, S farend,vcg::Point2<S> viewport=vcg::Point2<S>(500,-1));
|
||||||
|
|
||||||
|
|
@ -189,6 +226,23 @@ vcg::Point2<S> Camera<S>::LocalTo_neg1_1(const vcg::Point2<S> & p){
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// set the camera specifying the cavalieri view
|
||||||
|
template<class S>
|
||||||
|
void Camera<S>::SetCavalieri(S sx, S dx, S bt, S tp, S nearend, S farend, vcg::Point2<S> viewport=vcg::Point2<S>(500,-1) )
|
||||||
|
{
|
||||||
|
cameraType = CAVALIERI;
|
||||||
|
SetFrustum(sx, dx, bt, tp, nearend,farend,viewport);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// set the camera specifying the isometric view
|
||||||
|
template<class S>
|
||||||
|
void Camera<S>::SetIsometric(S sx, S dx, S bt, S tp, S nearend, S farend, vcg::Point2<S> viewport=vcg::Point2<S>(500,-1) )
|
||||||
|
{
|
||||||
|
cameraType = ISOMETRIC;
|
||||||
|
SetFrustum(sx, dx, bt, tp, nearend,farend,viewport);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// set the camera specifying the perspective view
|
/// set the camera specifying the perspective view
|
||||||
template<class S>
|
template<class S>
|
||||||
void Camera<S>::SetPerspective( S angle,
|
void Camera<S>::SetPerspective( S angle,
|
||||||
|
|
@ -197,12 +251,15 @@ template<class S>
|
||||||
S far_thr,
|
S far_thr,
|
||||||
vcg::Point2<S> vp)
|
vcg::Point2<S> vp)
|
||||||
{
|
{
|
||||||
|
cameraType = PERSPECTIVE;
|
||||||
S halfsize[2];
|
S halfsize[2];
|
||||||
halfsize[1] = tan(math::ToRad(angle/2)) * near_thr;
|
halfsize[1] = tan(math::ToRad(angle/2)) * near_thr;
|
||||||
halfsize[0] = halfsize[1]*ratio;
|
halfsize[0] = halfsize[1]*ratio;
|
||||||
SetFrustum(-halfsize[0],halfsize[0],-halfsize[1],halfsize[1],near_thr,far_thr,vp);
|
SetFrustum(-halfsize[0],halfsize[0],-halfsize[1],halfsize[1],near_thr,far_thr,vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// set the camera specifying the frustum view
|
/// set the camera specifying the frustum view
|
||||||
template<class S>
|
template<class S>
|
||||||
void Camera<S>::SetFrustum( S sx,
|
void Camera<S>::SetFrustum( S sx,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue