Open jonathanhogg opened 7 months ago
Note that I've specified radius
here such that it is divided by size
to get the actual model radii, with the model standardised at unit size and then scaled – which is what happens with every other mesh model. I feel that specifying the standardised radii would be really confusing for the user, e.g.:
!rbox size=100;100;50 radius=0.1;0.1;0
This would intuitively look like a tiny corner radius instead of the 10 unit radius it actually works out to be once the model is scaled, and even harder to make sense of if the side lengths don't match but a single radius is desired around the edges/corners.
Scaling the underlying models means that they can be more easily shared, since:
!rbox size=100
!rbox size=1000
can both use the same underlying model – though, arguably, this is rarely going to happen.
It also occurs to me now that:
@rbox size=2;1;1 radius=0.5
is a capsule!
Here's a functional implementation of what I mean:
A rounded box primitive would also generalise
!box
,!cylinder
and!sphere
in that:@rbox radius=0
is a!box
@rbox size=2;2;1 radius=1;1;0
is a!cylinder
@rbox size=2 radius=1
is a!sphere
The difference would come down to how the texture UV coordinates work.
Ideally an
!rbox
would use a box model of UV coordinates and carefully wrap each side 1/4th around the cylinders at the edges and over 1/8th "corners" of the spheres. This ought to take into account the relative area of the flat side vs the curved parts so that the texture isn't weirdly stretched or compressed. To keep the mapping correct, there would need to be seams around each of the 6 "faces" of the!rbox
. I guess this also then means thatsegments
must be a multiple of 8.