| Home | About | Links | Problems | Using the BaseCode | Contact |
This is a collection of examples about using the BaseCode. To run these examples, get the BaseCode here, and replace the MainControl source and header file for each example with the one provided. If anything other files are needed, it will be specified under the example description.
These examples should all run under DirectX, OpenGL or software (although software will not render textures, it will still compile and execute fine.) A project file that can easily switch between any of the four examples below (see Main.h for how to switch) and already contains all the necessary source, texture, and object files can be gotten below.
This demonstrates loading a variety of simple geometric shapes and rendering them in a rotating ring.
MainControlShapes.h, Web Version
MainControlShapes.cpp, Web Version
This demonstrates loading a variety of textures on some geometric shapes and rendering them in a rotating ring. It uses 4 textures, which can be gotten here.
MainControlTextures.h, Web Version
MainControlTextures.cpp, Web Version
This demonstrates loading obj files, and performing mesh splitting operations, where a mesh is broken into two meshes according to an arbitrary function that defines two regions in space. It needs two obj files, bunny and feilne, which can be gotten here or on the Links page (along with several other obj files.)
MainControlMeshes.h, Web Version
MainControlMeshes.cpp, Web Version
This demonstrates using a simple class to render spheres or cylinders in only a few lines of code (for pointing out certain vectors in the scene, for example.) It also demonstrates using and switching between two (or more) cameras, and uses the Indicator class to render the other camera. Finally, it shows how to capture the screen to a file.
MainControlCamera.h, Web Version
MainControlCamera.cpp, Web Version
To enable video capture, just go into God.cpp and set CapturingScreen to true (in any project.) The file will be outputted to whatever string is in AVIFileName. When you run your code, it will give you your choice of a list of compressors currently on your computer (I usually use DivX.) Then when you press C, it will begin capturing the scene into the file. Works best in full screen mode. Here's a sample output from an automatic Rubik's Cube solving and rendering program I wrote a while back:
AppInterface exists to make it easy to pass rendering focus between very different elements of the application, such as a title screen and the 3D-intensive main window. To demonstate how to do this, the four examples above can be easily toggled between while the application is running in the following project file. Press 1, 2, 3, or 4 at any time to switch between the four examples.
These examples show DirectX-only features. There are several other DirectX features, such as mesh simplification, and N-Patch ehancement, for which there aren't examples yet. I apologize if the examples aren't very well organized; I intend to rewrite them eventually.
Loading and rendering X-Files is a relatively simple task, using the XFileRenderer class. This example demonstrates this class; however, I can't use any really good DirectX files (as they are all copyright) so I have to make do with ones I made myself (a king and queen Chess piece, and a model of my old dorm, Hunt, at NCSSM.) The XFiles used and their associated textures follow the code, as well as a complete project file with everything included.
MainControlXFile.h, Web Version
MainControlXFile.cpp, Web Version
XFileResources.zip
BaseCodeDXExample.zip
This demonstrates using video textures. They are relatively straightforward, but need a few variables set. First, USE_VIDEO_TEXTURES must be #defined in Main.h. Second, DShow.lib must be linked with the project. Third, SleepBetweenFrames must be set to some reasonable number (like 30,) so that the application will let the video decoder have some time to decode the video. Once that is set up, VideoTexture can be used much like a normal texture in 3-4 lines of code. A project that automatically does all this (and includes a test avi file) is given.
MainControlVideo.h, Web Version
MainControlVideo.cpp, Web Version
BaseCodeVideo.zip
last updated: May 13th, 2005 © 2005 by Matthew Fisher