Commit 7f335b72 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

do not handle faceTextureIndex Mapping anymore

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8099 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 082211a9
......@@ -251,113 +251,6 @@ void TextureControlPlugin::handleFileOpenTextures( MeshT*& _mesh , int _objectId
slotTextureAdded("Original Per Face Texture Coords","unknown.png",2,_objectId);
slotSetTextureMode("Original Per Face Texture Coords","type=halfedgebased",_objectId);
// ================================================================================
// If this property is available we have a mapping between face_index_property and
// available textures stored in the map. So we have to enable multi texturing
// ================================================================================
OpenMesh::MPropHandleT< std::map< int, std::string > > property;
if ( _mesh->get_property_handle(property,"TextureMapping") ) {
// ================================================================================
// As internal texture indices might differ from the available ones loaded from files,
// We have to remap them after loading the textures!
// ================================================================================
std::map< int,int > newMapping;
// zero ( no texture ) always maps to to zero
newMapping[0]=0;
// TODO : If only one Texture, use single Texturing mode
if ( true ) {
std::cerr << "Size : " << _mesh->property(property).size() << std::endl;
// Assume multiTexture Mode now and load the Textures
for ( std::map< int, std::string >::iterator texture = _mesh->property(property).begin();
texture != _mesh->property(property).end(); texture++ ) {
int textureId = -1;
std::cerr << "Generating Texture " << texture->second.c_str() << std::endl;
QString textureBlock = QString(texture->second.c_str());
QStringList options = textureBlock.split(" ",QString::SkipEmptyParts);
while ( options.size() > 1 ) {
if ( options[0] == "-blendu" ) {
} else if ( options[0] == "-blendu" ) {
options.pop_front();
options.pop_front();
} else if ( options[0] == "-blendv" ) {
options.pop_front();
options.pop_front();
} else if ( options[0] == "-cc" ) {
options.pop_front();
options.pop_front();
} else if ( options[0] == "-clamp" ) {
options.pop_front();
options.pop_front();
} else if ( options[0] == "-mm" ) {
options.pop_front();
options.pop_front();
options.pop_front();
} else if ( options[0] == "-o" ) {
options.pop_front();
options.pop_front();
options.pop_front();
options.pop_front();
} else if ( options[0] == "-s" ) {
options.pop_front();
options.pop_front();
options.pop_front();
options.pop_front();
} else if ( options[0] == "-t" ) {
options.pop_front();
options.pop_front();
options.pop_front();
options.pop_front();
} else if ( options[0] == "-texres" ) {
options.pop_front();
options.pop_front();
} else {
break;
}
}
QString fullName = obj->path() + QDir::separator() + options.join(" ");
std::cerr << "rest " << fullName.toStdString() << std::endl;
//
QFileInfo info(fullName);
if ( info.exists() )
slotMultiTextureAdded("OBJ Data",fullName , fullName, _objectId, textureId );
else {
emit log(LOGWARN,"Unable to load texture image " + QString(texture->second.c_str()));
slotMultiTextureAdded("OBJ Data","Unknown Texture image " + QString::number(textureId), "unknown.png", _objectId, textureId );
}
newMapping[texture->first] = textureId;
}
// Convert the indices stored in the mesh to the actual ones used for rendering
OpenMesh::FPropHandleT< int > newIndexProperty;
if (! _mesh->get_property_handle(newIndexProperty,"TextureControl: OriginalFileIndexMapping") )
_mesh->add_property(newIndexProperty,"TextureControl: OriginalFileIndexMapping");
for ( TriMesh::FaceIter f_it = _mesh->faces_begin(); f_it != _mesh->faces_end(); ++f_it)
_mesh->property(newIndexProperty, f_it ) = newMapping[_mesh->texture_index( f_it )];
// =================================================================================================
// We use a different property for storing the IndexProperty to prevent overwriting the original one
// =================================================================================================
slotSetTextureMode("OBJ Data","indexProperty=TextureControl: OriginalFileIndexMapping", _objectId);
doSwitchTexture("OBJ Data",_objectId);
}
}
}
void TextureControlPlugin::fileOpened( int _id ) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment