Added Cone directions
This commit is contained in:
parent
86133c9bac
commit
e10aa57ee2
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.1 2004/09/09 22:38:57 cignoni
|
||||
Initial Update
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __VCG_GEN_NORMAL
|
||||
|
@ -52,6 +55,26 @@ static void Random(int vn, std::vector<Point3<ScalarType > > &NN)
|
|||
}
|
||||
}
|
||||
}
|
||||
static void UniformCone(int vn, std::vector<Point3<ScalarType > > &NN, ScalarType AngleRad, Point3x dir=Point3x(0,1,0))
|
||||
{
|
||||
std::vector<Point3<ScalarType > > NNT;
|
||||
NN.clear();
|
||||
// per prima cosa si calcola il volume della spherical cap di angolo AngleRad
|
||||
ScalarType Height= 1.0 - cos(AngleRad); // height is measured from top...
|
||||
// Surface is the one of the tangent cylinder
|
||||
ScalarType CapArea = 2.0*M_PI*Height;
|
||||
ScalarType Ratio = CapArea / (4.0*M_PI );
|
||||
|
||||
printf("----------AngleRad %f Angledeg %f ratio %f vn %i vn2 %i \n",AngleRad,math::ToDeg(AngleRad),Ratio,vn,int(vn/Ratio));
|
||||
Uniform(vn/Ratio,NNT);
|
||||
std::vector<Point3x>::iterator vi;
|
||||
|
||||
ScalarType DotProd = cos(AngleRad);
|
||||
for(vi=NNT.begin();vi!=NNT.end();++vi)
|
||||
{
|
||||
if(dir*(*vi) >= DotProd) NN.push_back(*vi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void Uniform(int vn, std::vector<Point3<ScalarType > > &NN)
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.4 2004/09/09 22:34:38 cignoni
|
||||
Integrated lost modifications...
|
||||
|
||||
Revision 1.3 2004/09/09 14:35:54 ponchio
|
||||
Various changes for gcc compatibility
|
||||
|
||||
|
@ -42,6 +45,7 @@ Added GPL comments
|
|||
|
||||
|
||||
#include <wrap/callback.h>
|
||||
#include <vcg/math/base.h>
|
||||
#include <wrap/gui/trackball.h>
|
||||
#include <vcg/simplex/vertex/with/vcvn.h>
|
||||
#include <vcg/simplex/vertex/with/vcvn.h>
|
||||
|
@ -76,6 +80,8 @@ unsigned int TexInd=0;
|
|||
bool SwapFlag=false;
|
||||
bool CullFlag=false;
|
||||
bool ClosedFlag=false;
|
||||
Point3f ConeDir(0,1,0);
|
||||
float ConeAngleRad = math::ToRad(180.0f);
|
||||
|
||||
float lopass=0,hipass=1,gamma=1;
|
||||
float diff=.8;
|
||||
|
@ -296,7 +302,8 @@ void ViewKey(unsigned char key, int , int )
|
|||
gamma=gamma+.05; printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma);
|
||||
UpdateVis(); break;
|
||||
case 13 :
|
||||
Vis.ComputeUniform(SampleNum,ViewVector,cb);
|
||||
//Vis.ComputeUniform(SampleNum,ViewVector,cb);
|
||||
Vis.ComputeUniformCone(SampleNum,ViewVector, ConeAngleRad,ConeDir,cb);
|
||||
UpdateVis(); break;
|
||||
case ' ' : {
|
||||
Point3f dir = Q->camera.ViewPoint();
|
||||
|
@ -429,8 +436,8 @@ int main(int argc, char** argv)
|
|||
" -z# z offset (default 1e-3)\n"
|
||||
" -c assume that the mesh is closed (slightly faster, default false)\n"
|
||||
" -f Flip normal of the model\n"
|
||||
//" -da # Cone Direction Angle in degree (default 45)\n"
|
||||
//" -dv # # # Cone Direction vector (default 0 0 1)\n"
|
||||
" -da # Cone Direction Angle in degree (default 180)\n"
|
||||
" -dv # # # Cone Direction vector (default 0 0 1)\n"
|
||||
);
|
||||
|
||||
return 1;
|
||||
|
@ -442,6 +449,9 @@ int main(int argc, char** argv)
|
|||
{
|
||||
switch(argv[i][1])
|
||||
{
|
||||
case 'd' : if(argv[i][2] == 'a') { ConeAngleRad = math::ToRad(atof(argv[i+1])); ++i; break; }
|
||||
if(argv[i][2] == 'v') { ConeDir = Point3f(atof(argv[i+1]),atof(argv[i+2]),atof(argv[i+3])); i+=3; break; }
|
||||
break;
|
||||
case 'n' : SampleNum = atoi(argv[i]+2); break;
|
||||
case 'f' : SwapFlag=false; break;
|
||||
case 'c' : ClosedFlag=true; break;
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.5 2004/09/09 22:59:21 cignoni
|
||||
Removed many small warnings
|
||||
|
||||
Revision 1.4 2004/09/09 22:37:48 cignoni
|
||||
Integrated lost modifications...
|
||||
|
||||
|
@ -186,26 +189,6 @@ void Compute( CallBack *cb)
|
|||
RestoreGL();
|
||||
}
|
||||
|
||||
void ComputeCone(int nn, Point3x &dir, ScalarType ConeAngleDeg, CallBack *cb)
|
||||
{
|
||||
std::string buf;
|
||||
ScalarType ConeAngleRad=ToRad(ConeAngleDeg);
|
||||
ScalarType SolidAngleSter = (1.0 - Cos(ConeAngleRad))*2*M_PI;
|
||||
int Frac=(4.0*M_PI)/SolidAngleSter;
|
||||
printf("ComputeCone for an angle of %f , solidAngle =%f pi asked %i normals, forecasted we need to ask %i normals\n",
|
||||
ConeAngleDeg,SolidAngleSter/M_PI,nn,nn*Frac);
|
||||
|
||||
VN.clear();
|
||||
std::vector<Point3x> nvt;
|
||||
GenNormal(nn*Frac,nvt);
|
||||
ScalarType CosConeAngle=Cos(ConeAngleRad);
|
||||
for(int i=0;i<nvt.size();++i)
|
||||
if(dir*nvt[i]>=CosConeAngle) VN.push_back(nvt[i]);
|
||||
|
||||
printf("Asked %i normal, got %i normals\n",nn,VN.size());
|
||||
Compute(cb);
|
||||
}
|
||||
|
||||
void ComputeHalf(int nn, Point3x &dir, CallBack *cb)
|
||||
{
|
||||
std::string buf;
|
||||
|
@ -220,6 +203,18 @@ void ComputeHalf(int nn, Point3x &dir, CallBack *cb)
|
|||
Compute(cb);
|
||||
}
|
||||
|
||||
void ComputeUniformCone(int nn, std::vector<Point3x> &vv, ScalarType AngleRad, Point3x &ConeDir, CallBack *cb)
|
||||
{
|
||||
VN.clear();
|
||||
GenNormal<ScalarType>::UniformCone(nn,VN,AngleRad,ConeDir);
|
||||
for(vector<Point3x>::iterator vi=VN.begin();vi!=VN.end();++vi)
|
||||
vv.push_back(*vi);
|
||||
|
||||
char buf[256];
|
||||
sprintf(buf,"Asked %i normal, got %i normals\n",nn,VN.size());
|
||||
cb(buf);
|
||||
Compute(cb);
|
||||
}
|
||||
void ComputeUniform(int nn, std::vector<Point3x> &vv, CallBack *cb)
|
||||
{
|
||||
VN.clear();
|
||||
|
|
Loading…
Reference in New Issue