From Marco Jez:

here is a patch that enables a new option named "BIND_TEXTURE_MAP" in the LWO plugin. Its purpose is to allow explicit binding between texture UV maps defined in the LWO file and OpenGL texture units, overriding the default mechanism that allocates texture units automatically. This is useful when you have an UV map built in Lightwave (for example an atlas map) but no textures actually using it, so you can keep the UV map (that would be discarded otherwise) and add a texture later int your program.

Syntax is:
BIND_TEXTURE_MAP <map_name> <texunit>
This commit is contained in:
Robert Osfield
2006-01-18 12:13:48 +00:00
parent 2067543aea
commit fe3b68dbb1
6 changed files with 157 additions and 126 deletions

View File

@@ -255,7 +255,7 @@ void Surface::generate_stateset(int max_tex_units, bool force_arb_compression, c
}
}
osg::Group *Surface::apply(osg::Geometry *geo, const VertexMap_map *texture_maps, const VertexMap_map *rgb_maps, const VertexMap_map *rgba_maps, int max_tex_units, bool use_osgfx, bool force_arb_compression, const osgDB::ReaderWriter::Options* db_options) const
osg::Group *Surface::apply(osg::Geometry *geo, const VertexMap_map *texture_maps, const VertexMap_map *rgb_maps, const VertexMap_map *rgba_maps, int max_tex_units, bool use_osgfx, bool force_arb_compression, const VertexMap_binding_map &texmap_bindings, const osgDB::ReaderWriter::Options* db_options) const
{
int num_points = 0;
@@ -284,6 +284,25 @@ osg::Group *Surface::apply(osg::Geometry *geo, const VertexMap_map *texture_maps
}
}
}
for (VertexMap_binding_map::const_iterator i=texmap_bindings.begin(); i!=texmap_bindings.end(); ++i)
{
for (VertexMap_map::const_iterator j=texture_maps->begin(); j!=texture_maps->end(); ++j)
{
if (j->first == i->first)
{
if (geo->getTexCoordArray(i->second) != 0)
{
osg::notify(osg::WARN) << "Warning: lwosg::Surface: explicing binding of texture map '" << i->first << "' to texunit " << i->second << " will replace existing texture map" << std::endl;
}
geo->setTexCoordArray(i->second, j->second->asVec2Array(num_points));
}
else
{
osg::notify(osg::WARN) << "Warning: lwosg::Surface: explicit binding of texture map '" << i->first << "' to texunit " << i->second << " was requested but there is no such map in this LWO file" << std::endl;
}
}
}
osg::Vec4 color = osg::Vec4(base_color_, 1-transparency_);