Closed bdice closed 3 years ago
Built-in mesh test scene
This defines shape_colors
but only uses the first shape color for all replicas in the primitive. This means that the left cell is colored according to its shape color but the right cell is not (it uses the left cell's shape color). A warning shows:
plato/plato/draw/fresnel/Mesh.py:30: UserWarning: Multiple shape colors were provided, but only the first provided shape color will be used for all mesh replicas in the primitive.
Low-poly Stanford Bunny 3D model From https://www.thingiverse.com/thing:151081 by user johnny6, licensed CC BY-NC 4.0 This shows nonzero outline width and vertex colors.
This looks great; thanks! I think the way you've implemented the per-shape color warning works fine. I'll probably merge these tomorrow.
On the topic of adding outlines to Mesh
objects, do you know of anyone using them? If needed, we could probably add them without too much difficulty in other backends.
@klarh Thanks! Glad you like it. 😄
I defer to your expertise on adding outlines to other backends - I have been only adding features as needed. I guess it would not be much harder than for ConvexPolyhedra but I don’t have interest in writing the vispy shaders. If you (or someone else) is interested, I could help with pythreejs if you wanted to add support in vispy. I’d be fine with either of us tackling povray if that’s the route we choose to take.
Trying to close/open to trigger ReadTheDocs to run on this pull request.
Not sure. ReadTheDocs is running but I don't see how to make the check appear with the built docs link. I'll ignore this for now, hopefully it will work on future PRs.
Summary
This PR adds
Mesh
support to thefresnel
backend. It converts the input arrays of vertices and indices into a(3T, 3)
array of triangle vertices, whereT
is the number of triangles.I also refactored fresnel's default material support so that every primitive gets a newly-constructed Material instance, rather than sharing a module-level constant. I removed the module constants
plato.draw.fresnel.FresnelPrimitive.DEFAULT_MATERIAL
andplato.draw.fresnel.FresnelPrimitive.SOLID_MATERIAL
which is technically an API break, but I don't think any external code would have relied on these default materials.References:
Caveats
It does not fully support the
shape_colors
attribute. The cases that are handled correctly are:shape_color_fraction
is 0In the case where multiple distinct shape colors are provided and
shape_color_fraction > 0
, only the first shape color is used.