There are a few different ways you could do this. Basically, the issue is that the model that is loaded carries the info about what kind of model it is (triangles, not lines), and the ModelBatch looks at that info to decide how to draw it.
The most straight-forward way to do it would be to export the model in a format that specifies that it's lines, and then convert it to libgdx's native format (G3D) using fbx-conv
. I don't think it's possible to specify .obj
files as lines, so you would need something like FBX or maybe Collada.
Here's the simplest way I can think of getting quick and dirty results without fooling with the model file:
Subclass ModelInstance
and override the following method like this:
public Renderable getRenderable(final Renderable out, final Node node,
final NodePart nodePart) {
super.getRenderable(out, node, nodePart);
out.primitiveType = GL20.GL_LINE_STRIP;
return out;
}
Then use this subclass instead of ModelInstance. This will tell the ModelBatch that the mesh is a line strip mesh to make it draw lines. The downside is that it will connect all the vertices in the order they are presented in the file, so you will have some unexpected extra lines that jump across the model in some places. You could use GL_LINES
instead, but then you'll have a bunch of missing line segments.