Some of you may not have seen, but I have made a real time 3D model viewer using 3D projection algorithms, the thing is, it only draws in wireframe, and I was wondering if anyone knew of how I could implement face shading (with a lightsource). I have seen many things on the internet, but they always stump me on some of the variables, and do not give enough explaination for me to understand.
I'm sure some people on the scratch forums understand this, or understand maths better than me to work out what to do (which is implement face shading into my project).
Here is a link to a page that (I think) says what to do: http://www.exaflop.org/docs/waynelight/index.html
Here is my projection: http://scratch.mit.edu/projects/rookwood101/2038517 (read description for instructions).
Thanks in advanced,
Rook
Offline
Sure it's possible.
Congrats for taking on these hard problems!
It would have been nice if you credited my work. (It looks like you based it mostly on mine, except you did add 3 axis rotation, cool, (I did just 2 for speed.)
First you'll need to redo my blender exporting tutorial to export the 3d model as 3 sided "polygons" and "vertices" instead of "lines" and "vertices".
(Why did you rename it to links and coordinates?)
So, convert the 3d model to all tris- 3 sided polygons first though.
so instead of a lines (links?) list, call it polygons and store three references to vertices...
And for each time you draw you will also need to sort these polygons in order from distance to the camera. (but face sorting is slow which is why I did line rendering. lines can be drawn in any order and still look right. See my newer one that is faster and renders them in a random order so you see the shape quicker.)
Get that far and I'll help more. Let me know if I need to reword that better.
But smooth shading it would be very slow, figuing out vertex normals... and each pixel would have to be drawn...
I would do flat shading first, which can be fast. (Tip: It is possible to draw shaded triangles in three stamps.)
Nice work, looking forward to more!
Offline
Ah you see, that's where you're wrong, I did not base it off yours, it may be pretty much the same code, but it was all written from scratch, using This Tutorial and working out the other bits myself. Although I must say I was inspired by you, so I'll put that in there
And yes, I can export it with faces, and I plan on doing flat shading, I (think) that's what lambert shading is, right? And I think smooth shading is called phong shading, but correct me if I'm wrong. - Actually, I just had a look and lambert shading is smooth, I do mean flat shading
Anyway thanks for the help,
Rook
Offline
Have you noticed that your random line drawing method misses out a couple of lines? Well it does for me at least http://scratch.mit.edu/projects/rookwood101/2042026(One of the back lines of the road). Is there any way to fix it? Other than that, it works very well.
Offline
I'm not sure what you mean... Check my "Beta Lighting Effect" I think that would help...
Offline