Added support for orthographic camera.
The FEdgeXDetector class for silhouette edge detection and the ViewMapBuilder class for view map creation are enhanced. All changes are related to view point handling (i.e., the camera location). In the perspective projection, the visibility of feature edges and edge types (e.g., borders and crease lines) are computed based on a fixed view point, whereas the view point in the orthographic projection is an arbitrary point on the XY plane at the origin and is determined so that a line segment from the view point to a point in the 3D space is perpendicular to the XY plane. All view point related portions of the class definitions were modified so as to deal with the two different camera modes.
This commit is contained in:
@@ -450,6 +450,7 @@ void Controller::ComputeViewMap()
|
|||||||
_Chrono.start();
|
_Chrono.start();
|
||||||
|
|
||||||
edgeDetector.setViewpoint(Vec3r(vp));
|
edgeDetector.setViewpoint(Vec3r(vp));
|
||||||
|
edgeDetector.enableOrthographicProjection(proj[3][3] != 0.0);
|
||||||
edgeDetector.enableRidgesAndValleysFlag(_ComputeRidges);
|
edgeDetector.enableRidgesAndValleysFlag(_ComputeRidges);
|
||||||
edgeDetector.enableSuggestiveContours(_ComputeSuggestive);
|
edgeDetector.enableSuggestiveContours(_ComputeSuggestive);
|
||||||
edgeDetector.setSphereRadius(_sphereRadius);
|
edgeDetector.setSphereRadius(_sphereRadius);
|
||||||
|
|||||||
@@ -129,14 +129,23 @@ void FEdgeXDetector::preProcessFace(WXFace *iFace){
|
|||||||
Vec3r N = iFace->GetNormal();
|
Vec3r N = iFace->GetNormal();
|
||||||
|
|
||||||
// Compute the dot product between V (=_Viewpoint - firstPoint) and N:
|
// Compute the dot product between V (=_Viewpoint - firstPoint) and N:
|
||||||
Vec3r V(_Viewpoint - firstPoint);
|
Vec3r V;
|
||||||
|
if (_orthographicProjection) {
|
||||||
|
V = Vec3r(0.0, 0.0, _Viewpoint.z() - firstPoint.z());
|
||||||
|
} else {
|
||||||
|
V = Vec3r(_Viewpoint - firstPoint);
|
||||||
|
}
|
||||||
N.normalize();
|
N.normalize();
|
||||||
V.normalize();
|
V.normalize();
|
||||||
iFace->setDotP(N * V);
|
iFace->setDotP(N * V);
|
||||||
|
|
||||||
// compute the distance between the face center and the viewpoint:
|
// compute the distance between the face center and the viewpoint:
|
||||||
Vec3r dist_vec(iFace->center() - _Viewpoint);
|
if (_orthographicProjection) {
|
||||||
iFace->setZ(dist_vec.norm());
|
iFace->setZ(iFace->center().z() - _Viewpoint.z());
|
||||||
|
} else {
|
||||||
|
Vec3r dist_vec(iFace->center() - _Viewpoint);
|
||||||
|
iFace->setZ(dist_vec.norm());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FEdgeXDetector::computeCurvatures(WXVertex *vertex){
|
void FEdgeXDetector::computeCurvatures(WXVertex *vertex){
|
||||||
@@ -181,7 +190,11 @@ void FEdgeXDetector::computeCurvatures(WXVertex *vertex){
|
|||||||
|
|
||||||
// compute radial curvature :
|
// compute radial curvature :
|
||||||
n = C->e1 ^ C->e2;
|
n = C->e1 ^ C->e2;
|
||||||
v = _Viewpoint - vertex->GetVertex();
|
if (_orthographicProjection) {
|
||||||
|
v = Vec3r(0.0, 0.0, _Viewpoint.z() - vertex->GetVertex().z());
|
||||||
|
} else {
|
||||||
|
v = Vec3r(_Viewpoint - vertex->GetVertex());
|
||||||
|
}
|
||||||
C->er = v - (v * n) * n;
|
C->er = v - (v * n) * n;
|
||||||
C->er.normalize();
|
C->er.normalize();
|
||||||
e1 = C->e1;
|
e1 = C->e1;
|
||||||
@@ -243,14 +256,23 @@ void FEdgeXDetector::ProcessSilhouetteFace(WXFace *iFace)
|
|||||||
for(int i=0; i<numVertices; i++){
|
for(int i=0; i<numVertices; i++){
|
||||||
point = iFace->GetVertex(i)->GetVertex();
|
point = iFace->GetVertex(i)->GetVertex();
|
||||||
normal = iFace->GetVertexNormal(i);
|
normal = iFace->GetVertexNormal(i);
|
||||||
Vec3r V(_Viewpoint - point);
|
|
||||||
normal.normalize();
|
normal.normalize();
|
||||||
|
Vec3r V;
|
||||||
|
if (_orthographicProjection) {
|
||||||
|
V = Vec3r(0.0, 0.0, _Viewpoint.z() - point.z());
|
||||||
|
} else {
|
||||||
|
V = Vec3r(_Viewpoint - point);
|
||||||
|
}
|
||||||
V.normalize();
|
V.normalize();
|
||||||
real d = normal * V;
|
real d = normal * V;
|
||||||
faceLayer->PushDotP(d);
|
faceLayer->PushDotP(d);
|
||||||
// Find the point the closest to the viewpoint
|
// Find the point the closest to the viewpoint
|
||||||
Vec3r dist_vec(point - _Viewpoint);
|
if (_orthographicProjection) {
|
||||||
dist = dist_vec.norm();
|
dist = point.z() - _Viewpoint.z();
|
||||||
|
} else {
|
||||||
|
Vec3r dist_vec(point - _Viewpoint);
|
||||||
|
dist = dist_vec.norm();
|
||||||
|
}
|
||||||
if(dist < minDist) {
|
if(dist < minDist) {
|
||||||
minDist = dist;
|
minDist = dist;
|
||||||
closestPointId = i;
|
closestPointId = i;
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
_computeRidgesAndValleys = true;
|
_computeRidgesAndValleys = true;
|
||||||
_computeSuggestiveContours = true;
|
_computeSuggestiveContours = true;
|
||||||
_sphereRadius = 1.0;
|
_sphereRadius = 1.0;
|
||||||
|
_orthographicProjection = false;
|
||||||
_changes = false;
|
_changes = false;
|
||||||
_kr_derivative_epsilon = 0.0;
|
_kr_derivative_epsilon = 0.0;
|
||||||
}
|
}
|
||||||
@@ -107,6 +108,7 @@ public:
|
|||||||
|
|
||||||
/*! Sets the current viewpoint */
|
/*! Sets the current viewpoint */
|
||||||
inline void setViewpoint(const Vec3r& ivp) {_Viewpoint = ivp;}
|
inline void setViewpoint(const Vec3r& ivp) {_Viewpoint = ivp;}
|
||||||
|
inline void enableOrthographicProjection(bool b) {_orthographicProjection = b;}
|
||||||
inline void enableRidgesAndValleysFlag(bool b) {_computeRidgesAndValleys = b;}
|
inline void enableRidgesAndValleysFlag(bool b) {_computeRidgesAndValleys = b;}
|
||||||
inline void enableSuggestiveContours(bool b) {_computeSuggestiveContours = b;}
|
inline void enableSuggestiveContours(bool b) {_computeSuggestiveContours = b;}
|
||||||
/*! Sets the radius of the geodesic sphere around each vertex (for the curvature computation)
|
/*! Sets the radius of the geodesic sphere around each vertex (for the curvature computation)
|
||||||
@@ -136,6 +138,7 @@ protected:
|
|||||||
real _maxKr;
|
real _maxKr;
|
||||||
unsigned _nPoints;
|
unsigned _nPoints;
|
||||||
real _meanEdgeSize;
|
real _meanEdgeSize;
|
||||||
|
bool _orthographicProjection;
|
||||||
|
|
||||||
bool _computeRidgesAndValleys;
|
bool _computeRidgesAndValleys;
|
||||||
bool _computeSuggestiveContours;
|
bool _computeSuggestiveContours;
|
||||||
|
|||||||
@@ -103,7 +103,12 @@ void ViewMapBuilder::computeCusps(ViewMap *ioViewMap){
|
|||||||
Vec3r m((A+B)/2.0);
|
Vec3r m((A+B)/2.0);
|
||||||
Vec3r crossP(AB^(fes)->normal());
|
Vec3r crossP(AB^(fes)->normal());
|
||||||
crossP.normalize();
|
crossP.normalize();
|
||||||
Vec3r viewvector(m-_viewpoint);
|
Vec3r viewvector;
|
||||||
|
if (_orthographicProjection) {
|
||||||
|
viewvector = Vec3r(0.0, 0.0, m.z()-_viewpoint.z());
|
||||||
|
} else {
|
||||||
|
viewvector = Vec3r(m-_viewpoint);
|
||||||
|
}
|
||||||
viewvector.normalize();
|
viewvector.normalize();
|
||||||
if(first){
|
if(first){
|
||||||
if(((crossP)*(viewvector)) > 0)
|
if(((crossP)*(viewvector)) > 0)
|
||||||
@@ -583,7 +588,12 @@ void ViewMapBuilder::FindOccludee(FEdge *fe, Grid* iGrid, real epsilon, Polygon3
|
|||||||
A = Vec3r(((fe)->vertexA()->point3D() + (fe)->vertexB()->point3D())/2.0);
|
A = Vec3r(((fe)->vertexA()->point3D() + (fe)->vertexB()->point3D())/2.0);
|
||||||
edge = Vec3r((fe)->vertexB()->point3D()-(fe)->vertexA()->point3D());
|
edge = Vec3r((fe)->vertexB()->point3D()-(fe)->vertexA()->point3D());
|
||||||
origin = Vec3r((fe)->vertexA()->point3D());
|
origin = Vec3r((fe)->vertexA()->point3D());
|
||||||
Vec3r u(_viewpoint-A);
|
Vec3r u;
|
||||||
|
if (_orthographicProjection) {
|
||||||
|
u = Vec3r(0.0, 0.0, _viewpoint.z()-A.z());
|
||||||
|
} else {
|
||||||
|
u = Vec3r(_viewpoint-A);
|
||||||
|
}
|
||||||
u.normalize();
|
u.normalize();
|
||||||
if(A < iGrid->getOrigin())
|
if(A < iGrid->getOrigin())
|
||||||
cerr << "Warning: point is out of the grid for fedge " << fe->getId().getFirst() << "-" << fe->getId().getSecond() << endl;
|
cerr << "Warning: point is out of the grid for fedge " << fe->getId().getFirst() << "-" << fe->getId().getSecond() << endl;
|
||||||
@@ -637,13 +647,19 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, Grid* iGrid, real eps
|
|||||||
// //return 0;
|
// //return 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Vec3r u(_viewpoint - center);
|
Vec3r vp;
|
||||||
|
if (_orthographicProjection) {
|
||||||
|
vp = Vec3r(center.x(), center.y(), _viewpoint.z());
|
||||||
|
} else {
|
||||||
|
vp = Vec3r(_viewpoint);
|
||||||
|
}
|
||||||
|
Vec3r u(vp - center);
|
||||||
real raylength = u.norm();
|
real raylength = u.norm();
|
||||||
u.normalize();
|
u.normalize();
|
||||||
//cout << "grid origin " << iGrid->getOrigin().x() << "," << iGrid->getOrigin().y() << "," << iGrid->getOrigin().z() << endl;
|
//cout << "grid origin " << iGrid->getOrigin().x() << "," << iGrid->getOrigin().y() << "," << iGrid->getOrigin().z() << endl;
|
||||||
//cout << "center " << center.x() << "," << center.y() << "," << center.z() << endl;
|
//cout << "center " << center.x() << "," << center.y() << "," << center.z() << endl;
|
||||||
|
|
||||||
iGrid->castRay(center, Vec3r(_viewpoint), occluders, timestamp);
|
iGrid->castRay(center, vp, occluders, timestamp);
|
||||||
|
|
||||||
WFace *face = 0;
|
WFace *face = 0;
|
||||||
if(fe->isSmooth()){
|
if(fe->isSmooth()){
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ private:
|
|||||||
//SilhouetteGeomEngine _GeomEngine;
|
//SilhouetteGeomEngine _GeomEngine;
|
||||||
ProgressBar *_pProgressBar;
|
ProgressBar *_pProgressBar;
|
||||||
Vec3r _viewpoint;
|
Vec3r _viewpoint;
|
||||||
|
bool _orthographicProjection;
|
||||||
Grid* _Grid;
|
Grid* _Grid;
|
||||||
ViewEdgeXBuilder *_pViewEdgeBuilder;
|
ViewEdgeXBuilder *_pViewEdgeBuilder;
|
||||||
bool _EnableQI;
|
bool _EnableQI;
|
||||||
@@ -129,6 +130,7 @@ public:
|
|||||||
real iFocalLength,
|
real iFocalLength,
|
||||||
real iAspect,
|
real iAspect,
|
||||||
real iFovy) {
|
real iFovy) {
|
||||||
|
_orthographicProjection = (iProjectionMatrix[3][3] != 0.0);
|
||||||
SilhouetteGeomEngine::setTransform(iModelViewMatrix, iProjectionMatrix, iViewport, iFocalLength);
|
SilhouetteGeomEngine::setTransform(iModelViewMatrix, iProjectionMatrix, iViewport, iFocalLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user