Show
Ignore:
Timestamp:
12/10/07 18:30:18 (7 years ago)
Author:
robert
Message:

From Roland Smeenk, "Attached you will find a large set of small typo fixes (mainly in the comments)."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osggeometry/osggeometry.cpp

    r6941 r7648  
    4040// This demos uses the illustrates how to creates the various different types of geometry that 
    4141// the osg::Geometry class can represent.  This demos uses the OpenGL red books diagram of different  
    42 // OpenGL Primitives as a template for all the equivilant OpenSceneGraph Primitives.  The OpenSceneGraph  
     42// OpenGL Primitives as a template for all the equivalent OpenSceneGraph Primitives.  The OpenSceneGraph  
    4343// wraps OpenGL very thinly so uses all the same enum and naming conventions. The coordinate data is also  
    44 // wrapped around OpenGL's vertex arrays and draw arrays/elements calls.  Familarity with 
     44// wrapped around OpenGL's vertex arrays and draw arrays/elements calls.  Familiarity with 
    4545// OpenGL will help understand the the osg::Geometry class which encapsulate all this, or if you 
    46 // havn't learnt OpenGL yet, learning osg::Geometry will help you understand how OpenGL 
     46// havn't learned OpenGL yet, learning osg::Geometry will help you understand how OpenGL 
    4747// works! 
    4848 
    4949// The osg::Geometry class "is a" subclass of osg::Drawable base class, so is an object that provides 
    5050// a draw method for drawing objects in the scene.  osg::Geometry contains all the vertex, normal 
    51 // color and texture coordate arrays required to specify the coordinates of your objects, and the 
    52 // primtives join these coordinates together as the points, lines or surfaces that you will see 
     51// color and texture coordinate arrays required to specify the coordinates of your objects, and the 
     52// primitives join these coordinates together as the points, lines or surfaces that you will see 
    5353// rendered on your screen.  
    5454// 
     
    6868}; 
    6969 
    70 // decompose Drawable primtives into triangles, print out these triangles and computed normals. 
     70// decompose Drawable primitives into triangles, print out these triangles and computed normals. 
    7171void printTriangles(const std::string& name, osg::Drawable& drawable) 
    7272{ 
     
    8686 
    8787    // follows are separate blocks for creating POINTS, LINES, LINE_STRIP, LINE_LOOP, POLYGON, QUADS, 
    88     // QUAD_STRIP, TRIANGLES, TRIANGLE_STRIP and TRIANGLE_FAN primtives.  A image of these primtives 
    89     // are provided in the distribution : OpenSceneGraph-Data/Images/primtives.gif. 
     88    // QUAD_STRIP, TRIANGLES, TRIANGLE_STRIP and TRIANGLE_FAN primitives.  A image of these primitives 
     89    // are provided in the distribution : OpenSceneGraph-Data/Images/primitives.gif. 
    9090 
    9191 
    9292    // create POINTS 
    9393    { 
    94         // create Geometry object to store all the vetices and points primtive. 
     94        // create Geometry object to store all the vertices and points primitive. 
    9595        osg::Geometry* pointsGeom = new osg::Geometry(); 
    9696         
    9797        // create a Vec3Array and add to it all my coordinates. 
    98         // Like all the *Array variants (see include/osg/Array) , Vec3Array is derivied from both osg::Array  
     98        // Like all the *Array variants (see include/osg/Array) , Vec3Array is derived from both osg::Array  
    9999        // and std::vector<>.  osg::Array's are reference counted and hence sharable, 
    100         // which std::vector<> provides all the convinience, flexibility and robustness 
     100        // which std::vector<> provides all the convenience, flexibility and robustness 
    101101        // of the most popular of all STL containers. 
    102102        osg::Vec3Array* vertices = new osg::Vec3Array; 
     
    113113         
    114114        // create the color of the geometry, one single for the whole geometry. 
    115         // for consitency of design even one single color must added as an element 
     115        // for consistency of design even one single color must added as an element 
    116116        // in a color array. 
    117117        osg::Vec4Array* colors = new osg::Vec4Array; 
     
    119119        colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f)); 
    120120         
    121         // pass the color arry to points geometry, note the binding to tell the geometry 
     121        // pass the color array to points geometry, note the binding to tell the geometry 
    122122        // that only use one color for the whole object. 
    123123        pointsGeom->setColorArray(colors); 
     
    132132 
    133133 
    134         // create and add a DrawArray Primitive (see include/osg/Primtive).  The first 
    135         // paramter passed to the DrawArrays constructor is the Primtive::Mode which 
     134        // create and add a DrawArray Primitive (see include/osg/Primitive).  The first 
     135        // parameter passed to the DrawArrays constructor is the Primitive::Mode which 
    136136        // in this case is POINTS (which has the same value GL_POINTS), the second 
    137137        // parameter is the index position into the vertex array of the first point 
     
    140140         
    141141         
    142         // add the points geomtry to the geode. 
     142        // add the points geometry to the geode. 
    143143        geode->addDrawable(pointsGeom); 
    144144    } 
     
    146146    // create LINES 
    147147    { 
    148         // create Geometry object to store all the vetices and lines primtive. 
     148        // create Geometry object to store all the vertices and lines primitive. 
    149149        osg::Geometry* linesGeom = new osg::Geometry(); 
    150150         
    151         // this time we'll prealloacte the vertex array to the size we 
     151        // this time we'll preallocate the vertex array to the size we 
    152152        // need and then simple set them as array elements, 8 points 
    153153        // makes 4 line segments. 
     
    166166        linesGeom->setVertexArray(vertices); 
    167167         
    168         // set the colors as before, plus using the aobve 
     168        // set the colors as before, plus using the above 
    169169        osg::Vec4Array* colors = new osg::Vec4Array; 
    170170        colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f)); 
     
    185185         
    186186         
    187         // add the points geomtry to the geode. 
     187        // add the points geometry to the geode. 
    188188        geode->addDrawable(linesGeom); 
    189189    } 
     
    191191    // create LINE_STRIP 
    192192    { 
    193         // create Geometry object to store all the vetices and lines primtive. 
     193        // create Geometry object to store all the vertices and lines primitive. 
    194194        osg::Geometry* linesGeom = new osg::Geometry(); 
    195195         
    196         // this time we'll prealloacte the vertex array to the size  
     196        // this time we'll preallocate the vertex array to the size  
    197197        // and then use an iterator to fill in the values, a bit perverse 
    198198        // but does demonstrate that we have just a standard std::vector underneath. 
     
    208208        linesGeom->setVertexArray(vertices); 
    209209         
    210         // set the colors as before, plus using the aobve 
     210        // set the colors as before, plus using the above 
    211211        osg::Vec4Array* colors = new osg::Vec4Array; 
    212212        colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f)); 
     
    227227         
    228228         
    229         // add the points geomtry to the geode. 
     229        // add the points geometry to the geode. 
    230230        geode->addDrawable(linesGeom); 
    231231    } 
     
    233233    // create LINE_LOOP 
    234234    { 
    235         // create Geometry object to store all the vetices and lines primtive. 
     235        // create Geometry object to store all the vertices and lines primitive. 
    236236        osg::Geometry* linesGeom = new osg::Geometry(); 
    237237         
    238         // this time we'll a C arrays to initilize the vertices. 
     238        // this time we'll a C arrays to initialize the vertices. 
    239239         
    240240        osg::Vec3 myCoords[] = 
     
    255255        linesGeom->setVertexArray(vertices); 
    256256         
    257         // set the colors as before, plus using the aobve 
     257        // set the colors as before, plus using the above 
    258258        osg::Vec4Array* colors = new osg::Vec4Array; 
    259259        colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f)); 
     
    274274         
    275275         
    276         // add the points geomtry to the geode. 
     276        // add the points geometry to the geode. 
    277277        geode->addDrawable(linesGeom); 
    278278    } 
     
    306306    // create POLYGON 
    307307    { 
    308         // create Geometry object to store all the vetices and lines primtive. 
     308        // create Geometry object to store all the vertices and lines primitive. 
    309309        osg::Geometry* polyGeom = new osg::Geometry(); 
    310310         
    311         // this time we'll a C arrays to initilize the vertices. 
    312         // note, anticlockwsie ordering. 
     311        // this time we'll a C arrays to initialize the vertices. 
     312        // note, anticlockwise ordering. 
    313313        // note II, OpenGL polygons must be convex plan polygons, otherwise  
    314314        // undefined results will occur.  If you have concave polygons or ones 
     
    347347        printTriangles("Polygon",*polyGeom); 
    348348         
    349         // add the points geomtry to the geode. 
     349        // add the points geometry to the geode. 
    350350        geode->addDrawable(polyGeom); 
    351351    } 
     
    354354    // create QUADS 
    355355    { 
    356         // create Geometry object to store all the vetices and lines primtive. 
     356        // create Geometry object to store all the vertices and lines primitive. 
    357357        osg::Geometry* polyGeom = new osg::Geometry(); 
    358358         
    359         // note, anticlockwsie ordering. 
     359        // note, anticlockwise ordering. 
    360360        osg::Vec3 myCoords[] = 
    361361        { 
     
    395395        printTriangles("Quads",*polyGeom); 
    396396 
    397         // add the points geomtry to the geode. 
     397        // add the points geometry to the geode. 
    398398        geode->addDrawable(polyGeom); 
    399399    } 
     
    401401    // create QUAD_STRIP 
    402402    { 
    403         // create Geometry object to store all the vetices and lines primtive. 
     403        // create Geometry object to store all the vertices and lines primitive. 
    404404        osg::Geometry* polyGeom = new osg::Geometry(); 
    405405         
     
    444444        printTriangles("Quads strip",*polyGeom); 
    445445 
    446         // add the points geomtry to the geode. 
     446        // add the points geometry to the geode. 
    447447        geode->addDrawable(polyGeom); 
    448448    } 
     
    450450    // create TRIANGLES, TRIANGLE_STRIP and TRIANGLE_FAN all in one Geometry/ 
    451451    { 
    452         // create Geometry object to store all the vetices and lines primtive. 
     452        // create Geometry object to store all the vertices and lines primitive. 
    453453        osg::Geometry* polyGeom = new osg::Geometry(); 
    454454         
     
    457457        { 
    458458            // TRIANGLES 6 vertices, v0..v5 
    459             // note in aniclockwise order. 
     459            // note in anticlockwise order. 
    460460            osg::Vec3(-1.12056, -2.15188e-09, -0.840418), 
    461461            osg::Vec3(-0.95165, -2.15188e-09, -0.840418), 
    462462            osg::Vec3(-1.11644, 9.18133e-09, -0.716827), 
    463463 
    464             // note in aniclockwise order. 
     464            // note in anticlockwise order. 
    465465            osg::Vec3(-0.840418, 9.18133e-09, -0.778623), 
    466466            osg::Vec3(-0.622074, 9.18133e-09, -0.613835), 
     
    479479 
    480480            // TRIANGLE FAN 5 vertices, v12..v16 
    481             // note defined in anticlockwsie order. 
     481            // note defined in anticlockwise order. 
    482482            osg::Vec3(0.844538, 9.18133e-09, -0.712708), 
    483483            osg::Vec3(1.0258, 9.18133e-09, -0.799221), 
     
    519519        printTriangles("Triangles/Strip/Fan",*polyGeom); 
    520520 
    521         // add the points geomtry to the geode. 
     521        // add the points geometry to the geode. 
    522522        geode->addDrawable(polyGeom); 
    523523    } 
     
    567567     
    568568  
    569     // create Geometry object to store all the vetices and lines primtive. 
     569    // create Geometry object to store all the vertices and lines primitive. 
    570570    osg::Geometry* polyGeom = new osg::Geometry(); 
    571571 
    572     // note, anticlockwsie ordering. 
     572    // note, anticlockwise ordering. 
    573573    osg::Vec3 myCoords[] = 
    574574    { 
     
    621621    int numIndices = sizeof(myIndices)/sizeof(unsigned short); 
    622622 
    623     // Theere are three variants of the DrawElements osg::Primitive, UByteDrawElements which 
    624     // contains unsigned char indicies, UShortDrawElements which contains unsigned short indices, 
    625     // and UIntDrawElements whcih contains ... unsigned int indices.   
     623    // There are three variants of the DrawElements osg::Primitive, UByteDrawElements which 
     624    // contains unsigned char indices, UShortDrawElements which contains unsigned short indices, 
     625    // and UIntDrawElements which contains ... unsigned int indices.   
    626626    // The first parameter to DrawElements is  
    627627    polyGeom->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::QUADS,numIndices,myIndices)); 
     
    643643    osg::Geode* geode = new osg::Geode(); 
    644644 
    645     // add the points geomtry to the geode. 
     645    // add the points geometry to the geode. 
    646646    geode->addDrawable(polyGeom); 
    647647 
    648648    //return geode; 
    649649 
    650     // create a tranform to move the background back and forward with. 
     650    // create a transform to move the background back and forward with. 
    651651  
    652652    osg::MatrixTransform* transform = new osg::MatrixTransform();