SuperQuadric.H

Go to the documentation of this file.
00001 /*!@file GUI/SuperQuadric.H  3D render SuperQuadric */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the University of Southern California (USC) and the iLab at USC.  //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: Lior Elazary <elazary@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/GUI/SuperQuadric.H $
00035 // $Id: SuperQuadric.H 13070 2010-03-28 15:59:21Z lior $
00036 //
00037 
00038 #ifndef SuperQuadric_H_DEFINED
00039 #define SuperQuadric_H_DEFINED
00040 
00041 #include <stdio.h>
00042 #include <string.h>
00043 #include <stdlib.h>
00044 #include <GL/gl.h>
00045 #undef APIENTRY // otherwise it gets redefined between gl.h and glut.h???
00046 #include <GL/glut.h>
00047 
00048 #include <math.h>
00049 #include <stdio.h>
00050 #include <stdlib.h>
00051 
00052 //This class is derived from examples from http://www.gamedev.net/reference/articles/article1172.asp
00053 //
00054 class SuperQuadric
00055 {
00056 public:
00057 
00058   SuperQuadric();
00059 
00060   ~SuperQuadric();
00061 
00062   /* sqEllipsoid(a1, a2, a3, u, v, n, e, *x, *y, *z, *nx, *ny, *nz)
00063    *
00064    * a1, a2, and a3 are the x, y, and z scaling factors, respecfully.
00065    * For proper generation of the solid, u should be >= -PI / 2 and <= PI / 2.
00066    * Similarly, v should be >= -PI and <= PI.
00067    */
00068   void ellipsoid ( float a1, float a2, float a3,
00069       float u, float v, float n, float e, 
00070       float *x, float  *y, float *z,
00071       float *nx, float *ny, float *nz );
00072 
00073   /* sqToroid(a1, a2, a3, u, v, n, e, alpha, *x, *y, *z, *nx, *ny, *nz)
00074    *
00075    * a1, a2, and a3 are the x, y, and z scaling factors, respecfully.
00076    * For proper generation of the solid, u should be >= -PI and <= PI.
00077    * Similarly, v should be >= -PI and <= PI.
00078    * Also, alpha should be > 1.
00079    */
00080   void toroid ( float a1, float a2, float a3,
00081       float u, float v, float n, float e, float alpha,
00082       float *x, float  *y, float *z,
00083       float *nx, float *ny, float *nz );
00084 
00085 
00086   /* sqSolidEllipsoid 
00087    * 
00088    * Generates a solid ellipsoid using the parameters from sq and optionally 
00089    * generates texture coordinates and a display list using the ID from sq.
00090    */
00091   void solidEllipsoid();
00092 
00093   /* sqSolidToroid ( sq, make_display_list, gen_texture_coordinates )
00094    * 
00095    * Generates a solid toroid using the parameters from sq and optionally 
00096    * generates texture coordinates and a display list using the ID from sq.
00097    */
00098   void solidToroid();
00099 
00100   /* sqEllipsoidInsideOut (x, y, z )
00101    *
00102    * Tests to see if point P is inside the SuperQuadric sq.
00103    * Returns 1 if on the surface, > 1 if outside the surface, or
00104    * < 1 if inside the surface
00105    */
00106   float ellipsoidInsideOut ( float x, float y, float z );
00107 
00108   /* sqToroidInsideOut ( x, y, z )
00109    *
00110    * Tests to see if point P is inside the SuperQuadric sq.
00111    * Returns 1 if on the surface, > 1 if outside the surface, or
00112    * < 1 if inside the surface
00113    */
00114   float toroidInsideOut (float x, float y, float z );
00115 
00116   //Some simple SuperQuadrics
00117   void solidSphere ( float radius );
00118   void solidCylinder ( float radius );
00119   void solidStar ( float radius );
00120   void solidDoublePyramid ( float radius );
00121   void solidTorus ( float radius1, float radius2 );
00122   void solidPineappleSlice ( float radius1, float radius2 );
00123   void solidPillow ( float radius );
00124   void solidSquareTorus ( float radius1, float radius2 );
00125   void solidPinchedTorus ( float radius1, float radius2 );
00126   void solidRoundCube ( float radius );
00127 
00128 public:
00129   float its_a1, its_a2, its_a3;     /* Scaling factors for x, y, and z */
00130   float its_alpha;          /* For generating toroids. This is the inner radius */
00131   float its_n, its_e;           /* North-South/East-West Roundness/Squareness Factors */
00132   float its_u1, its_u2;         /* Initial and Final U values */
00133   float its_v1, its_v2;         /* Initial and Final V values */
00134   int its_u_segs;           /* Number of segments for U */
00135   int its_v_segs;           /* Number of segments for V */
00136   float its_s1, its_t1;         /* Initial s and t texture coordinates */
00137   float its_s2, its_t2;         /* Final S and T texture coordinates */
00138   int itsTextureFlag;     /* Flag determining texture coordinate specification */
00139   int itsGlListId;       /* OpenGL Display List ID */
00140   bool itsUseDisplayList;
00141   bool itsUseTexture;
00142 };
00143 
00144 
00145 // ######################################################################
00146 /* So things look consistent in everyone's emacs... */
00147 /* Local Variables: */
00148 /* indent-tabs-mode: nil */
00149 /* End: */
00150 
00151 #endif //
Generated on Sun May 8 08:40:41 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3