[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
DenTut13-Pas
This trainer is on starfields, which is by request of more then one person. This is quite an easy effect, and you should have no trouble grasping the concept behind it. I will be doing a 3d starfield, a horizontal starfield is very easy with you merely incrementing a x-value for each star for each frame. I am not even going to bother doing code for that one (unless requested).
So I am off to go grab my antibiotics pills and I will be right back with the tutorial!
This is a 3d starfield. If you look closely, you will see that all the stars seem to originate from a point, the point you are travelling towards. This is an illusion which thankfully happens automatically, you don't have to code for it ;)
Starfields look very nice, and can make a big difference to an otherwise black background. It also makes a great screen saver
In easier language, we decrease the z value of all the the stars so that they come closer to you, and eventually whizz past.
This solves all our problems. Stars that are close to us on the x and y scales will pass us by faster then those that are very far from us on the x and y scales. The only thing we must watch out for is that no star is at 0,0 , ie. exactly in front of us, otherwise there will be a collision which will not look good.
Okay, now we start the actual viewing section. Here are the steps :
A starfield can make just about any routine look just that much more professional, and can itself be improved to be a great effect all on it's own.
Oh, well, the medicine has been taken, it is time for me to go. Hello to all those people who have sent me mail, and those great guys on #coders in IRC (you know who you are). Wow. That is the first greets I have ever done in a trainer. Hmm. Maybe I'm just ill
Happy coding people! - Denthor 19:28 24-7-94
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
DenTut13-Pas
ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸
³ W E L C O M E ³
³ To the VGA Trainer Program ³ ³
³ By ³ ³
³ DENTHOR of ASPHYXIA ³ ³ ³
ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ; ³ ³
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
--==[ PART 13 ]==--
- Introduction
This trainer is on starfields, which is by request of more then one person. This is quite an easy effect, and you should have no trouble grasping the concept behind it. I will be doing a 3d starfield, a horizontal starfield is very easy with you merely incrementing a x-value for each star for each frame. I am not even going to bother doing code for that one (unless requested).
So I am off to go grab my antibiotics pills and I will be right back with the tutorial!
- What is a 3d starfield?
This is a 3d starfield. If you look closely, you will see that all the stars seem to originate from a point, the point you are travelling towards. This is an illusion which thankfully happens automatically, you don't have to code for it ;)
Starfields look very nice, and can make a big difference to an otherwise black background. It also makes a great screen saver
- How do they work?
In easier language, we decrease the z value of all the the stars so that they come closer to you, and eventually whizz past.
This solves all our problems. Stars that are close to us on the x and y scales will pass us by faster then those that are very far from us on the x and y scales. The only thing we must watch out for is that no star is at 0,0 , ie. exactly in front of us, otherwise there will be a collision which will not look good.
- How do we code this?
Okay, now we start the actual viewing section. Here are the steps :
1) Convert our 3-d coords into their 2-d versions. Have a look at tut 8 to see how this is done, but basically we divide by z. 2) Clear away all old stars that may be on the screen. 3) Draw all our stars according to our 2-d values we have calculated in 1) 4) Move all the stars either closer to us or further away from us by decreasing or increasing their z values respectively. 5) If a star's z value has passed into the negative, place it at the very back of our "queue" so that it will come around again 6) Jump back to 1) ad-infinitum.That is, as they say, it. In our sample program the steps have been neatly placed into individual procedures for easy reading.
- What next?
A starfield can make just about any routine look just that much more professional, and can itself be improved to be a great effect all on it's own.
- In closing
Oh, well, the medicine has been taken, it is time for me to go. Hello to all those people who have sent me mail, and those great guys on #coders in IRC (you know who you are). Wow. That is the first greets I have ever done in a trainer. Hmm. Maybe I'm just ill
Happy coding people! - Denthor 19:28 24-7-94
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
