Ignore:
Timestamp:
06/10/08 10:54:13 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.cpp

    r2642 r2746  
    8989        return true; 
    9090} 
     91 
    9192 
    9293void Geometry::GenerateList() 
     
    112113                                break; 
    113114                } 
     115 
    114116                glEndList(); 
    115117        } 
    116118} 
     119 
    117120 
    118121void Geometry::Render() 
     
    238241        { 
    239242                glBegin(GL_TRIANGLE_STRIP); 
    240                         while(teapot_indices[i] != STRIP_END) 
    241                         {        
    242                                 int index = teapot_indices[i] * 3; 
    243                                  
    244                                 glNormal3fv(teapot_normals + index); 
    245                                 glVertex3fv(teapot_vertices + index); 
    246                                  
    247                                 i++;             
    248                         } 
     243                 
     244                while (teapot_indices[i] != STRIP_END) 
     245                {        
     246                        int index = teapot_indices[i] * 3; 
     247 
     248                        glNormal3fv(teapot_normals + index); 
     249                        glVertex3fv(teapot_vertices + index); 
     250                         
     251                        ++ i;            
     252                } 
     253 
    249254                glEnd(); 
    250                  
    251                 i++; // skip strip end flag 
    252         } 
    253 } 
     255 
     256                ++ i; // skip strip end flag 
     257        } 
     258} 
     259 
    254260 
    255261void Geometry::CalcBoundingVolume() 
     
    276282        Vector3 *rotatedPoints = new Vector3[num_vertices]; 
    277283         
    278         for(int i = 0; i < num_vertices; i++) 
     284        for (int i = 0; i < num_vertices; ++ i) 
    279285        { 
    280286                copyVector3Values(rotatedPoints[i], vertices[i * 3], 
     
    288294        calcCubicHull(mBoundingBox.min, mBoundingBox.max, rotatedPoints, num_vertices); 
    289295 
    290         for(int i=0; i< 3; i++) 
     296        for (int i = 0; i < 3; ++ i) 
    291297        { 
    292298                mBoundingBox.min[i] *= mScale; 
     
    325331} 
    326332 
    327 /* 
    328         creates a torus with specified radii, with number of rings and ring 
     333/*      Creates a torus with specified radii, with number of rings and ring 
    329334        subdivision = precision. 
    330335*/ 
     
    338343        torus_indices = new int[num_torus_indices]; 
    339344 
    340         for(int i = 0; i < precision + 1; ++ i) 
     345        for (int i = 0; i < precision + 1; ++ i) 
    341346        { 
    342347                int index = i * 3; 
     
    364369        } 
    365370 
    366         for(int i_rng = 1; i_rng < precision + 1; ++ i_rng) 
    367         { 
    368                 for(int i=0; i<precision+1; ++i) 
     371        for (int i_rng = 1; i_rng < precision + 1; ++ i_rng) 
     372        { 
     373                for(int i = 0; i<precision + 1; ++ i) 
    369374                { 
    370375                        int index = 3 * (i_rng * (precision + 1) + i); 
     
    388393        } 
    389394 
    390         for(int i_rng = 0; i_rng < precision; ++ i_rng) 
    391         { 
    392                 for(int i = 0; i < precision; ++ i) 
     395        for (int i_rng = 0; i_rng < precision; ++ i_rng) 
     396        { 
     397                for (int i = 0; i < precision; ++ i) 
    393398                { 
    394399                        int index = ((i_rng * precision + i) * 2) * 3; 
     
    407412} 
    408413 
    409 /** 
    410         counts the triangles of the teapot. 
     414 
     415/** Counts the triangles of the teapot. 
    411416        traverses through all the triangle strips. 
    412417*/ 
     
    414419{ 
    415420        int result = 0; 
    416         int i=0; 
     421        int i = 0; 
     422 
    417423        // n - 2 triangles are drawn for a strip 
    418         while(i < num_teapot_indices) 
    419         { 
    420                 while(teapot_indices[i] != STRIP_END) 
     424        while (i < num_teapot_indices) 
     425        { 
     426                while (teapot_indices[i] != STRIP_END) 
    421427                {        
    422428                        result ++;; 
    423                         i++;             
     429                        ++ i;            
    424430                } 
    425431                result -= 2; 
    426                 i++; // skip STRIP_END 
    427         } 
     432                ++ i; // skip STRIP_END 
     433        } 
     434 
    428435        return result; 
    429436} 
    430437 
    431 /** 
    432         counts the triangles of the torus 
     438 
     439/**     Counts the triangles of the torus 
    433440*/ 
    434441int Geometry::CountTorusTriangles() 
     
    452459        int result = 0; 
    453460 
    454         switch(objectType) 
     461        switch (objectType) 
    455462        { 
    456463                case TEAPOT: 
     
    466473                        break; 
    467474        } 
     475 
    468476        return result; 
    469477} 
     
    497505} 
    498506 
    499 /** 
    500    renders a sphere with sphere_precision subdivisions. 
    501    note: works only for even sphere_precision 
     507 
     508/** Renders a sphere with sphere_precision subdivisions.  
     509    Note: works only for even sphere_precision 
    502510*/ 
    503511void Geometry::RenderSphere() 
     
    508516        glFrontFace(GL_CW); 
    509517 
    510         for (int j = 0; j < sphere_precision/2; ++j)  
     518        for (int j = 0; j < sphere_precision / 2; ++ j)  
    511519        { 
    512520                double alpha = j * PI * 2.0 / (double)sphere_precision - PI_2; 
     
    515523                glBegin(GL_TRIANGLE_STRIP); 
    516524 
    517                 for (int i = 0; i <= sphere_precision; ++i)  
     525                for (int i = 0; i <= sphere_precision; ++ i)  
    518526                { 
    519527                        double gamma = i * PI * 2.0 / (double)sphere_precision; 
     
    536544                glEnd(); 
    537545        } 
     546 
    538547        glFrontFace(GL_CCW); 
    539548} 
Note: See TracChangeset for help on using the changeset viewer.