SOS - Simple OBJect Shading ***Updated***(again - 6/14/05)
Moderators: Víctor Paredes, Belgarath, slowtiger
What I was talking about is what I would assume is the bottom of the sub. I figured the larger pojection with the antenna or periscope or whatever was the conning tower.
And just to prove I could waste time in a ridiculous manner as well as the next guy, I wanted to see how far I could push things... all of these were with the brightness set at 0, the edge offset in the Layer Properties>3D Options set to 0 (turned off), and a 2 pixel, no offset-no blur black shadow on the layer.
I know it messes with the design, but I smoothed the model a few (3 I think) times, ending up with almost 50,000 faces. This was with the Shading Levels at 500, shading inc 0.2%.
Same model, but with the Shading Levels at 6 and the Increment at 15%. Woohoo, toon shading!
I went back to the original model, an triangulated it before I smoothed it. 3 triangulates, 2 smooths. almost the same number of faces but arranges quite differently. Again, 500 shades at 0.2%.
Same triangulated model, with 8 shades at 10%. The edges are a little random but it eliminates the obvious blockiness that you get in the models that are just smoothed.
And boy does a model that size cut down the programs responsiveness! I know part of the problem is I have to streamline how I'm doing things because I'm probably creating 3 times as many points as I should, I'll fix that. I also fixed the little bug with the base shading, I'll put the update at the top.
And just to prove I could waste time in a ridiculous manner as well as the next guy, I wanted to see how far I could push things... all of these were with the brightness set at 0, the edge offset in the Layer Properties>3D Options set to 0 (turned off), and a 2 pixel, no offset-no blur black shadow on the layer.
I know it messes with the design, but I smoothed the model a few (3 I think) times, ending up with almost 50,000 faces. This was with the Shading Levels at 500, shading inc 0.2%.
Same model, but with the Shading Levels at 6 and the Increment at 15%. Woohoo, toon shading!
I went back to the original model, an triangulated it before I smoothed it. 3 triangulates, 2 smooths. almost the same number of faces but arranges quite differently. Again, 500 shades at 0.2%.
Same triangulated model, with 8 shades at 10%. The edges are a little random but it eliminates the obvious blockiness that you get in the models that are just smoothed.
And boy does a model that size cut down the programs responsiveness! I know part of the problem is I have to streamline how I'm doing things because I'm probably creating 3 times as many points as I should, I'll fix that. I also fixed the little bug with the base shading, I'll put the update at the top.
- jakob polack
- Posts: 29
- Joined: Thu Mar 17, 2005 8:08 pm
- Location: copenhagen denmark
- Contact:
hi there - all this seems interesting....but..how do I get your lua script inside moho ?
jakobpcph
jakobpcph
hey look here its my private webspace:
http://uk.geocities.com/jakobpcph/
http://uk.geocities.com/jakobpcph/
In the first post of the topic, the 2 lines in red are links to the script files. Right click (or equivalent, depending on what OS your on) and save the files to your computer. You need to find your Moho installation directory. Inside that is another directory named "scripts", and inside that another 3, called "menu", "tool" and "utility". The Library script (sf_utilities.lua) should be placed in the "utility" folder. Inside the "menu" folder are all the subfolders where the scripts you can access from the "Scripts" menu in Moho live. You can put the sf_sos.lua file pretty much anywhere in the "menu" directory you want, but it kinda makes sense to put it in the "3D" folder. After you've done that, either start Moho, or if it is already open, press <CTRL><F5>. That reloads all of the scripts. Then you can access it from Scripts>3D>Simple OBJect Shading.
Have fun with it. It's kind of nifty if I do say so myself. And in general, you'll usually be told if something is a "menu" or "tool" script, and that tells you where they should go. The sf_utility.lua script is a bit of an exception, and it's basically there to keep me from having to type the same code over and over again. It also both makes the other scripts code more understandable (if you're into that sort of thing) and some handy functions available to other people who might want to whip up a script.
Have fun with it. It's kind of nifty if I do say so myself. And in general, you'll usually be told if something is a "menu" or "tool" script, and that tells you where they should go. The sf_utility.lua script is a bit of an exception, and it's basically there to keep me from having to type the same code over and over again. It also both makes the other scripts code more understandable (if you're into that sort of thing) and some handy functions available to other people who might want to whip up a script.
Jorgy - what I did was select all the edges (maybe points, I don't remember) of the old fin, and moved it away from the rest of the model. Deselect everything, and then select only the two endpoints. Connect them to make a face. Triangulate the face, because theres something else wierd going on there. Delete all these new faces. If I remember right, there are still 4 vertexes and 3 sides left, there must have been something overlapping. Again, select the endpoints, connect them, triangulate, and delete the whole mess. Then it should be gone for good. If you just try to delete that whole thing without the extra steps, the whole model goes away. Why? I haven't got a clue.
7ft,
I'm still having trouble with your script. I'm still getting errors:
invalid type in variable assignment
value is 'nil'; 'number' is expected
I've managed to narrow down my complicated examples to a rather simple box with bevelled top that still exhibits this behavior.
http://65.98.71.13/moho/broken.wings
http://65.98.71.13/moho/broken.obj
http://65.98.71.13/moho/broken.mtl
Any help would be appreciated.
Thanks!
jorgy
[/i]
I'm still having trouble with your script. I'm still getting errors:
invalid type in variable assignment
value is 'nil'; 'number' is expected
I've managed to narrow down my complicated examples to a rather simple box with bevelled top that still exhibits this behavior.
http://65.98.71.13/moho/broken.wings
http://65.98.71.13/moho/broken.obj
http://65.98.71.13/moho/broken.mtl
Any help would be appreciated.
Thanks!
jorgy
[/i]
It shouldn't, as that script doesn't do anything external, but I'll give it the once over. Is there a line number for the error? How far does it get? If need be, I'll whip some debugging code in there so we can see exactly where it's crapping out. I don't like things not workin' the way their supposed to.
I commented in some of your debugging statements, and it looks like:
http://putfile.com/pic.php?pic=6/16017165528.gif&s=x2
Unfortunately, it doesn't give a line number, but it is part way (on face 40 of 70) through.
http://putfile.com/pic.php?pic=6/16017165528.gif&s=x2
Unfortunately, it doesn't give a line number, but it is part way (on face 40 of 70) through.
This is just a first shot in the dark, but try using this lib:
http://www.sharemation.com/Moho/MenuScr ... sV1.05.zip
Maybe I did something dumb in there. I actually have a few minutes right now, so I'll give it the once over. I don't see a damn thing wrong with the initial file, and as I said it's working on my box.
This is a version that will print out the script line numbers as it runs through the offending loop. That should help to nail it down :
http://www.sharemation.com/Moho/MenuScr ... s_test.lua
Give that one a shot and tell me where it dies. I'm really clueless at this point. I hate that part...
http://www.sharemation.com/Moho/MenuScr ... sV1.05.zip
Maybe I did something dumb in there. I actually have a few minutes right now, so I'll give it the once over. I don't see a damn thing wrong with the initial file, and as I said it's working on my box.
This is a version that will print out the script line numbers as it runs through the offending loop. That should help to nail it down :
http://www.sharemation.com/Moho/MenuScr ... s_test.lua
Give that one a shot and tell me where it dies. I'm really clueless at this point. I hate that part...
I think I found the problem, and I think it's due to a bit of a bug in Lua itself. Not to get too crazy in the math, but under some circumstances (in particular where the script would crap out on you) the length of the normal of the face (FNLength)would end up being zero. Consequently, the dot product of the light vector and the faces normal would be zero. Gah. So the line:
ends up dividing zero by zero, and coming up with a number that lua showed as " -1.#IND ". Which doesn't look a whole lot like anything to me. Just for the hell of it I tried the math.abs function on it to try to make it positive, and got " -1.#QNAN ". So I think theres a bug in there. So...
In the test version, line #274 reads:
Wasn't sure if I had to normalize it at the time. What I seem to have gotten working is changing that line to:
It at least gets rid of the meaningless "number", and I think that screwy angle was what was mucking up the indexing of the material ID's. Windows seemed to just see it as a zero anyway, maybe in Linux it was properly interpreting it as complete shite and looked at it as nil. That's my guess. Try that fix out, and if it works, I'll put up a proper update. If not, I'll find it eventually.
Also, around line#250 in the test version there is this block:
That whole bit should probably be commented out. It might be mucking up the indexing to the shades. Anyway, there's no good reason to just copy over all the original materials when they might not even be used in the shaded version of the OBJ.
Hopefully some of this will help. If not, I'll figure it out eventually.
Code: Select all
angle = dot / (LVLength * FNLength)
In the test version, line #274 reads:
Code: Select all
faceNormal = faceNormal--:Norm()
Code: Select all
faceNormal:NormMe()
Also, around line#250 in the test version there is this block:
Code: Select all
----------------------------------------------
-- Copy all original materials to the new mesh
----------------------------------------------
for i = 0, (mesh:CountMaterials() - 1) do
local newMaterial = newMesh:CreateNewMaterial()
local oldMat = mesh:Material(i)
newMaterial.color = oldMat.color
end
Hopefully some of this will help. If not, I'll figure it out eventually.