Menu
RENDERING PROCESS:
MISCELLANEOUS:
|
Step I: Understanding the Basic Principles Behind Raycasting
WHAT IS RAYCASTING ?
OK, let's imagine that you're stood in the centre of a field. You can see
trees, hedges and grass. You look up and see the sky and the Sun, birds
gliding overhead. You can see those things because rays of light, usually
from the Sun, bounce off objects and into your eye (to put it rather crudely
and simply :) Now, imagine if it was the other way around (as some early Greek
scientist thought...) Imagine that your eyes cast invisible rays (not of
light, but at the same speed) out until they hit something. When one of them
encounters an object, it will send information, such as it's distance, back to
you. Each ray's information is then compiled into some sort of order and sent
to your brain, producing an image that gives a visual appearance of your
surrounding environment.
Although impractical in real-life, this is exactly what happens in a
raycasting world. The analogy above has hopefully made clear the idea behind
raycasting; if not, then just mail me. I'll now run through some conventions
that we'll use during these pages.
SOME CONVENTIONS:
This one was inevitable: coordinates. We need a coordinate system for our
worlds and engine. You'll all be familiar with the Cartesian coordinate
system (named after Rene Descartes), right ? You know, the one that gives
points (vertices to be technical :) as (x, y) ? On paper, X
usually runs horizontally across the paper, and Y normally goes
vertically up and down the paper. The origin is where
the two axis intersect. The X axis normally increases to the
right (ie. +1, +2, +3...) and decreases to the left
(ie. -1, -2, -3...). Y is usually the same, except it increases going up, and
decreases going down. The point (0,0) is where the two axis intersect each
other, and is called the origin. This is illustrated in fig3:

fig3: The basic Cartesian coordinate system
For our engine we will change round the Y axis, so that it is increasing
downwards and we'll also ignore the negative values on all axes (basically,
it's so that the world can be stored as an array of cells, and can be indexed
easier; the next step covers the details).
We also need to define direction. For our purposes, we will have 0 degrees
facing east, 90 degrees facing north, etc. This needn't be so, any kind of
system would do as long as you're consistent in its use, although it's not
recommended you use another system because it's fiddly :) The reason for
choosing this orientation is discussed in later pages, but for now be content
with knowing it's a speed-up and simplifies rendering a little. Anyhow, the
two systems that my documentation uses are illustrated in fig4:

fig4: Our systems of direction
CONCLUSION:
This was a very basic introduction, but I hope I've given you sufficient
background knowledge so that you have no problems understanding the next
sections. We'll be moving on to raycasting worlds (maps is probably a more
accurate term) next, where you'll see some of the stuff above being applied.
NEXT PAGE
|
PREVIOUS PAGE
|
|