renderstack::shapes::grid Class Reference

#include <polymesh.hpp>

Inherits renderstack::shapes::polymesh.

Public Member Functions

 grid (float cell_width, int positive_cell_count)

Detailed Description

Definition at line 75 of file polymesh.hpp.


Constructor & Destructor Documentation

renderstack::shapes::grid::grid ( float  cell_width,
int  positive_cell_count 
)

Definition at line 1811 of file polymesh.cpp.

01812 {
01813     /*    2   9  11  13   3    0.. 3  corners              */ 
01814     /*                         2.. 7  min_x...max_x lines  */ 
01815     /*    6   .   .   .   7    8..13  min_z..,max_z lines  */ 
01816     /*                                                     */ 
01817     /*    4   .   x   .   5    positive_cell_count = 2     */ 
01818     /*                                                     */ 
01819     /*    2   .   .   .   3                                */ 
01820     /*                                                     */ 
01821     /*    0   8  10  12   1                                */ 
01822 
01823     float extreme = (float)(positive_cell_count) * cell_width;
01824     int index = 0;
01825 
01826     /*  Corner vertices  */ 
01827     {
01828         push_point(-extreme, -extreme, 0.0f); index++;
01829         push_point( extreme, -extreme, 0.0f); index++;
01830         push_point(-extreme,  extreme, 0.0f); index++;
01831         push_point( extreme,  extreme, 0.0f); index++;
01832     }
01833 
01834     /*  min x...max x vertices  */ 
01835     {
01836         /*  min z :  min_x...max_x  */ 
01837         {
01838             make_polygon(0, 1);
01839         }
01840         {
01841             int z;
01842             int range = (positive_cell_count - 1);
01843 
01844             for(z = -range; z <= range; ++z)
01845             {
01846                 float   z_position = (float)(z) * cell_width;
01847                 int     v0 = index++;
01848                 int     v1 = index++;
01849                 push_point(-extreme, z_position, 0.0f);
01850                 push_point( extreme, z_position, 0.0f);
01851                 make_polygon(v0, v1);
01852             }
01853         }
01854 
01855         /*  max z :  min_x...max_x  */ 
01856         {
01857             make_polygon(2, 3);
01858         }
01859     }
01860 
01861     /*  min z...max z vertices  */ 
01862     {
01863         /*  min x :  min_z...max_z  */ 
01864         {
01865             make_polygon(0, 2);
01866         }
01867 
01868         {
01869             int x;
01870             int range = (positive_cell_count - 1);
01871 
01872             for(x = -range; x <= range; ++x)
01873             {
01874                 float   x_position = (float)(x) * cell_width;
01875                 int     v0 = index++;
01876                 int     v1 = index++;
01877                 push_point(x_position, -extreme, 0.0f);
01878                 push_point(x_position,  extreme, 0.0f);
01879                 make_polygon(v0, v1);
01880             }
01881         }
01882 
01883         /*  max x :  min_z...max_z  */ 
01884         {
01885             make_polygon(1, 3);
01886         }
01887     }
01888 
01889     /*  Done  */ 
01890     build_mesh_from_geometry();
01891 }


The documentation for this class was generated from the following files:
Generated on Sun Apr 11 12:23:12 2010 for RenderStack by  doxygen 1.6.3