Commit 83ebfddc authored by Dirk Wilden's avatar Dirk Wilden
Browse files

request textureCoords in FilePlugins

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8382 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a292f088
......@@ -193,9 +193,9 @@
mesh_->request_edge_status();
mesh_->request_vertex_colors();
mesh_->request_face_colors();
mesh_->request_vertex_texcoords2D();
mesh_->request_halfedge_texcoords2D();
mesh_->request_face_texture_index();
// mesh_->request_vertex_texcoords2D();
// mesh_->request_halfedge_texcoords2D();
// mesh_->request_face_texture_index();
// Only initialize scenegraph nodes when we initialized a gui!!
......
......@@ -223,8 +223,13 @@ void OBJImporter::setVertexTexCoord(VertexHandle _vh, int _texCoordID){
if ( _texCoordID < (int) texCoords_.size() ){
//perhaps request texCoords for the mesh
if ( !currentTriMesh()->has_vertex_texcoords2D() )
currentTriMesh()->request_vertex_texcoords2D();
//set the texCoords
if ( vertexMapTri_.find( _vh ) != vertexMapTri_.end() )
currentTriMesh()->set_texcoord2D( vertexMapTri_[_vh], texCoords_[ _texCoordID ] );
currentTriMesh()->set_texcoord2D( vertexMapTri_[_vh], texCoords_[ _texCoordID ] );
}else{
std::cerr << "Error: TexCoord ID too large" << std::endl;
......@@ -236,9 +241,14 @@ void OBJImporter::setVertexTexCoord(VertexHandle _vh, int _texCoordID){
if ( !currentPolyMesh() ) return;
if ( _texCoordID < (int) texCoords_.size() ){
//perhaps request texCoords for the mesh
if ( !currentPolyMesh()->has_vertex_texcoords2D() )
currentPolyMesh()->request_vertex_texcoords2D();
//set the texCoords
if ( vertexMapPoly_.find( _vh ) != vertexMapPoly_.end() )
currentPolyMesh()->set_texcoord2D( vertexMapPoly_[_vh], texCoords_[ _texCoordID ] );
currentPolyMesh()->set_texcoord2D( vertexMapPoly_[_vh], texCoords_[ _texCoordID ] );
}else{
std::cerr << "Error: TexCoord ID too large" << std::endl;
......@@ -381,6 +391,11 @@ void OBJImporter::addFace(const VHandles& _indices, const std::vector<int>& _fac
addedFacesTri_.push_back( TriMesh::FaceHandle(n_faces+i) );
//perhaps request texCoords for the mesh
if ( !currentTriMesh()->has_halfedge_texcoords2D() )
currentTriMesh()->request_halfedge_texcoords2D();
//now add texCoords
// get first halfedge handle
......@@ -395,10 +410,9 @@ void OBJImporter::addFace(const VHandles& _indices, const std::vector<int>& _fac
{
if ( _face_texcoords[i] < (int)texCoords_.size() ){
if ( currentTriMesh()->has_halfedge_texcoords2D() ){
PolyMesh::TexCoord2D tex = OpenMesh::vector_cast<TriMesh::TexCoord2D>( texCoords_[ _face_texcoords[i] ] );
currentTriMesh()->set_texcoord2D(cur_heh, tex);
}
PolyMesh::TexCoord2D tex = OpenMesh::vector_cast<TriMesh::TexCoord2D>( texCoords_[ _face_texcoords[i] ] );
currentTriMesh()->set_texcoord2D(cur_heh, tex);
cur_heh = currentTriMesh()->next_halfedge_handle(cur_heh);
}else
......@@ -429,6 +443,10 @@ void OBJImporter::addFace(const VHandles& _indices, const std::vector<int>& _fac
addedFacePoly_ = currentPolyMesh()->add_face( vertices );
//perhaps request texCoords for the mesh
if ( !currentPolyMesh()->has_halfedge_texcoords2D() )
currentPolyMesh()->request_halfedge_texcoords2D();
//now add texCoords
// get first halfedge handle
......@@ -443,10 +461,9 @@ void OBJImporter::addFace(const VHandles& _indices, const std::vector<int>& _fac
{
if ( _face_texcoords[i] < (int)texCoords_.size() ){
if ( currentPolyMesh()->has_halfedge_texcoords2D() ){
PolyMesh::TexCoord2D tex = OpenMesh::vector_cast<PolyMesh::TexCoord2D>( texCoords_[ _face_texcoords[i] ] );
currentPolyMesh()->set_texcoord2D(cur_heh, tex);
}
PolyMesh::TexCoord2D tex = OpenMesh::vector_cast<PolyMesh::TexCoord2D>( texCoords_[ _face_texcoords[i] ] );
currentPolyMesh()->set_texcoord2D(cur_heh, tex);
cur_heh = currentPolyMesh()->next_halfedge_handle(cur_heh);
}else
......
......@@ -122,6 +122,10 @@ void OFFImporter::setVertexTexCoord(VertexHandle _vh, int _texCoordID){
if ( _texCoordID < (int) texCoords_.size() ){
//perhaps request texCoords for the mesh
if ( !triMesh()->has_vertex_texcoords2D() )
triMesh()->request_vertex_texcoords2D();
if ( vertexMapTri_.find( _vh ) != vertexMapTri_.end() )
triMesh()->set_texcoord2D( vertexMapTri_[_vh], texCoords_[ _texCoordID ] );
objectOptions_ |= VERTEXTEXCOORDS;
......@@ -137,6 +141,10 @@ void OFFImporter::setVertexTexCoord(VertexHandle _vh, int _texCoordID){
if ( _texCoordID < (int) texCoords_.size() ){
//perhaps request texCoords for the mesh
if ( !polyMesh()->has_vertex_texcoords2D() )
polyMesh()->request_vertex_texcoords2D();
if ( vertexMapPoly_.find( _vh ) != vertexMapPoly_.end() )
polyMesh()->set_texcoord2D( vertexMapPoly_[_vh], texCoords_[ _texCoordID ] );
objectOptions_ |= VERTEXTEXCOORDS;
......
......@@ -290,6 +290,11 @@ int FileOMPlugin::loadTriMeshObject(QString _filename){
}
/// \todo only request if needed
object->mesh()->request_vertex_texcoords2D();
object->mesh()->request_halfedge_texcoords2D();
object->mesh()->request_face_texture_index();
// load file
bool ok = OpenMesh::IO::read_mesh( (*object->mesh()) , filename, opt );
if (!ok)
......@@ -365,6 +370,11 @@ int FileOMPlugin::loadPolyMeshObject(QString _filename){
}
/// \todo only request if needed
object->mesh()->request_vertex_texcoords2D();
object->mesh()->request_halfedge_texcoords2D();
object->mesh()->request_face_texture_index();
// load file
bool ok = OpenMesh::IO::read_mesh( (*object->mesh()) , filename, opt );
if (!ok)
......
......@@ -285,6 +285,11 @@ int FilePLYPlugin::loadTriMeshObject(QString _filename){
}
/// \todo only request if needed
object->mesh()->request_vertex_texcoords2D();
object->mesh()->request_halfedge_texcoords2D();
object->mesh()->request_face_texture_index();
// load file
bool ok = OpenMesh::IO::read_mesh( (*object->mesh()) , filename, opt );
if (!ok)
......@@ -356,6 +361,11 @@ int FilePLYPlugin::loadPolyMeshObject(QString _filename){
}
/// \todo only request if needed
object->mesh()->request_vertex_texcoords2D();
object->mesh()->request_halfedge_texcoords2D();
object->mesh()->request_face_texture_index();
// load file
bool ok = OpenMesh::IO::read_mesh( (*object->mesh()) , filename, opt );
if (!ok)
......
......@@ -231,28 +231,36 @@ void TextureControlPlugin::handleFileOpenTextures( MeshT*& _mesh , int _objectId
// ================================================================================
// Create a backup of the original per Vertex texture Coordinates
// ================================================================================
OpenMesh::VPropHandleT< typename MeshT::TexCoord2D > oldVertexCoords;
if ( !_mesh->get_property_handle(oldVertexCoords,"Original Per Vertex Texture Coords") )
_mesh->add_property(oldVertexCoords,"Original Per Vertex Texture Coords");
for ( TriMesh::VertexIter v_it = _mesh->vertices_begin(); v_it != _mesh->vertices_end(); ++v_it)
_mesh->property(oldVertexCoords, v_it ) = _mesh->texcoord2D( v_it );
slotTextureAdded("Original Per Vertex Texture Coords","unknown.png",2,_objectId);
slotSetTextureMode("Original Per Vertex Texture Coords","type=vertexbased",_objectId);
if ( _mesh->has_vertex_texcoords2D() ){
OpenMesh::VPropHandleT< typename MeshT::TexCoord2D > oldVertexCoords;
if ( !_mesh->get_property_handle(oldVertexCoords,"Original Per Vertex Texture Coords") )
_mesh->add_property(oldVertexCoords,"Original Per Vertex Texture Coords");
for ( TriMesh::VertexIter v_it = _mesh->vertices_begin(); v_it != _mesh->vertices_end(); ++v_it)
_mesh->property(oldVertexCoords, v_it ) = _mesh->texcoord2D( v_it );
slotTextureAdded("Original Per Vertex Texture Coords","unknown.png",2,_objectId);
slotSetTextureMode("Original Per Vertex Texture Coords","type=vertexbased",_objectId);
}
// ================================================================================
// Create a backup of the original per Face texture Coordinates
// ================================================================================
OpenMesh::HPropHandleT< typename MeshT::TexCoord2D > oldHalfedgeCoords;
if ( !_mesh->get_property_handle(oldHalfedgeCoords,"Original Per Face Texture Coords") )
_mesh->add_property(oldHalfedgeCoords,"Original Per Face Texture Coords");
for ( TriMesh::HalfedgeIter he_it = _mesh->halfedges_begin(); he_it != _mesh->halfedges_end(); ++he_it)
_mesh->property(oldHalfedgeCoords, he_it ) = _mesh->texcoord2D( he_it );
slotTextureAdded("Original Per Face Texture Coords","unknown.png",2,_objectId);
slotSetTextureMode("Original Per Face Texture Coords","type=halfedgebased",_objectId);
if ( _mesh->has_halfedge_texcoords2D() ){
OpenMesh::HPropHandleT< typename MeshT::TexCoord2D > oldHalfedgeCoords;
if ( !_mesh->get_property_handle(oldHalfedgeCoords,"Original Per Face Texture Coords") )
_mesh->add_property(oldHalfedgeCoords,"Original Per Face Texture Coords");
for ( TriMesh::HalfedgeIter he_it = _mesh->halfedges_begin(); he_it != _mesh->halfedges_end(); ++he_it)
_mesh->property(oldHalfedgeCoords, he_it ) = _mesh->texcoord2D( he_it );
slotTextureAdded("Original Per Face Texture Coords","unknown.png",2,_objectId);
slotSetTextureMode("Original Per Face Texture Coords","type=halfedgebased",_objectId);
}
}
......
Supports Markdown
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