From 0c4e210bba9990d5ef0fec86ecd04ed344899f2b Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Fri, 19 Nov 2021 16:03:05 +0100 Subject: [PATCH] added PLY import support for vertex texture coordinates as double --- wrap/io_trimesh/import_ply.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/wrap/io_trimesh/import_ply.h b/wrap/io_trimesh/import_ply.h index ab6bda9c..2da70ab4 100644 --- a/wrap/io_trimesh/import_ply.h +++ b/wrap/io_trimesh/import_ply.h @@ -63,6 +63,7 @@ public: typedef typename VertexType::QualityType VertQualityType; typedef typename OpenMeshType::FaceType FaceType; typedef typename FaceType::QualityType FaceQualityType; + typedef typename VertexType::TexCoordType::ScalarType TexScalarType; typedef typename OpenMeshType::VertexIterator VertexIterator; typedef typename OpenMeshType::FaceIterator FaceIterator; @@ -159,7 +160,7 @@ public: float k4; }; -#define _VERTDESC_LAST_ 32 +#define _VERTDESC_LAST_ 34 static const PropDescriptor &VertDesc(int i) { static const PropDescriptor pv[_VERTDESC_LAST_]={ @@ -189,14 +190,16 @@ public: /*22*/ {"vertex", "s", ply::T_FLOAT, ply::T_FLOAT, offsetof(LoadPly_VertAux,u),0,0,0,0,0 ,0}, /*23*/ {"vertex", "t", ply::T_FLOAT, ply::T_FLOAT, offsetof(LoadPly_VertAux,v),0,0,0,0,0 ,0}, // DOUBLE - /*24*/ {"vertex", "x", ply::T_DOUBLE, PlyType(),offsetof(LoadPly_VertAux,p),0,0,0,0,0 ,0}, - /*25*/ {"vertex", "y", ply::T_DOUBLE, PlyType(),offsetof(LoadPly_VertAux,p) + sizeof(ScalarType) ,0,0,0,0,0 ,0}, - /*26*/ {"vertex", "z", ply::T_DOUBLE, PlyType(),offsetof(LoadPly_VertAux,p) + 2*sizeof(ScalarType),0,0,0,0,0 ,0}, - /*27*/ {"vertex", "nx", ply::T_DOUBLE, PlyType(),offsetof(LoadPly_VertAux,n) ,0,0,0,0,0 ,0}, - /*28*/ {"vertex", "ny", ply::T_DOUBLE, PlyType(),offsetof(LoadPly_VertAux,n) + 1*sizeof(ScalarType),0,0,0,0,0 ,0}, - /*29*/ {"vertex", "nz", ply::T_DOUBLE, PlyType(),offsetof(LoadPly_VertAux,n) + 2*sizeof(ScalarType),0,0,0,0,0 ,0}, - /*30*/ {"vertex", "radius", ply::T_DOUBLE, PlyType(),offsetof(LoadPly_VertAux,radius),0,0,0,0,0 ,0}, - /*31*/ {"vertex", "quality", ply::T_DOUBLE, PlyType(),offsetof(LoadPly_VertAux,q),0,0,0,0,0 ,0} + /*24*/ {"vertex", "x", ply::T_DOUBLE, PlyType(), offsetof(LoadPly_VertAux,p),0,0,0,0,0 ,0}, + /*25*/ {"vertex", "y", ply::T_DOUBLE, PlyType(), offsetof(LoadPly_VertAux,p) + sizeof(ScalarType) ,0,0,0,0,0 ,0}, + /*26*/ {"vertex", "z", ply::T_DOUBLE, PlyType(), offsetof(LoadPly_VertAux,p) + 2*sizeof(ScalarType),0,0,0,0,0 ,0}, + /*27*/ {"vertex", "nx", ply::T_DOUBLE, PlyType(), offsetof(LoadPly_VertAux,n) ,0,0,0,0,0 ,0}, + /*28*/ {"vertex", "ny", ply::T_DOUBLE, PlyType(), offsetof(LoadPly_VertAux,n) + 1*sizeof(ScalarType),0,0,0,0,0 ,0}, + /*29*/ {"vertex", "nz", ply::T_DOUBLE, PlyType(), offsetof(LoadPly_VertAux,n) + 2*sizeof(ScalarType),0,0,0,0,0 ,0}, + /*30*/ {"vertex", "radius", ply::T_DOUBLE, PlyType(), offsetof(LoadPly_VertAux,radius),0,0,0,0,0 ,0}, + /*31*/ {"vertex", "quality", ply::T_DOUBLE, PlyType(), offsetof(LoadPly_VertAux,q),0,0,0,0,0 ,0}, + /*32*/ {"vertex", "texture_u", ply::T_DOUBLE, PlyType(), offsetof(LoadPly_VertAux,u),0,0,0,0,0 ,0}, + /*33*/ {"vertex", "texture_v", ply::T_DOUBLE, PlyType(), offsetof(LoadPly_VertAux,v),0,0,0,0,0 ,0}, }; return pv[i]; } @@ -514,6 +517,10 @@ public: { pi.mask |= Mask::IOM_VERTTEXCOORD; } + if(( pf.AddToRead(VertDesc(32))!=-1 )&& (pf.AddToRead(VertDesc(33))!=-1)) + { + pi.mask |= Mask::IOM_VERTTEXCOORD; + } } if(tri::HasPerVertexRadius(m)) { @@ -1198,6 +1205,9 @@ public: if( pf.AddToRead(VertDesc(18))!=-1 && pf.AddToRead(VertDesc(19))!=-1) mask |= Mask::IOM_VERTTEXCOORD; + if( pf.AddToRead(VertDesc(32))!=-1 && + pf.AddToRead(VertDesc(33))!=-1) mask |= Mask::IOM_VERTTEXCOORD; + if( pf.AddToRead(FaceDesc(0))!=-1 ) mask |= Mask::IOM_FACEINDEX; if( pf.AddToRead(FaceDesc(1))!=-1 ) mask |= Mask::IOM_FACEFLAGS; if( pf.AddToRead(FaceDesc(10))!=-1 &&