Direct3D Samples Readme
Copyright (C) 1995, 1996 Microsoft Corporation. All Rights Reserved.

1.  Immediate Mode Samples

The samples are divided into three parts: a shared foundation which
creates and manages all DirectDraw and Direct3D objects needed to
render (D3DApp), source unique to each sample which creates and
renders the scene and a shared link between the two which creates and
handles a window (D3DMain).

For information on creation and rendering of scenes using execute
buffers, consult the individual sample files.  Consult the D3DApp
source for a better understanding of the interaction between
DirectDraw, Direct3D and Windows, creation and management of
DirectDraw and Direct3D objects, and hardware compatibility issues.

1.1 Flipcube

A cube is created and spun through mouse and keyboard input.  The
world matrix is changed in response to mouse and keyboard input and
set before rendering each frame.  Keyboard and mouse cues:

        F11 - closer
        F12 - further
        left-mouse drag - spin with mouse movement
        right-mouse click - resume spinning

Vertices are not shared because the normals are different for each
side.  Each side is covered by a separate material.
DLIGHTSTATE_MATERIAL must be set and D3DPROCESSVERTICES_TRANSFORMLIGHT
must be called for each side of the cube.

1.2 Oct1

Simple spinning shape constructed from vertex and triangle data within
the source.  Two materials are used.  The second material is only used
on one vertex.  Spinning is done by updating and setting the matrix
each frame.  The background material contains a texture.

1.3 Oct2

Identical to oct1 except that the background does not contain a
texture.

1.4 Sphere

A simple spinning sphere with one material.  The spinning is done
through a matrix multiply within the execute buffer.

1.5 Triangle

One triangle on a textured background.  The triangle is created by
specifying the screen coordinates for the vertices using TLVERTEXs.

The top left vertex, the first vertex in the triangle data, has a
diffuse color of blue.  Switching between flat and gouraud shading
changes the effect this vertex has on the lighting across the
triangle.  When flat shading, the first vertex specifies the lighting
for the entire triangle. When gouraud shading, the lighting is
interpolated across the triangle.  Lighting is different in the two
software renderers.  The RAMP driver does not modulate the texture's
color with the material color.

The rhw value of the top right vertex is larger than the other
two; it is closer to the eye.  Turning perspective correction on and
off changes the interpolation of the texture across the triangle.

1.6 Tunnel

Camera moves through a tunnel generated around a spline.  Only a small
section of the tunnel is placed in the execute buffer at a time.
After each frame, the buffer is locked and the tunnel vertices updated
to include the next section.

Triflags are set so the segments of the tunnel are drawn as quads
rather than triangles when rendered in wireframe.

1.7 Twist

Two ends of a flattened sphere are twisted in opposite directions.
All motion and twisting in done in the execute buffer by a series of
matrix multiplies.

1.8 D3DApp

D3DApp is the collection of helper functions for Direct3D which is
used by the immediate mode samples and can be a great help when you
write your first applications.  Use D3DApp to create and manage all
the DirectDraw and Direct3D objects needed to begin rendering.  D3DApp
consists of the following files:

misc\d3dapp.h

Main D3DApp header to be included by application. The best source for
complete information on how D3DApp is used.

misc\d3dappi.h

Internal header

misc\d3dapp.c

D3DApp functions seen by application.

misc\ddcalls.c

All calls to DirectDraw objects except textures.

misc\d3dcalls.c

All calls to Direct3D objects except textures.

misc\texture.c

Texture loading and managing texture list.

misc\misc.c

Miscellaneous functions.

1.9 D3DMain

D3DMain is the link between D3DApp and each sample.  It creates a
window, asks D3DApp to set it up for rendering, then asks the sample
to create it's scene and render itself.  All menu and keyboard input
from the user is handled by this code.

misc\d3dmain.cpp

Main source which includes WinMain and message handler.

misc\d3dres.h

Header for d3dmain.rc.

misc\d3dmain.rc

Defines menus and keyboard accelerator.

misc\d3ddemo.h.

Defines the functions D3DMain uses to communicate with each sample.

misc\stats.cpp

Calculates and displays frame rate and other information.

1.10 Miscellaneous

Many samples use these miscellaneous functions for execute buffer
creation and math.

misc\d3dmacs.h

Very useful collection of macros which are used in the creation of
execute buffers and matrices.

misc\d3dmath.h

Header for d3dmath.c.

misc\d3dmath.c

Collection of vector and matrix mathematical functions and generation
of a spline curve.

misc\d3dshpr.h

Header for d3dsphr.c.

misc\d3dsphr.c

