The DejaVU Framework -- hush 3.1

include: graphic-directx-game-17-Walk-Terrain-Demo-d3dUtil.h /home/ae/www/media


- [up] [top] - index make include source logic grammar scripts html configure mx slides talks scenes reports projects
<body bgcolor="#FFFFFF" text="#000000">

//=============================================================================
// d3dUtil.h by Frank Luna (C) 2005 All Rights Reserved.
//
// Contains various utility code for DirectX applications, such as, clean up
// and debugging code.
//=============================================================================

ifndef D3DUTIL_H
define D3DUTIL_H

// Enable extra D3D debugging in debug builds if using the debug DirectX runtime.  
// This makes D3D objects work well in the debugger watch window, but slows down 
// performance slightly.
if defined(DEBUG) | defined(_DEBUG)
ifndef D3D_DEBUG_INFO
define D3D_DEBUG_INFO
endif
endif

include <d3d9.h>
include <d3dx9.h>
include <dxerr9.h>
include 
include 
include 

//===============================================================
// Globals for convenient access.
class D3DApp;
extern D3DApp* gd3dApp;
extern IDirect3DDevice9* gd3dDevice;
class Camera;
extern Camera* gCamera;

//===============================================================
// Clean up

define ReleaseCOM(x) { if(x){ x->Release();x = 0; } }

//===============================================================
// Geometry generation.

void GenTriGrid(int numVertRows, int numVertCols, 
        float dx, float dz, const D3DXVECTOR3& center, 
        std::vector& verts, std::vector& indices);

//===============================================================
// Colors and Materials

const D3DXCOLOR WHITE(1.0f, 1.0f, 1.0f, 1.0f);
const D3DXCOLOR BLACK(0.0f, 0.0f, 0.0f, 1.0f);
const D3DXCOLOR RED(1.0f, 0.0f, 0.0f, 1.0f);
const D3DXCOLOR GREEN(0.0f, 1.0f, 0.0f, 1.0f);
const D3DXCOLOR BLUE(0.0f, 0.0f, 1.0f, 1.0f);

struct Mtrl
{
        Mtrl()
                :ambient(WHITE), diffuse(WHITE), spec(WHITE), specPower(8.0f){}
        Mtrl(const D3DXCOLOR& a, const D3DXCOLOR& d, 
                 const D3DXCOLOR& s, float power)
                :ambient(a), diffuse(d), spec(s), specPower(power){}

        D3DXCOLOR ambient;
        D3DXCOLOR diffuse;
        D3DXCOLOR spec;
        float specPower;
};

struct DirLight
{
        D3DXCOLOR ambient;
        D3DXCOLOR diffuse;
        D3DXCOLOR spec;
        D3DXVECTOR3 dirW;
};

//===============================================================
// .X Files

void LoadXFile(
        const std::string& filename, 
        ID3DXMesh** meshOut, 
        std::vector& mtrls, 
        std::vector& texs);

//===============================================================
// Math Constants

const float INFINITY = FLT_MAX;
const float EPSILON  = 0.001f;

//===============================================================
// Bounding Volumes

struct AABB 
{
        // Initialize to an infinitely small bounding box.
        AABB()
                : minPt(INFINITY, INFINITY, INFINITY),
                  maxPt(-INFINITY, -INFINITY, -INFINITY){}

    D3DXVECTOR3 center()
        {
                return 0.5f*(minPt+maxPt);
        }

        D3DXVECTOR3 minPt;
        D3DXVECTOR3 maxPt;
};

struct BoundingSphere 
{
        BoundingSphere()
                : pos(0.0f, 0.0f, 0.0f), radius(0.0f){}

        D3DXVECTOR3 pos;
        float radius;
};

//===============================================================
// Debug

if defined(DEBUG) | defined(_DEBUG)
        #ifndef HR
        #define HR(x)                                      \
        {                                                  \
                HRESULT hr = x;                                \
                if(FAILED(hr))                                 \
                {                                              \
                        DXTrace(__FILE__, __LINE__, hr, #x, TRUE); \
                }                                              \
        }
        #endif

else
        #ifndef HR
        #define HR(x) x;
        #endif
endif 

endif // D3DUTIL_H
<hr> <style type="text/css"> div.mainnavigate { margin: 20px 2px; /* background-color: #ffffff; */ border: 1px solid black; } </style> <div class=xnavigate> [] <black>readme</black> course(s) preface <black>I</black> 1 2 <black>II</black> 3 4 <black>III</black> 5 6 7 <black>IV</black> 8 9 10 <black>V</black> 11 12 afterthought(s) <black>appendix</black> reference(s) example(s) <black>resource(s)</black> _ </div> <hr>

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author. </div> <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-2780434-1"; urchinTracker(); </script> </body> </html> <hr> <hr> <table cellpadding=10> <tr> <td> <address> Hush Online Technology </address> hush@cs.vu.nl <br>04/07/09 </td><td> </td> <td></td><td></td><td></td><td></td><td></td><td></td><td></td> <td> </td> </tr> </table>