A couple of weeks ago I was asked by someone if I knew of a way to get the inside face of a hollowed cube to texture exactly. As in, how to work out the repeat so the texture appears to be one per "face" (okay, there's only one inside face, but when it's square it looks like there's four, or three for a triangle, etc...).
By coincidence I'd been faced with the exact same problem just a day earlier with a build that I was working on (and should be released in the next day or so) and after a bit of searching had found a blog post with some useful pointers.
Given that scripting is my thing, I thought I'd turn that information into a simple script that helps out. It's not terribly clever, and it assumes that you want an effective repeat of 4 for a square hollow, 3 for a triangle hollow and 1 for a circle. It also, for now at least, only bothers working on cubes (although there's little reason why it can't work with other types -- it's just I normally only want to do this with cubes and it makes the default hollow shape decision easier to do).
Here it is: you just drop it in the cube you want to texture, hollow it, throw the texture on the inside face and you should be good to go (so delete the script again). If you change the hollow size it'll recalculate on the fly.
Hi Antony.
ReplyDeleteThank you very much for writing this script; it certainly saves performing those calculations by hand. However, I must point out one thing regarding the horizontal offset equation. There are cases where it ends up giving you an offset that's above 1.
Let's take this simple example: We have a box, 40% hollow, and we want two texture repeats in the hollow part of it.
According to the texture repeats equation I found in the JIRA, we need to enter 5 repeats. As for the offsets...
The math is:
Horizontal Offset = [ ( Desired Horizontal Repeats / Hollow ) - Desired Horizontal Repeats ] / 2
So, it's:
Horizontal Offset = [(2/0.4) - 2]/2 = 1.5
This can be confusing and even off-putting to many builders. I figured out that 1.5 should be interpreted as 0.5. However, there's very little in the way of explanations in the documentation of the build tools w.r.t. texturing the hollowed-out part of a prim. Quite frankly, I happened upon that JIRA by sheer luck - I asked a question in one of Nyx Linden's meetings and someone had seen that JIRA and pointed me to it.
What happens, though, when the prim in question is a cylinder? A ring? A torus? A sphere? A tube? I've yet to see any information that would help builders. That particular section of the official Second Life wiki could certainly use a lot of love, as the information in it dates back to the days of version 1.23 of the viewer.
I'd really love to see documentation that would cover these other prim types as well - and, of course, this would enable you to write scripts for them as well.
Once again, thanks for putting this script together.
Yeah, I ran into the offset thing while writing it, hence I set it to this:
Delete-( nOffset - (integer) nOffset )
Ignoring the non-fractional part seems to work in every case I tried. (the negation is to get the texture flip, of course).
Now, if only we had the math for texturing hollowed spheres, cylinders, rings, toruses and tubes...
DeleteI did try it briefly with a cylinder and another shape that I can't recall now and it appeared to work okay (these were shapes where the hollow was really no different than if you'd hollowed a cube).
DeleteI should probably tweak the script some more so that it works okay with other shapes.
If you fancy trying it just comment out the test for "PRIM_TYPE_BOX".
That'd be great, Antony. Thank you.
DeleteHaving a bit more of a play now. Here's a funny thing. I've been dabbling with building in SL since 2006, and have been avidly building since early 2010. And only tonight have I realised that the prism you can rez from the build floater (at least in Firestorm, I've not used the Lab viewer in such a long time) isn't PRIM_TYPE_PRISM.
DeleteI forgot to mention: those calculations don't appear to work for PRIM_TYPE_PRISM.
DeletePRIM_TYPE_SPHERE doesn't look so good either. My guess at this point is that it's only really good, as quoted in the JIRA, for box and cylinder.
DeleteI'll poke Nyx again for the math to calculate repeats in spheres and prisms. Official documentation here is very scarce, and I'm putting it very mildly.
DeleteI'd be interested to hear what you find out.
DeleteI've updated the script so that it at least does something cylinders as well as cubes now.
I'll have to try next week. Let's hope Nyx will have the information by then.
Delete