Generates verticies and triangle list data for a sphere.

misc\lclib.h

Header for lclib.c

misc\lclib.c

Replacements for two string functions.

2 Retained Mode Samples

The retained mode samples are divided into two parts: a shared harness
which uses the D3DRM Windows device to setup a window for rendering
(RMMain) and source which is unique to each sample.  (Fly is an
exception, see below).

To learn how to use D3DRM to setup a window for rendering, read
through the RMMain source.  For information on building and rendering
scenes, consult the individual sample files.

2.1 Egg

Loading a simple XOF of a single mesh object.

2.2 Faces

Creation of mesh objects one face at a time.

2.3 Fly

Using animations to set the position of a spaceship along a curved
path.

2.4 Globe

Loading a simple XOF of a single mesh object with textures.

2.5 Hier1

A simple hierarchy of two meshes demonstrating the concept of frames.

2.6 Hier2

Another simple hierarchy of four meshes.

2.7 Quat

Using quaternions to interpolate between two vectors in space.

2.8 Shadow

Creating a shadow of a mesh object.

2.9 Tex1

Loading a simple texture mapped mesh object.

2.10 Tex3

Using texture wraps for special effects.

2.11 Tex4

Another example of using texture wraps for special effects.

2.12 Tex5

Using a Wrap for Chrome mapping and a Texture map as decal.

2.13 Trans

Using transparent texture maps in various ways.

2.14 Uvis

This is an important example demonstrating how D3D can be used with
D3DRM. It demonstrates how a D3D immediate mode execute buffer can be
used as a visual in a D3D retained mode scene.

2.15 Vertcol

Setting the colors at each vertex of a triangle. This can be seen only
in RGB mode.

2.16 RMMain

Uses D3DRM to setup a window for rendering, ask the sample to build
it's scene and then renders the scene.

misc\rmmain.cpp

Main source file which includes WinMain and message handler.  Creates
D3DRM, uses it to setup the window for rendering and then asks the
sample to build it's scene.

misc\rmmain.h

Header for rmmain.cpp.

misc\rmmain.rc

Resource file for rmmain.cpp.

misc\rmerror.cpp

D3DRM error code to string and error message box.

misc\rmerror.h

Header for rmerror.cpp.

misc\rmdemo.h

Because the samples do not create and manage all DirectDraw and
Direct3D objects themselves, the source is much simpler than the
immediate mode samples, but they can only run in a window.
Optionally, the D3DRM samples can be linked to D3DApp via another
harness.  This will allow them to enter fullscreen modes.  Fly is
linked to these files.

misc\rmfull.cpp

Main source file which includes WinMain and message handler.  Uses
D3DApp to setup rendering.

misc\rmfull.h

Header for rmfull.cpp.

misc\rmfull.rc

Defines menus and keyboard accelerator.

misc\rmfullrc.h

Header for rmfull.rc.

misc\rmstats.cpp

Calculates and displays frame rate and other information.



3.0 Viewer

This is a stand alone D3DRM app that allows you to load and view 3d
objects.

The initial scene has a light source in the top right. To see this the
view can be moved backwards and forwards using the T and R
keys. Additional objects can be loaded from the file menu, and new
light sources can be added from the lights menu.  Objects can be
rotated with the left mouse button and dragged with the right.

The last object that was rotated or dragged remains the current
selection.

The device quality can be altered using the Renderer menu. Using this
menu the type of device used can also be switched from ramp to
RGB. When using the RGB device the color of lights in the scene can be
changed in the same way as you change the color of objects. In 256
color mode it is advisable to dither an RGB device for best results.

Additional keyboard controls

T Forwards
R Back
Z Move current selection forwards
X Move current selection back.
Ctrl+G Gouraud shade
Ctrl+F Flat Shade
Ctrl+D Dither toggle.
Arrow Keys Move left/right/up/down
Delete Delete the current selection.


4.0  Rockem3D

A robot fighting game written with DirectDraw, Direct3D Retained Mode and
DirectSound.  Move the blue robot around the ring and attempt to knock out
your computer opponent.

Up   Forwards
Down Back
Spc  Punch
Ctrl Block

Press TAB for an information bar containing the current screen mode and frame
rate.  The letter at the end of the bar indicates whether Rockem3D is running
on a hardware device (H) or in software emulation (S).

Additional keys are:

F2     Side Camera View
F3     Behind Camera View
F4     Head Camera View
PgUp   Increase Video Mode
PgDn   Decrease Video Mode
Home   Highest Video Mode
End    Lowest Video Mode
Ctrl+M Toggle music on/off
Ctrl+S Toggle sound on/off
