I think applying a custom shader is the best option. Adding lines might work too, but you will end up with LOTs of them for larger organic meshes. You could look at how grid.shader draws lines.
-
1
I think applying a custom shader is the best option. Adding lines might work too, but you will end up with LOTs of them for larger organic meshes. You could look at how grid.shader draws lines.
[Hey ahoeben, I was just writing a solution I've found, which uses addLine(). Since I've got it almost written I'll just leave it here for anyone curious, but I'll try using a shader as you say]
I've discovered that I can simply create a second mesh inside a single SceneNode, and then render each mesh separately. I discovered this by looking into Cura's BuildVolume class. More or less my code is this:
1) Create a _grid_mesh and build the wireframe with AddLine()
2) Override the SceneNode.render() method:
def render(self, renderer): if (self.isVisible()): #To draw the colored faces -> The most simple rendering renderer.queueNode(self) #To draw the edges -> A Lines AKA wireframe rendering renderer.queueNode(self, mesh=self._grid_mesh, mode=RenderBatch.RenderMode.Lines) return True
3) Make sure the active view runs this render()
I still can't control the lines' color though (always white).
Recommended Posts
ahoeben 1,852
The mesh needs to have normals.
Link to post
Share on other sites
Tyronnosaurus 7
Thanks, ahoeben. It works now with this change:
Added screenshot
Link to post
Share on other sites
Tyronnosaurus 7
One additional related question if you don't mind: how would you approach drawing the edges (black lines delimiting each square) like in my first screenshot?
1) With addLine(): I've tried but for some reason the resulting mesh is not drawn correctly when combining addQuad & addLine.
2) Option 1 but putting the lines in a child sceneNode's mesh
3) Some shader or rendering option, if it exists
4) Implementing a custom shader, akin to how the Platform is a single quad but draws a 1x1cm mesh
5) Something else
Link to post
Share on other sites