
Basically simple objects that came out of Wings with one single color material applied overall (okay, I cheated, I made a second material for the outlines on the crib section there - I bevelled all the edges a tiny bit and gave the bevel an "outline" material. Which by the way works really well with geometric objects in Moho). Run the script, tell it the point from which the light is coming from, the number of shades of each material, how subtle or harsh you want it to be, if you want the brightness punched up at the top for a highlight, and there you go.
It makes a "baked" copy of the layer that's selected. One of the cool things about that is that all the information about that 3D doojigger is now stored safely inside the .moho file. Don't have to worry where the .OBJ file went to.
There are 6 parameters you can set. The X, Y, and Z coordinates of the "light source". The number of shading levels, meaning if you have 20 shading levels then something directly facing the "light" will use shade 1, directly away shade 20. You can set the interval between the shades - a % value, each shade is X% darker than the last. And there's an "Added Brightness" parameter that lets you set how much you would like to add to the original material's brightness for the first shade.
A few tips.
-- Right now, the light direction relates only to where the imported object was from right when you imported it. It takes no account of things if you translated or rotated it around. I really, really tried to make it take the layers translations and rotations into account, but wierd things happend. I'll get it.
-- If you set the light point to 0,0,0, you don't get nothin'. so don't try and get funny. Also, you don't get shadows. Don't even ask.
-- After you run the script, you won't see much interesting until you hide the original 3D layer (if you hadn't move the original around, that is). They're right on top of each other, and that mucks up the works.
-- If you do something like apply it to a 10,000 polygon shape with 50 materials set for 150 shading levels, you are certainly going to get one bloated object, it may take a million years, and I make no guaratees whatsover that it won't make Moho die. That's all on you. Use some restraint.
-- I don't take textures into account at all. Haven't tried it with them, don't know what it'll do. But likely as not, since I don't copy the texture points, the texture will just vaporize.
--if you rerun the script on a copy you have already shaded, you will, each time, create and exponentially expanding set of probably useless materials. If you aren't happy with what you got, it's better to delete the shaded (copy) layer and start again. Believe me - while I was debugging I ended up with one of the cubes made from the "Cube" menu script with thousands and thousands of materials, and it wasn't pretty.
--if an object has no materials (like what you'll get from the "Torus" menu script) the script gives you a warning and exits. I'll probably set something up so you can apply some sort of default material if you want.
I must have crashed Moho 3 or 4 hundred times while I was writing this. Like one every minute or so for hours. Guess I'm one determined bonehead. Never tried to write any 3D stuff before. Anyone who want's to pick apart the code or suggest improvements, I'm all ears. Without furthur ado -
UPDATED - bugfix 6:40am GMT 4/21/2005
-- fixed a little bug where the base shade wasn't adjusted if you changed the brightness. Also put all of the stats in an info window instead of the Lua console.
-- just the SOS script, the Library is the same.
UPDATED - wierd Lua bug 5:00pm GMT 6/14/2005 v1.02
-- Lua let's you divide zero by zero, giving nonsense in some cases. All tuned up.
Simple OBJect Shading
put that somewhere in your Moho>Scripts>Menu directory
My handy dandy library
This needs to go in the Moho>Scripts>Utilities directory.
Next, I think I actually have a proper automated lipsync solution. Only for Windows, but as the auto phoneme detection part from an old Win95 program (freely available), it should work on any old kinda Win emulation.
bwWAAAHAhahahah...