Commit fcefb813 authored by Isaak Lim's avatar Isaak Lim
Browse files

the original per face/vertex texture coordinates are now back-upped when loading an OM file

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14180 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 9f4f6f11
......@@ -319,6 +319,8 @@ int FileOMPlugin::loadTriMeshObject(QString _filename){
object->update();
backupTextureCoordinates(*(object->mesh()));
return object->id();
} else {
......@@ -400,6 +402,8 @@ int FileOMPlugin::loadPolyMeshObject(QString _filename){
object->update();
backupTextureCoordinates(*(object->mesh()));
return object->id();
} else {
......@@ -410,6 +414,36 @@ int FileOMPlugin::loadPolyMeshObject(QString _filename){
//-----------------------------------------------------------------------------------------------------
template <class MeshT>
void FileOMPlugin::backupTextureCoordinates(MeshT& _mesh) {
// Create a backup of the original per Vertex texture Coordinates
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 (typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it)
_mesh.property(oldVertexCoords, v_it) = _mesh.texcoord2D(v_it);
}
// Create a backup of the original per Face texture Coordinates
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 (typename MeshT::HalfedgeIter he_it = _mesh.halfedges_begin(); he_it != _mesh.halfedges_end(); ++he_it)
_mesh.property(oldHalfedgeCoords, he_it) = _mesh.texcoord2D(he_it);
}
}
//-----------------------------------------------------------------------------------------------------
bool FileOMPlugin::saveObject(int _id, QString _filename)
{
BaseObjectData* object;
......
......@@ -124,6 +124,12 @@ class FileOMPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter
QString version() { return QString("1.0"); };
private :
/// creates a backup of the original per vertex/face texture coordinates
template <class MeshT>
void backupTextureCoordinates(MeshT& _mesh);
private :
//Option Widgets
......
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