| 1 | /**************************************************************************** |
| 2 | * VCGLib o o * |
| 3 | * Visual and Computer Graphics Library o o * |
| 4 | * _ O _ * |
| 5 | * Copyright(C) 2004 \/)\/ * |
| 6 | * Visual Computing Lab /\/| * |
| 7 | * ISTI - Italian National Research Council | * |
| 8 | * \ * |
| 9 | * All rights reserved. * |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or modify * |
| 12 | * it under the terms of the GNU General Public License as published by * |
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
| 14 | * (at your option) any later version. * |
| 15 | * * |
| 16 | * This program is distributed in the hope that it will be useful, * |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 19 | * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * |
| 20 | * for more details. * |
| 21 | * * |
| 22 | ****************************************************************************/ |
| 23 | /**************************************************************************** |
| 24 | History |
| 25 | |
| 26 | $Log: trackutils.h,v $ |
| 27 | Revision 1.14 2008/02/26 18:55:55 ponchio |
| 28 | removed some garbage. |
| 29 | |
| 30 | Revision 1.13 2008/02/26 18:46:55 ponchio |
| 31 | Fixed bug in drawing position of the trackball when changin center. |
| 32 | |
| 33 | Revision 1.12 2008/02/24 18:10:54 ponchio |
| 34 | Fixed scale behaviour. |
| 35 | |
| 36 | Revision 1.11 2008/02/24 18:05:08 ponchio |
| 37 | Should work as before. I didn't test cylinder and other exotic modes. |
| 38 | |
| 39 | Revision 1.10 2008/02/24 14:37:00 ponchio |
| 40 | Restored trackball functionality. Not very much tested, and code will need some |
| 41 | cleanup. |
| 42 | |
| 43 | Revision 1.9 2008/02/22 18:57:47 benedetti |
| 44 | first attempt to correct after quaternion ToMatrix() inversion (does not work yet) |
| 45 | |
| 46 | Revision 1.8 2008/02/15 20:54:45 benedetti |
| 47 | removed some variable initialization related warning |
| 48 | |
| 49 | Revision 1.7 2007/10/22 14:39:54 cignoni |
| 50 | corrected bug into the drawsphere (thanks to nico and guido!) |
| 51 | |
| 52 | Revision 1.6 2007/08/17 09:19:40 cignoni |
| 53 | glEnable (GL_LINE_SMOOTH) should go before changing the linewidth. |
| 54 | |
| 55 | Revision 1.5 2007/07/14 12:44:40 benedetti |
| 56 | Minor edits in Doxygen documentation. |
| 57 | |
| 58 | Revision 1.4 2007/07/09 22:41:22 benedetti |
| 59 | Added Doxygen documentation, removed using namespace std, some other minor changes. |
| 60 | |
| 61 | Revision 1.3 2007/06/12 08:58:08 benedetti |
| 62 | Minor fix in DrawUglyCylinderMode() |
| 63 | |
| 64 | Revision 1.2 2007/05/28 08:10:47 fiorin |
| 65 | Removed type cast warnings |
| 66 | |
| 67 | Revision 1.1 2007/05/15 14:57:34 benedetti |
| 68 | Utility functions for the trackmodes, first version |
| 69 | |
| 70 | ****************************************************************************/ |
| 71 | |
| 72 | #ifndef TRACKUTILS_H |
| 73 | #define TRACKUTILS_Hcxx . . $ `vcg/wrap/gui/trackutils.h:73:9`! |
| 74 | |
| 75 | #include <assert.h> |
| 76 | #include <vcg/math/base.h>cxx . . $ `<file>/vcg/vcg/math/base.h`/ |
| 77 | #include <vcg/math/similarity.h>cxx . . $ `<file>/vcg/vcg/math/similarity.h`/ |
| 78 | #include <vcg/space/intersection3.h>cxx . . $ `<file>/vcg/vcg/space/intersection3.h`/ |
| 79 | #include <vcg/space/line3.h>cxx . . $ `<file>/vcg/vcg/space/line3.h`/ |
| 80 | #include <vcg/space/plane3.h>cxx . . $ `<file>/vcg/vcg/space/plane3.h`/ |
| 81 | #include <wrap/gl/math.h>cxx . . $ `<file>/vcg/wrap/gl/math.h`/ |
| 82 | #include <wrap/gl/space.h>cxx . . $ `<file>/vcg/wrap/gl/space.h`/ |
| 83 | #include <vector> |
| 84 | #include <iostream> |
| 85 | using namespace std; |
| 86 | |
| 87 | namespace vcgcxx . . $ vcg/ { |
| 88 | |
| 89 | /*! |
| 90 | @brief This namespace contains some support functions used by TrackMode subclassess. |
| 91 | |
| 92 | \warning Many of these functions shouldn't be here and are supposed to be moved to some appropriate place by the library administrator. |
| 93 | \warning The \e DrawUgly series of functions is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 94 | */ |
| 95 | namespace trackutilscxx . . $ vcg/trackutils/ { |
| 96 | |
| 97 | /*! |
| 98 | @brief Compute the plane perpedicular to view dir and passing through the manipulator center. |
| 99 | |
| 100 | @param camera the camera of the manipulator. |
| 101 | @param center the center of the manipulator. |
| 102 | @return the plane perpedicular to view dir and passing through the manipulator center. |
| 103 | */ |
| 104 | Plane3fcxx . . $ vcg/Plane3f# GetViewPlanecxx . . $ vcg/trackutils/GetViewPlane(68ced6af6c9ab41d). (const Viewcxx . . $ vcg/View# < float >&camera, const Point3fcxx . . $ vcg/Point3f# & center) |
| 105 | { |
| 106 | Point3fcxx . . $ vcg/Point3f# vp = camera.ViewPointcxx . . $ vcg/View#ViewPoint(d14b145c9ae9c214). (); |
| 107 | Plane3fcxx . . $ vcg/Plane3f# plcxx . . $ vcg/Plane3#Plane3(49f6e7a06ebc5aa8).; |
| 108 | Point3fcxx . . $ vcg/Point3f# plnorm = vp -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). center; |
| 109 | plnorm.Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58). (); |
| 110 | pl.Setcxx . . $ vcg/Plane3#Set(4e93b0e637e623f). (plnorm, plnorm *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). center); |
| 111 | return pl; |
| 112 | } |
| 113 | |
| 114 | /*! |
| 115 | @brief Convert a line to a normalized ray. |
| 116 | |
| 117 | @param l the line to be converted. |
| 118 | @return the normalized ray. |
| 119 | */ |
| 120 | Ray3fcxx . . $ vcg/Ray3f# line2raycxx . . $ vcg/trackutils/line2ray(4583dc1c3fdac3e0).(const Line3fcxx . . $ vcg/Line3f# &l){ |
| 121 | Ray3fcxx . . $ vcg/Ray3f# rcxx . . $ vcg/Ray3#Ray3(d881d180352d7f4a).(l.Origincxx . . $ vcg/Line3#Origin(61080bd0aaebf357).(),l.Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).()); |
| 122 | r.Normalizecxx . . $ vcg/Ray3#Normalize(fce7fde446037ee4).(); |
| 123 | return r; |
| 124 | } |
| 125 | |
| 126 | |
| 127 | /*! |
| 128 | @brief Project a window coordinate point on the plane perpedicular to view dir and passing through the manipulator center. |
| 129 | |
| 130 | @param tb the manipulator. |
| 131 | @param p the window coordinate point. |
| 132 | @return p's projection on plane perpedicular to view dir and passing through the manipulator center. |
| 133 | */ |
| 134 | Point3fcxx . . $ vcg/Point3f# HitViewPlanecxx . . $ vcg/trackutils/HitViewPlane(973390b3fc0c6841). (Trackballcxx . . $ vcg/Trackball# * tb, const Point3fcxx . . $ vcg/Point3f# & p) |
| 135 | { |
| 136 | Plane3fcxx . . $ vcg/Plane3f# vp = GetViewPlanecxx . . $ vcg/trackutils/GetViewPlane(68ced6af6c9ab41d). (tb->cameracxx . . $ vcg/Trackball#camera., tb->centercxx . . $ vcg/Transform#center.); |
| 137 | Line3fNcxx . . $ vcg/Line3fN# ln = tbcxx . . $ vcg/Line3#Line3(1ff0e9a7d980245f).->cameracxx . . $ vcg/Trackball#camera..ViewLineFromWindowcxx . . $ vcg/View#ViewLineFromWindow(49e77427d541d16d). (Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2). (p[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).0], p[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).1], 0)); |
| 138 | Point3fcxx . . $ vcg/Point3f# PonVPcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).; |
| 139 | IntersectionLinePlanecxx . . $ vcg/IntersectionLinePlane(d9fb62fae53f22b). < float >(vp, lncxx . . $ vcg/Line3#Line3(1ff0e9a7d980245f)., PonVP); |
| 140 | return PonVPcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).; |
| 141 | } |
| 142 | |
| 143 | // nota: non ho scritto io questa funzione, |
| 144 | // quindi la documentazione doxy potrebbe non essere accurata al 100%. |
| 145 | /*! |
| 146 | @brief Project a window coordinate point on the rotational hyperboloid relative to the manipulator. |
| 147 | |
| 148 | <br>The original documentation (in italian) follows: |
| 149 | <pre> |
| 150 | dato un punto in coordinate di schermo e.g. in pixel stile opengl |
| 151 | calcola il punto di intersezione tra la viewline che passa per |
| 152 | viewpoint e per hitplane e l'iperboloide. |
| 153 | l'iperboloide si assume essere quello di rotazione attorno alla |
| 154 | retta viewpoint-center e di raggio rad |
| 155 | si assume come sistema di riferimento quello con l'origine |
| 156 | su center ecome x la retta center-viewpoint |
| 157 | |
| 158 | eq linea |
| 159 | hitplane.y |
| 160 | y = - ----------- * x + hitplane.y |
| 161 | viewpoint.x |
| 162 | |
| 163 | eq hiperboloide di raggio r (e.g. che passa per (r/sqrt2,r/sqrt2) |
| 164 | |
| 165 | 1 |
| 166 | y = --- * (r^2 /2.0) |
| 167 | x |
| 168 | |
| 169 | hitplane.y |
| 170 | ----------- * x^2 - hitplane.y *x + (r^2/2.0) == 0 |
| 171 | viewpoint.x |
| 172 | </pre> |
| 173 | |
| 174 | @param center the center of the manipulator. |
| 175 | @param radius the radius of the manipulator. |
| 176 | @param viewpoint the view point. |
| 177 | @param vp the view plane. |
| 178 | @param hitplane the projection of the window coordinate point on the view plane. |
| 179 | @param hit the projection of hitplane on the rotational hyperboloid relative to the manipulator. |
| 180 | @return true if and only if hit is valid. |
| 181 | */ |
| 182 | bool HitHypercxx . . $ vcg/trackutils/HitHyper(2a43547ce9db4983). (Point3fcxx . . $ vcg/Point3f# center, float radius, Point3fcxx . . $ vcg/Point3f# viewpoint, Plane3fcxx . . $ vcg/Plane3f# vp, |
| 183 | Point3fcxx . . $ vcg/Point3f# hitplane, Point3fcxx . . $ vcg/Point3f# & hit) |
| 184 | { |
| 185 | float hitplaney = Distancecxx . . $ vcg/Distance(1e0ebe277e908d16). (center, hitplane); |
| 186 | float viewpointx = Distancecxx . . $ vcg/Distance(1e0ebe277e908d16). (center, viewpoint); |
| 187 | |
| 188 | float a = hitplaney / viewpointx; |
| 189 | float b = -hitplaney; |
| 190 | float c = radius * radius / 2.0f; |
| 191 | float delta = b * b - 4 * a * c; |
| 192 | float x1, x2, xval, yval; |
| 193 | |
| 194 | if (delta > 0) { |
| 195 | x1 = (-b - sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1). (delta)) / (2.0f * a); |
| 196 | x2 = (-b + sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1). (delta)) / (2.0f * a); |
| 197 | |
| 198 | xval = x1; // always take the minimum value solution |
| 199 | yval = c / xval; // alternatively it also could be the other part of the equation yval=-(hitplaney/viewpointx)*xval+hitplaney; |
| 200 | } |
| 201 | else { |
| 202 | return false; |
| 203 | } |
| 204 | // Computing the result in 3d space; |
| 205 | Point3fcxx . . $ vcg/Point3f# dirRadial = hitplane -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). center; |
| 206 | dirRadial.Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58). (); |
| 207 | Point3fcxx . . $ vcg/Point3f# dirView = vpcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357). (); |
| 208 | dirView.Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58). (); |
| 209 | hit =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). center +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). dirRadial *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). yval +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). dirView *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). xval; |
| 210 | return true; |
| 211 | } |
| 212 | |
| 213 | // nota: non ho scritto io questa funzione, |
| 214 | // quindi la documentazione doxy potrebbe non essere accurata al 100%. |
| 215 | /*! |
| 216 | @brief Project a window coordinate point on the sphere relative to the manipulator. |
| 217 | |
| 218 | <br>The original documentation (in italian) follows: |
| 219 | <pre> |
| 220 | dato un punto in coordinate di schermo e.g. in pixel stile opengl |
| 221 | restituisce un punto in coordinate di mondo sulla superficie |
| 222 | della trackball. |
| 223 | La superficie della trackball e' data da una sfera + una porzione |
| 224 | di iperboloide di rotazione. |
| 225 | Assumiamo la sfera di raggio unitario e centrata sull'origine e |
| 226 | di guardare lungo la y negativa. |
| 227 | |
| 228 | X 0 sqrt(1/2) 1 |
| 229 | eq sfera: y=sqrt(1-x*x); 1 sqrt(1/2) 0 |
| 230 | eq iperboloide : y=1/2*x; inf sqrt(1/2) 1/2 |
| 231 | eq cono y=x+sqrt(2); |
| 232 | </pre> |
| 233 | |
| 234 | @param tb the manipulator. |
| 235 | @param p the window coordinate point. |
| 236 | @return the projection of p on the sphere relative to the manipulator. |
| 237 | */ |
| 238 | Point3fcxx . . $ vcg/Point3f# HitSpherecxx . . $ vcg/trackutils/HitSphere(973390b3fc0c6841). (Trackballcxx . . $ vcg/Trackball# * tb, const Point3fcxx . . $ vcg/Point3f# & p) |
| 239 | { |
| 240 | Point3fcxx . . $ vcg/Point3f# center = tbcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).->centercxx . . $ vcg/Transform#center.; |
| 241 | Line3fNcxx . . $ vcg/Line3fN# ln = tbcxx . . $ vcg/Line3#Line3(1ff0e9a7d980245f).->cameracxx . . $ vcg/Trackball#camera..ViewLineFromWindowcxx . . $ vcg/View#ViewLineFromWindow(49e77427d541d16d). (Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2). (p[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).0], p[cxx . . $ vcg/Point3#`operator[]`(e2681f9bb6b2f357).1], 0)); |
| 242 | Plane3fcxx . . $ vcg/Plane3f# vp = GetViewPlanecxx . . $ vcg/trackutils/GetViewPlane(68ced6af6c9ab41d). (tb->cameracxx . . $ vcg/Trackball#camera., center); |
| 243 | Point3fcxx . . $ vcg/Point3f# hitPlanecxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0), //intersection view plane with point touched |
| 244 | hitSpherecxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0), |
| 245 | hitSphere1cxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0), |
| 246 | hitSphere2cxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0), |
| 247 | hitHypercxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0); |
| 248 | IntersectionLinePlanecxx . . $ vcg/IntersectionLinePlane(d9fb62fae53f22b). < float >(vp, lncxx . . $ vcg/Line3#Line3(1ff0e9a7d980245f)., hitPlane); |
| 249 | |
| 250 | Sphere3fcxx . . $ vcg/Sphere3f# spherecxx . . $ vcg/Sphere3#Sphere3(7acac8d8771ca344). (center, tb->radiuscxx . . $ vcg/Transform#radius.);//trackball sphere |
| 251 | bool resSp = IntersectionLineSpherecxx . . $ vcg/IntersectionLineSphere(2f29617d534bafcf). < float >(sphere, lncxx . . $ vcg/Line3#Line3(1ff0e9a7d980245f)., hitSphere1, hitSphere2); |
| 252 | |
| 253 | Point3fcxx . . $ vcg/Point3f# viewpoint = tb->cameracxx . . $ vcg/Trackball#camera..ViewPointcxx . . $ vcg/View#ViewPoint(d14b145c9ae9c214). (); |
| 254 | if (resSp == true) { |
| 255 | if (Distancecxx . . $ vcg/Distance(1e0ebe277e908d16). (viewpoint, hitSphere1) < Distancecxx . . $ vcg/Distance(1e0ebe277e908d16). (viewpoint, hitSphere2)) |
| 256 | hitSphere =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). hitSphere1; |
| 257 | else |
| 258 | hitSphere =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). hitSphere2; |
| 259 | } |
| 260 | |
| 261 | /*float dl= */ Distancecxx . . $ vcg/Distance(6c105e538d57e6db). (ln, center); |
| 262 | bool resHp = HitHypercxx . . $ vcg/trackutils/HitHyper(2a43547ce9db4983). (centercxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)., tb->radiuscxx . . $ vcg/Transform#radius., viewpointcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)., vp, hitPlanecxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)., hitHyper); |
| 263 | |
| 264 | // four cases |
| 265 | |
| 266 | // 1) Degenerate line tangent to both sphere and hyperboloid! |
| 267 | if ((!resSp && !resHp)) { |
| 268 | Point3fcxx . . $ vcg/Point3f# hit = ClosestPointcxx . . $ vcg/ClosestPoint(a6df6447a6ff4598). (ln, center); |
| 269 | //printf("closest point to line %f\n",Distance(hit,tb->center)); |
| 270 | return hitcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).; |
| 271 | } |
| 272 | if ((resSp && !resHp)) |
| 273 | return hitSpherecxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).; // 2) line cross only the sphere |
| 274 | if ((!resSp && resHp)) |
| 275 | return hitHypercxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).; // 3) line cross only the hyperboloid |
| 276 | |
| 277 | // 4) line cross both sphere and hyperboloid: choose according angle. |
| 278 | float angleDeg = mathcxx . . $ vcg/math/::ToDegcxx . . $ vcg/math/ToDeg(b9cd5987e7aec515). (Anglecxx . . $ vcg/Angle(1e0ebe277e908d16). ((viewpoint -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). center), (hitSphere -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). center))); |
| 279 | |
| 280 | //printf("Angle %f (%5.2f %5.2f %5.2f) (%5.2f %5.2f %5.2f)\n",angleDeg,hitSphere[0],hitSphere[1],hitSphere[2],hitHyper[0],hitHyper[1],hitHyper[2]); |
| 281 | if (angleDeg < 45) |
| 282 | return hitSpherecxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).; |
| 283 | else |
| 284 | return hitHypercxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).; |
| 285 | |
| 286 | // Codice ORIGINALE PONCHIO |
| 287 | //vp.SetOffset(vp.Offset() + Thr); |
| 288 | |
| 289 | //Point3f hit; |
| 290 | //bool res = Intersection<float>(vp, ln, hit); |
| 291 | //float d = Distance(tb->center - vn.Direction()*Thr, hit); |
| 292 | //if(d < Thr) { |
| 293 | // Point3f hit2; |
| 294 | // Sphere3f sphere(tb->center, tb->radius); |
| 295 | // bool res = Intersection<float>(sphere, ln, hit, hit2); |
| 296 | |
| 297 | // //find closest intersection to sphere |
| 298 | // float d = (hit - viewpoint).Norm(); |
| 299 | // float d2 = (hit2 - viewpoint).Norm(); |
| 300 | // if(d > d2) hit = hit2; |
| 301 | // hit -= tb->center; |
| 302 | //} else { |
| 303 | // if(d > 2.99 * Thr) |
| 304 | // d = 2.99 * Thr; |
| 305 | // Point3f norm = (hit - tb->center)^(viewpoint - tb->center); |
| 306 | // norm.Normalize(); |
| 307 | // float phi = -M_PI/4 - 3*M_PI/8 *(d - Thr)/Thr; |
| 308 | |
| 309 | // Quaternionf q(phi, norm); |
| 310 | // hit = q.Rotate((viewpoint - tb->center).Normalize() * tb->radius); |
| 311 | //} |
| 312 | // hit.Normalize(); |
| 313 | // return hit; |
| 314 | } |
| 315 | |
| 316 | /*! |
| 317 | @brief Calculates the minimal distance between 2 lines. |
| 318 | |
| 319 | P and Q are the lines, P_s and Q_t are set to be the closest points on these lines. |
| 320 | |
| 321 | it's returned the distance from P_s and Q_t, and a boolean value which is true |
| 322 | if the lines are parallel enough. |
| 323 | |
| 324 | if P and Q are parallel P_s and Q_t aren't set. |
| 325 | |
| 326 | the formula is taken from pages 81-83 of |
| 327 | <em>"Eric Lengyel - Mathematics for 3D Game Programming & Computer Graphics"</em> |
| 328 | @param P the first line. |
| 329 | @param Q the second line. |
| 330 | @param P_s the point on P closest to Q. |
| 331 | @param Q_t the point on Q closest to P. |
| 332 | @return a std::pair made with the distance from P_s to Q_t and a boolean value, true if and only if P and Q are almost parallel. |
| 333 | */ |
| 334 | stdcxx . . $ std/::pair< float, bool > LineLineDistancecxx . . $ vcg/trackutils/LineLineDistance(90936bbd52d6020).(const Line3fcxx . . $ vcg/Line3f# & P,const Line3fcxx . . $ vcg/Line3f# & Q,Point3fcxx . . $ vcg/Point3f# & P_s, Point3fcxx . . $ vcg/Point3f# & Q_t){ |
| 335 | Point3fcxx . . $ vcg/Point3f# p0 = Pcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..Origincxx . . $ vcg/Line3#Origin(61080bd0aaebf357). (), Vp = Pcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357). (); |
| 336 | Point3fcxx . . $ vcg/Point3f# q0 = Qcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..Origincxx . . $ vcg/Line3#Origin(61080bd0aaebf357). (), Vq = Qcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357). (); |
| 337 | float VPVP = Vp *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vp; |
| 338 | float VQVQ = Vq *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vq; |
| 339 | float VPVQ = Vp *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vq; |
| 340 | const float det = ( VPVP * VQVQ ) - ( VPVQ * VPVQ ); |
| 341 | const float EPSILON = 0.00001f; |
| 342 | if ( fabscxx . . $ fabs(fbcf3211dfe1bfd1).(det) < EPSILON ) { |
| 343 | return stdcxx . . $ std/::make_pair(Distancecxx . . $ vcg/Distance(6c105e538d57e6db).(P,q0), true); |
| 344 | } |
| 345 | float b1= (q0 -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). p0) *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vp; |
| 346 | float b2= (p0 -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). q0) *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vq; |
| 347 | float s = ( (VQVQ * b1) + (VPVQ * b2) ) / det; |
| 348 | float t = ( (VPVQ * b1) + (VPVP * b2) ) / det; |
| 349 | P_s =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). p0 +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). (Vp *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). s); |
| 350 | Q_t =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). q0 +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). (Vq *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). t); |
| 351 | return stdcxx . . $ std/::make_pair(Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(P_s,Q_t),false); |
| 352 | } |
| 353 | |
| 354 | /*! |
| 355 | @brief Calculates the minimal distance between a ray and a line. |
| 356 | |
| 357 | R is the ray and Q is the line, R_s and Q_t are set to be the closest points on |
| 358 | the ray and the line. |
| 359 | |
| 360 | it's returned the distance from R_s and Q_t, and a boolean value which is true |
| 361 | if the ray and the line are parallel enough. |
| 362 | |
| 363 | if R and Q are parallel R_s and Q_t aren't set. |
| 364 | @param R the ray. |
| 365 | @param Q the line. |
| 366 | @param R_s the point on R closest to Q. |
| 367 | @param Q_t the point on Q closest to R. |
| 368 | @return a std::pair made with the distance from R_s to Q_t and a boolean value, true if and only if P and Q are almost parallel. |
| 369 | */ |
| 370 | stdcxx . . $ std/::pair< float, bool > RayLineDistancecxx . . $ vcg/trackutils/RayLineDistance(2e0b6ed8e96aa94b).(const Ray3fcxx . . $ vcg/Ray3f# & R,const Line3fcxx . . $ vcg/Line3f# & Q,Point3fcxx . . $ vcg/Point3f# & R_s, Point3fcxx . . $ vcg/Point3f# & Q_t){ |
| 371 | Point3fcxx . . $ vcg/Point3f# r0 = Rcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..Origincxx . . $ vcg/Ray3#Origin(61080bd0aaebf357). (), Vr = Rcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..Directioncxx . . $ vcg/Ray3#Direction(61080bd0aaebf357). (); |
| 372 | Point3fcxx . . $ vcg/Point3f# q0 = Qcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..Origincxx . . $ vcg/Line3#Origin(61080bd0aaebf357). (), Vq = Qcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357). (); |
| 373 | float VRVR = Vr *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vr; |
| 374 | float VQVQ = Vq *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vq; |
| 375 | float VRVQ = Vr *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vq; |
| 376 | const float det = ( VRVR * VQVQ ) - ( VRVQ * VRVQ ); |
| 377 | const float EPSILON = 0.00001f; |
| 378 | if ( ( det >= 0.0f ? det : -det) < EPSILON ) { |
| 379 | return stdcxx . . $ std/::make_pair(Distancecxx . . $ vcg/Distance(6c105e538d57e6db).(Q,r0), true); |
| 380 | } |
| 381 | float b1= (q0 -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). r0) *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vr; |
| 382 | float b2= (r0 -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). q0) *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vq; |
| 383 | float s = ( (VQVQ * b1) + (VRVQ * b2) ) / det; |
| 384 | float t = ( (VRVQ * b1) + (VRVR * b2) ) / det; |
| 385 | if(s<0){ |
| 386 | R_s =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). r0; |
| 387 | Q_t =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). ClosestPointcxx . . $ vcg/ClosestPoint(a6df6447a6ff4598).(Q,R_s); |
| 388 | }else { |
| 389 | R_s =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). r0 +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). (Vr *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). s); |
| 390 | Q_t =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). q0 +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). (Vq *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). t); |
| 391 | } |
| 392 | return stdcxx . . $ std/::make_pair(Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(R_s,Q_t),false); |
| 393 | } |
| 394 | |
| 395 | /*! |
| 396 | @brief Calculates the minimal distance between 2 segments. |
| 397 | |
| 398 | R e Q are the segments, R_s and Q_t are set to be the closest points on |
| 399 | the segments. |
| 400 | |
| 401 | it's returned the distance from R_s and Q_t, and a boolean value which is true |
| 402 | if the segments are parallel enough. |
| 403 | @param R the first segment. |
| 404 | @param Q the second segment. |
| 405 | @param R_s the point on R closest to Q. |
| 406 | @param Q_t the point on Q closest to R. |
| 407 | @return a std::pair made with the distance from R_s to Q_t and a boolean value, true if and only if P and Q are almost parallel. |
| 408 | */ |
| 409 | stdcxx . . $ std/::pair< float, bool > SegmentSegmentDistancecxx . . $ vcg/trackutils/SegmentSegmentDistance(da606baca246057e).(const Segment3fcxx . . $ vcg/Segment3f# & R, const Segment3fcxx . . $ vcg/Segment3f# & Q, Point3fcxx . . $ vcg/Point3f# & R_s, Point3fcxx . . $ vcg/Point3f# & Q_t) |
| 410 | { |
| 411 | float R_len=Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(R.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(),R.P1cxx . . $ vcg/Segment3#P1(61080bd0aaebf357).()); |
| 412 | float Q_len=Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(Q.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(),Q.P1cxx . . $ vcg/Segment3#P1(61080bd0aaebf357).()); |
| 413 | const float EPSILON_LENGTH = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(R_len,Q_len)*0.0001f; |
| 414 | if(R_len < EPSILON_LENGTH){ |
| 415 | R_s=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).R.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(); |
| 416 | Q_t=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(Q,R_s); |
| 417 | return stdcxx . . $ std/::make_pair(Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(R_s,Q_t),true); |
| 418 | } |
| 419 | if( Q_len < EPSILON_LENGTH){ |
| 420 | Q_t=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).Q.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(); |
| 421 | R_s=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(R,Q_t); |
| 422 | return stdcxx . . $ std/::make_pair(Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(R_s,Q_t),true); |
| 423 | } |
| 424 | Point3fcxx . . $ vcg/Point3f# r0 = Rcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(), Vr = (cxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).R.P1cxx . . $ vcg/Segment3#P1(61080bd0aaebf357).()-cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c).R.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).()).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 425 | Point3fcxx . . $ vcg/Point3f# q0 = Qcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(), Vq = (cxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).Q.P1cxx . . $ vcg/Segment3#P1(61080bd0aaebf357).()-cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c).Q.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).()).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 426 | float VRVR = Vr *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vr; |
| 427 | float VQVQ = Vq *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vq; |
| 428 | float VRVQ = Vr *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vq; |
| 429 | const float det = ( VRVR * VQVQ ) - ( VRVQ * VRVQ ); |
| 430 | const float EPSILON = 0.00001f; |
| 431 | if ( ( det >= 0.0f ? det : -det) < EPSILON ) { |
| 432 | Line3fcxx . . $ vcg/Line3f# lRcxx . . $ vcg/Line3#Line3(d881d180352d7f4a).(R.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(),R.P1cxx . . $ vcg/Segment3#P1(61080bd0aaebf357).()); |
| 433 | float qa=lR.Projectioncxx . . $ vcg/Line3#Projection(9bd70c6a86ff971a).(Q.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).()); |
| 434 | float qb=lR.Projectioncxx . . $ vcg/Line3#Projection(9bd70c6a86ff971a).(Q.P1cxx . . $ vcg/Segment3#P1(61080bd0aaebf357).()); |
| 435 | if( (qa<=0.0f) && qb<=(0.0f)){ |
| 436 | R_s=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).R.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(); |
| 437 | Q_t=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(Q,R_s); |
| 438 | } else if ( (qa >= 1.0f) && (qb >= 1.0f) ){ |
| 439 | R_s=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).R.P1cxx . . $ vcg/Segment3#P1(61080bd0aaebf357).(); |
| 440 | Q_t=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(Q,R_s); |
| 441 | } else { |
| 442 | if( (qa >= 0.0f) && (qa <= 1.0f) ){ |
| 443 | Q_t=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).Q.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(); |
| 444 | R_s=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(R,Q_t); |
| 445 | } else if((qb >= 0.0f) && (qb <= 1.0f) ){ |
| 446 | Q_t=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).Q.P1cxx . . $ vcg/Segment3#P1(61080bd0aaebf357).(); |
| 447 | R_s=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(R,Q_t); |
| 448 | } else { |
| 449 | if( ((qa<=0.0f)&&(qb>=1.0f) ||((qb<=0.0f)&&(qa>=1.0f)))){ |
| 450 | R_s=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).R.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(); |
| 451 | Q_t=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).ClosestPointcxx . . $ vcg/ClosestPoint(413bbb65ae115496).(Q,R_s); |
| 452 | }else{ |
| 453 | assertcxx . . $ `/usr/include/assert.h:50:10`!(0); |
| 454 | } |
| 455 | } |
| 456 | } |
| 457 | return stdcxx . . $ std/::make_pair(Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(R_s,Q_t),true); |
| 458 | } |
| 459 | float b1= (q0 -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). r0) *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vr; |
| 460 | float b2= (r0 -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). q0) *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). Vq; |
| 461 | float s = ( (VQVQ * b1) + (VRVQ * b2) ) / det; |
| 462 | float t = ( (VRVQ * b1) + (VRVR * b2) ) / det; |
| 463 | if( s < 0 ){ |
| 464 | R_s =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). R.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(); |
| 465 | }else if ( s > R_len ){ |
| 466 | R_s =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). R.P1cxx . . $ vcg/Segment3#P1(61080bd0aaebf357).(); |
| 467 | } else { |
| 468 | R_s =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). r0 +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). (Vr *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). s); |
| 469 | } |
| 470 | if( t < 0){ |
| 471 | Q_t =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Q.P0cxx . . $ vcg/Segment3#P0(61080bd0aaebf357).(); |
| 472 | }else if ( t > Q_len ){ |
| 473 | Q_t =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Q.P1cxx . . $ vcg/Segment3#P1(61080bd0aaebf357).(); |
| 474 | }else{ |
| 475 | Q_t =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). q0 +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). (Vq *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). t); |
| 476 | } |
| 477 | return stdcxx . . $ std/::make_pair(Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(R_s,Q_t),false); |
| 478 | } |
| 479 | |
| 480 | /*! |
| 481 | @brief Compute the point on a line closest to the ray projection of a window coordinate point. |
| 482 | |
| 483 | Given a window coordinate point, computes a ray starting from the manipulator |
| 484 | camera eye and passing through the point's projection on the viewplane, then uses RayLineDistance() |
| 485 | to get the closest point to ray on a given line. |
| 486 | @see RayLineDistance(const Ray3f & R,const Line3f & Q,Point3f & R_s, Point3f & Q_t) |
| 487 | @param tb the manipulator. |
| 488 | @param axis the axis. |
| 489 | @param point the window coordinate point. |
| 490 | @return a std::pair made with the point on axis closest to the ray projection of point and a boolean true if and only if the ray doesn't diverges respect to the axis. |
| 491 | */ |
| 492 | stdcxx . . $ std/::pair< Point3fcxx . . $ vcg/Point3f#,bool > HitNearestPointOnAxiscxx . . $ vcg/trackutils/HitNearestPointOnAxis(3c3311225a63c6d9). (Trackballcxx . . $ vcg/Trackball# * tb,Line3fcxx . . $ vcg/Line3f# axis, Point3fcxx . . $ vcg/Point3f# point) |
| 493 | { |
| 494 | Ray3fNcxx . . $ vcg/Ray3fN# ray = line2raycxx . . $ vcg/Ray3#Ray3(df917d9193d4eced).(tb->cameracxx . . $ vcg/Trackball#camera..ViewLineFromWindowcxx . . $ vcg/View#ViewLineFromWindow(49e77427d541d16d). (point)); |
| 495 | Point3fcxx . . $ vcg/Point3f# axis_pcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0), ray_pcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0); |
| 496 | stdcxx . . $ std/::pair< float, bool > resp=RayLineDistancecxx . . $ vcg/trackutils/RayLineDistance(2e0b6ed8e96aa94b).(raycxx . . $ vcg/Ray3#Ray3(df917d9193d4eced).,axis,ray_p,axis_p); |
| 497 | if(resp.second || (ray_p ==cxx . . $ vcg/Point3#`operator==`(87cc7e3dc2d06c05). ray.Origincxx . . $ vcg/Ray3#Origin(4077b4b17ed9401d).())){ |
| 498 | return stdcxx . . $ std/::make_pair(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0),false); |
| 499 | } |
| 500 | return stdcxx . . $ std/::make_pair(axis_p,true); |
| 501 | } |
| 502 | |
| 503 | /*! |
| 504 | @brief Project a line into a plane. |
| 505 | |
| 506 | Given a line and a plane, returns the line projection on the plane. |
| 507 | |
| 508 | The line returned is \e not normalized. |
| 509 | @param ln the line. |
| 510 | @param pl the plane. |
| 511 | @return the (non normalized) line projected. |
| 512 | */ |
| 513 | Line3fcxx . . $ vcg/Line3f# ProjectLineOnPlanecxx . . $ vcg/trackutils/ProjectLineOnPlane(49131df0238fb562).(const Line3fcxx . . $ vcg/Line3f# & ln, const Plane3fcxx . . $ vcg/Plane3f# & pl) |
| 514 | { |
| 515 | Point3fcxx . . $ vcg/Point3f# l0=lncxx . . $ vcg/Point3#Point3(5401f57a7bce03f4)..Origincxx . . $ vcg/Line3#Origin(61080bd0aaebf357).(); |
| 516 | Point3fcxx . . $ vcg/Point3f# l1=l0+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).ln.Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).(); |
| 517 | Point3fcxx . . $ vcg/Point3f# p1cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,p2cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).; |
| 518 | p1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pl.Projectioncxx . . $ vcg/Plane3#Projection(7198c4a0a81b097f).(l0); |
| 519 | p2=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).pl.Projectioncxx . . $ vcg/Plane3#Projection(7198c4a0a81b097f).(l1); |
| 520 | Line3fcxx . . $ vcg/Line3f# rescxx . . $ vcg/Line3#Line3(d881d180352d7f4a).(p1,p2-cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c).p1); |
| 521 | return res; |
| 522 | } |
| 523 | |
| 524 | /*! |
| 525 | @brief Computes a signed line-point distance. |
| 526 | |
| 527 | Given a line, a point and a positivity direction, computes the signed distance between the line and the point. |
| 528 | @param line the line. |
| 529 | @param pt the point. |
| 530 | @param positive_dir the positivity direction. |
| 531 | @return the signed distance. |
| 532 | */ |
| 533 | float signedDistancecxx . . $ vcg/trackutils/signedDistance(910fb716c289e83a).(Line3fcxx . . $ vcg/Line3f# line,Point3fcxx . . $ vcg/Point3f# pt,Point3fcxx . . $ vcg/Point3f# positive_dir) |
| 534 | { |
| 535 | return Distancecxx . . $ vcg/Distance(6c105e538d57e6db).(line,pt) * ((((pt-cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c).ClosestPointcxx . . $ vcg/ClosestPoint(a6df6447a6ff4598).(line,pt)) *cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61). positive_dir) >= 0.0f )? 1.0f: -1.0f); |
| 536 | } |
| 537 | |
| 538 | /*! |
| 539 | @brief Computes the verical component of an user mouse drag. |
| 540 | |
| 541 | @param tb the manipulator. |
| 542 | @param new_point the new mouse pointer coordinate. |
| 543 | @return The verical component of the user mouse drag. |
| 544 | */ |
| 545 | float getDeltaYcxx . . $ vcg/trackutils/getDeltaY(cd77a98eeff4ce03).(Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# new_point) |
| 546 | { |
| 547 | float ScreenHeight = float (tb->cameracxx . . $ vcg/Trackball#camera..viewportcxx . . $ vcg/View#viewport.[3] - tb->cameracxx . . $ vcg/Trackball#camera..viewportcxx . . $ vcg/View#viewport.[1]); |
| 548 | return (new_point[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).1] - tb->last_pointcxx . . $ vcg/Trackball#last_point.[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).1]) / ScreenHeight; |
| 549 | } |
| 550 | |
| 551 | /*! |
| 552 | @brief Computes the intersection between a ray and a plane. |
| 553 | |
| 554 | @param pl the plane. |
| 555 | @param ray the ray. |
| 556 | @param po the intersection point. |
| 557 | @return true if and only if there is intersection (po is valid). |
| 558 | */ |
| 559 | template<class T> |
| 560 | inline bool IntersectionRayPlanecxx . . $ vcg/trackutils/IntersectionRayPlane(14ea33c1efc35614).( const Plane3cxx . . $ vcg/Plane3#<T> & pl, const Ray3cxx . . $ vcg/Ray3#<T> & ray, Point3cxx . . $ vcg/Point3#<T> &po){ |
| 561 | const T epsilon = T(1e-8); |
| 562 | |
| 563 | T k = pl.Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).() *cxx . . $ vcg/`operator*`(a9bd0f68cbe04cf9). ray.Directioncxx . . $ vcg/Ray3#Direction(61080bd0aaebf357).(); // Compute 'k' factor |
| 564 | if( (k >cxx . . $ std/`operator>`(a0a51a13f7e42509). -cxx . . $ vcg/operator-(15359579ba43381e).epsilon) && (k <cxx . . $ std/`operator<`(a0a51a13f7e42509). epsilon)) |
| 565 | return false; |
| 566 | T r = (pl.Offsetcxx . . $ vcg/Plane3#Offset(ea465e50d690edfe).() -cxx . . $ vcg/operator-(15359579ba43381e). pl.Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).()*cxx . . $ vcg/`operator*`(a9bd0f68cbe04cf9).ray.Origincxx . . $ vcg/Ray3#Origin(61080bd0aaebf357).())/k; // Compute ray distance |
| 567 | if (r <cxx . . $ std/`operator<`(a0a51a13f7e42509). 0) |
| 568 | return false; |
| 569 | po = ray.Origincxx . . $ vcg/Ray3#Origin(61080bd0aaebf357).() +cxx . . $ std/operator+(2764d1739bf7913d). ray.Directioncxx . . $ vcg/Ray3#Direction(61080bd0aaebf357).()*cxx . . $ vcg/`operator*`(a9bd0f68cbe04cf9).r; |
| 570 | return true; |
| 571 | } |
| 572 | |
| 573 | /*! |
| 574 | @brief Project a window coordinate point on a plane. |
| 575 | |
| 576 | Given a window coordinate point, computes a ray starting from the manipulator |
| 577 | camera eye and passing through the point's projection on the viewplane, then uses IntersectionRayPlane() |
| 578 | to get the ray intersection with a given plane. |
| 579 | |
| 580 | @see IntersectionRayPlane() |
| 581 | @param tb the manipulator. |
| 582 | @param point the window coordinate point. |
| 583 | @param plane the plane. |
| 584 | @return a std::pair made with p's projection on the.plane and a boolean true if and only if the ray doesn't diverges respect to the plane. |
| 585 | */ |
| 586 | stdcxx . . $ std/::pair< Point3fcxx . . $ vcg/Point3f#, bool > HitPlanecxx . . $ vcg/trackutils/HitPlane(588e4de9d9172459). (Trackballcxx . . $ vcg/Trackball# * tb, Point3fcxx . . $ vcg/Point3f# point, Plane3fcxx . . $ vcg/Plane3f# plane) |
| 587 | { |
| 588 | Ray3fNcxx . . $ vcg/Ray3fN# ray = line2raycxx . . $ vcg/Ray3#Ray3(df917d9193d4eced).(tb->cameracxx . . $ vcg/Trackball#camera..ViewLineFromWindowcxx . . $ vcg/View#ViewLineFromWindow(49e77427d541d16d). (point)); |
| 589 | Point3fcxx . . $ vcg/Point3f# pcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0); |
| 590 | bool res = IntersectionRayPlanecxx . . $ vcg/trackutils/IntersectionRayPlane(14ea33c1efc35614). < float >(plane, raycxx . . $ vcg/Ray3#Ray3(df917d9193d4eced)., p); |
| 591 | return stdcxx . . $ std/::make_pair(p,res); |
| 592 | } |
| 593 | |
| 594 | |
| 595 | // drawing section |
| 596 | |
| 597 | // nota: non ho scritto io questa classe, |
| 598 | // quindi la documentazione doxy potrebbe non essere accurata al 100%. |
| 599 | /*! |
| 600 | @brief Drawing hints for manipulators |
| 601 | |
| 602 | This class is an holder for drawing-related variables. |
| 603 | |
| 604 | It's mainly used for SphereMode and InactiveMode drawings. |
| 605 | */ |
| 606 | class DrawingHintcxx . . $ vcg/trackutils/DrawingHint# { |
| 607 | public: |
| 608 | /*! |
| 609 | @brief Drawing hints constructor |
| 610 | |
| 611 | assign the drawing-related variables. |
| 612 | */ |
| 613 | DrawingHintcxx . . $ vcg/trackutils/DrawingHint#DrawingHint(49f6e7a06ebc5aa8). () { |
| 614 | CircleStepcxx . . $ vcg/trackutils/DrawingHint#CircleStep. = 64; |
| 615 | HideStillcxx . . $ vcg/trackutils/DrawingHint#HideStill. = false; |
| 616 | DrawTrackcxx . . $ vcg/trackutils/DrawingHint#DrawTrack. = false; |
| 617 | LineWidthStillcxx . . $ vcg/trackutils/DrawingHint#LineWidthStill. = 0.5f; |
| 618 | LineWidthMovingcxx . . $ vcg/trackutils/DrawingHint#LineWidthMoving. = 1.5f; |
| 619 | colorcxx . . $ vcg/trackutils/DrawingHint#color. =cxx . . $ vcg/Color4#`operator=`(5e3804f1db0db3a7). Color4bcxx . . $ vcg/Color4#Color4(22fb27e10ceb577).::LightBluecxx . . $ vcg/Color4#LightBlue.; |
| 620 | } |
| 621 | /// The circles resolution. |
| 622 | int CircleStepcxx . . $ vcg/trackutils/DrawingHint#CircleStep.; |
| 623 | /// currently not in use. |
| 624 | bool HideStillcxx . . $ vcg/trackutils/DrawingHint#HideStill.; |
| 625 | /// currently not in use. |
| 626 | bool DrawTrackcxx . . $ vcg/trackutils/DrawingHint#DrawTrack.; |
| 627 | /// circle color |
| 628 | Color4bcxx . . $ vcg/Color4b# colorcxx . . $ vcg/trackutils/DrawingHint#color.; |
| 629 | /// circle line width when inactive. |
| 630 | float LineWidthStillcxx . . $ vcg/trackutils/DrawingHint#LineWidthStill.; |
| 631 | /// circle line width when active. |
| 632 | float LineWidthMovingcxx . . $ vcg/trackutils/DrawingHint#LineWidthMoving.; |
| 633 | }; |
| 634 | |
| 635 | /// the drawing hint used by the manipulators |
| 636 | DrawingHintcxx . . $ vcg/trackutils/DrawingHint# DHcxx . . $ vcg/trackutils/DH.; |
| 637 | |
| 638 | // nota: non ho scritto io questa funzione, |
| 639 | // quindi la documentazione doxy potrebbe non essere accurata al 100%. |
| 640 | /*! |
| 641 | @brief Draw 2 squares, used by DrawCircle(). |
| 642 | */ |
| 643 | void DrawPlaneHandlecxx . . $ vcg/trackutils/DrawPlaneHandle(49f6e7a06ebc5aa8). () |
| 644 | { |
| 645 | float r = 1.0; |
| 646 | float dr = r / 10.0f; |
| 647 | |
| 648 | glBegin (GL_LINE_STRIPcxx . . $ `<external>/18396878532286971346/glew.h:339:9`!); |
| 649 | glVertex3f (+r + dr, +r, 0.0); |
| 650 | glVertex3f (+r, +r + dr, 0.0); |
| 651 | glVertex3f (+r - dr, +r, 0.0); |
| 652 | glVertex3f (+r, +r - dr, 0.0); |
| 653 | glVertex3f (+r + dr, +r, 0.0); |
| 654 | glEnd (); |
| 655 | glBegin (GL_LINE_STRIPcxx . . $ `<external>/18396878532286971346/glew.h:339:9`!); |
| 656 | glVertex3f (-r + dr, -r, 0.0); |
| 657 | glVertex3f (-r, -r + dr, 0.0); |
| 658 | glVertex3f (-r - dr, -r, 0.0); |
| 659 | glVertex3f (-r, -r - dr, 0.0); |
| 660 | glVertex3f (-r + dr, -r, 0.0); |
| 661 | glEnd (); |
| 662 | } |
| 663 | |
| 664 | // nota: non ho scritto io questa funzione, |
| 665 | // quindi la documentazione doxy potrebbe non essere accurata al 100%. |
| 666 | /*! |
| 667 | @brief Draw a circle with 2 squares, used by DrawSphereIcon(). |
| 668 | */ |
| 669 | void DrawCirclecxx . . $ vcg/trackutils/DrawCircle(49f6e7a06ebc5aa8). () |
| 670 | { |
| 671 | int nside = DHcxx . . $ vcg/trackutils/DH..CircleStepcxx . . $ vcg/trackutils/DrawingHint#CircleStep.; |
| 672 | const double pi2 = 3.14159265 * 2.0; |
| 673 | glBegin (GL_LINE_LOOPcxx . . $ `<external>/18396878532286971346/glew.h:336:9`!); |
| 674 | for (double i = 0; i < nside; i++) { |
| 675 | glNormal3d (coscxx . . $ cos(fee4f1d22bc8e617). (i * pi2 / nside), sincxx . . $ sin(fee4f1d22bc8e617). (i * pi2 / nside), 0.0); |
| 676 | glVertex3d (coscxx . . $ cos(fee4f1d22bc8e617). (i * pi2 / nside), sincxx . . $ sin(fee4f1d22bc8e617). (i * pi2 / nside), 0.0); |
| 677 | } |
| 678 | glEnd (); |
| 679 | DrawPlaneHandlecxx . . $ vcg/trackutils/DrawPlaneHandle(49f6e7a06ebc5aa8). (); |
| 680 | } |
| 681 | |
| 682 | /*! |
| 683 | @brief Draw a spherical manipulator icon. |
| 684 | |
| 685 | @param tb the manipulator. |
| 686 | @param active boolean to be set to true if the icon is active. |
| 687 | */ |
| 688 | void DrawSphereIconcxx . . $ vcg/trackutils/DrawSphereIcon(34a67efc0690795a). (Trackballcxx . . $ vcg/Trackball# * tb,bool active) |
| 689 | { |
| 690 | glPushAttrib (GL_TRANSFORM_BITcxx . . $ `<external>/18396878532286971346/glew.h:627:9`! |GL_ENABLE_BITcxx . . $ `<external>/18396878532286971346/glew.h:713:9`! | GL_LINE_BITcxx . . $ `<external>/18396878532286971346/glew.h:340:9`! | GL_CURRENT_BITcxx . . $ `<external>/18396878532286971346/glew.h:331:9`! | GL_LIGHTING_BITcxx . . $ `<external>/18396878532286971346/glew.h:350:9`!); |
| 691 | glMatrixMode(GL_MODELVIEWcxx . . $ `<external>/18396878532286971346/glew.h:678:9`!); |
| 692 | glPushMatrix (); |
| 693 | |
| 694 | Point3fcxx . . $ vcg/Point3f# center = tb->centercxx . . $ vcg/Transform#center. +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). tb->trackcxx . . $ vcg/Transform#track..InverseMatrixcxx . . $ vcg/Similarity#InverseMatrix(7c114f2e28b188e1).()*cxx . . $ vcg/`operator*`(a9bd0f68cbe04cf9).Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0, 0, 0); |
| 695 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6).(center); |
| 696 | glScalecxx . . $ vcg/glScale(733da83e8cfbc73e). (tb->radiuscxx . . $ vcg/Transform#radius./tb->trackcxx . . $ vcg/Transform#track..scacxx . . $ vcg/Similarity#sca.); |
| 697 | |
| 698 | float amb[4] = { .3f, .3f, .3f, 1.0f }; |
| 699 | float col[4] = { .5f, .5f, .8f, 1.0f }; |
| 700 | glEnable (GL_LINE_SMOOTHcxx . . $ `<external>/18396878532286971346/glew.h:431:9`!); |
| 701 | if (active) |
| 702 | glLineWidth (DHcxx . . $ vcg/trackutils/DH..LineWidthMovingcxx . . $ vcg/trackutils/DrawingHint#LineWidthMoving.); |
| 703 | else |
| 704 | glLineWidth (DHcxx . . $ vcg/trackutils/DH..LineWidthStillcxx . . $ vcg/trackutils/DrawingHint#LineWidthStill.); |
| 705 | glEnable (GL_LIGHTINGcxx . . $ `<external>/18396878532286971346/glew.h:449:9`!); |
| 706 | glEnable (GL_LIGHT0cxx . . $ `<external>/18396878532286971346/glew.h:764:9`!); |
| 707 | glEnable (GL_BLENDcxx . . $ `<external>/18396878532286971346/glew.h:496:9`!); |
| 708 | glBlendFunc (GL_SRC_ALPHAcxx . . $ `<external>/18396878532286971346/glew.h:369:9`!, GL_ONE_MINUS_SRC_ALPHAcxx . . $ `<external>/18396878532286971346/glew.h:370:9`!); |
| 709 | glColorcxx . . $ vcg/glColor(57713e9b429ea9ae). (DHcxx . . $ vcg/trackutils/DH..colorcxx . . $ vcg/trackutils/DrawingHint#color.); |
| 710 | glMaterialfv (GL_FRONT_AND_BACKcxx . . $ `<external>/18396878532286971346/glew.h:385:9`!, GL_EMISSIONcxx . . $ `<external>/18396878532286971346/glew.h:674:9`!, amb); |
| 711 | glMaterialfv (GL_FRONT_AND_BACKcxx . . $ `<external>/18396878532286971346/glew.h:385:9`!, GL_DIFFUSEcxx . . $ `<external>/18396878532286971346/glew.h:636:9`!, col); |
| 712 | |
| 713 | DrawCirclecxx . . $ vcg/trackutils/DrawCircle(49f6e7a06ebc5aa8). (); |
| 714 | glRotatef (90, 1, 0, 0); |
| 715 | DrawCirclecxx . . $ vcg/trackutils/DrawCircle(49f6e7a06ebc5aa8). (); |
| 716 | glRotatef (90, 0, 1, 0); |
| 717 | DrawCirclecxx . . $ vcg/trackutils/DrawCircle(49f6e7a06ebc5aa8). (); |
| 718 | |
| 719 | glPopMatrix (); |
| 720 | glPopAttrib (); |
| 721 | } |
| 722 | |
| 723 | // TEMPORARY drawing section |
| 724 | // Disclaimer: the following code is of VERY POOR quality |
| 725 | // feel free to delete and rewrite everything |
| 726 | |
| 727 | /*! |
| 728 | @brief Support function for the \e DrawUgly series of functions |
| 729 | |
| 730 | Prepare the OpenGL attributes. |
| 731 | \warning this method is part of the \e DrawUgly series of functions, which is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 732 | */ |
| 733 | void prepare_attribcxx . . $ vcg/trackutils/prepare_attrib(49f6e7a06ebc5aa8).() |
| 734 | { |
| 735 | float amb[4] = { .3f, .3f, .3f, 1.0f }; |
| 736 | float col[4] = { .5f, .5f, .8f, 1.0f }; |
| 737 | glEnable (GL_LIGHTINGcxx . . $ `<external>/18396878532286971346/glew.h:449:9`!); |
| 738 | glEnable (GL_LIGHT0cxx . . $ `<external>/18396878532286971346/glew.h:764:9`!); |
| 739 | glEnable (GL_LINE_SMOOTHcxx . . $ `<external>/18396878532286971346/glew.h:431:9`!); |
| 740 | glEnable (GL_BLENDcxx . . $ `<external>/18396878532286971346/glew.h:496:9`!); |
| 741 | glBlendFunc (GL_SRC_ALPHAcxx . . $ `<external>/18396878532286971346/glew.h:369:9`!, GL_ONE_MINUS_SRC_ALPHAcxx . . $ `<external>/18396878532286971346/glew.h:370:9`!); |
| 742 | glMaterialfv (GL_FRONT_AND_BACKcxx . . $ `<external>/18396878532286971346/glew.h:385:9`!, GL_EMISSIONcxx . . $ `<external>/18396878532286971346/glew.h:674:9`!, amb); |
| 743 | glMaterialfv (GL_FRONT_AND_BACKcxx . . $ `<external>/18396878532286971346/glew.h:385:9`!, GL_DIFFUSEcxx . . $ `<external>/18396878532286971346/glew.h:636:9`!, col); |
| 744 | } |
| 745 | |
| 746 | /*! |
| 747 | @brief Support function for the \e DrawUgly series of functions. |
| 748 | |
| 749 | Draw a coordinate vector, usually a letter, near the manipulator icon in a user readable oriantation. |
| 750 | \warning this method is part of the \e DrawUgly series of functions, which is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 751 | @param tb the manipulator. |
| 752 | @param ugly_letter the coordinate vector. |
| 753 | */ |
| 754 | void DrawUglyLettercxx . . $ vcg/trackutils/DrawUglyLetter(56f3b2c0f2d40a02).(Trackballcxx . . $ vcg/Trackball# * tb,stdcxx . . $ std/::vectorcxx . . $ std/vector#<Point3fcxx . . $ vcg/Point3f#> ugly_letter) |
| 755 | { |
| 756 | Point3fcxx . . $ vcg/Point3f# center=tb->cameracxx . . $ vcg/Trackball#camera..Projectcxx . . $ vcg/View#Project(7198c4a0a81b097f).(tb->centercxx . . $ vcg/Transform#center.); |
| 757 | float offset=0; |
| 758 | offset=stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(offset,Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(center,tb->cameracxx . . $ vcg/Trackball#camera..Projectcxx . . $ vcg/View#Project(7198c4a0a81b097f).(tb->centercxx . . $ vcg/Transform#center.+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,0,0) *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). tb->radiuscxx . . $ vcg/Transform#radius.)))); |
| 759 | offset=stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(offset,Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(center,tb->cameracxx . . $ vcg/Trackball#camera..Projectcxx . . $ vcg/View#Project(7198c4a0a81b097f).(tb->centercxx . . $ vcg/Transform#center.+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,1,0) *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). tb->radiuscxx . . $ vcg/Transform#radius.)))); |
| 760 | offset=stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(offset,Distancecxx . . $ vcg/Distance(1e0ebe277e908d16).(center,tb->cameracxx . . $ vcg/Trackball#camera..Projectcxx . . $ vcg/View#Project(7198c4a0a81b097f).(tb->centercxx . . $ vcg/Transform#center.+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,1) *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). tb->radiuscxx . . $ vcg/Transform#radius.)))); |
| 761 | glPushMatrix(); |
| 762 | glPushAttrib (GL_ALL_ATTRIB_BITScxx . . $ `<external>/18396878532286971346/glew.h:856:9`!); |
| 763 | // go to world coords |
| 764 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (tb->centercxx . . $ vcg/Transform#center.); |
| 765 | glMultMatrixcxx . . $ vcg/glMultMatrix(d6fcb610a9d9294f). (tb->trackcxx . . $ vcg/Transform#track..InverseMatrixcxx . . $ vcg/Similarity#InverseMatrix(7c114f2e28b188e1). ()); |
| 766 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (-cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).tb->centercxx . . $ vcg/Transform#center.); |
| 767 | prepare_attribcxx . . $ vcg/trackutils/prepare_attrib(49f6e7a06ebc5aa8).(); |
| 768 | glColor3f(1,1,1); |
| 769 | glLineWidth(4.0); |
| 770 | |
| 771 | glBegin(GL_LINE_STRIPcxx . . $ `<external>/18396878532286971346/glew.h:339:9`!); |
| 772 | for(unsigned int i=0;i<ugly_letter.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();i++){ |
| 773 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(tb->cameracxx . . $ vcg/Trackball#camera..UnProjectcxx . . $ vcg/View#UnProject(7198c4a0a81b097f).(center+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(ugly_letter[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i] *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). offset *cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d). 0.25) |
| 774 | +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(-offset,-offset,0))); |
| 775 | } |
| 776 | glEnd(); |
| 777 | glPopAttrib (); |
| 778 | glPopMatrix(); |
| 779 | |
| 780 | } |
| 781 | |
| 782 | /*! |
| 783 | @brief PanMode drawing function, member of the \e DrawUgly series. |
| 784 | |
| 785 | Draw a PanMode manipulator in an ugly way. |
| 786 | \warning this method is part of the \e DrawUgly series of functions, which is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 787 | @param tb the manipulator. |
| 788 | */ |
| 789 | void DrawUglyPanModecxx . . $ vcg/trackutils/DrawUglyPanMode(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb) |
| 790 | { |
| 791 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Point3fcxx . . $ vcg/Point3f#> ugly_pcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 792 | ugly_p.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(-1,-1,0)); |
| 793 | ugly_p.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(-1,1,0)); |
| 794 | ugly_p.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,1,0)); |
| 795 | ugly_p.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,0,0)); |
| 796 | ugly_p.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(-1,0,0)); |
| 797 | |
| 798 | DrawUglyLettercxx . . $ vcg/trackutils/DrawUglyLetter(56f3b2c0f2d40a02).(tb,ugly_pcxx . . $ std/vector#vector(a1201200cf0efa42).); |
| 799 | } |
| 800 | |
| 801 | /*! |
| 802 | @brief ZMode drawing function, member of the \e DrawUgly series. |
| 803 | |
| 804 | Draw a ZMode manipulator in an ugly way. |
| 805 | \warning this method is part of the \e DrawUgly series of functions, which is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 806 | @param tb the manipulator. |
| 807 | */ |
| 808 | void DrawUglyZModecxx . . $ vcg/trackutils/DrawUglyZMode(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb) |
| 809 | { |
| 810 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Point3fcxx . . $ vcg/Point3f#> ugly_zcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 811 | ugly_z.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(-1,1,0)); |
| 812 | ugly_z.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,1,0)); |
| 813 | ugly_z.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(-1,-1,0)); |
| 814 | ugly_z.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,-1,0)); |
| 815 | DrawUglyLettercxx . . $ vcg/trackutils/DrawUglyLetter(56f3b2c0f2d40a02).(tb,ugly_zcxx . . $ std/vector#vector(a1201200cf0efa42).); |
| 816 | } |
| 817 | |
| 818 | /*! |
| 819 | @brief ScaleMode drawing function, member of the \e DrawUgly series. |
| 820 | |
| 821 | Draw a ScaleMode manipulator in an ugly way. |
| 822 | \warning this method is part of the \e DrawUgly series of functions, which is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 823 | @param tb the manipulator. |
| 824 | */ |
| 825 | void DrawUglyScaleModecxx . . $ vcg/trackutils/DrawUglyScaleMode(3c6e6be657895f3d).(Trackballcxx . . $ vcg/Trackball# * tb) |
| 826 | { |
| 827 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Point3fcxx . . $ vcg/Point3f#> ugly_scxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 828 | ugly_s.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,1,0)); |
| 829 | ugly_s.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(-1,1,0)); |
| 830 | ugly_s.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(-1,0,0)); |
| 831 | ugly_s.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,0,0)); |
| 832 | ugly_s.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,-1,0)); |
| 833 | ugly_s.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(-1,-1,0)); |
| 834 | DrawUglyLettercxx . . $ vcg/trackutils/DrawUglyLetter(56f3b2c0f2d40a02).(tb,ugly_scxx . . $ std/vector#vector(a1201200cf0efa42).); |
| 835 | } |
| 836 | |
| 837 | /*! |
| 838 | @brief AxisMode drawing function, member of the \e DrawUgly series. |
| 839 | |
| 840 | Draw an AxisMode manipulator in an ugly way. |
| 841 | \warning this method is part of the \e DrawUgly series of functions, which is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 842 | @param tb the manipulator. |
| 843 | @param axis AxisMode's axis. |
| 844 | */ |
| 845 | void DrawUglyAxisModecxx . . $ vcg/trackutils/DrawUglyAxisMode(2723725398461483).(Trackballcxx . . $ vcg/Trackball# * tb,Line3fcxx . . $ vcg/Line3f# axis) |
| 846 | { |
| 847 | glPushMatrix(); |
| 848 | glPushAttrib (GL_ALL_ATTRIB_BITScxx . . $ `<external>/18396878532286971346/glew.h:856:9`!); |
| 849 | // go to world coords |
| 850 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (tb->centercxx . . $ vcg/Transform#center.); |
| 851 | glMultMatrixcxx . . $ vcg/glMultMatrix(d6fcb610a9d9294f). (tb->trackcxx . . $ vcg/Transform#track..InverseMatrixcxx . . $ vcg/Similarity#InverseMatrix(7c114f2e28b188e1). ()); |
| 852 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (-cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).tb->centercxx . . $ vcg/Transform#center.); |
| 853 | prepare_attribcxx . . $ vcg/trackutils/prepare_attrib(49f6e7a06ebc5aa8).(); |
| 854 | glColor3f(0.9f, 0.9f, 0.2f); |
| 855 | glLineWidth(2.0); |
| 856 | glBegin(GL_LINEScxx . . $ `<external>/18396878532286971346/glew.h:335:9`!); |
| 857 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(axis.Origincxx . . $ vcg/Line3#Origin(4077b4b17ed9401d).()+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(axis.Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).()*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).100)); |
| 858 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(axis.Origincxx . . $ vcg/Line3#Origin(4077b4b17ed9401d).()-cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c).(axis.Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).()*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).100)); |
| 859 | glEnd(); |
| 860 | glPointSize(8.0); |
| 861 | glColor3f(0.2f, 0.2f, 0.9f); |
| 862 | glBegin(GL_POINTScxx . . $ `<external>/18396878532286971346/glew.h:330:9`!); |
| 863 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(axis.Origincxx . . $ vcg/Line3#Origin(4077b4b17ed9401d).()); |
| 864 | glEnd(); |
| 865 | glPopAttrib (); |
| 866 | glPopMatrix(); |
| 867 | } |
| 868 | |
| 869 | /*! |
| 870 | @brief PlaneMode drawing function, member of the \e DrawUgly series. |
| 871 | |
| 872 | Draw a PlaneMode manipulator in an ugly way. |
| 873 | \warning this method is part of the \e DrawUgly series of functions, which is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 874 | @param tb the manipulator. |
| 875 | @param plane PlaneMode's plane. |
| 876 | */ |
| 877 | void DrawUglyPlaneModecxx . . $ vcg/trackutils/DrawUglyPlaneMode(ea6189cad2d31736).(Trackballcxx . . $ vcg/Trackball# * tb,Plane3fcxx . . $ vcg/Plane3f# plane) |
| 878 | { |
| 879 | glPushMatrix(); |
| 880 | glPushAttrib (GL_ALL_ATTRIB_BITScxx . . $ `<external>/18396878532286971346/glew.h:856:9`!); |
| 881 | // go to world coords |
| 882 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (tb->centercxx . . $ vcg/Transform#center.); |
| 883 | glMultMatrixcxx . . $ vcg/glMultMatrix(d6fcb610a9d9294f). (tb->trackcxx . . $ vcg/Transform#track..InverseMatrixcxx . . $ vcg/Similarity#InverseMatrix(7c114f2e28b188e1). ()); |
| 884 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (-cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).tb->centercxx . . $ vcg/Transform#center.); |
| 885 | prepare_attribcxx . . $ vcg/trackutils/prepare_attrib(49f6e7a06ebc5aa8).(); |
| 886 | Point3fcxx . . $ vcg/Point3f# p0cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,d1cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,d2cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,normcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).; |
| 887 | norm=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).plane.Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).(); |
| 888 | p0=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).plane.Projectioncxx . . $ vcg/Plane3#Projection(7198c4a0a81b097f).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0)); |
| 889 | d1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,1,0); |
| 890 | if(norm ==cxx . . $ vcg/Point3#`operator==`(87cc7e3dc2d06c05). d1 || norm ==cxx . . $ vcg/Point3#`operator==`(87cc7e3dc2d06c05). -cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).d1) |
| 891 | d1 =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,0,0); |
| 892 | d2=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).plane.Projectioncxx . . $ vcg/Plane3#Projection(7198c4a0a81b097f).(d1); |
| 893 | d1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).(d2 -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). p0).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 894 | d2=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).(d1 ^cxx . . $ vcg/Point3#`operator^`(df3b8fd47e21bd0c). norm).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 895 | glLineWidth(3.0); |
| 896 | glColor3f(0.2f, 0.2f, 0.9f); |
| 897 | glBegin(GL_LINEScxx . . $ `<external>/18396878532286971346/glew.h:335:9`!); |
| 898 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(p0); |
| 899 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(p0+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).norm); |
| 900 | glEnd(); |
| 901 | glLineWidth(1.0); |
| 902 | for(float i=0.5f; i<100.0f; i+=0.7f){ |
| 903 | glBegin(GL_LINE_LOOPcxx . . $ `<external>/18396878532286971346/glew.h:336:9`!); |
| 904 | for(int a=0;a<360;a+=10){ |
| 905 | float f0=i*cosf((float(M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!)*float(a))/180.0f); |
| 906 | float f1=i*sinf((float(M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!)*float(a))/180.0f); |
| 907 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(p0+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(d1*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).f0)+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(d2*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).f1)); |
| 908 | } |
| 909 | glEnd(); |
| 910 | } |
| 911 | glColor3f(0.9f, 0.9f, 0.2f); |
| 912 | glPointSize(8.0f); |
| 913 | glBegin(GL_POINTScxx . . $ `<external>/18396878532286971346/glew.h:330:9`!); |
| 914 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(p0); |
| 915 | glEnd(); |
| 916 | glColor3f(0.7f, 0.7f, 0.0f); |
| 917 | glPointSize(6.0); |
| 918 | glBegin(GL_POINTScxx . . $ `<external>/18396878532286971346/glew.h:330:9`!); |
| 919 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(p0+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).norm); |
| 920 | glEnd(); |
| 921 | glPopAttrib (); |
| 922 | glPopMatrix(); |
| 923 | } |
| 924 | |
| 925 | /*! |
| 926 | @brief CylinderMode drawing function, member of the \e DrawUgly series. |
| 927 | |
| 928 | Draw a CylinderMode manipulator in an ugly way. |
| 929 | \warning this method is part of the \e DrawUgly series of functions, which is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 930 | @param tb the manipulator. |
| 931 | @param axis CylinderMode's axis. |
| 932 | */ |
| 933 | void DrawUglyCylinderModecxx . . $ vcg/trackutils/DrawUglyCylinderMode(2723725398461483).(Trackballcxx . . $ vcg/Trackball# * tb,Line3fcxx . . $ vcg/Line3f# axis) |
| 934 | { |
| 935 | glPushMatrix(); |
| 936 | glPushAttrib (GL_ALL_ATTRIB_BITScxx . . $ `<external>/18396878532286971346/glew.h:856:9`!); |
| 937 | // go to world coords |
| 938 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (tb->centercxx . . $ vcg/Transform#center.); |
| 939 | glMultMatrixcxx . . $ vcg/glMultMatrix(d6fcb610a9d9294f). (tb->trackcxx . . $ vcg/Transform#track..InverseMatrixcxx . . $ vcg/Similarity#InverseMatrix(7c114f2e28b188e1). ()); |
| 940 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (-cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).tb->centercxx . . $ vcg/Transform#center.); |
| 941 | prepare_attribcxx . . $ vcg/trackutils/prepare_attrib(49f6e7a06ebc5aa8).(); |
| 942 | Plane3fcxx . . $ vcg/Plane3f# planecxx . . $ vcg/Plane3#Plane3(49f6e7a06ebc5aa8).; |
| 943 | plane.Initcxx . . $ vcg/Plane3#Init(d881d180352d7f4a).(axis.Origincxx . . $ vcg/Line3#Origin(4077b4b17ed9401d).(),axis.Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).()); |
| 944 | Point3fcxx . . $ vcg/Point3f# p0cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,d1cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,d2cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,normcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).; |
| 945 | norm=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).plane.Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).(); |
| 946 | p0=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).plane.Projectioncxx . . $ vcg/Plane3#Projection(7198c4a0a81b097f).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0)); |
| 947 | d1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,1,0); |
| 948 | if(norm ==cxx . . $ vcg/Point3#`operator==`(87cc7e3dc2d06c05). d1 || norm ==cxx . . $ vcg/Point3#`operator==`(87cc7e3dc2d06c05). -cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).d1) |
| 949 | d1 =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,0,0); |
| 950 | d2=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).plane.Projectioncxx . . $ vcg/Plane3#Projection(7198c4a0a81b097f).(d1); |
| 951 | d1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).(d2 -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). p0).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 952 | d2=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).(d1 ^cxx . . $ vcg/Point3#`operator^`(df3b8fd47e21bd0c). norm).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 953 | glLineWidth(1.0); |
| 954 | glColor3f(0.2f, 0.2f, 0.9f); |
| 955 | for(int i=-100;i<100;i++){ |
| 956 | glBegin(GL_LINE_LOOPcxx . . $ `<external>/18396878532286971346/glew.h:336:9`!); |
| 957 | for(int a=0;a<360;a+=10){ |
| 958 | float f0=(tb->radiuscxx . . $ vcg/Transform#radius.)*cosf((float(M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!)*float(a))/180.0f); |
| 959 | float f1=(tb->radiuscxx . . $ vcg/Transform#radius.)*sinf((float(M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!)*float(a))/180.0f); |
| 960 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(axis.Origincxx . . $ vcg/Line3#Origin(4077b4b17ed9401d).()+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).p0+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(norm*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).float(i))+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(d1*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).f0)+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(d2*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).f1)); |
| 961 | } |
| 962 | glEnd(); |
| 963 | } |
| 964 | glLineWidth(3.0); |
| 965 | glColor3f(0.2f, 0.2f, 0.9f); |
| 966 | glBegin(GL_LINEScxx . . $ `<external>/18396878532286971346/glew.h:335:9`!); |
| 967 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(axis.Origincxx . . $ vcg/Line3#Origin(4077b4b17ed9401d).()); |
| 968 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(axis.Origincxx . . $ vcg/Line3#Origin(4077b4b17ed9401d).()+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(axis.Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).()*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).100)); |
| 969 | glEnd(); |
| 970 | glLineWidth(1.5); |
| 971 | glColor3f(0.9f, 0.2f, 0.9f); |
| 972 | glBegin(GL_LINEScxx . . $ `<external>/18396878532286971346/glew.h:335:9`!); |
| 973 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(axis.Origincxx . . $ vcg/Line3#Origin(4077b4b17ed9401d).()); |
| 974 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(axis.Origincxx . . $ vcg/Line3#Origin(4077b4b17ed9401d).()-cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c).(axis.Directioncxx . . $ vcg/Line3#Direction(61080bd0aaebf357).()*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).100)); |
| 975 | glEnd(); |
| 976 | glColor3f(0.9f, 0.9f, 0.2f); |
| 977 | glPointSize(8.0); |
| 978 | glBegin(GL_POINTScxx . . $ `<external>/18396878532286971346/glew.h:330:9`!); |
| 979 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(axis.Origincxx . . $ vcg/Line3#Origin(4077b4b17ed9401d).()); |
| 980 | glEnd(); |
| 981 | glPopAttrib (); |
| 982 | glPopMatrix(); |
| 983 | } |
| 984 | |
| 985 | /*! |
| 986 | @brief PathMode drawing function, member of the \e DrawUgly series. |
| 987 | |
| 988 | Draw a PathMode manipulator in an ugly way. |
| 989 | \warning this method is part of the \e DrawUgly series of functions, which is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 990 | @param tb the manipulator. |
| 991 | @param points PathMode's points. |
| 992 | @param current_point PathMode's current point. |
| 993 | @param prev_point PathMode's prev point. |
| 994 | @param next_point PathMode's next point. |
| 995 | @param old_hitpoint PathMode's old hitpoint. |
| 996 | @param wrap PathMode's wrap. |
| 997 | */ |
| 998 | void DrawUglyPathModecxx . . $ vcg/trackutils/DrawUglyPathMode(eea556f2aa4961e5).(Trackballcxx . . $ vcg/Trackball# * tb,const stdcxx . . $ std/::vectorcxx . . $ std/vector# < Point3fcxx . . $ vcg/Point3f# > &points, |
| 999 | Point3fcxx . . $ vcg/Point3f# current_point,Point3fcxx . . $ vcg/Point3f# prev_point, |
| 1000 | Point3fcxx . . $ vcg/Point3f# next_point,Point3fcxx . . $ vcg/Point3f# old_hitpoint,bool wrap) |
| 1001 | { |
| 1002 | glPushMatrix(); |
| 1003 | glPushAttrib (GL_ALL_ATTRIB_BITScxx . . $ `<external>/18396878532286971346/glew.h:856:9`!); |
| 1004 | // go to world coords |
| 1005 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (tb->centercxx . . $ vcg/Transform#center.); |
| 1006 | glMultMatrixcxx . . $ vcg/glMultMatrix(d6fcb610a9d9294f). (tb->trackcxx . . $ vcg/Transform#track..InverseMatrixcxx . . $ vcg/Similarity#InverseMatrix(7c114f2e28b188e1). ()); |
| 1007 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (-cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).tb->centercxx . . $ vcg/Transform#center.); |
| 1008 | prepare_attribcxx . . $ vcg/trackutils/prepare_attrib(49f6e7a06ebc5aa8).(); |
| 1009 | glColor3f(0.9f, 0.9f, 0.2f); |
| 1010 | glLineWidth(2.0); |
| 1011 | if(wrap) |
| 1012 | glBegin(GL_LINE_LOOPcxx . . $ `<external>/18396878532286971346/glew.h:336:9`!); |
| 1013 | else |
| 1014 | glBegin(GL_LINE_STRIPcxx . . $ `<external>/18396878532286971346/glew.h:339:9`!); |
| 1015 | for (stdcxx . . $ std/::vectorcxx . . $ std/vector# < Point3f >::const_iteratorcxx . . $ std/vector#const_iterator# i = points.begincxx . . $ std/vector#begin(d1e1699016b9d7e6). (); i != points.endcxx . . $ std/vector#end(d1e1699016b9d7e6). (); ++i){ |
| 1016 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(*i); |
| 1017 | } |
| 1018 | glEnd(); |
| 1019 | glColor3f(1,0,1); |
| 1020 | glPointSize(8.0); |
| 1021 | glBegin(GL_POINTScxx . . $ `<external>/18396878532286971346/glew.h:330:9`!); |
| 1022 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(current_point); |
| 1023 | glEnd(); |
| 1024 | glColor3f(0.6f, 0.0f, 0.6f); |
| 1025 | glPointSize(7.0); |
| 1026 | glBegin(GL_POINTScxx . . $ `<external>/18396878532286971346/glew.h:330:9`!); |
| 1027 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(old_hitpoint); |
| 1028 | glEnd(); |
| 1029 | glColor3f(0.7f, 0.7f, 0.7f); |
| 1030 | glPointSize(6.5); |
| 1031 | glBegin(GL_POINTScxx . . $ `<external>/18396878532286971346/glew.h:330:9`!); |
| 1032 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(prev_point); |
| 1033 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(next_point); |
| 1034 | glEnd(); |
| 1035 | glPopAttrib (); |
| 1036 | glPopMatrix(); |
| 1037 | } |
| 1038 | |
| 1039 | /*! |
| 1040 | @brief AreaMode drawing function, member of the \e DrawUgly series. |
| 1041 | |
| 1042 | Draw an AreaMode manipulator in an ugly way. |
| 1043 | \warning this method is part of the \e DrawUgly series of functions, which is a \b TEMPORARY solution, used while waiting for the \e DrawBeautiful series... |
| 1044 | @param tb the manipulator. |
| 1045 | @param points AreaMode's points. |
| 1046 | @param status AreaMode's status. |
| 1047 | @param old_status AreaMode's old status. |
| 1048 | @param plane AreaMode's plane. |
| 1049 | @param path AreaMode's path. |
| 1050 | @param rubberband_handle AreaMode's rubberband handle. |
| 1051 | */ |
| 1052 | void DrawUglyAreaModecxx . . $ vcg/trackutils/DrawUglyAreaMode(da0f49b836d7f101).(Trackballcxx . . $ vcg/Trackball# * tb,const stdcxx . . $ std/::vectorcxx . . $ std/vector# < Point3fcxx . . $ vcg/Point3f# > &points, |
| 1053 | Point3fcxx . . $ vcg/Point3f# status,Point3fcxx . . $ vcg/Point3f# old_status,Plane3fcxx . . $ vcg/Plane3f# plane, |
| 1054 | const stdcxx . . $ std/::vectorcxx . . $ std/vector# < Point3fcxx . . $ vcg/Point3f# > &path,Point3fcxx . . $ vcg/Point3f# rubberband_handle) |
| 1055 | { |
| 1056 | glPushMatrix(); |
| 1057 | glPushAttrib (GL_ALL_ATTRIB_BITScxx . . $ `<external>/18396878532286971346/glew.h:856:9`!); |
| 1058 | // go to world coords |
| 1059 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (tb->centercxx . . $ vcg/Transform#center.); |
| 1060 | glMultMatrixcxx . . $ vcg/glMultMatrix(d6fcb610a9d9294f). (tb->trackcxx . . $ vcg/Transform#track..InverseMatrixcxx . . $ vcg/Similarity#InverseMatrix(7c114f2e28b188e1). ()); |
| 1061 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (-cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).tb->centercxx . . $ vcg/Transform#center.); |
| 1062 | prepare_attribcxx . . $ vcg/trackutils/prepare_attrib(49f6e7a06ebc5aa8).(); |
| 1063 | glColor3f(0.9f, 0.9f, 0.2f); |
| 1064 | glLineWidth(2.0); |
| 1065 | glBegin(GL_LINE_LOOPcxx . . $ `<external>/18396878532286971346/glew.h:336:9`!); |
| 1066 | for (stdcxx . . $ std/::vectorcxx . . $ std/vector# < Point3f >::const_iteratorcxx . . $ std/vector#const_iterator# i = points.begincxx . . $ std/vector#begin(d1e1699016b9d7e6). (); i != points.endcxx . . $ std/vector#end(d1e1699016b9d7e6). (); ++i){ |
| 1067 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(*i); |
| 1068 | } |
| 1069 | glEnd(); |
| 1070 | glColor3f(0.0f, 0.9f, 0.2f); |
| 1071 | glLineWidth(1.2f); |
| 1072 | glBegin(GL_LINE_STRIPcxx . . $ `<external>/18396878532286971346/glew.h:339:9`!); |
| 1073 | for (stdcxx . . $ std/::vectorcxx . . $ std/vector# < Point3f >::const_iteratorcxx . . $ std/vector#const_iterator# i = path.begincxx . . $ std/vector#begin(d1e1699016b9d7e6). (); i != path.endcxx . . $ std/vector#end(d1e1699016b9d7e6). (); ++i){ |
| 1074 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(*i); |
| 1075 | } |
| 1076 | glEnd(); |
| 1077 | glColor3f(1,0,1); |
| 1078 | glPointSize(8.0); |
| 1079 | glBegin(GL_POINTScxx . . $ `<external>/18396878532286971346/glew.h:330:9`!); |
| 1080 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(status); |
| 1081 | glEnd(); |
| 1082 | glColor3f(0.6f, 0.0f, 0.6f); |
| 1083 | glPointSize(7.0); |
| 1084 | glBegin(GL_POINTScxx . . $ `<external>/18396878532286971346/glew.h:330:9`!); |
| 1085 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(old_status); |
| 1086 | glEnd(); |
| 1087 | glColor3f(0.6f, 0.0f, 0.0f); |
| 1088 | glPointSize(6.0); |
| 1089 | glBegin(GL_POINTScxx . . $ `<external>/18396878532286971346/glew.h:330:9`!); |
| 1090 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(rubberband_handle); |
| 1091 | glEnd(); |
| 1092 | glLineWidth(1.0); |
| 1093 | glBegin(GL_LINEScxx . . $ `<external>/18396878532286971346/glew.h:335:9`!); |
| 1094 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(rubberband_handle); |
| 1095 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(status); |
| 1096 | glEnd(); |
| 1097 | Point3fcxx . . $ vcg/Point3f# p0cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,d1cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,d2cxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,normcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).; |
| 1098 | norm=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).plane.Directioncxx . . $ vcg/Plane3#Direction(61080bd0aaebf357).(); |
| 1099 | p0=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).plane.Projectioncxx . . $ vcg/Plane3#Projection(7198c4a0a81b097f).(Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0)); |
| 1100 | d1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,1,0); |
| 1101 | if(norm ==cxx . . $ vcg/Point3#`operator==`(87cc7e3dc2d06c05). d1 || norm ==cxx . . $ vcg/Point3#`operator==`(87cc7e3dc2d06c05). -cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).d1) |
| 1102 | d1 =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,0,0); |
| 1103 | d2=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).plane.Projectioncxx . . $ vcg/Plane3#Projection(7198c4a0a81b097f).(d1); |
| 1104 | d1=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).(d2 -cxx . . $ vcg/Point3#operator-(df3b8fd47e21bd0c). p0).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 1105 | d2=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).(d1 ^cxx . . $ vcg/Point3#`operator^`(df3b8fd47e21bd0c). norm).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 1106 | glLineWidth(3.0); |
| 1107 | glColor3f(0.2f, 0.2f, 0.9f); |
| 1108 | glBegin(GL_LINEScxx . . $ `<external>/18396878532286971346/glew.h:335:9`!); |
| 1109 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(p0); |
| 1110 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(p0+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).norm); |
| 1111 | glEnd(); |
| 1112 | glLineWidth(0.1f); |
| 1113 | for(float i=0.5f;i<100.0f; i+=0.7f){ |
| 1114 | glBegin(GL_LINE_LOOPcxx . . $ `<external>/18396878532286971346/glew.h:336:9`!); |
| 1115 | for(int a=0;a<360;a+=10){ |
| 1116 | float f0=i*cosf((float(M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!)*float(a))/180.0f); |
| 1117 | float f1=i*sinf((float(M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!)*float(a))/180.0f); |
| 1118 | glVertexcxx . . $ vcg/glVertex(fc87840241e07ad6).(p0+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(d1*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).f0)+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).(d2*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).f1)); |
| 1119 | } |
| 1120 | glEnd(); |
| 1121 | } |
| 1122 | |
| 1123 | glPopAttrib (); |
| 1124 | glPopMatrix(); |
| 1125 | } |
| 1126 | |
| 1127 | |
| 1128 | } //end namespace trackutils |
| 1129 | |
| 1130 | } //end namespace vcg |
| 1131 | |
| 1132 | #endif //TRACKUTILS_H |