Removed type cast warnings

This commit is contained in:
Paolo Cignoni 2007-05-28 08:10:47 +00:00
parent 3cf34fb91a
commit 9554ee4245
2 changed files with 46 additions and 40 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.21 2007/05/16 08:44:05 ganovelli
added inclusion of glew.h
Revision 1.20 2007/05/15 14:58:57 benedetti Revision 1.20 2007/05/15 14:58:57 benedetti
Main restructuring. added many new modes Main restructuring. added many new modes
@ -244,7 +247,7 @@ void PlaneMode::Draw(Trackball * tb){
// Cylinder mode implementation. // Cylinder mode implementation.
void CylinderMode::Apply (Trackball * tb, float WheelNotch) void CylinderMode::Apply (Trackball * tb, float WheelNotch)
{ {
const float PI2=6.283185307179586232; const float PI2=6.283185307179586232f;
tb->track.rot = tb->last_track.rot * Quaternionf (WheelNotch/(tb->radius * PI2),axis.Direction()); tb->track.rot = tb->last_track.rot * Quaternionf (WheelNotch/(tb->radius * PI2),axis.Direction());
} }
@ -256,7 +259,7 @@ void CylinderMode::Apply (Trackball * tb, Point3f new_point)
float angle; float angle;
const float EPSILON=0.005f; // this IS scale independent const float EPSILON=0.005f; // this IS scale independent
if(axisproj.Direction().Norm() < EPSILON){ if(axisproj.Direction().Norm() < EPSILON){
angle=(10.0 * getDeltaY(tb,new_point)) / tb->radius; angle=(10.0f * getDeltaY(tb,new_point)) / tb->radius;
} else { } else {
Point3f hitOld = HitViewPlane (tb, tb->last_point); Point3f hitOld = HitViewPlane (tb, tb->last_point);
Point3f hitNew = HitViewPlane (tb, new_point); Point3f hitNew = HitViewPlane (tb, new_point);
@ -277,7 +280,7 @@ void CylinderMode::Draw(Trackball * tb){
// Path mode implementation. // Path mode implementation.
void PathMode::Init(const vector < Point3f > &pts) void PathMode::Init(const vector < Point3f > &pts)
{ {
unsigned int npts=pts.size(); unsigned int npts = int(pts.size());
assert(npts >= 2); assert(npts >= 2);
points.reserve(npts); points.reserve(npts);
for(unsigned int i=0;i<npts;i++){ for(unsigned int i=0;i<npts;i++){
@ -310,7 +313,7 @@ Point3f PathMode::SetStartNear(Point3f point)
float nearest_state=0; float nearest_state=0;
Point3f nearest_point=points[0]; Point3f nearest_point=points[0];
float nearest_distance=Distance(nearest_point,point); float nearest_distance=Distance(nearest_point,point);
unsigned int npts=points.size(); unsigned int npts = int(points.size());
for(unsigned int i = 1;i <= npts;i++){ for(unsigned int i = 1;i <= npts;i++){
if( i == npts){ if( i == npts){
if (wrap){ if (wrap){
@ -348,7 +351,7 @@ void PathMode::GetPoints(float state, Point3f & point, Point3f & prev_point, Poi
assert(state <= 1.0f); assert(state <= 1.0f);
float remaining_norm=state; float remaining_norm=state;
Point3f p0,p1; Point3f p0,p1;
unsigned int npts=points.size(); unsigned int npts = int(points.size());
for(unsigned int i = 1;i <= npts;i++){ for(unsigned int i = 1;i <= npts;i++){
if( i == npts){ if( i == npts){
if (wrap){ if (wrap){
@ -511,13 +514,13 @@ void PathMode::Draw(Trackball * tb){
// Area mode implementation. // Area mode implementation.
void AreaMode::Init(const vector < Point3f > &pts) void AreaMode::Init(const vector < Point3f > &pts)
{ {
unsigned int npts=pts.size(); unsigned int npts = int(pts.size());
assert(npts >= 3); assert(npts >= 3);
//get the plane //get the plane
Point3f p0=pts[0]; Point3f p0=pts[0];
unsigned int onethird=(unsigned int)floor(npts/3.0); unsigned int onethird=(unsigned int)floor(npts/3.0);
const float EPSILON=0.005; const float EPSILON = 0.005f;
bool pts_not_in_line=false; bool pts_not_in_line=false;
Point3f a,b; Point3f a,b;
for(unsigned int i=0;i<onethird;i++){ for(unsigned int i=0;i<onethird;i++){
@ -607,7 +610,7 @@ Point3f AreaMode::Move(Point3f start,Point3f end)
Point3f pside,phit; Point3f pside,phit;
bool slide,mid_inside; bool slide,mid_inside;
int np=points.size(), i, j; int np = int(points.size()), i, j;
for (i = 0, j = np-1; i < np; j = i++) { for (i = 0, j = np-1; i < np; j = i++) {
Segment3f side(points[i],points[j]); Segment3f side(points[i],points[j]);
Point3f pseg,psid; Point3f pseg,psid;
@ -657,7 +660,7 @@ bool AreaMode::Inside(Point3f point)
float x=point[first_coord_kept]; float x=point[first_coord_kept];
float y=point[second_coord_kept]; float y=point[second_coord_kept];
float yi, yj, xi, xj; float yi, yj, xi, xj;
int i, j, np=points.size(); int i, j, np=int(points.size());
for (i = 0, j = np-1; i < np; j = i++) { for (i = 0, j = np-1; i < np; j = i++) {
xi=points[i][first_coord_kept]; xi=points[i][first_coord_kept];
yi=points[i][second_coord_kept]; yi=points[i][second_coord_kept];
@ -681,7 +684,7 @@ Point3f AreaMode::SetStartNear(Point3f point)
} }
Point3f nearest_point=initial_status; Point3f nearest_point=initial_status;
float nearest_distance=Distance(nearest_point,candidate); float nearest_distance=Distance(nearest_point,candidate);
int i, j, np=points.size(); int i, j, np=int(points.size());
for (i = 0, j = np-1; i < np; j = i++) { for (i = 0, j = np-1; i < np; j = i++) {
Segment3f side(points[i],points[j]); Segment3f side(points[i],points[j]);
Point3f side_point=ClosestPoint(side,candidate); Point3f side_point=ClosestPoint(side,candidate);

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.1 2007/05/15 14:57:34 benedetti
Utility functions for the trackmodes, first version
****************************************************************************/ ****************************************************************************/
@ -385,7 +388,7 @@ Line3f ProjectLineOnPlane(const Line3f & ln, const Plane3f & pl)
float signedDistance(Line3f line,Point3f pt,Point3f positive_dir) float signedDistance(Line3f line,Point3f pt,Point3f positive_dir)
{ {
return Distance(line,pt) * ((((pt-ClosestPoint(line,pt)) * positive_dir) >= 0.0 )? 1.0: -1.0); return Distance(line,pt) * ((((pt-ClosestPoint(line,pt)) * positive_dir) >= 0.0f )? 1.0f: -1.0f);
} }
float getDeltaY(Trackball * tb, Point3f new_point) float getDeltaY(Trackball * tb, Point3f new_point)
@ -602,14 +605,14 @@ void DrawUglyAxisMode(Trackball * tb,Line3f axis)
glMultMatrix (tb->track.InverseMatrix ()); glMultMatrix (tb->track.InverseMatrix ());
glTranslate (-tb->center); glTranslate (-tb->center);
prepara_attrib(); prepara_attrib();
glColor3f(0.9,0.9,0.2); glColor3f(0.9f, 0.9f, 0.2f);
glLineWidth(2.0); glLineWidth(2.0);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex(axis.Origin()+(axis.Direction()*100)); glVertex(axis.Origin()+(axis.Direction()*100));
glVertex(axis.Origin()-(axis.Direction()*100)); glVertex(axis.Origin()-(axis.Direction()*100));
glEnd(); glEnd();
glPointSize(8.0); glPointSize(8.0);
glColor3f(0.2,0.2,0.9); glColor3f(0.2f, 0.2f, 0.9f);
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(axis.Origin()); glVertex(axis.Origin());
glEnd(); glEnd();
@ -636,27 +639,27 @@ void DrawUglyPlaneMode(Trackball * tb,Plane3f plane)
d1=(d2 - p0).Normalize(); d1=(d2 - p0).Normalize();
d2=(d1 ^ norm).Normalize(); d2=(d1 ^ norm).Normalize();
glLineWidth(3.0); glLineWidth(3.0);
glColor3f(0.2,0.2,0.9); glColor3f(0.2f, 0.2f, 0.9f);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex(p0); glVertex(p0);
glVertex(p0+norm); glVertex(p0+norm);
glEnd(); glEnd();
glLineWidth(1.0); glLineWidth(1.0);
for(float i=0.5;i<100.0; i+=0.7){ for(float i=0.5f; i<100.0f; i+=0.7f){
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
for(int a=0;a<360;a+=10){ for(int a=0;a<360;a+=10){
float f0=i*cos((M_PI*a)/180); float f0=i*cosf((float(M_PI)*float(a))/180.0f);
float f1=i*sin((M_PI*a)/180); float f1=i*sinf((float(M_PI)*float(a))/180.0f);
glVertex(p0+(d1*f0)+(d2*f1)); glVertex(p0+(d1*f0)+(d2*f1));
} }
glEnd(); glEnd();
} }
glColor3f(0.9,0.9,0.2); glColor3f(0.9f, 0.9f, 0.2f);
glPointSize(8.0); glPointSize(8.0f);
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(p0); glVertex(p0);
glEnd(); glEnd();
glColor3f(0.7,0.7,0); glColor3f(0.7f, 0.7f, 0.0f);
glPointSize(6.0); glPointSize(6.0);
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(p0+norm); glVertex(p0+norm);
@ -686,29 +689,29 @@ void DrawUglyCylinderMode(Trackball * tb,Line3f axis)
d1=(d2 - p0).Normalize(); d1=(d2 - p0).Normalize();
d2=(d1 ^ norm).Normalize(); d2=(d1 ^ norm).Normalize();
glLineWidth(1.0); glLineWidth(1.0);
glColor3f(0.2,0.2,0.9); glColor3f(0.2f, 0.2f, 0.9f);
for(int i=-100;i<100;i++){ for(int i=-100;i<100;i++){
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
for(int a=0;a<360;a+=10){ for(int a=0;a<360;a+=10){
float f0=(tb->radius)*cos((M_PI*a)/180); float f0=(tb->radius)*cosf((float(M_PI)*float(a))/180.0f);
float f1=(tb->radius)*sin((M_PI*a)/180); float f1=(tb->radius)*sinf((float(M_PI)*float(a))/180.0f);
glVertex(p0+(norm*i)+(d1*f0)+(d2*f1)); glVertex(p0+(norm*float(i))+(d1*f0)+(d2*f1));
} }
glEnd(); glEnd();
} }
glLineWidth(3.0); glLineWidth(3.0);
glColor3f(0.2,0.2,0.9); glColor3f(0.2f, 0.2f, 0.9f);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex(axis.Origin()); glVertex(axis.Origin());
glVertex(axis.Origin()+(axis.Direction()*100)); glVertex(axis.Origin()+(axis.Direction()*100));
glEnd(); glEnd();
glLineWidth(1.5); glLineWidth(1.5);
glColor3f(0.9,0.2,0.9); glColor3f(0.9f, 0.2f, 0.9f);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex(axis.Origin()); glVertex(axis.Origin());
glVertex(axis.Origin()-(axis.Direction()*100)); glVertex(axis.Origin()-(axis.Direction()*100));
glEnd(); glEnd();
glColor3f(0.9,0.9,0.2); glColor3f(0.9f, 0.9f, 0.2f);
glPointSize(8.0); glPointSize(8.0);
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(axis.Origin()); glVertex(axis.Origin());
@ -728,7 +731,7 @@ void DrawUglyPathMode(Trackball * tb,const vector < Point3f > &points,
glMultMatrix (tb->track.InverseMatrix ()); glMultMatrix (tb->track.InverseMatrix ());
glTranslate (-tb->center); glTranslate (-tb->center);
prepara_attrib(); prepara_attrib();
glColor3f(0.9,0.9,0.2); glColor3f(0.9f, 0.9f, 0.2f);
glLineWidth(2.0); glLineWidth(2.0);
if(wrap) if(wrap)
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
@ -743,12 +746,12 @@ void DrawUglyPathMode(Trackball * tb,const vector < Point3f > &points,
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(current_point); glVertex(current_point);
glEnd(); glEnd();
glColor3f(0.6,0,0.6); glColor3f(0.6f, 0.0f, 0.6f);
glPointSize(7.0); glPointSize(7.0);
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(old_hitpoint); glVertex(old_hitpoint);
glEnd(); glEnd();
glColor3f(0.7,0.7,0.7); glColor3f(0.7f, 0.7f, 0.7f);
glPointSize(6.5); glPointSize(6.5);
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(prev_point); glVertex(prev_point);
@ -769,15 +772,15 @@ void DrawUglyAreaMode(Trackball * tb,const vector < Point3f > &points,
glMultMatrix (tb->track.InverseMatrix ()); glMultMatrix (tb->track.InverseMatrix ());
glTranslate (-tb->center); glTranslate (-tb->center);
prepara_attrib(); prepara_attrib();
glColor3f(0.9,0.9,0.2); glColor3f(0.9f, 0.9f, 0.2f);
glLineWidth(2.0); glLineWidth(2.0);
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
for (vector < Point3f >::const_iterator i = points.begin (); i != points.end (); ++i){ for (vector < Point3f >::const_iterator i = points.begin (); i != points.end (); ++i){
glVertex(*i); glVertex(*i);
} }
glEnd(); glEnd();
glColor3f(0.0,0.9,0.2); glColor3f(0.0f, 0.9f, 0.2f);
glLineWidth(1.2); glLineWidth(1.2f);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
for (vector < Point3f >::const_iterator i = path.begin (); i != path.end (); ++i){ for (vector < Point3f >::const_iterator i = path.begin (); i != path.end (); ++i){
glVertex(*i); glVertex(*i);
@ -788,12 +791,12 @@ void DrawUglyAreaMode(Trackball * tb,const vector < Point3f > &points,
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(status); glVertex(status);
glEnd(); glEnd();
glColor3f(0.6,0,0.6); glColor3f(0.6f, 0.0f, 0.6f);
glPointSize(7.0); glPointSize(7.0);
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(old_status); glVertex(old_status);
glEnd(); glEnd();
glColor3f(0.6,0,0.0); glColor3f(0.6f, 0.0f, 0.0f);
glPointSize(6.0); glPointSize(6.0);
glBegin(GL_POINTS); glBegin(GL_POINTS);
glVertex(rubberband_handle); glVertex(rubberband_handle);
@ -813,17 +816,17 @@ void DrawUglyAreaMode(Trackball * tb,const vector < Point3f > &points,
d1=(d2 - p0).Normalize(); d1=(d2 - p0).Normalize();
d2=(d1 ^ norm).Normalize(); d2=(d1 ^ norm).Normalize();
glLineWidth(3.0); glLineWidth(3.0);
glColor3f(0.2,0.2,0.9); glColor3f(0.2f, 0.2f, 0.9f);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex(p0); glVertex(p0);
glVertex(p0+norm); glVertex(p0+norm);
glEnd(); glEnd();
glLineWidth(0.1); glLineWidth(0.1f);
for(float i=0.5;i<100.0; i+=0.7){ for(float i=0.5f;i<100.0f; i+=0.7f){
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
for(int a=0;a<360;a+=10){ for(int a=0;a<360;a+=10){
float f0=i*cos((M_PI*a)/180); float f0=i*cosf((float(M_PI)*float(a))/180.0f);
float f1=i*sin((M_PI*a)/180); float f1=i*sinf((float(M_PI)*float(a))/180.0f);
glVertex(p0+(d1*f0)+(d2*f1)); glVertex(p0+(d1*f0)+(d2*f1));
} }
glEnd(); glEnd();