Microsoft DirectX 8.1 (Visual Basic)

Dolphin Sample

Description

The Dolphin sample shows an underwater scene of a dolphin swimming, with caustic effects on the dolphin and sea floor. The dolphin is animated using a technique called tweening. The underwater effect uses fog, and the water caustics use an animated set of textures.

Path

Source: (SDK root)\Samples\Multimedia\VBSamples\Direct3D\Dolphin

Executable: (SDK root)\Samples\Multimedia\VBSamples\Direct3D\Bin

User's Guide

The following table lists the keys that are implemented.

Key Action
F2 Prompts you to select a new rendering device or display mode.
ALT+ENTER Toggles between full-screen and windowed modes.
ESC Exits the application.

Programming Notes

Several things are happening in this sample. First, the use of fog gives an underwater effect. The fog parameters are set in the InitDeviceObjects function.

The water caustics are achieved by animating a set of 32 textures (Caust00.tga through Caust31.tga). The caustics can be blended into the scene using multitexturing or multipass blending techniques. Because the bottom of the dolphin should not have caustic effects, a separate pass is done in which ambient light is removed and the dolphin is lit from above, and then the diffuse color is blended with the caustic texture.

Using tweening, the dolphin model's vertices are linearly blended from multiple sets of vertices. The source models for these other sets of vertices are loaded from Dolphin_group.x, which consists of the dolphin model in three positions. For each frame, a destination mesh is generated by blending some combination of the positions and normals from these meshes together.

For more information on tweening, see Vertex Tweening.

This sample uses common Microsoft® DirectX® code that consists of programming elements such as helper functions. This code is shared with other samples on the DirectX SDK. You can find the common source code in (SDK root)\Samples\Multimedia\VBSamples.