UltiMaker uses functional, analytical and tracking cookies. Tracking cookies enhance your experience on our website and may also collect your personal data outside of Ultimaker websites. If you agree with the use of tracking cookies, click “I agree, continue browsing”. You can withdraw your consent at any time. If you do not consent with the use of tracking cookies, click “Refuse”. You can find more information about cookies on our Privacy and Cookie Policy page.
Support for rendering color gradients on mesh and/or slice preview
Posted
(edited)
· Support for rendering color gradients on mesh and/or slice preview
Hey, late reply but good news. What you want to do is exactly how Cura works behind the scenes. When adding a triangle (or quad, or line...), Cura uses setVertexColor() on each of its 3 vertices, but uses the same color so there's no gradient.
What you can do is first create your mesh with your primitives, and afterwards go vertex by vertex changing the color.
For example, I tested it on this cube I built for a project of mine. It's made up of 10x10x10 quads. Mind you, quads are actually just a pair of triangles:
Then I used this code to randomize the color of every vertex:
def PrepareMeshBuilder(self):
...
[Here goes code to add primitives (tris, quads...), calculate normals, etc.]
...
import random
for vIndex,_ in enumerate(self.mb.getVertices()):
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
self.mb.setVertexColor(vIndex, Color(r, g, b, 255))
And got this:
Edit:
If I were you, I would override or create a custom addFace() method that took 3 colors instead of 1 and applied them directly. This way you could create your triangles and paint them at the same time.
In the Cura 5.8 stable release, everyone can now tune their Z seams to look better than ever. Method series users get access to new material profiles, and the base Method model now has a printer profile, meaning the whole Method series is now supported in Cura!
We are happy to announce the next evolution in the UltiMaker 3D printer lineup: the UltiMaker Factor 4 industrial-grade 3D printer, designed to take manufacturing to new levels of efficiency and reliability. Factor 4 is an end-to-end 3D printing solution for light industrial applications
Recommended Posts
Tyronnosaurus 7
Hey, late reply but good news. What you want to do is exactly how Cura works behind the scenes. When adding a triangle (or quad, or line...), Cura uses setVertexColor() on each of its 3 vertices, but uses the same color so there's no gradient.
What you can do is first create your mesh with your primitives, and afterwards go vertex by vertex changing the color.
For example, I tested it on this cube I built for a project of mine. It's made up of 10x10x10 quads. Mind you, quads are actually just a pair of triangles:
Then I used this code to randomize the color of every vertex:
And got this:
Edit:
If I were you, I would override or create a custom addFace() method that took 3 colors instead of 1 and applied them directly. This way you could create your triangles and paint them at the same time.
Link to post
Share on other sites
odd08 0
This is great! Thank you.
Link to post
Share on other sites