?/TD>
Microsoft DirectX 9.0

Cube Map Sample


Description

The Cube Map sample demonstrates an environment-mapping technique called cube mapping. Environment mapping is a technique in which the environment surrounding a 3-D object, such as the lights, is put into a texture map so that the object can have complex lighting effects without the time-consuming lighting calculations.

Not all cards support all features for environment-mapping techniques such as cube mapping and projected textures. For more information about environment mapping, see Environment Mapping.

Path

Source: (SDK root)\Samples\C++\Direct3D\EnvMapping\CubeMap

Executable: (SDK root)\Samples\C++\Direct3D\Bin

User's Guide

The following table lists the keys that are implemented. You can use menu commands for the same controls.

KeyAction
ENTERStarts and stops the scene.
SPACEBARAdvances the scene by a small increment.
F2Prompts the user to select a new rendering device or display mode.
ALT+ENTERToggles between full-screen and windowed modes.
ESCExits the application.

Programming Notes

Cube mapping is a technique that employs a six-sided texture. To visualize the effects of this technique, imagine a wallpapered room in which the wallpaper has been shrink-wrapped around an object. Cube mapping is superior to sphere-mapping because the latter is inherently view dependent; sphere maps are constructed for one particular viewpoint in mind. Cube maps also have no geometry distortions so they can be generated on the fly using IDirect3DDevice9::SetRenderTarget for all six cube map faces.

Cube mapping works with Microsoft?Direct3D?texture coordinate generation. By setting D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR, Direct3D generates cube map texture coordinates from the reflection vector for a vertex, thereby making this technique easy for environment mapping effects where the environment is reflected in the object.

This sample uses common Microsoft DirectX?code that consists of programming elements such as helper functions. This code is shared with other samples in the DirectX software development kit (SDK). You can find the sample framework headers and source code in (SDK root)\DXSDK\Samples\C++\Common\Include and (SDK root)\DXSDK\Samples\C++\Common\Src.



© 2002 Microsoft Corporation. All rights reserved.