ratcave / wavefront_reader

A basic Wavefront .obj and .mtl reader module for Python
MIT License
12 stars 10 forks source link

Loses the information whether the faces are triads or quads #4

Open bvraghav opened 6 years ago

bvraghav commented 6 years ago

Description

I was trying to read a cube exported as obj from blender. Which exports quads. But the obj reader does not retain the information whether it is quad or triads...

What I Did

import wavefront_reader
mesh = read_wavefront('/path/to/cube.obj')
print(mesh)
  'usemtl': 'Material',
  's': 'off',                                                                                                                                      
  'v': array([[ 1.      , -1.      , -1.      ],                                                                                                   
         [ 1.      , -1.      ,  1.      ],
         [-1.      , -1.      ,  1.      ],
         [-1.      , -1.      , -1.      ],
         [ 1.      ,  1.      , -0.999999],
         [-1.      ,  1.      , -1.      ],
         [-1.      ,  1.      ,  1.      ],
         [ 0.999999,  1.      ,  1.000001],                                                                                                        
         [ 1.      , -1.      , -1.      ],                                                                                                        
         [ 1.      ,  1.      , -0.999999],
         [ 0.999999,  1.      ,  1.000001],
         [ 1.      , -1.      ,  1.      ],
         [ 1.      , -1.      ,  1.      ],
         [ 0.999999,  1.      ,  1.000001],
         [-1.      ,  1.      ,  1.      ],
         [-1.      , -1.      ,  1.      ],
         [-1.      , -1.      ,  1.      ],
         [-1.      ,  1.      ,  1.      ],
         [-1.      ,  1.      , -1.      ],
         [-1.      , -1.      , -1.      ],
         [ 1.      ,  1.      , -0.999999],
         [ 1.      , -1.      , -1.      ],
         [-1.      , -1.      , -1.      ],
         [-1.      ,  1.      , -1.      ]]),
  'vt': (),
  'vn': array([[ 0., -1.,  0.], 
         [ 0., -1.,  0.],
         [ 0., -1.,  0.],            
         [ 0., -1.,  0.],
         [ 0.,  1.,  0.],
         [ 0.,  1.,  0.],
         [ 0.,  1.,  0.],
         [ 0.,  1.,  0.],
         [ 1.,  0.,  0.],
         [ 1.,  0.,  0.],
         [ 1.,  0.,  0.],
         [ 1.,  0.,  0.],
         [-0., -0.,  1.],
         [-0., -0.,  1.],
         [-0., -0.,  1.],
         [-0., -0.,  1.],
         [-1., -0., -0.],
         [-1., -0., -0.],
         [-1., -0., -0.],
         [-1., -0., -0.],
         [ 0.,  0., -1.],
         [ 0.,  0., -1.],
         [ 0.,  0., -1.],
         [ 0.,  0., -1.]]),
  'material': {'Ns': 96.078431,
   'Ka': (1.0, 1.0, 1.0),
   'Kd': (0.64, 0.64, 0.64),
   'Ks': (0.5, 0.5, 0.5),
   'Ke': (0.0, 0.0, 0.0),
   'Ni': 1.0,
   'd': 1.0,
   'illum': 2}}}

This object loses the vital information whether the geometry is to be rendered as quad or triad.