Retained
Mode: Basics
By: Jack Hoxley
Written: May 2000
Download: Rm_Basics.zip
(230kb)
Direct3D retained mode is as
easy as 3D programming gets; to put it simply, if you can't understand this
dont expect that immediate mode will be any better. The reason retained mode
is easier is because a lot of the complicated stuff is hidden from you, and
the complicated stuff is simplified further.
Because of this simplification
it is easy and quick to set up a retained mode application. This is a huge advantage,
but as with all things directX - If it's the easy way it'll also be the slow
way. The difference between immediate mode and retained mode can be quite big
sometimes. Retained mode is excellent if you want to create that simple, but
professional spinning text, or clever 3D interface; but where speed and features
are paramount you are best advised to leave retained mode alone and venture
into immediate mode.
There is one remaining huge disadvantage
with retained mode - it's been discontinued. There is nothing new in DirectX7
for retained mode, it has been left in there only so that older applications
can still use it. Which means that you are going to be programming old technology,
top end 3D last year is going to be radically different from this years middle-end
3D, let alone top end 3D. Whether microsoft keep the legacy code for retained
mode in future editions of directX will only be known as and when they are released.
It is quite possible that DirectX 9 or 10 will completely drop retained mode
- therefore stopping your program from working; From what I have read and seen,
I do not believe that they will take retained mode out of directx 8.
Then there is the second, generic,
problem with 3D programming: you need to understand that basics of 3D design
and how it is represented on a computer. This can go from extremely easy for
some people, to a mammoth task for others; you really need to understand certain
things BEFORE you launch into making a proper application. You will also need
a reasonable knowledge of directdraw; as this is linked in with both versions
of direct3D.
As well as this you will need
some form of 3D renderer. Assuming that you are going to be loading models into
your program you will need a program that makes them. Again, these can be extremely
complicated or annoyingly simple. There is also the downside that some are extremely
expensive, but on the other hand you can get simple ones cheap or for free on
the internet. As with many things in life - you get what you pay for. A 3D package
costing £500 is going to be amazing, one that costs £100 may be
okay, and one that is free will probably only take you through the learning
process. In my experience 3D Studio Max 1,2 or 3 is the best package around.
Others include truespace and lightwave. You can sometimes find copies of older
versions and/or cut down versions for free either on magazines cover CD's or
the internet. The end line is that you will NEED a similiar program for even
the simplest programs.
Although a lot of this list will
be explained in other tutorials, here are some basic pointers to what they mean
and what you need to know about them:
COORDINATES
These are the simplest things in 3D, but you will need to be able to visualise
them in your head - It can be quite confusing though. You should be familiar
with conventional 2D coordinates; X and Y (Horizontal and Vertical respectively).
These still exist in 3D space, but they are joined by a third axis - Z. Z is
depth; this is where most people stumble, an object can't physically be deeper
in the screen than anything else; but an object can be up/down and left/right
physically. Think of Z as the distance into the scene. For reference purposes,
all axis are positive and negative, and this can always change in relation to
the camera. Depending on where the camera is, the axis will have different real
world positions.
ROTATION
This is fairly simple, rotation is always a translation around a coordinate.
If you have a 2D square with a bottom corner at 1,1 and you rotate it about
0,0 it will always be 1 unit away from the center of rotation. Basically, it
is rotated around a global point - referenced to the whole screen NOT on the
local object.
MOVEMENT
This is also very simple, it requires that you work in 3 dimensions though.
It can get extremely confusing when the X/Y/Z axis's aren't the same as in the
physical world - ie, positive X may not be right, and negative X may not be
Y
SCENES
In retained mode, you render a scene onto the screen. A scene can be made up
of many objects and features, typically they will be pre-made objects, lights
and backgrounds.
CAMERAS
The camera represents where you are - the camera looks from a point in 3D space
to another point in 3D space. Currently there are no technologies commonly available
that support focusing and depth-of-field; so how far away the destination is
doesn't matter. Think of your screen being at the start point, and looking towards
the destination point.
RENDER MODES
Three main render mode are WIREFRAME, SOLID and GOURAUD. These will be discussed
in another tutorial. For now just think of them as being different levels of
detail - Wireframe is just a set of lines, Solid just fills the spaces between
the lines with colour and Gouraud adds shading. There is no support for Phong
shading currently.
LIGHTING
If there are no lights in a scene then it is quite likely that you will see
nothing. These will be discussed in a later tutorial. There are two main types
of light that will interest you - Ambient and Spot lights. Ambient lights apply
the same amount of light to every part of an object. Spot lights (not a technical
name) have light eminating from a point, and cast shadows and different levels
of light in different places.
TEXTURES
These are what make an object look real. They tend to be bitmaps of simple
real world materials - ie, metal, stone, brick walls. They are then applied
to normal objects to give them a more real world look and feel. These will be
explained fully in a later tutorial.
The sample included with this
tutorial is very well commented, and I advise that you look through it. You
can get it from the top of the page, or from my Downloads
page.
|