Hi,

I'm trying to implement a bump mapping shader. That works well for a simple 
shape like that plane, where I define the tangent attribute manually:


Code:
        Geometry* plane = new Geometry();
   Vec3Array* vertices = new Vec3Array();
        Vec3Array* normals = new Vec3Array();
        DrawElementsUInt* faces = new DrawElementsUInt(PrimitiveSet::TRIANGLES, 
0);
        Vec3Array* texcoords = new Vec3Array();
        Vec3Array* tangents = new Vec3Array();

        vertices->push_back(Vec3f(1.0f, 0.0f, 1.0f));
        vertices->push_back(Vec3f(-1.0f, 0.0f, 1.0f));
        vertices->push_back(Vec3f(1.0f, 0.0f, -1.0f));
        vertices->push_back(Vec3f(-1.0f, 0.0f, -1.0f));

        normals->push_back(Vec3f(0.0f, -1.0f, 0.0f));

        texcoords->push_back(Vec3f(1.0f, 1.0f, 1.0f));
        texcoords->push_back(Vec3f(0.0f, 1.0f, 1.0f));
        texcoords->push_back(Vec3f(1.0f, 0.0f, 1.0f));
        texcoords->push_back(Vec3f(0.0f, 0.0f, 1.0f));

        faces->push_back(0);
        faces->push_back(1);
        faces->push_back(3);
        faces->push_back(3);
        faces->push_back(2);
        faces->push_back(0);

        tangents->push_back(Vec3(-1,0,0));

        plane->setVertexArray(vertices);
        plane->setNormalArray(normals);
        plane->setTexCoordArray(0, texcoords);
        plane->addPrimitiveSet(faces);
        plane->setNormalBinding(Geometry::BIND_OVERALL);

        plane->setVertexAttribData(6, Geometry::ArrayData(tangents, 
Geometry::BIND_OVERALL));



But for more complex shapes I have to use the TangentGenerator. When I try to 
run this:


Code:
ref_ptr<osgUtil::TangentSpaceGenerator> tsg = new 
osgUtil::TangentSpaceGenerator();
tsg->generate(plane, 0);



I get an "Debug Assertion Failed" with "Expression: vector subscript out of 
range" in generate().

Did I forget something? I cannot see the fault.

Daniel

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35575#35575





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to