Ok. I can get the mesh to work using the mtl file, but I have gone back and tried to get the basic geometric textures working and I am still having problems. I created a simple geometry for a box using the code shown below. I set it up to try and place the texture file once on each face. When I run this I get something that looks exactly like what happens when I just use the box shape. This is getting frustrating. Any help with what I am doing wrong would be greatly appreciated.
Code: osg::Geometry* CreateBoxGeometry() { osg::Geometry* box = new osg::Geometry; // Vertices osg::Vec3Array* vertices = new osg::Vec3Array; vertices->push_back(osg::Vec3(-.5, -.5, -.5)); // 0 vertices->push_back(osg::Vec3( .5, -.5, -.5)); // 3 vertices->push_back(osg::Vec3( .5, -.5, .5)); // 5 vertices->push_back(osg::Vec3(-.5, -.5, .5)); // 1 vertices->push_back(osg::Vec3(-.5, -.5, .5)); // 1 vertices->push_back(osg::Vec3( .5, -.5, .5)); // 5 vertices->push_back(osg::Vec3( .5, .5, .5)); // 7 vertices->push_back(osg::Vec3(-.5, .5, .5)); // 4 vertices->push_back(osg::Vec3(-.5, -.5, -.5)); // 0 vertices->push_back(osg::Vec3(-.5, -.5, .5)); // 1 vertices->push_back(osg::Vec3(-.5, .5, .5)); // 4 vertices->push_back(osg::Vec3(-.5, .5, -.5)); // 2 vertices->push_back(osg::Vec3( .5, -.5, -.5)); // 3 vertices->push_back(osg::Vec3( .5, .5, -.5)); // 6 vertices->push_back(osg::Vec3( .5, .5, .5)); // 7 vertices->push_back(osg::Vec3( .5, -.5, .5)); // 5 vertices->push_back(osg::Vec3( .5, .5, -.5)); // 6 vertices->push_back(osg::Vec3(-.5, .5, -.5)); // 2 vertices->push_back(osg::Vec3(-.5, .5, .5)); // 4 vertices->push_back(osg::Vec3( .5, .5, .5)); // 7 vertices->push_back(osg::Vec3( .5, -.5, -.5)); // 3 vertices->push_back(osg::Vec3(-.5, -.5, -.5)); // 0 vertices->push_back(osg::Vec3(-.5, .5, -.5)); // 2 vertices->push_back(osg::Vec3( .5, .5, -.5)); // 6 box->setVertexArray(vertices); // Normals osg::Vec3Array* normals = new osg::Vec3Array; normals->push_back(osg::Vec3( 0, -1, 0)); normals->push_back(osg::Vec3( 0, -1, 0)); normals->push_back(osg::Vec3( 0, -1, 0)); normals->push_back(osg::Vec3( 0, -1, 0)); normals->push_back(osg::Vec3( 0, 0, 1)); normals->push_back(osg::Vec3( 0, 0, 1)); normals->push_back(osg::Vec3( 0, 0, 1)); normals->push_back(osg::Vec3( 0, 0, 1)); normals->push_back(osg::Vec3(-1, 0, 0)); normals->push_back(osg::Vec3(-1, 0, 0)); normals->push_back(osg::Vec3(-1, 0, 0)); normals->push_back(osg::Vec3(-1, 0, 0)); normals->push_back(osg::Vec3( 1, 0, 0)); normals->push_back(osg::Vec3( 1, 0, 0)); normals->push_back(osg::Vec3( 1, 0, 0)); normals->push_back(osg::Vec3( 1, 0, 0)); normals->push_back(osg::Vec3( 0, 1, 0)); normals->push_back(osg::Vec3( 0, 1, 0)); normals->push_back(osg::Vec3( 0, 1, 0)); normals->push_back(osg::Vec3( 0, 1, 0)); normals->push_back(osg::Vec3( 0, 0, -1)); normals->push_back(osg::Vec3( 0, 0, -1)); normals->push_back(osg::Vec3( 0, 0, -1)); normals->push_back(osg::Vec3( 0, 0, -1)); box->setNormalArray(normals); box->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); // Faces box->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, vertices->size())); // Colors osg::Vec4Array* colors = new osg::Vec4Array; colors->push_back(osg::Vec4(1,1,1,1)); box->setColorArray(colors); box->setColorBinding(osg::Geometry::BIND_OVERALL); // Text Coords osg::Vec2Array* tx = new osg::Vec2Array; tx->push_back(osg::Vec2( 0.f, 0.f)); // 0 tx->push_back(osg::Vec2( 1.f, 0.f)); // 3 tx->push_back(osg::Vec2( 1.f, 1.f)); // 5 tx->push_back(osg::Vec2( 0.f, 1.f)); // 1 tx->push_back(osg::Vec2( 0.f, 0.f)); // 1 tx->push_back(osg::Vec2( 1.f, 0.f)); // 5 tx->push_back(osg::Vec2( 1.f, 1.f)); // 7 tx->push_back(osg::Vec2( 0.f, 1.f)); // 4 tx->push_back(osg::Vec2( 0.f, 0.f)); // 0 tx->push_back(osg::Vec2( 1.f, 0.f)); // 1 tx->push_back(osg::Vec2( 1.f, 1.f)); // 4 tx->push_back(osg::Vec2( 0.f, 1.f)); // 2 tx->push_back(osg::Vec2( 0.f, 0.f)); // 3 tx->push_back(osg::Vec2( 1.f, 0.f)); // 6 tx->push_back(osg::Vec2( 1.f, 1.f)); // 7 tx->push_back(osg::Vec2( 0.f, 1.f)); // 5 tx->push_back(osg::Vec2( 0.f, 0.f)); // 6 tx->push_back(osg::Vec2( 1.f, 0.f)); // 2 tx->push_back(osg::Vec2( 1.f, 1.f)); // 4 tx->push_back(osg::Vec2( 0.f, 1.f)); // 7 tx->push_back(osg::Vec2( 0.f, 0.f)); // 3 tx->push_back(osg::Vec2( 1.f, 0.f)); // 0 tx->push_back(osg::Vec2( 1.f, 1.f)); // 2 tx->push_back(osg::Vec2( 0.f, 1.f)); // 6 box->setTexCoordArray( 0, tx ); return box; } osg::Node* createModel() { osg::Group* root = new osg::Group; osg::ref_ptr<osg::Geode> geode = new osg::Geode; osg::Geometry *lpGeom = CreateBoxGeometry(); geode->addDrawable( lpGeom ); root->addChild(geode.get()); osg::ref_ptr<osg::Image> image = osgDB::readImageFile("gravel.bmp"); osg::StateSet* state = lpGeom->getOrCreateStateSet(); state->setTextureAttributeAndModes(0, new osg::Texture2D(image.get())); return root; } Thanks, David ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=24637#24637 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org