Tuesday, September 29, 2009

Sine Language Lesson, Part 2

In Part 1 of this post I discussed some useful applications of the sine function without really delving into the details of how it works. Specifically, we focused on the equation y = sin(x). Here is a more useful variation of the sine function as demonstrated in the Ocean Waves demo:

y = A * sin(K*distance - F*time + S)
  • A = amplitude
  • K = angular frequency
  • F = time frequency
  • S = shift
Amplitude represents the height of the wave; it typically ranges from -1 to 1 but can be set to an arbitrary value (e.g. set A = 25 for the wave to range from -25 to 25). The angular frequency represents how quickly the wave travels vertically. The time frequency represents how quickly the wave travels horizontally; note that F*time can be omitted from the sine function to view a static snapshot of the wave at a point in time but is included in the Ocean Waves demo to provide the effect of a wave in motion. Finally, the shift parameter allows us to move the wave by a horizontal offset so it starts from a new position (e.g. setting S = -π/2 would map it to the cosine function).

The Point Light demo from Part 1 sets the light source position's Z-coordinate using a simple sine function and then calculates the X- and Y-coordinates as sine functions using the computed Z value as the distance parameter. The Ocean Waves demo combines multiple sine waves to achieve the illusion of irregularity (not all waves in the ocean are the same height and hit shore at the same regular time interval). For example, to apply the effects of y = sin(x) and y = 12 * sin(3x), we can simply write y = sin(x) + (12 * sin(3x)). Observe that the two functions are added together. Watch the web preview of Combining Sine Waves to see the concept in motion.

I hope this post encourages you to investigate some potential uses of sine/cosine functions, as well as return to Part 1 if you missed the demo programs. It seems some things we learned in high school actually did turn out to be useful!

Wednesday, September 23, 2009

Staying Motivated

I can't believe I started this blog more than six months ago. I remember thinking initially, after seeing many game development blogs trail off after just a couple months, that I would surely put out at least five posts every week. Ha! Let's just say I may have been a little ambitious. It's easy to push forward full steam when something is new, but the question of true dedication comes when the going isn't so easy.

I've seen forum posts regarding burnout on the game development dream and even noticed one of the blogs I followed (and had linked here) seems to have disappeared. So... how do you stay motivated when your enthusiasm wanes? I think part of it is remembering what you enjoyed about it (whether it is game development or another hobby) in the first place, and looking forward to what you will be able to do with practice. In my case I'm reading through a very dry, technical graphics book right now and sometimes it is flat-out boring; but I know that by reading it and working through the examples I will in time be a better game developer.

Quite honestly, I think everyone loses their enthusiasm at times. If you stay away from an activity too long it can be hard (though not impossible) to get back into it, and if you play with something too long it can start to feel like work. But the best approach is to just stick with it. Don't give up!

Check out Brenda Brathwaite's blog post for more inspirational thoughts on staying motivated. I'm proud to say that even though I'm not posting as frequently, I am still learning new graphics tricks (today was Direct3D meshes) and will not be disappearing any time soon!