_

OpenGL | povRAY | DirectX | Interaction | Modeler | Surface Display

COS350 - DirectX

 

Project Information:

    |  October 30, 2002  |  08:00 MWF  |  Dr. Toll  |  COS 350  |  Project #3 - povRAY  |  \~jwinslow\350\DirectX\index.html  |

Assignment Description:

    We were to write a C++ program, using the ugly DirectX API to display a 3D scene with at least two objects, two light sources, materials for the objects, and a mouse interaction feature which would toggle the lights on and off accordingly (left click - left light switch).

Defending My Code:

    I modified the lightcube DirectX lightcube example for my project. I customized it with two light sources, custom textures, a new and improved middle mouse button feature. The two light sources are merely adaptations of the example code, though the original only had one light source. I chose to retain the ambient light settings as well, since I wanted the cubes to be partially visible when both light sources were turned off. The textures were bitmap files made by me that were later mapped to the cubes. The middle mouse button was improved by allowing it to rotate around a new axis each time. It would cycle through the X, Y, and Z axes with each new middle mouse button event (0 clicks = X-axis, 1st click = Y-axis, 2nd click = Z-axis, 3rd click = X-axis, etc).

Rendered Scene Thumbnails:

Rotation #1 Rotation #2 Rotation #3
Default Rotation Custom Rotation #1 Custom Rotation #2
Cubes rotate around X-axis A user-defined rotation A user-defined rotation

 

Left Light Right Light Ambient Light
Left Light Only Right Light Only Ambient Light Only
toggled by left mouse click toggled by right mouse click always on, hard-coded

 

Texture #1 Texture #2 Texture-less Scene
Simple Bitmap Simple Bitmap Blank Cubes
Mapped to cube #1 Mapped to cube #2 Have materials besides *.bmp

Final Comments:

    This project was completed on time somehow, though I feared for a while that I would never be able to decipher the nearly illegible syntax that DirectX uses. Clearly the language is quite powerful, as I learned from this project and knew from my gaming experience, yet it seems to me that the code could be much cleaner. Not so much the way the language is structured as much as the default constant names and function calls. Take the code below for example:

    if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))
    {
        return E_FAIL;
    }

    Now this is a fairly straight forward line of code. Yet between the use of names like d3ddm and having 4 lines of code to make sure a function call passes, to an inexperienced coder this language seems like it could be dramatically improved. Yet I'm an artist at heart before a coder (yet I'm still a CSS-Graphics major) so I probably am being too aesthetically picky about an area perfected by those who love the simplicity of programming.

 

_
Modified: October 2, 2004 6:11 AM