To access the contents, click the chapter and section titles.
Cutting Edge Direct 3D Programming
(Publisher: The Coriolis Group)
Author(s): Stan Trujillo
ISBN: 1576100502
Publication Date: 11/01/96
Appendix Working with the Demo Programs
Programming books are interesting because they vary so much. Most include a disk or CD-ROM. Some, especially those that include a CD-ROM, include various shareware, freeware, and trial versions of semi-related products. These extras are fine, but ultimately it is the code that makes a disk valuable. After all, shareware and freeware software is almost always available elsewhere.
The quality of the code that comes with books also varies. Some books include code that doesnt even compile. Others provide code that compiles but doesnt run. Other books provide high-quality professional code that serves as a valuable resource for many readers.
The CD-ROM that comes with this book has virtually no shareware and freeware software. That, quite frankly, is because I didnt have time. The vast majority of my time was spent on the books demos. I reasoned that youd rather have demos than shareware, so that is how I spent my time. Ill leave surfing the Internet in search of more tools to you.
The CD-ROM Contents
The contents of the CD-ROM can be divided into three categories:
- Source code for the books demos
- Data files for meshes and textures
- Extra software
The CD-ROM includes full source code for the 22 demo programs, Xpose the mesh viewer, and the Direct3D AppWizard. Source code is also included for all of the meshes and textures that are used in the demos. The meshes are included in both X and 3DS form. Finally, two utilities are included: Texture Magic and 3DS2POV.
Installation
The CD-ROM is autoplay enabled, meaning that an installation program is executed automatically when the disk is inserted into your CD-ROM drive. The installation program, with your permission, performs these steps:
- Copies the source code and executables for the books demos to your hard drive (to a drive and directory of your choice)
- Adds a folder to your Windows Start menu to allow the demos to be executed easily
- Installs the Direct3D AppWizard (if Visual C++ is installed)
- Associates X files with Xpose so that clicking on an X file runs Xpose automatically
The installation program also allows you to run the demos directly from the CD-ROM.
Directory Structure
The CD-ROM directory structure is shown in Figure A.1.
Figure A.1 The CD-ROM directory structure.
All of the books source code is stored in the SRC directory. The demo executable files are stored in the BIN directory. The contents of these two directories are what is installed on your hard drive by the CD-ROM installation program.
The 3ds directory contains the 3D Studio files that were used to create the meshes for the demos. These files arent required to use the books source code, but might be handy if you use 3D Studio or if you use utilities that read the 3DS file format.
The meshes directory contains X and MRF files. X files can contain meshes, animations, frame hierarchies, and entire scenes. Most of the meshes in the meshes directory, however, merely contain meshes. MRF files are X files that contain meshes that make up a morph sequence. Chapter 8 discusses MRF files and how you can make your own. The textures directory contains BMP and PPM files that can be used as textures.
The files in the meshes and textures directories are not used by the demos, so it isnt necessary for these directories to be installed on your hard drive. Each demo provides its own copy of the meshes and textures that it requires.
The EXTRAS directory contains two software utilities: Texture Magic and 3DS2POV. Well talk about these utilities later in this appendix.
The Demo Code
The demo source code is located in the src directory. Each demos source code is stored in a separate src sub-directory. These sub-directories appear in Figure A.2.
Figure A.2 The contents of the src directory.
Each directory contains a number of files, each of which is necessary for the successful compilation of the demo. These files are discussed next.
CPP and H Files
CPP and H files contain the C++ source code that is used in this book.
MDP Files
MDP files are known as project, or workspace, files. They contain all of the information that is required to compile the demo. These workspace files are created and modified by Visual C++. Loading these files with Visual C++ is the fastest and easiest way to compile, test, and modify an application.
MAK
MAK files are makefiles that can be used to compile the demos. These files are created automatically by Visual C++ and are usually ignored. They can be invaluable, however, if for some reason an MDP file is not available. MAK files allow projects to be compiled with either the command-line compiler (cl), or with Visual C++. MAK files can be used to create MDP files. Use the File|Open Workspace menu, and load the MAK file with the file dialog.
CLW
Visual C++s ClassWizard tool stores its data in CLW files. Normally, Visual C++ uses these files without your knowledge. There are situations, however, when CLW files become corrupt and cannot be read by Visual C++. If this happens, close the workspace, delete the CLW file, and re-open the workspace. Then invoke the ClassWizard tool. You will be presented with a dialog that allows you to specify the source code files that should be used to create new ClassWizard data.
RC Files
RC files are used by Visual C++ to store information specific to the applications resources (menus, icons, bitmaps, meshes, etc.). Visual C++ modifies these files automatically when resources are modified via the Visual C++ interface. Resources can be moved and copied between workspaces by opening multiple RC files, and then cutting and pasting resources between the two files.
X, BMP, and PPM Files
In the case of the demos on the CD-ROM, X, BMP, and PPM files contain Direct3D specific resources that are compiled into the resulting EXE file, and accessed during program operation. The meshes and textures that a demo uses can be changed by replacing these files with new versions and re-compiling the demo.
Modifying The Demos
Each demo sub-directory contains all of the necessary files for compilation of the demo. This means that the demos are completely independent from each other. Any combination of demos can be moved or copied, and they will continue to compile.
Chapter 4 explains that almost all of the demos use the same versions of the RMWin and RMApp C++ classes. This is true, but each demo uses its own copy. In fact, 21 of the 23 demos use identical copies of the RMWin.cpp, RMWin.h, RMApp.cpp, and RMApp.h files. The exceptions are the FullScreen and MultiView demos.
Extra Stuff
While I was working on this book, I found these two tools to be very useful. I hope you get as much use out of them as I did.
Texture Magic
Surfing the Internet, as it has come to be known, is generally overrated. There are times, however, when it pays off. This is true with Texture Magic. Texture Magic is a texture-creation tool that I found online and with which I have been very impressed. Texture Magic was written by Scott Pultz. Scott has created a Web page for Texture Magic at www.eskimo.com/~scott/povtext.html. Youll need to have a copy of the POV-ray ray-tracer to use Texture Magic. POV-ray is available on CompuServe (GO POVRAY), or at ftp.povray.org.
Texture Magic is cleverly written because, although its specialty is creating textures, it can be used as a front end to POV-ray. It allows both texture settings and POV-ray source code to be modified from within a comfortable and well organized interface. Texture Magic appears in Figure A.3.
Figure A.3 Texture Magic.
3DS2POV
The 3DS2POV utility converts 3DS scenes to POV-ray scenes. The utility is short a few features, but provides an easy way to use modellers to design POV-ray scenes. The utility is usually best used to create a first draft of the scene. The resulting POV-ray source code can then be modified. 3DS2POV was written by Steve Anger and Jeff Bowermaster.
A Word About Visual C++ 4.2
Before finishing this book, I uploaded the Direct3D AppWizard to several CompuServe forums. I got positive feedback, but some Visual C++ 4.2 users were unable to compile the projects that the AppWizard created.
The problem turned out to be that DirectX 1 is part of Visual C++ 4.2. The compiler was locating the DirectX 1 version of ddraw.h. DirectX 1 didnt include Direct3D, so naturally the compilation failed.
The best solution to this problem is to go to the Tools|Options, and select the Directories tab. The dialog allows you to move the directory where DirectX is located above the standard directory entries. This causes the compiler to locate the correct version of ddraw.h.
|