Topic was automatically imported from the old Question2Answer platform.
Asked By
Alexandre Courbot
Old Version
Published before Godot 3 was released.
Hi,
So, I would like to be able to easily create and render a dot and wireframe version of an imported model in godot. My current idea is to create a MeshInstance with a script that parses the vertices/indices of the initial model, and creates a new one with add_surface(Mesh.PRIMITIVE_LINE_STRIP) or Mesh.PRIMITIVE_LINE_POINTS.
But as far as I know, there is no way to access the geometry or a model from GDscript… or have I missed something?
I’m also open to any other way of rendering the model that way - I have played with shaders to make a wireframe representation, but it is just not as straightforward as it should be (GL can render points and lines and I would like to take advantage of that).
Looking at the documentation, the MeshDataTool class looks like a promising start to this.
Again, reading only from the documentation, since I don’t have much time for testing right now, the proper way to initialize one should be:
var mesh = ...
var mdt = MeshDataTool.new()
mdt.create_from_surface(mesh, 0) # 0 is the surface index
# do stuff with mesh data tool...
# Optionally, if you just want to change vertexes, etc.:
mdt.commit_to_surface(another_mesh) # creates a new surface on the target mesh
BTW, you might like using SurfaceTool for generating the lines and points, and using MeshDataTool only for reading the vertex locations.
Good luck
Thanks a lot for this perfect answer. This is exactly what I needed (and more - SurfaceTool!).
I’m still new to Godot and somehow failed to find this in the documentation, but fortunately the community backing it is also awesome!
Alexandre Courbot | 2016-06-27 13:48
Thank you! This is exactly what I was looking for.