Closed rdeits closed 8 years ago
@@ master #18 diff @@
==========================================
Files 6 6
Lines 273 275 +2
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 262 265 +3
+ Misses 11 10 -1
Partials 0 0
Powered by Codecov. Last updated by fe6878b...45b88fa
Great! Do you happen to have a simple model flying around to add to the tests?
Sure, will do!
OK, I added a very simple OBJ mesh with a 6-vertex face and a test to verify triangulation.
If you'd like, I can also add one of the actual meshes I've been working with (I'm playing around with the model of the NASA Valkyrie robot: https://github.com/rdeits/RigidBodyTreeInspector.jl/pull/3#issuecomment-222233185 ), but this seemed like a nice minimal way to test the change.
By the way, I also have a pretty slick way of visualizing meshes from Julia now, in case you're interested. I'm part of a robotics group at MIT, and we've got a nice visualizer for 3D geometries as part of our lab's free toolbox: http://drake.mit.edu/ and https://github.com/RobotLocomotion/director/
I've put together some Julia bindings for that package, which currently live here: https://github.com/rdeits/DrakeVisualizer.jl . Currently, that package only works if you've already installed Drake (which is free and supported on all platforms), but I'm hoping to give it the ability to build its own copy of the visualizer using BinDeps soon.
Anyway, with those pieces in place, visualizing a mesh is as easy as:
julia> using FileIO
julia> using MeshIO
julia> mesh = load(joinpath("test/testfiles/test.obj"))
HomogenousMesh(
normals: 2248xGeometryTypes.Normal{3,Float32}, vertices: 2248xFixedSizeArrays.Point{3,Float32}, faces: 3954xGeometryTypes.Face{3,UInt32,-1}, )
julia> using DrakeVisualizer
julia> vis = Visualizer(mesh)
which causes the viewer to display:
and it's easy to adjust the display properties within the viewer:
Anyway, if you're interested I'm happy to help make this more user-friendly.
Did I forgot to merge this? This should be good to go, right?
Yup, should be good to go 😄
thanks!
.obj
files can contain faces with an arbitrary number of vertices. This patch changes theobj
loader to triangulate any polygonal faces when loading the mesh.Note that this calls
decompose()
even when it's not strictly necessary (when the face is already a triangle). But the@generated
decompose
method for such a case compiles down to just a single call to the constructor of the newFace
type, so there shouldn't be any additional cost for doing so.