Show
Ignore:
Timestamp:
10/21/14 17:10:27 (10 days ago)
Author:
robert
Message:

Added shaders to support experimental shader based displacement mapping technique osgTerrain::ShaderTerrain?.

Files:
1 modified

Legend:

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

    r12529 r13471  
    209209        geom->setStateSet(album->getBackgroundStateSet()); 
    210210 
    211         osg::Vec3Array* coords = new osg::Vec3Array(4); 
    212         (*coords)[0].set(0.0f,0.0,height); 
    213         (*coords)[1].set(0.0f,0.0,0); 
    214         (*coords)[2].set(width,0.0,0); 
    215         (*coords)[3].set(width,0.0,height); 
     211        osg::Vec3Array* coords = new osg::Vec3Array(8); 
     212        (*coords)[0].set(0.0f,0.0f,0.0f); 
     213        (*coords)[1].set(0.0f,0.0f,height); 
     214        (*coords)[2].set(0.0f,0.0f,height); 
     215        (*coords)[3].set(width,0.0f,height); 
     216        (*coords)[4].set(width,0.0f,height); 
     217        (*coords)[5].set(width,0.0f,0.0f); 
     218        (*coords)[6].set(width,0.0f,0.0f); 
     219        (*coords)[7].set(0.0f,0.0f,0.0f); 
    216220        geom->setVertexArray(coords); 
    217221         
    218222 
    219         osg::Vec3Array* normals = new osg::Vec3Array(4); 
     223        osg::Vec3Array* normals = new osg::Vec3Array(8); 
    220224        (*normals)[0].set(-1.0f,0.0f,0.0f); 
    221         (*normals)[1].set(0.0f,0.0f,-1.0f); 
    222         (*normals)[2].set(1.0f,0.0f,0.0f); 
    223         (*normals)[3].set(0.0f,0.0f,1.0f); 
     225        (*normals)[1].set(-1.0f,0.0f,0.0f); 
     226        (*normals)[2].set(0.0f,0.0f,-1.0f); 
     227        (*normals)[3].set(0.0f,0.0f,-1.0f); 
     228        (*normals)[4].set(1.0f,0.0f,0.0f); 
     229        (*normals)[5].set(1.0f,0.0f,0.0f); 
     230        (*normals)[6].set(0.0f,0.0f,1.0f); 
     231        (*normals)[7].set(0.0f,0.0f,1.0f); 
    224232        geom->setNormalArray(normals); 
    225         geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE); 
    226  
    227         osg::Vec2Array* tcoords = new osg::Vec2Array(4); 
    228         (*tcoords)[0].set(0.0f,1.0f); 
    229         (*tcoords)[1].set(0.0f,0.0f); 
    230         (*tcoords)[2].set(1.0f,0.0f); 
     233        geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); 
     234 
     235        osg::Vec2Array* tcoords = new osg::Vec2Array(8); 
     236        (*tcoords)[0].set(0.0f,0.0f); 
     237        (*tcoords)[1].set(0.0f,1.0f); 
     238        (*tcoords)[2].set(0.0f,1.0f); 
    231239        (*tcoords)[3].set(1.0f,1.0f); 
     240        (*tcoords)[4].set(1.0f,1.0f); 
     241        (*tcoords)[5].set(0.0f,1.0f); 
     242        (*tcoords)[6].set(0.0f,1.0f); 
     243        (*tcoords)[7].set(0.0f,0.0f); 
    232244        geom->setTexCoordArray(0,tcoords); 
    233245 
     
    236248        geom->setColorArray(colours); 
    237249        geom->setColorBinding(osg::Geometry::BIND_OVERALL); 
    238  
    239         osg::UByteArray* vindices = new osg::UByteArray(8); 
    240         (*vindices)[0]=0; 
    241         (*vindices)[1]=1; 
    242         (*vindices)[2]=1; 
    243         (*vindices)[3]=2; 
    244         (*vindices)[4]=2; 
    245         (*vindices)[5]=3; 
    246         (*vindices)[6]=3; 
    247         (*vindices)[7]=0; 
    248  
    249         geom->setVertexIndices(vindices); 
    250         geom->setTexCoordIndices(0,vindices); 
    251250 
    252251        geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,8));