Commit bfb2a7a9 authored by Jan Möbius's avatar Jan Möbius

Fixed incomplete setting of multitexture index property when reading obj files.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5816 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 17fe8d45
......@@ -195,8 +195,11 @@ void TextureControlPlugin::addedEmptyObject( int _id ) {
}
template< typename MeshT >
void TextureControlPlugin::handleFileOpenTextures( MeshT*& _mesh , int _objectId ) {
void TextureControlPlugin::handleFileOpenTextures( MeshT*& _mesh , int _objectId, TextureData& _textureData ) {
// ================================================================================
// Create a backup of the original per Vertex texture Coordinates
// ================================================================================
OpenMesh::VPropHandleT< typename MeshT::TexCoord2D > oldVertexCoords;
_mesh->add_property(oldVertexCoords,"Original Per Vertex Texture Coords");
for ( TriMesh::VertexIter v_it = _mesh->vertices_begin(); v_it != _mesh->vertices_end(); ++v_it)
......@@ -204,6 +207,9 @@ void TextureControlPlugin::handleFileOpenTextures( MeshT*& _mesh , int _objectId
slotTextureAdded("Original Per Vertex Texture Coords","",_objectId);
// ================================================================================
// Create a backup of the original per Face texture Coordinates
// ================================================================================
OpenMesh::HPropHandleT< typename MeshT::TexCoord2D > oldHalfedgeCoords;
_mesh->add_property(oldHalfedgeCoords,"Original Per Face Texture Coords");
for ( TriMesh::HalfedgeIter he_it = _mesh->halfedges_begin(); he_it != _mesh->halfedges_end(); ++he_it)
......@@ -212,8 +218,10 @@ void TextureControlPlugin::handleFileOpenTextures( MeshT*& _mesh , int _objectId
slotTextureAdded("Original Per Face Texture Coords","",_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
// 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") ) {
......@@ -235,6 +243,7 @@ void TextureControlPlugin::handleFileOpenTextures( MeshT*& _mesh , int _objectId
OpenMesh::FPropHandleT< int > newIndexProperty;
if (! _mesh->get_property_handle(newIndexProperty,"TextureControl: OriginalFileIndexMapping") ) {
_mesh->add_property(newIndexProperty,"TextureControl: OriginalFileIndexMapping");
_textureData.texture("OBJ Data").indexMappingProperty("TextureControl: OriginalFileIndexMapping");
}
for ( TriMesh::FaceIter f_it = _mesh->faces_begin(); f_it != _mesh->faces_end(); ++f_it)
......@@ -242,7 +251,11 @@ void TextureControlPlugin::handleFileOpenTextures( MeshT*& _mesh , int _objectId
// We use a different property for storing the IndexProperty to prevent overwriting them
slotSetTextureMode("OBJ Data","indexProperty=TextureControl: OriginalFileIndexMapping", _objectId);
doSwitchTexture("OBJ Data",_objectId);
}
}
}
......@@ -254,6 +267,7 @@ void TextureControlPlugin::fileOpened( int _id ) {
BaseObjectData* obj;
if (! PluginFunctions::getObject( _id , obj ) ) {
emit log(LOGERR,"Unable to get Object for id " + QString::number(_id) );
return;
}
// Check if we support this kind of data
......@@ -269,17 +283,6 @@ void TextureControlPlugin::fileOpened( int _id ) {
obj->setObjectData(TEXTUREDATA, texData);
}
// Check if the file contains a texture map, store original textures and handle them before adding global textures
if( obj->dataType( DATA_TRIANGLE_MESH ) ) {
TriMesh* mesh = PluginFunctions::triMesh(obj);
if ( mesh )
handleFileOpenTextures(mesh,_id);
} else if ( obj->dataType( DATA_POLY_MESH ) ) {
PolyMesh* mesh = PluginFunctions::polyMesh(obj);
if ( mesh )
handleFileOpenTextures(mesh,_id);
}
// Iterate over all available global textures and add them to the object
for ( uint i = 0 ; i < globalTextures_.textures().size() ; ++i) {
......@@ -330,6 +333,18 @@ void TextureControlPlugin::fileOpened( int _id ) {
}
}
// Check if the file contains a texture map, store original textures and handle them before adding global textures
if( obj->dataType( DATA_TRIANGLE_MESH ) ) {
TriMesh* mesh = PluginFunctions::triMesh(obj);
if ( mesh )
handleFileOpenTextures(mesh,_id,*texData);
} else if ( obj->dataType( DATA_POLY_MESH ) ) {
PolyMesh* mesh = PluginFunctions::polyMesh(obj);
if ( mesh )
handleFileOpenTextures(mesh,_id,*texData);
}
}
void TextureControlPlugin::slotTextureUpdated( QString _textureName , int _identifier ) {
......
......@@ -162,7 +162,7 @@ class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, Me
/// Handles data stored in new opened files ( e.g. Texture Information )
template< typename MeshT >
void handleFileOpenTextures( MeshT*& _mesh , int _objectId );
void handleFileOpenTextures( MeshT*& _mesh , int _objectId , TextureData& _textureData );
/** \brief parse texture mode settings
* Parses the string _mode and changes the settings in _texture according to the string.
......
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