PDA

View Full Version : Here is some abandoned code that might help others.



kryton9
12-07-2010, 05:49
I was working on some stuff and abandoned it. I thought I would put it up here to help others. I know this stuff, boggled my mind and getting this to work felt good and could help someone interested in this stuff.

There are 3 files, one was going to be a part of lessons on 3D programming. The one included in the 9th, calculating normals.

The next two are terrain files. It reads raw greyscale file and makes a terrain from it. The one that creates bogus normals( Normals are used for light calculations to get the lighting correct). What is funny, is the bogus normals are brighter and look better than the one with normals calculated( This is because there is only one light and it moves with the camera).

The third file is, well you guess it, terrain with normals. It takes the 3 vertices of the face and finds the average normal per face.

All the keyboard commands are in the window title bars. The mouse is not used. Escape in all three programs will exit the program.

In the terrain apps, using a combo or up arrow and left arrow will make you go straight. You will get the hang of it once you start out like that. Back arrow and right arrow will bring you straight back. A/Z raises and lowers the camera so you can adjust your height as you move around the terrain.

In the normal terrain example, additional keys to rotate the camera so you can see the lighting better as you move around. S/X rot the camera up and down. C/V rot that camera left and right.

If you use both hands, right on the arrows and the left on the other keys, it works out pretty well.

Petr Schreiber
12-07-2010, 07:35
Thanks for sharing Kent,

the dusty corners of hard drive sometimes hide nice examples :)

Just one note regarding visual quality - setting draw distance to 1 000 000 is quite a lot. As Z-buffer has constant precision, the larger you set the view distance, the more rough the depth sorting will become.

When you set the view distance to 1 000 and scale the model to 1/1000, you will get the same sized model, but with much better rendering quality.


Petr

kryton9
12-07-2010, 09:57
I know Petr, I always like to push that up high, I hate it when I move back and lose the model. This way only one number to change and I am set. I guess in final program I would adjust it perfectly. But for tests, I push it high.