Read normals and textures from OBJ, do not duplicate vertices.

PiperOrigin-RevId: 510461549
Change-Id: I19245d691e722a8371e61153383f275f599353d6
This commit is contained in:
Alessio Quaglino
2023-02-17 10:14:25 -08:00
committed by Copybara-Service
parent 35967a30d9
commit 9756ed0d80
16 changed files with 279 additions and 168 deletions
+11 -5
View File
@@ -542,7 +542,8 @@ struct mjModel_ {
int nlight; // number of lights
int nmesh; // number of meshes
int nmeshvert; // number of vertices in all meshes
int nmeshtexvert; // number of vertices with texcoords in all meshes
int nmeshnormal; // number of normals in all meshes
int nmeshtexcoord; // number of texcoords in all meshes
int nmeshface; // number of triangular faces in all meshes
int nmeshgraph; // number of ints in mesh auxiliary data
int nskin; // number of skins
@@ -738,14 +739,19 @@ struct mjModel_ {
// meshes
int* mesh_vertadr; // first vertex address (nmesh x 1)
int* mesh_vertnum; // number of vertices (nmesh x 1)
int* mesh_texcoordadr; // texcoord data address; -1: no texcoord (nmesh x 1)
int* mesh_faceadr; // first face address (nmesh x 1)
int* mesh_facenum; // number of faces (nmesh x 1)
int* mesh_normaladr; // first normal address (nmesh x 1)
int* mesh_normalnum; // number of normals (nmesh x 1)
int* mesh_texcoordadr; // texcoord data address; -1: no texcoord (nmesh x 1)
int* mesh_texcoordnum; // number of texcoord (nmesh x 1)
int* mesh_graphadr; // graph data address; -1: no graph (nmesh x 1)
float* mesh_vert; // vertex positions for all meshes (nmeshvert x 3)
float* mesh_normal; // vertex normals for all meshes (nmeshvert x 3)
float* mesh_texcoord; // vertex texcoords for all meshes (nmeshtexvert x 2)
int* mesh_face; // triangle face data (nmeshface x 3)
float* mesh_normal; // normals for all meshes (nmeshnormal x 3)
float* mesh_texcoord; // vertex texcoords for all meshes (nmeshtexcoord x 2)
int* mesh_face; // vertex face data (nmeshface x 3)
int* mesh_facenormal; // normal face data (nmeshface x 3)
int* mesh_facetexcoord; // texture face data (nmeshface x 3)
int* mesh_graph; // convex graph data (nmeshgraph x 1)
// skins
+9 -3
View File
@@ -74,7 +74,8 @@
X( nlight ) \
X( nmesh ) \
X( nmeshvert ) \
X( nmeshtexvert ) \
X( nmeshnormal ) \
X( nmeshtexcoord ) \
X( nmeshface ) \
X( nmeshgraph ) \
X( nskin ) \
@@ -263,14 +264,19 @@
X( float, light_specular, nlight, 3 ) \
X( int, mesh_vertadr, nmesh, 1 ) \
X( int, mesh_vertnum, nmesh, 1 ) \
X( int, mesh_normaladr, nmesh, 1 ) \
X( int, mesh_normalnum, nmesh, 1 ) \
X( int, mesh_texcoordadr, nmesh, 1 ) \
X( int, mesh_texcoordnum, nmesh, 1 ) \
X( int, mesh_faceadr, nmesh, 1 ) \
X( int, mesh_facenum, nmesh, 1 ) \
X( int, mesh_graphadr, nmesh, 1 ) \
X( float, mesh_vert, nmeshvert, 3 ) \
X( float, mesh_normal, nmeshvert, 3 ) \
X( float, mesh_texcoord, nmeshtexvert, 2 ) \
X( float, mesh_normal, nmeshnormal, 3 ) \
X( float, mesh_texcoord, nmeshtexcoord, 2 ) \
X( int, mesh_face, nmeshface, 3 ) \
X( int, mesh_facenormal, nmeshface, 3 ) \
X( int, mesh_facetexcoord, nmeshface, 3 ) \
X( int, mesh_graph, nmeshgraph, 1 ) \
X( int, skin_matid, nskin, 1 ) \
X( int, skin_group, nskin, 1 ) \