Restructure repository to include all source folders

Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-29 20:17:20 +09:00
parent 5d3cd64a25
commit dd97ddec92
11602 changed files with 1446576 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
#ifndef _3DMATH_H
#define _3DMATH_H
#include "vector.h"
#include "matrix.h"
#include "color.h"
#include "quaternion.h"
#include "Intersection.h"
#include "FastMath.h"
#endif

View File

@@ -0,0 +1,597 @@
// BaseGraphic.cpp: implementation of the BaseGraphic class.
//
//////////////////////////////////////////////////////////////////////
#include "BaseGraphicsLayer.h"
#include <d3d8.h>
#include <d3dx8.h>
#include "Vertex.h"
#include "FastMath.h"
#include "dxutil.h"
#include "SceneStateMgr.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CViewCamera BaseGraphicsLayer::m_ViewCamera;
LPDIRECT3DDEVICE8 BaseGraphicsLayer::m_pd3dDevice;
LPDIRECT3D8 BaseGraphicsLayer:: m_pD3D;
D3DPRESENT_PARAMETERS BaseGraphicsLayer::m_d3dpp;
long BaseGraphicsLayer::m_lScreenSx;
long BaseGraphicsLayer::m_lScreenSy;
color BaseGraphicsLayer::m_ClearColor;
HWND BaseGraphicsLayer::m_hWnd;
bool BaseGraphicsLayer::m_VoodooOption=false;
BaseGraphicsLayer::BaseGraphicsLayer()
{
m_hWnd=NULL;
m_pd3dDevice=NULL;
m_pD3D=NULL;
m_fFov=m_fNear=m_fFar=0.0f;
m_ClearColor.c=0x0;
m_bEditorMode=false;
}
BaseGraphicsLayer::~BaseGraphicsLayer()
{
if(m_pd3dDevice)
m_pd3dDevice->Release();
if(m_pD3D)
m_pD3D->Release();
if(m_pFont)
delete m_pFont;
}
void BaseGraphicsLayer::Create(HWND hWnd, bool bWindowed,bool Editor, long screenx, long screeny)
{
//LogMessage("BaseGraphicsLayer Create Start");
m_hWnd=hWnd;
m_bWindowed=bWindowed;
m_bEditorMode=Editor;
GetWindowRect( m_hWnd, &m_rcWindowBounds );
GetClientRect( m_hWnd, &m_rcWindowClient );
if(NULL == (m_pD3D=Direct3DCreate8(D3D_SDK_VERSION)))
{
throw CGraphicLayerError("BaseGraphicsLayer:Create,GetDirect3D Interface getting fail");
}
//LogMessage("Direct3D 8.0 Create");
/*
D3DAdapterInfo* pAdapterInfo = &CEnumD3D::m_Adapters[CEnumD3D::m_dwAdapter];
D3DDeviceInfo* pDeviceInfo = &pAdapterInfo->devices[pAdapterInfo->dwCurrentDevice];
D3DModeInfo* pModeInfo = &pDeviceInfo->modes[pDeviceInfo->dwCurrentMode];
*/
D3DAdapterInfo* pAdapterInfo = &CEnumD3D::m_Adapters[CEnumD3D::m_nAdapter];
D3DDeviceInfo* pDeviceInfo = &pAdapterInfo->devices[CEnumD3D::m_nDevice];
D3DModeInfo* pModeInfo = &pDeviceInfo->modes[CEnumD3D::m_nMode];
if(strstr(pAdapterInfo->d3dAdapterIdentifier.Description,"Voodoo"))
{
m_VoodooOption=true;
//MessageBox(NULL,"Voodoo",0,0);
}
else
{
m_VoodooOption=false;
}
// Set up the presentation parameters
ZeroMemory( &m_d3dpp, sizeof(m_d3dpp) );
m_d3dpp.Windowed = bWindowed;
m_d3dpp.BackBufferCount = 1;
m_d3dpp.MultiSampleType = pDeviceInfo->MultiSampleType;
//m_d3dpp.SwapEffect = D3DSWAPEFFECT_COPY ;
m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD ;
m_d3dpp.Flags=D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
m_d3dpp.hDeviceWindow=m_hWnd;
m_d3dpp.EnableAutoDepthStencil=TRUE;
if(Editor)
{
//m_d3dpp.AutoDepthStencilFormat=D3DFMT_D16_LOCKABLE;
m_d3dpp.AutoDepthStencilFormat = pModeInfo->DepthStencilFormat;
m_d3dpp.AutoDepthStencilFormat =D3DFMT_D24S8;
m_d3dpp.Flags=D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
}
else
{
m_d3dpp.AutoDepthStencilFormat = pModeInfo->DepthStencilFormat;
m_d3dpp.Flags=D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
}
if(bWindowed)
{
m_lScreenSx=m_d3dpp.BackBufferWidth = m_rcWindowClient.right - m_rcWindowClient.left;
m_lScreenSy=m_d3dpp.BackBufferHeight = m_rcWindowClient.bottom - m_rcWindowClient.top;
if(pAdapterInfo->d3ddmDesktop.Format==D3DFMT_X8R8G8B8)
{
m_d3dpp.BackBufferFormat=D3DFMT_A8R8G8B8;
}
else
{
m_d3dpp.BackBufferFormat=pAdapterInfo->d3ddmDesktop.Format;
}
}
else
{
m_lScreenSx=m_d3dpp.BackBufferWidth = pModeInfo->Width;
m_lScreenSy=m_d3dpp.BackBufferHeight = pModeInfo->Height;
m_d3dpp.BackBufferFormat = pModeInfo->Format;
m_d3dpp.FullScreen_PresentationInterval=D3DPRESENT_INTERVAL_IMMEDIATE;
}
if(Editor)
{
if(FAILED(m_pD3D->CreateDevice( CEnumD3D::m_dwAdapter, pDeviceInfo->DeviceType,
m_hWnd,
//D3DCREATE_SOFTWARE_VERTEXPROCESSING,
//D3DCREATE_MIXED_VERTEXPROCESSING,
pModeInfo->dwBehavior,
&m_d3dpp,
&m_pd3dDevice )))
{
throw CGraphicLayerError("BaseGraphicsLayer:Create, CreateDevice is failed");
}
}
else
{
if(FAILED(m_pD3D->CreateDevice( CEnumD3D::m_dwAdapter, pDeviceInfo->DeviceType,
m_hWnd,
//D3DCREATE_SOFTWARE_VERTEXPROCESSING,
//D3DCREATE_MIXED_VERTEXPROCESSING,
pModeInfo->dwBehavior,
&m_d3dpp,
&m_pd3dDevice )))
{
throw CGraphicLayerError("BaseGraphicsLayer:Create, CreateDevice is failed");
}
}
m_dwStartRemainTextureMemory=m_pd3dDevice->GetAvailableTextureMem();
//LogMessage("Direct3D Device Create");
//LogMessage("Direct3D 7.0 Create");
// Follow code is to Initial RenderState( light ,matrix,material);
CTexture::Init(m_pd3dDevice);
matrix matProj;
float fAspect=(float)m_d3dpp.BackBufferWidth/(float)m_d3dpp.BackBufferHeight;
fAspect=1.0f/fAspect;
//fAspect=1.0f;
matProj.MakeProjection(3.1415f/3.0f,fAspect,50.0f,620000.0f);
m_pd3dDevice->SetTransform(D3DTS_PROJECTION,(D3DMATRIX*)&matProj);
matrix matView;
matView.MakeIdent();
m_pd3dDevice->SetTransform(D3DTS_VIEW,(D3DMATRIX*)&matView);
matrix matWorld;
matWorld.MakeIdent();
m_pd3dDevice->SetTransform(D3DTS_WORLD,(D3DMATRIX*)&matWorld);
CSceneManager::SetDevice(m_pd3dDevice);
CSceneStateMgr::_SetD3DRenderState( D3DRS_ZENABLE, TRUE );
CSceneStateMgr::_SetD3DRenderState(D3DRS_LOCALVIEWER,FALSE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_CLIPPING,TRUE);
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_MAGFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_MIPFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(1,D3DTSS_MAGFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(1,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(1,D3DTSS_MIPFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(2,D3DTSS_MAGFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(2,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(2,D3DTSS_MIPFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(3,D3DTSS_MAGFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(3,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(3,D3DTSS_MIPFILTER,D3DTEXF_LINEAR);
//CSceneStateMgr::_SetD3DRenderState(D3DRS_CLIPPING,FALSE);
D3DLIGHT8 light;
ZeroMemory( &light, sizeof(D3DLIGHT8) );
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
light.Position.x = light.Direction.x = 0.0f;
light.Position.y = light.Direction.y = -1.0f;
light.Position.z = light.Direction.z = 0.0f;
light.Direction.x = 0.0f;
light.Range = 1000.0f;
m_pd3dDevice->SetLight( 0,&light );
m_pd3dDevice->LightEnable( 0,TRUE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_LIGHTING, TRUE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_AMBIENT,0xffffffff);
D3DMATERIAL8 mtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL8) );
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
mtrl.Diffuse.b = mtrl.Ambient.b = 1.0f;
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
m_pd3dDevice->SetMaterial( &mtrl );
m_pFont= new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
m_pFont->InitDeviceObjects( m_pd3dDevice );
m_pFont->RestoreDeviceObjects();
// For Init View Frustum //
m_ViewCamera.BuildFrustum(fAspect,3.1415f/3.0f,40.0f,1300000.0f);
//LogMessage("Setting Default Device RenderState");
CFastMath::Init();
CSceneStateMgr::_SetD3DRenderState(D3DRS_RANGEFOGENABLE,TRUE);
//float fMipLodBias=-2.0f;
//CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_MIPMAPLODBIAS,*((LPDWORD)(&fMipLodBias)));
//LogMessage("FastMath Class Init");
}
void BaseGraphicsLayer::GetPickPoint(long lScreenX, long lScreenY, float &fsX, float &fsY, float &fsZ)
{
RECT rect;
rect.left=lScreenX;
rect.right=lScreenX+1;
rect.top=lScreenY;
rect.bottom=lScreenY+1;
POINT p;
p.x=0;
p.y=0;
D3DLOCKED_RECT d3dlocked_rect;
LPDIRECT3DSURFACE8 pBackBuffer;
m_pd3dDevice->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&pBackBuffer);
pBackBuffer->LockRect(&d3dlocked_rect,NULL,D3DLOCK_READONLY|D3DLOCK_NO_DIRTY_UPDATE );
DWORD *e=(DWORD*)d3dlocked_rect.pBits;
pBackBuffer->UnlockRect();
pBackBuffer->Release();
LPDIRECT3DSURFACE8 pZBuffer;
m_pd3dDevice->GetDepthStencilSurface( &pZBuffer );
pZBuffer->LockRect(&d3dlocked_rect,&rect,D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_READONLY);
if(d3dlocked_rect.pBits==NULL)
return;
BYTE *pb=(BYTE*)d3dlocked_rect.pBits;
WORD wLen=0;
wLen|=*(pb+1)<<8;
wLen|=*(pb);
pZBuffer->UnlockRect();
pZBuffer->Release();
matrix matView,matProj;
m_pd3dDevice->GetTransform(D3DTS_VIEW,(D3DMATRIX*)&matView);
m_pd3dDevice->GetTransform(D3DTS_PROJECTION,(D3DMATRIX*)&matProj);
matrix matSet=matView*matProj;
matrix matInv;
//matInv.Inverse(matSet);
float d;
D3DXMatrixInverse((D3DXMATRIX*)&matInv,&d,(D3DXMATRIX*)&matSet);
float fX,fY,fZ;
fX=2.0/m_d3dpp.BackBufferWidth;
fY=2.0/m_d3dpp.BackBufferHeight;
fZ=(float)wLen/(float)0xffff;
fX=lScreenX*(fX)-1.0f;
fY=1.0f-(lScreenY)*(fY);
float fXp=matInv._11*fX + matInv._21*fY + matInv._31*fZ + matInv._41;
float fYp=matInv._12*fX + matInv._22*fY + matInv._32*fZ + matInv._42;
float fZp=matInv._13*fX + matInv._23*fY + matInv._33*fZ + matInv._43;
float fWp=matInv._14*fX + matInv._24*fY + matInv._34*fZ + matInv._44;
fsX=fXp/fWp;
fsY=fYp/fWp;
fsZ=fZp/fWp;
}
void BaseGraphicsLayer::Flip()
{
//RECT rect={100,100,800,600};
m_pd3dDevice->Present(NULL,NULL,m_hWnd,NULL);
//m_pd3dDevice->Present(&rect,&rect,NULL,NULL);
/*
LPDIRECT3DSURFACE8 pddsFrontBuffer,pddsBackBuffer;
m_pd3dDevice->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&pddsBackBuffer);
m_pd3dDevice->GetFrontBuffer(&pddsFrontBuffer);
RECT rect={0,0,800,600};
POINT pt={0,0};
m_pd3dDevice->CopyRects(pddsBackBuffer,&rect,0,pddsFrontBuffer,&pt);
pddsFrontBuffer->Release();
pddsBackBuffer->Release();
*/
}
void BaseGraphicsLayer::PrefareRender()
{
m_pd3dDevice->SetTransform(D3DTS_VIEW,m_ViewCamera.GetMatView());
m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, m_ClearColor.c, 1.0f, 0 );
}
void BaseGraphicsLayer::ShowState()
{
CSceneStateMgr::_SetD3DRenderState( D3DRS_LIGHTING,FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_FOGENABLE,FALSE);
/*
TLVertex NSVertex[4];
float fZvalue=0.01f;
float fProjectedPositionW=0.01f;
NSVertex[0].v=vector3(0.0f,100.0f,fZvalue);
NSVertex[0].tu=0.0f;
NSVertex[0].tv=1.0f;
NSVertex[1].v=vector3(0.0f,0.0f,fZvalue);
NSVertex[1].tu=0.0f;
NSVertex[1].tv=0.0f;
NSVertex[2].v=vector3(100.0f,100.0f,fZvalue);
NSVertex[2].tu=1.0f;
NSVertex[2].tv=1.0f;
NSVertex[3].v=vector3(100.0f,0.0f,fZvalue);
NSVertex[3].tu=1.0f;
NSVertex[3].tv=0.0f;
NSVertex[0].v=vector3(100.0f,100.0f,fZvalue);
NSVertex[1].v=vector3(100.0f,100.0f,fZvalue);
NSVertex[2].v=vector3(100.0f,100.0f,fZvalue);
NSVertex[3].v=vector3(100.0f,100.0f,fZvalue);
float fNsSize=100.0f;
NSVertex[0].v.x+=fNsSize*cosf(0.0f + 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
NSVertex[0].v.y+=fNsSize*sinf(0.0f + 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
NSVertex[1].v.x+=fNsSize*cosf(3.1415f*0.5f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
NSVertex[1].v.y+=fNsSize*sinf(3.1415f*0.5f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
NSVertex[2].v.x+=fNsSize*cosf(3.1415f*1.5f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
NSVertex[2].v.y+=fNsSize*sinf(3.1415f*1.5f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
NSVertex[3].v.x+=fNsSize*cosf(3.1415f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
NSVertex[3].v.y+=fNsSize*sinf(3.1415f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
NSVertex[0].w=fProjectedPositionW;
NSVertex[1].w=fProjectedPositionW;
NSVertex[2].w=fProjectedPositionW;
NSVertex[3].w=fProjectedPositionW;
NSVertex[0].Diffuse.c=0xff000000;
NSVertex[1].Diffuse.c=0xff000000;
NSVertex[2].Diffuse.c=0xff000000;
NSVertex[3].Diffuse.c=0xff000000;
NSVertex[0].Specular.c=0x0;
NSVertex[1].Specular.c=0x0;
NSVertex[2].Specular.c=0x0;
NSVertex[3].Specular.c=0x0;
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE,TRUE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
CSceneStateMgr::_SetD3DRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
m_pd3dDevice->SetVertexShader(TLVERTEXFVF);
m_pd3dDevice->SetTexture(0,m_NsTexture.GetTexture());
m_pd3dDevice->SetTexture(1,NULL);
m_pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,NSVertex,sizeof(TLVertex));
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
//*/
static FLOAT fLastTime = 0.0f;
static DWORD dwFrames = 0L;
static char strFrameStats[256];
FLOAT fTime = DXUtil_Timer( TIMER_GETABSOLUTETIME );
++dwFrames;
// Update the scene stats once per second
if( fTime - fLastTime > 1.0f )
{
float fFPS = dwFrames / (fTime - fLastTime);
fLastTime = fTime;
dwFrames = 0L;
sprintf( strFrameStats, "%.02f fps", fFPS);
}
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,0,0),strFrameStats);
static char strSectorPos[256];
matrix *matPos=m_ViewCamera.GetMatPosition();
sprintf(strSectorPos," Sector-X = %d , Sector-Y = %d",(int)(matPos->_41/(63.0f*500.0f)),(int)(matPos->_43/(63.0f*500.0f)));
m_pFont->DrawText( 2, 60, D3DCOLOR_ARGB(255,255,0,0),strSectorPos);
sprintf(strSectorPos,"Viewer Position x=%.2f y=%.2f z=%.2f",matPos->_41,matPos->_42,matPos->_43);
m_pFont->DrawText( 2, 80, D3DCOLOR_ARGB(255,255,0,0),strSectorPos);
m_dwAbleTextureMemory=m_pd3dDevice->GetAvailableTextureMem();
sprintf(strSectorPos,"Total used texture memory %d ",m_dwStartRemainTextureMemory-m_dwAbleTextureMemory);
m_pFont->DrawText( 2, 95, D3DCOLOR_ARGB(255,255,0,0),strSectorPos);
sprintf(strSectorPos,"Remain Texture memory %d ",m_dwAbleTextureMemory);
m_pFont->DrawText( 2, 115, D3DCOLOR_ARGB(255,255,0,0),strSectorPos);
sprintf(strSectorPos,"Rotate %2.3f ",m_ViewCamera.GetRotationY());
m_pFont->DrawText( 2, 135, D3DCOLOR_ARGB(255,255,0,0),strSectorPos);
}
bool BaseGraphicsLayer::TransformVector(vector3 &t,vector3 &vecResult,float &w)
{
DWORD dwClipWidth;
DWORD dwClipHeight;
dwClipWidth=m_d3dpp.BackBufferWidth/2;
dwClipHeight=m_d3dpp.BackBufferHeight/2;
//dwClipWidth=256/2.0f;
//dwClipHeight=256/2.0f;
matrix matWorld,matView,matProj;
m_pd3dDevice->GetTransform(D3DTS_WORLD,(D3DMATRIX*)&matWorld);
m_pd3dDevice->GetTransform(D3DTS_VIEW,(D3DMATRIX*)&matView);
m_pd3dDevice->GetTransform(D3DTS_PROJECTION,(D3DMATRIX*)&matProj);
//matrix matSet=matProj*matView;
matrix matSet=matView*matProj;
float x,y,z;
x=t.x;
y=t.y;
z=t.z;
float xp = matSet._11*x + matSet._21*y + matSet._31*z + matSet._41;
float yp = matSet._12*x + matSet._22*y + matSet._32*z + matSet._42;
float zp = matSet._13*x + matSet._23*y + matSet._33*z + matSet._43;
float wp = matSet._14*x + matSet._24*y + matSet._34*z + matSet._44;
vector3 vecTansform;
vecTansform.x= ( 1.0f + (xp/wp) ) * dwClipWidth;
vecTansform.y= ( 1.0f - (yp/wp) ) * dwClipHeight;
vecTansform.z= zp / wp;
w = wp;
vecResult=vecTansform;
if( 0.0f < vecTansform.x &&
vecTansform.x < m_d3dpp.BackBufferWidth &&
0.0f < vecTansform.y &&
vecTansform.y < m_d3dpp.BackBufferHeight)
{
return true;
}
return false;
}
void BaseGraphicsLayer::ManyTransformVector(vector3 *t, vector3 *result, float *w)
{
/*
DWORD dwClipWidth=m_d3dpp.BackBufferWidth/2;
DWORD dwClipHeight=m_d3dpp.BackBufferHeight/2;
matrix matView,matProj;
m_pd3dDevice->GetTransform(D3DTS_VIEW,(D3DMATRIX*)&matView);
m_pd3dDevice->GetTransform(D3DTS_PROJECTION,(D3DMATRIX*)&matProj);
//matrix matSet=matProj*matView;
matrix matSet=matView*matProj;
float x,y,z;
x=t.x;
y=t.y;
z=t.z;
float xp = matSet._11*x + matSet._21*y + matSet._31*z + matSet._41;
float yp = matSet._12*x + matSet._22*y + matSet._32*z + matSet._42;
float zp = matSet._13*x + matSet._23*y + matSet._33*z + matSet._43;
float wp = matSet._14*x + matSet._24*y + matSet._34*z + matSet._44;
vector3 vecTansform;
vecTansform.x= ( 1.0f + (xp/wp) ) * dwClipWidth;
vecTansform.y= ( 1.0f - (yp/wp) ) * dwClipHeight;
vecTansform.z= zp / wp;
w = wp;
vecResult=vecTansform;
if( 0.0f < vecTansform.x &&
vecTansform.x < m_d3dpp.BackBufferWidth &&
0.0f < vecTansform.y &&
vecTansform.y < m_d3dpp.BackBufferHeight)
{
return true;
}
return false;
*/
}
/*void BaseGraphicsLayer::RectFlip(List<RECT> &RectList)
{
for(int i=0;i<RectList.num;i++)
{
m_pd3dDevice->Present(&RectList[i],&RectList[i],NULL,NULL);
}
}*/
bool BaseGraphicsLayer::ProjectiveTextureMapping(vector3 vecPoint, float &fTu, float &fTv)
{
vector3 vecFrontPlaneNormal=(m_ViewCamera.m_vecFrustumNear[1]-m_ViewCamera.m_vecFrustumNear[0])^(m_ViewCamera.m_vecFrustumNear[2]-m_ViewCamera.m_vecFrustumNear[1]);
vecFrontPlaneNormal.Normalize();
//vecFrontPlaneNormal=-vecFrontPlaneNormal;
vector3 vecPos=m_ViewCamera.GetMatPosition()->GetLoc();
float fInter=CIntersection::PointFromPlane(vecFrontPlaneNormal,vecPos,vecPoint);
// TU
float fUInter=CIntersection::PointFromPlane(m_ViewCamera.m_vecCenterAxis[0],vecPos,vecPoint);
// TV
float fVInter=CIntersection::PointFromPlane(m_ViewCamera.m_vecCenterAxis[1],vecPos,vecPoint);
float fNormalSize=tanf(3.14159f/6.0f)*fInter;
fTu=fUInter/fNormalSize;
fTu=fTu*0.5f+0.5f;
float fAspect=(float)m_lScreenSx/(float)m_lScreenSy;
fNormalSize=tanf((3.14159f/6.0f))*fInter*fAspect;
fTv=fVInter/fNormalSize;
fTv=fTv*0.5f+0.5f;
vecFrontPlaneNormal^vector3(0.0f,1.0f,0.0f);
return false;
/*
if(fInter>=0.0f)
return true;
return false;
*/
}
HRESULT BaseGraphicsLayer::CheckResourceFormatSupport(D3DFORMAT fmt, D3DRESOURCETYPE resType, DWORD dwUsage)
{
HRESULT hr = S_OK;
IDirect3D8* tempD3D = NULL;
m_pd3dDevice->GetDirect3D(&tempD3D);
D3DCAPS8 devCaps;
m_pd3dDevice->GetDeviceCaps(&devCaps);
D3DDISPLAYMODE displayMode;
tempD3D->GetAdapterDisplayMode(devCaps.AdapterOrdinal, &displayMode);
hr = tempD3D->CheckDeviceFormat(devCaps.AdapterOrdinal, devCaps.DeviceType, displayMode.Format, dwUsage, resType, fmt);
tempD3D->Release(), tempD3D = NULL;
return hr;
}

View File

@@ -0,0 +1,69 @@
// BaseGraphic.h: interface for the BaseGraphic class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_BASEGRAPHIC_H__D2B16AD2_C324_44D0_A581_93528EA232C2__INCLUDED_)
#define AFX_BASEGRAPHIC_H__D2B16AD2_C324_44D0_A581_93528EA232C2__INCLUDED_
#include "VECTOR.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
#include "ViewCamera.h"
//#include "list.h"
#include "Exception.h"
#include "Texture.h"
#include "VertexBuffer.h"
#include "EnumD3D.h"
#include "D3DFont.h"
#include "StateLog.h"
class BaseGraphicsLayer
{
static HWND m_hWnd;
static LPDIRECT3DDEVICE8 m_pd3dDevice;
static LPDIRECT3D8 m_pD3D;
bool m_bWindowed;
bool m_bEditorMode;
//Projection Parameter//
float m_fFov,m_fNear,m_fFar;
//NS//
CTexture m_NsTexture;
DWORD m_dwStartRemainTextureMemory;
DWORD m_dwAbleTextureMemory;
public:
static bool ProjectiveTextureMapping(vector3 vecPoint,float &fTu,float &fTv);
// void RectFlip(List<RECT> &RectList);
static long m_lScreenSx,m_lScreenSy;
CD3DFont* m_pFont; // Font for drawing text
static D3DPRESENT_PARAMETERS m_d3dpp;
RECT m_rcWindowBounds;
RECT m_rcWindowClient;
static bool m_VoodooOption;
static HWND GethWnd(){return m_hWnd;};
void ManyTransformVector(vector3 *t,vector3 *result,float *w);
static bool TransformVector(vector3 &t,vector3 &vecResult,float &w);
void ShowState();
void PrefareRender();
void Flip();
void GetPickPoint(long lScreenX,long lScreenY,float &fsX,float &fsY,float &fsZ);
static CViewCamera m_ViewCamera;
static color m_ClearColor;
void Create(HWND hWnd,bool bWindowed,bool Editor,long screenx,long screeny);
BaseGraphicsLayer();
virtual ~BaseGraphicsLayer();
static LPDIRECT3DDEVICE8 GetDevice(){return m_pd3dDevice;};
static HRESULT CheckResourceFormatSupport(D3DFORMAT fmt, D3DRESOURCETYPE resType, DWORD dwUsage);
};
#endif // !defined(AFX_BASEGRAPHIC_H__D2B16AD2_C324_44D0_A581_93528EA232C2__INCLUDED_)

View File

@@ -0,0 +1,380 @@
// ConvertTexture.cpp: implementation of the CConvertTexture class.
//
//////////////////////////////////////////////////////////////////////
#include <d3dx8.h>
#include "ConvertTexture.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CConvertTexture::CConvertTexture()
{
m_pddNewTexture=NULL;
}
CConvertTexture::~CConvertTexture()
{
if(m_pddNewTexture)
m_pddNewTexture->Release();
}
void CConvertTexture::Compress(D3DFORMAT fmtTo)
{
if(m_pddNewTexture)
{
m_pddNewTexture->Release();
m_pddNewTexture=NULL;
}
int nMips=m_pddTexture->GetLevelCount();
//m_pd3dDevice->CreateTexture(m_dwWidth,m_dwHeight,0,0,fmtTo,D3DPOOL_MANAGED,&m_pddNewTexture);
m_pd3dDevice->CreateTexture(m_dwWidth,m_dwHeight,nMips,0,fmtTo,D3DPOOL_MANAGED,&m_pddNewTexture);
//int nMips=m_pddNewTexture->GetLevelCount();
LPDIRECT3DSURFACE8 pSurfaceSrc,pSurfaceDest;
for(int cLevel=0;cLevel<nMips;cLevel++)
{
HRESULT r;
r=((LPDIRECT3DTEXTURE8)m_pddTexture)->GetSurfaceLevel(cLevel,&pSurfaceSrc);
r=m_pddNewTexture->GetSurfaceLevel(cLevel,&pSurfaceDest);
r=D3DXLoadSurfaceFromSurface(pSurfaceDest,NULL,NULL,pSurfaceSrc,NULL,NULL,D3DX_FILTER_TRIANGLE,0);
pSurfaceSrc->Release();
pSurfaceDest->Release();
}
}
void CConvertTexture::GenerateMipMaps(bool bGenMipmap)
{
//m_pddNewTexture<72>̳ѿ<CCB3> <20>Ӹ<EFBFBD><D3B8><EFBFBD> <20><> <20>ؽ<EFBFBD><D8BD>İ<EFBFBD> <20><><EFBFBD>
D3DFORMAT fmt;
D3DSURFACE_DESC sd;
((LPDIRECT3DTEXTURE8)m_pddTexture)->GetLevelDesc(0, &sd);
fmt = sd.Format;
if(bGenMipmap)
m_pd3dDevice->CreateTexture(m_dwWidth,m_dwHeight,0,0,fmt,D3DPOOL_MANAGED,&m_pddNewTexture);
else
m_pd3dDevice->CreateTexture(m_dwWidth,m_dwHeight,1,0,fmt,D3DPOOL_MANAGED,&m_pddNewTexture);
LPDIRECT3DSURFACE8 pSurfaceSrc,pSurfaceDest;
((LPDIRECT3DTEXTURE8)m_pddNewTexture)->GetSurfaceLevel(0,&pSurfaceDest);
((LPDIRECT3DTEXTURE8)m_pddTexture)->GetSurfaceLevel(0,&pSurfaceSrc);
D3DXLoadSurfaceFromSurface(pSurfaceDest, NULL, NULL, pSurfaceSrc, NULL, NULL, D3DX_FILTER_TRIANGLE, 0);
pSurfaceSrc->Release();
pSurfaceDest->Release();
if(bGenMipmap)
D3DXFilterTexture(m_pddNewTexture, NULL, 0, D3DX_FILTER_TRIANGLE);
/*
D3DXFilterTexture(pmiptexNew, NULL, 0, D3DX_FILTER_TRIANGLE);
D3DXFilterTexture(m_pddNewTexture, NULL, 0, D3DX_FILTER_TRIANGLE);
m_ptexOrig = pmiptexNew;
if (m_ptexNew != NULL)
{
D3DSURFACE_DESC sd;
((LPDIRECT3DCUBETEXTURE8)m_ptexNew)->GetLevelDesc(0, &sd);
fmt = sd.Format;
Compress(fmt);
}
return;
*/
}
void CConvertTexture::SaveDDS(char *strFilename)
{
FILE *fp=fopen(strFilename,"wb");
DWORD dwMagic;
dwMagic=MAKEFOURCC('D','D','S',' ');
//dwMagic=0xffffffff;
fwrite(&dwMagic,sizeof(dwMagic),1,fp);
DDS_HEADER ddsh={sizeof(DDS_HEADER),};
ddsh.dwHeaderFlags=DDS_HEADER_FLAGS_TEXTURE;
ddsh.dwWidth=m_dwWidth;
ddsh.dwHeight=m_dwHeight;
ddsh.dwSurfaceFlags=DDS_SURFACE_FLAGS_TEXTURE;
int nMips=m_pddNewTexture->GetLevelCount();
if(nMips>1)
{
ddsh.dwHeaderFlags|=DDS_HEADER_FLAGS_MIPMAP;
ddsh.dwSurfaceFlags|=DDS_SURFACE_FLAGS_MIPMAP;
ddsh.dwMipMapCount=nMips;
}
D3DSURFACE_DESC sd;
D3DFORMAT fmt;
DWORD dwSize;
DWORD dwPitch = 0;
D3DLOCKED_RECT lr;
m_pddNewTexture->GetLevelDesc(0,&sd);
fmt=sd.Format;
dwSize=sd.Size;
m_pddNewTexture->LockRect(0,&lr,NULL,D3DLOCK_READONLY);
dwPitch=lr.Pitch;
m_pddNewTexture->UnlockRect(NULL);
switch (fmt)
{
case D3DFMT_DXT1:
ddsh.ddspf = DDSPF_DXT1;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
ddsh.dwPitchOrLinearSize = dwSize;
break;
case D3DFMT_DXT2:
ddsh.ddspf = DDSPF_DXT2;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
ddsh.dwPitchOrLinearSize = dwSize;
break;
case D3DFMT_DXT3:
ddsh.ddspf = DDSPF_DXT3;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
ddsh.dwPitchOrLinearSize = dwSize;
break;
case D3DFMT_DXT4:
ddsh.ddspf = DDSPF_DXT4;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
ddsh.dwPitchOrLinearSize = dwSize;
break;
case D3DFMT_DXT5:
ddsh.ddspf = DDSPF_DXT5;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
ddsh.dwPitchOrLinearSize = dwSize;
break;
case D3DFMT_A8R8G8B8:
ddsh.ddspf = DDSPF_A8R8G8B8;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
ddsh.dwPitchOrLinearSize = dwPitch;
break;
case D3DFMT_A1R5G5B5:
ddsh.ddspf = DDSPF_A1R5G5B5;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
ddsh.dwPitchOrLinearSize = dwPitch;
break;
case D3DFMT_A4R4G4B4:
ddsh.ddspf = DDSPF_A4R4G4B4;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
ddsh.dwPitchOrLinearSize = dwPitch;
break;
case D3DFMT_R8G8B8:
ddsh.ddspf = DDSPF_R8G8B8;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
ddsh.dwPitchOrLinearSize = dwPitch;
break;
case D3DFMT_R5G6B5:
ddsh.ddspf = DDSPF_R5G6B5;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
ddsh.dwPitchOrLinearSize = dwPitch;
break;
default:
return;
}
fwrite(&ddsh,sizeof(ddsh),1,fp);
LPDIRECT3DSURFACE8 pSurface;
for(int cLevel=0;cLevel<nMips;cLevel++)
{
if(FAILED(m_pddNewTexture->GetSurfaceLevel(cLevel,&pSurface)))
{
break;
}
pSurface->GetDesc(&sd);
pSurface->Release();
if(FAILED(m_pddNewTexture->LockRect(cLevel,&lr,NULL,0)))
{
break;
}
if (sd.Format == D3DFMT_DXT1 ||
sd.Format == D3DFMT_DXT2 ||
sd.Format == D3DFMT_DXT3 ||
sd.Format == D3DFMT_DXT4 ||
sd.Format == D3DFMT_DXT5)
{
fwrite(lr.pBits,sd.Size,1,fp);
}
else
{
WORD yp;
BYTE *pbDest=(BYTE*)lr.pBits;
LONG dataBytesPerRow=0;
if(sd.Format==D3DFMT_A8R8G8B8)
dataBytesPerRow=4*sd.Width;
else if(sd.Format==D3DFMT_R8G8B8)
dataBytesPerRow=3*sd.Width;
else
dataBytesPerRow=2*sd.Width;
for(yp=0;yp<sd.Height;yp++)
{
fwrite(pbDest,dataBytesPerRow,1,fp);
pbDest+=lr.Pitch;
}
}
m_pddNewTexture->UnlockRect(cLevel);
}
fclose(fp);
}
void CConvertTexture::SaveDDS(char *strFilename, int LowerSave,int MaxTextureSize)
{
FILE *fp=fopen(strFilename,"wb");
DWORD dwMagic;
dwMagic=MAKEFOURCC('D','D','S',' ');
fwrite(&dwMagic,sizeof(dwMagic),1,fp);
DDS_HEADER ddsh={sizeof(DDS_HEADER),};
ddsh.dwHeaderFlags=DDS_HEADER_FLAGS_TEXTURE;
ddsh.dwWidth=m_dwWidth/(int)pow(2,LowerSave);
ddsh.dwHeight=m_dwHeight/(int)pow(2,LowerSave);
long NowTextureSize=ddsh.dwWidth>=ddsh.dwHeight ? ddsh.dwWidth:ddsh.dwHeight;
while(NowTextureSize > MaxTextureSize)
{
LowerSave++;
ddsh.dwWidth=m_dwWidth/(int)pow(2,LowerSave);
ddsh.dwHeight=m_dwHeight/(int)pow(2,LowerSave);
NowTextureSize=ddsh.dwWidth>=ddsh.dwHeight ? ddsh.dwWidth:ddsh.dwHeight;
}
ddsh.dwSurfaceFlags=DDS_SURFACE_FLAGS_TEXTURE;
int nMips=m_pddNewTexture->GetLevelCount();
nMips-=LowerSave;
if(nMips>1)
{
ddsh.dwHeaderFlags|=DDS_HEADER_FLAGS_MIPMAP;
ddsh.dwSurfaceFlags|=DDS_SURFACE_FLAGS_MIPMAP;
ddsh.dwMipMapCount=nMips;
}
D3DSURFACE_DESC sd;
D3DFORMAT fmt;
DWORD dwSize;
DWORD dwPitch = 0;
D3DLOCKED_RECT lr;
m_pddNewTexture->GetLevelDesc(LowerSave,&sd);
fmt=sd.Format;
dwSize=sd.Size;
m_pddNewTexture->LockRect(LowerSave,&lr,NULL,D3DLOCK_READONLY);
dwPitch=lr.Pitch;
m_pddNewTexture->UnlockRect(LowerSave);
switch (fmt)
{
case D3DFMT_DXT1:
ddsh.ddspf = DDSPF_DXT1;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
ddsh.dwPitchOrLinearSize = dwSize;
break;
case D3DFMT_DXT2:
ddsh.ddspf = DDSPF_DXT2;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
ddsh.dwPitchOrLinearSize = dwSize;
break;
case D3DFMT_DXT3:
ddsh.ddspf = DDSPF_DXT3;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
ddsh.dwPitchOrLinearSize = dwSize;
break;
case D3DFMT_DXT4:
ddsh.ddspf = DDSPF_DXT4;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
ddsh.dwPitchOrLinearSize = dwSize;
break;
case D3DFMT_DXT5:
ddsh.ddspf = DDSPF_DXT5;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
ddsh.dwPitchOrLinearSize = dwSize;
break;
case D3DFMT_A8R8G8B8:
ddsh.ddspf = DDSPF_A8R8G8B8;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
ddsh.dwPitchOrLinearSize = dwPitch;
break;
case D3DFMT_A1R5G5B5:
ddsh.ddspf = DDSPF_A1R5G5B5;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
ddsh.dwPitchOrLinearSize = dwPitch;
break;
case D3DFMT_A4R4G4B4:
ddsh.ddspf = DDSPF_A4R4G4B4;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
ddsh.dwPitchOrLinearSize = dwPitch;
break;
case D3DFMT_R8G8B8:
ddsh.ddspf = DDSPF_R8G8B8;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
ddsh.dwPitchOrLinearSize = dwPitch;
break;
case D3DFMT_R5G6B5:
ddsh.ddspf = DDSPF_R5G6B5;
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
ddsh.dwPitchOrLinearSize = dwPitch;
break;
default:
return;
}
fwrite(&ddsh,sizeof(ddsh),1,fp);
LPDIRECT3DSURFACE8 pSurface;
for(int cLevel=0;cLevel<nMips;cLevel++)
{
if(FAILED(m_pddNewTexture->GetSurfaceLevel(cLevel+LowerSave,&pSurface)))
{
break;
}
pSurface->GetDesc(&sd);
pSurface->Release();
if(FAILED(m_pddNewTexture->LockRect(cLevel+LowerSave,&lr,NULL,0)))
{
break;
}
if (sd.Format == D3DFMT_DXT1 ||
sd.Format == D3DFMT_DXT2 ||
sd.Format == D3DFMT_DXT3 ||
sd.Format == D3DFMT_DXT4 ||
sd.Format == D3DFMT_DXT5)
{
fwrite(lr.pBits,sd.Size,1,fp);
}
else
{
WORD yp;
BYTE *pbDest=(BYTE*)lr.pBits;
LONG dataBytesPerRow=0;
if(sd.Format==D3DFMT_A8R8G8B8)
dataBytesPerRow=4*sd.Width;
else if(sd.Format==D3DFMT_R8G8B8)
dataBytesPerRow=3*sd.Width;
else
dataBytesPerRow=2*sd.Width;
for(yp=0;yp<sd.Height;yp++)
{
fwrite(pbDest,dataBytesPerRow,1,fp);
pbDest+=lr.Pitch;
}
}
m_pddNewTexture->UnlockRect(cLevel+LowerSave);
}
fclose(fp);
}

View File

@@ -0,0 +1,28 @@
// ConvertTexture.h: interface for the CConvertTexture class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CONVERTTEXTURE_H__CA884184_2931_4713_89E5_356F999EF196__INCLUDED_)
#define AFX_CONVERTTEXTURE_H__CA884184_2931_4713_89E5_356F999EF196__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Texture.h"
class CConvertTexture : public CTexture
{
public:
void SaveDDS(char *strFilename,int LowerSave,int MaxTextureSize);
LPDIRECT3DTEXTURE8 m_pddNewTexture;
void SaveDDS(char *strFilename);
void GenerateMipMaps(bool bGenMipmap);
void Compress(D3DFORMAT fmtTo);
int GetMipmapCount(){return m_pddTexture->GetLevelCount();};
CConvertTexture();
virtual ~CConvertTexture();
};
#endif // !defined(AFX_CONVERTTEXTURE_H__CA884184_2931_4713_89E5_356F999EF196__INCLUDED_)

View File

@@ -0,0 +1,245 @@
// DeviceInput.cpp: implementation of the CDeviceInput class.
//
//////////////////////////////////////////////////////////////////////
#include "DeviceInput.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LPDIRECTINPUT8 CDeviceInput::m_pDI;
LPDIRECTINPUTDEVICE8 CDeviceInput::m_pMouse;
LPDIRECTINPUTDEVICE8 CDeviceInput::m_pKeyboard;
bool CDeviceInput::m_MouseButton[3];
POINT CDeviceInput::m_MousePos;
bool CDeviceInput::m_isMouseMove;
POINT CDeviceInput::m_MouseMovePos;
bool CDeviceInput::m_isLeftMouseClick;
bool CDeviceInput::m_isRightMouseClick;
bool CDeviceInput::m_isLeftMouseDown;
bool CDeviceInput::m_isRightMouseDown;
bool CDeviceInput::m_isLeftMousePress;
bool CDeviceInput::m_isRightMousePress;
bool CDeviceInput::m_isRightMouseUp;
bool CDeviceInput::m_isMidMousePress;
float CDeviceInput::m_MouseSpeed;
int CDeviceInput::m_MouseZPos;
RECT CDeviceInput::m_rcMouseMove;
char CDeviceInput::m_aryKeyState[256];
char CDeviceInput::m_aryKeyOldState[256];
CDeviceInput::CDeviceInput()
{
m_pDI=NULL;
m_pMouse=NULL;
m_pKeyboard = NULL;
m_MouseButton[0]=false;
m_MouseButton[1]=false;
m_MouseButton[2]=false;
m_MousePos.x=0;
m_MousePos.y=0;
m_MouseZPos=0;
m_MouseMovePos.x=0;
m_MouseMovePos.y=0;
m_isLeftMouseClick=m_isRightMouseClick=false;
m_isLeftMouseDown=m_isRightMouseDown=false;
m_isLeftMousePress=m_isRightMousePress=false;
m_isRightMouseUp=false;
m_isMouseMove=false;
m_MouseSpeed=2.0f;
SetRect(&m_rcMouseMove,0,0,800-16,600-16);
memset(m_aryKeyState, 0, 256);
memset(m_aryKeyOldState, 0, 256);
}
CDeviceInput::~CDeviceInput()
{
if(m_pKeyboard)
m_pKeyboard->Release();
if(m_pMouse)
m_pMouse->Release();
if(m_pDI)
m_pDI->Release();
}
void CDeviceInput::Create(HWND hWnd)
{
HRESULT hr;
if( FAILED(DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION,
IID_IDirectInput8, (VOID**)&m_pDI, NULL ) ) )
{
}
// Obtain an interface to the system keyboard device.
if( FAILED(m_pDI->CreateDevice( GUID_SysKeyboard, &m_pKeyboard, NULL ) ) )
{
}
if( FAILED( hr = m_pKeyboard->SetDataFormat( &c_dfDIKeyboard ) ) )
{
}
if(FAILED(m_pKeyboard->SetCooperativeLevel( hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND )))
{
}
m_pKeyboard->Acquire();
// Obtain an interface to the system mouse device.
if( FAILED(m_pDI->CreateDevice( GUID_SysMouse, &m_pMouse, NULL ) ) )
{
}
if( FAILED( hr = m_pMouse->SetDataFormat( &c_dfDIMouse2 ) ) )
{
}
m_pMouse->SetCooperativeLevel(hWnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND);
m_pMouse->Acquire();
/*
if(FAILED(DirectInputCreate( (HINSTANCE)GetWindowLong( hWnd, GWL_HINSTANCE ),
DIRECTINPUT_VERSION, &m_pDI, NULL )))
{
throw CDeviceInputError("CDeviceInput:Create , Create DirectInput Error");
}
if(FAILED(m_pDI->CreateDevice( GUID_SysKeyboard, &m_pKeyboard, NULL )))
{
throw CDeviceInputError("CDeviceInput:Create , cannot Get a KeyboardDevice");
}
if(FAILED(m_pKeyboard->SetDataFormat( &c_dfDIKeyboard )))
{
throw CDeviceInputError("CDeviceInput:Create , Setting DataFormat failed");
}
if(FAILED(m_pKeyboard->SetCooperativeLevel( hWnd,DISCL_EXCLUSIVE | DISCL_FOREGROUND )))
{
throw CDeviceInputError("CDeviceInput:Create ,SetCooperativeLevel is failed");
}
*/
}
void CDeviceInput::Acquire()
{
if(m_pKeyboard)
m_pKeyboard->Acquire();
if(m_pMouse)
m_pMouse->Acquire();
}
void CDeviceInput::UnAcquire()
{
}
void CDeviceInput::UpdateInput()
{
HRESULT hr;
memcpy(m_aryKeyOldState, m_aryKeyState, 256);
hr = m_pKeyboard->GetDeviceState(256, (void *)&m_aryKeyState);
if(FAILED(hr))
{
memcpy(m_aryKeyState, m_aryKeyOldState, 256);
return;
}
DIMOUSESTATE2 dims2; // DirectInput mouse state structure
ZeroMemory( &dims2, sizeof(dims2) );
hr = m_pMouse->GetDeviceState( sizeof(DIMOUSESTATE2), &dims2 );
if( FAILED(hr) )
{
m_MouseMovePos.x=0;
m_MouseMovePos.y=0;
m_MouseZPos=0;
m_MouseButton[0]=false;
m_MouseButton[1]=false;
m_MouseButton[2]=false;
return;
}
m_MouseMovePos.x=dims2.lX;
m_MouseMovePos.y=dims2.lY;
m_MouseZPos=dims2.lZ;
bool oldMouseButton[3];
oldMouseButton[0]=m_MouseButton[0];
oldMouseButton[1]=m_MouseButton[1];
oldMouseButton[2]=m_MouseButton[2];
m_MouseButton[0]=(dims2.rgbButtons[0] & 0x80) ? true : false;
m_MouseButton[1]=(dims2.rgbButtons[1] & 0x80) ? true : false;
m_MouseButton[2]=(dims2.rgbButtons[2] & 0x80) ? true : false;
if(m_isMouseMove)
{
m_MousePos.x+=(int)(m_MouseMovePos.x*m_MouseSpeed);
m_MousePos.y+=(int)(m_MouseMovePos.y*m_MouseSpeed);
if(m_MousePos.x<=m_rcMouseMove.left)
m_MousePos.x=m_rcMouseMove.left;
if(m_MousePos.y<=m_rcMouseMove.top)
m_MousePos.y=m_rcMouseMove.top;
if(m_MousePos.x>=m_rcMouseMove.right)
m_MousePos.x=m_rcMouseMove.right;
if(m_MousePos.y>=m_rcMouseMove.bottom)
m_MousePos.y=m_rcMouseMove.bottom;
}
if(oldMouseButton[0]==true && m_MouseButton[0]==false)
m_isLeftMouseClick=true;
else
m_isLeftMouseClick=false;
if(oldMouseButton[1]==true && m_MouseButton[1]==false)
m_isRightMouseClick=true;
else
m_isRightMouseClick=false;
if(oldMouseButton[0]==false && m_MouseButton[0]==true)
m_isLeftMouseDown=true;
else
m_isLeftMouseDown=false;
if(oldMouseButton[1]==false && m_MouseButton[1]==true)
m_isRightMouseDown=true;
else
m_isRightMouseDown=false;
if(oldMouseButton[1]==true && m_MouseButton[1]==false)
m_isRightMouseUp=true;
else
m_isRightMouseUp=false;
if(m_MouseButton[0]==true)
m_isLeftMousePress=true;
else
m_isLeftMousePress=false;
if(m_MouseButton[1]==true)
m_isRightMousePress=true;
else
m_isRightMousePress=false;
if(m_MouseButton[2]==true)
m_isMidMousePress=true;
else
m_isMidMousePress=false;
}

View File

@@ -0,0 +1,75 @@
// DeviceInput.h: interface for the CDeviceInput class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DEVICEINPUT_H__70A5C6C2_40AB_4919_9E57_25A08751068F__INCLUDED_)
#define AFX_DEVICEINPUT_H__70A5C6C2_40AB_4919_9E57_25A08751068F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define DIRECTINPUT_VERSION 0x800
#include <dinput.h>
#include "Exception.h"
class CDeviceInput
{
static LPDIRECTINPUT8 m_pDI;
static LPDIRECTINPUTDEVICE8 m_pMouse;
static LPDIRECTINPUTDEVICE8 m_pKeyboard;
static bool m_MouseButton[3];
static POINT m_MousePos;
static int m_MouseZPos;
static bool m_isMouseMove;
static POINT m_MouseMovePos;
static bool m_isLeftMouseClick,m_isRightMouseClick;
static bool m_isLeftMouseDown,m_isRightMouseDown;
static bool m_isLeftMousePress,m_isRightMousePress;
static bool m_isRightMouseUp;
static bool m_isMidMousePress;
static float m_MouseSpeed;
static RECT m_rcMouseMove;
static char m_aryKeyState[256];
static char m_aryKeyOldState[256];
public:
void UpdateInput();
static bool GetIsMousePos(){return m_isMouseMove;};
static void SetIsMousePos(bool isMouseMove){m_isMouseMove=isMouseMove;};
static bool GetIsLeftMouseClick(){return m_isLeftMouseClick;};
static bool GetIsRightMouseClick(){return m_isRightMouseClick;};
static bool GetIsLeftMouseDown(){return m_isLeftMouseDown;};
static bool GetIsRightMouseDown(){return m_isRightMouseDown;};
static bool GetIsLeftMousePress(){return m_isLeftMousePress;};
static bool GetIsRightMousePress(){return m_isRightMousePress;};
static bool GetIsMidMousePress(){return m_isMidMousePress;};
static bool GetIsRightMouseUp(){return m_isRightMouseUp;};
static void Fake_LeftMouseDown(){ m_isLeftMouseDown=true; };
static POINT GetMousePosition(){return m_MousePos;};
static void SetMousePosition(POINT pt){m_MousePos=pt;};
static POINT GetMouseMove(){return m_MouseMovePos;};
static int GetMouseZMove(){return m_MouseZPos;};
static BOOL KeyDown(int KeyCode) { if((m_aryKeyState[KeyCode] & 0x80) && !(m_aryKeyOldState[KeyCode] & 0x80)) return TRUE; else return FALSE; }
static BOOL KeyHold(int KeyCode) { if(m_aryKeyState[KeyCode] & 0x80) return TRUE; else return FALSE; }
static BOOL KeyUp(int KeyCode) { if(!(m_aryKeyState[KeyCode] & 0x80) && (m_aryKeyOldState[KeyCode] & 0x80)) return TRUE; else return FALSE; }
static void InitKey(int KeyCode) { m_aryKeyState[KeyCode] = 0; m_aryKeyOldState[KeyCode] = 0; }
static void UnAcquire();
static void Acquire();
static void Create(HWND hWnd);
CDeviceInput();
virtual ~CDeviceInput();
};
#endif // !defined(AFX_DEVICEINPUT_H__70A5C6C2_40AB_4919_9E57_25A08751068F__INCLUDED_)

View File

@@ -0,0 +1,19 @@
// DeviceInputError.cpp: implementation of the CDeviceInputError class.
//
//////////////////////////////////////////////////////////////////////
#include "DeviceInputError.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDeviceInputError::CDeviceInputError()
{
}
CDeviceInputError::~CDeviceInputError()
{
}

View File

@@ -0,0 +1,35 @@
// DeviceInputError.h: interface for the CDeviceInputError class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DEVICEINPUTERROR_H__1F661071_76D1_4712_8943_137EA762B1DD__INCLUDED_)
#define AFX_DEVICEINPUTERROR_H__1F661071_76D1_4712_8943_137EA762B1DD__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Error.h"
class CDeviceInputError : public CError
{
public:
CDeviceInputError();
CDeviceInputError(char *msg)
{
SetErrorMsg(msg);
}
char *GetErrorMsg()
{
char msgtemp[MAX_ERRORBUFFER];
strcpy(msgtemp,"Device Input Error:");
strcat(msgtemp,m_strErrormsg);
strcpy(m_strErrormsg,msgtemp);
return m_strErrormsg;
};
virtual ~CDeviceInputError();
};
#endif // !defined(AFX_DEVICEINPUTERROR_H__1F661071_76D1_4712_8943_137EA762B1DD__INCLUDED_)

View File

@@ -0,0 +1,566 @@
// EnumD3D.cpp: implementation of the CEnumD3D class.
//
//////////////////////////////////////////////////////////////////////
#include "EnumD3D.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
D3DAdapterInfo CEnumD3D::m_Adapters[10];
DWORD CEnumD3D::m_dwNumAdapters;
DWORD CEnumD3D::m_dwAdapter;
BOOL CEnumD3D::m_bWindowed;
LPDIRECT3D8 CEnumD3D::m_pD3D;
BOOL CEnumD3D::m_bUseDepthBuffer;
long CEnumD3D::m_dwMinDepthBits;
long CEnumD3D::m_dwMinStencilBits;
long CEnumD3D::m_nAdapter;
long CEnumD3D::m_nDevice;
long CEnumD3D::m_nMode;
int SortModesCallback( const VOID* arg1, const VOID* arg2 )
{
D3DDISPLAYMODE* p1 = (D3DDISPLAYMODE*)arg1;
D3DDISPLAYMODE* p2 = (D3DDISPLAYMODE*)arg2;
if( p1->Format > p2->Format ) return -1;
if( p1->Format < p2->Format ) return +1;
if( p1->Width < p2->Width ) return -1;
if( p1->Width > p2->Width ) return +1;
if( p1->Height < p2->Height ) return -1;
if( p1->Height > p2->Height ) return +1;
return 0;
}
CEnumD3D::CEnumD3D()
{
m_bUseDepthBuffer=true;
m_nAdapter=m_nDevice=m_nMode=0;
}
CEnumD3D::~CEnumD3D()
{
}
HRESULT CEnumD3D::Enum()
{
/*
const TCHAR* strDeviceDescs[] = { "HAL", "REF" };
const D3DDEVTYPE DeviceTypes[] = { D3DDEVTYPE_HAL, D3DDEVTYPE_REF };
LPDIRECT3D8 pd3d=Direct3DCreate8(D3D_SDK_VERSION);
List<D3DAdapterInfo> m_AdapterInfo;
const int cDeviceTypes=2;
for(int cAdapter=0;cAdapter<pd3d->GetAdapterCount();cAdapter++)
{
D3DAdapterInfo AddAdapter;
pd3d->GetAdapterIdentifier(cAdapter,0,&AddAdapter.d3dAdapterIdentifier);
pd3d->GetAdapterDisplayMode(cAdapter,&AddAdapter.d3ddmDesktop);
AddAdapter.dwCurrentDevice=0;
AddAdapter.dwNumDevices=0;
List<D3DDISPLAYMODE> ModeList;
List<D3DFORMAT> PixelFormatList;
int cTotalMode=pd3d->GetAdapterModeCount(cAdapter);
for(int cMode=0;cMode<cTotalMode;cMode++)
{
D3DDISPLAYMODE DisplayMode;
pd3d->EnumAdapterModes(cAdapter,cMode,&DisplayMode);
if(DisplayMode.Width < 640 || DisplayMode.Height<400)
continue;
for(int cAlreadyMode=0;cAlreadyMode<ModeList.num;cAlreadyMode)
{
if( ModeList[cAlreadyMode].Width == DisplayMode.Width &&
ModeList[cAlreadyMode].Height == DisplayMode.Height &&
ModeList[cAlreadyMode].Format == DisplayMode.Format)
{
break;
}
}
if(cAlreadyMode==ModeList.num)
{
ModeList.Add(DisplayMode);
PixelFormatList.AddUnique(DisplayMode.Format);
}
}
for(int cDevice=0;cDevice<2;cDevice++)
{
D3DDeviceInfo AddDevice;
AddDevice.DeviceType=DeviceTypes[cDevice];
pd3d->GetDeviceCaps(cAdapter,DeviceTypes[cDevice],&AddDevice.d3dCaps);
AddDevice.strDesc=strDeviceDescs[cDevice];
AddDevice.dwNumModes=0;
AddDevice.dwCurrentMode=0;
AddDevice.bCanDoWindowed=FALSE;
AddDevice.bWindowed=FALSE;
AddDevice.MultiSampleType=D3DMULTISAMPLE_NONE;
BOOL bFormatConfirmed[20];
DWORD dwBehavior[20];
D3DFORMAT fmtDepthStencil[20];
for(int cFormat=0;cFormat<PixelFormatList.num;cFormat++)
{
bFormatConfirmed[cFormat]=FALSE;
fmtDepthStencil[cFormat]=D3DFMT_UNKNOWN;
if(FAILED( pd3d->CheckDeviceType( cAdapter, AddDevice.DeviceType,PixelFormatList[cFormat],PixelFormatList[cFormat],FALSE)))
{
continue;
}
if(AddDevice.DeviceType=D3DDEVTYPE_HAL)
{
// 3D ī<><C4AB><EFBFBD><EFBFBD> <20>޷<EFBFBD><DEB7>ְ<EFBFBD>//
}
if( AddDevice.d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
{
if( AddDevice.d3dCaps.DevCaps & D3DDEVCAPS_PUREDEVICE)
{
dwBehavior[cFormat]=D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE;
// Confirmed is true when ConfirmDevice's Return value Succeeded//
bFormatConfirmed[cFormat]=TRUE;
}
if(bFormatConfirmed[cFormat]==FALSE)
{
dwBehavior[cFormat]=D3DCREATE_HARDWARE_VERTEXPROCESSING;
// Confirmed is true when ConfirmDevice's Return value Succeeded//
bFormatConfirmed[cFormat]=TRUE;
}
if(bFormatConfirmed[cFormat]==FALSE)
{
dwBehavior[cFormat]=D3DCREATE_MIXED_VERTEXPROCESSING;
// Confirmed is true when ConfirmDevice's Return value Succeeded//
bFormatConfirmed[cFormat]=TRUE;
}
}
if(bFormatConfirmed[cFormat]==FALSE)
{
dwBehavior[cFormat]=D3DCREATE_SOFTWARE_VERTEXPROCESSING;
// Confirmed is true when ConfirmDevice's Return value Succeeded//
bFormatConfirmed[cFormat]=TRUE;
}
if( bFormatConfirmed[cFormat] && m_bUseDepthBuffer)
{
if(!FindDepthStencilFormat(cAdapter,AddDevice.DeviceType,PixelFormatList[cFormat],&fmtDepthStencil[cFormat]))
{
bFormatConfirmed[cFormat]=FALSE;
}
}
}
for(int cMode=0;cMode<ModeList.num;cMode++)
{
for(int cFormat=0;cFormat<PixelFormatList.num;cFormat++)
{
if( ModeList[cMode].Format == PixelFormatList[cFormat] )
{
if(bFormatConfirmed[cFormat]==TRUE)
{
AddDevice.modes[AddDevice.dwNumModes].Width=ModeList[cMode].Width;
AddDevice.modes[AddDevice.dwNumModes].Height=ModeList[cMode].Height;
AddDevice.modes[AddDevice.dwNumModes].Format=ModeList[cMode].Format;
AddDevice.modes[AddDevice.dwNumModes].dwBehavior=dwBehavior[cFormat];
AddDevice.modes[AddDevice.dwNumModes].DepthStencilFormat=fmtDepthStencil[cFormat];
AddDevice.dwNumModes++;
}
}
}
}
for(cMode=0;cMode<AddDevice.dwNumModes;cMode++)
{
if(AddDevice.modes[cMode].Width==640 && AddDevice.modes[cMode].Height==480)
{
AddDevice.dwCurrentMode=cMode;
if( AddDevice.modes[cMode].Format==D3DFMT_R5G6B5||
AddDevice.modes[cMode].Format==D3DFMT_X1R5G5B5||
AddDevice.modes[cMode].Format==D3DFMT_A1R5G5B5)
{
break;
}
}
}
if( bFormatConfirmed[0] && (AddDevice.d3dCaps.Caps2 & D3DCAPS2_CANRENDERWINDOWED) )
{
AddDevice.bCanDoWindowed = TRUE;
AddDevice.bWindowed = TRUE;
}
if( AddDevice.dwNumModes > 0 )
AddAdapter.dwNumDevices++;
}
m_AdapterInfo.Add(AddAdapter);
}
return S_OK;
*/
m_pD3D=Direct3DCreate8(D3D_SDK_VERSION);
const DWORD dwNumDeviceTypes = 2;
const TCHAR* strDeviceDescs[] = { "HAL", "REF" };
const D3DDEVTYPE DeviceTypes[] = { D3DDEVTYPE_HAL, D3DDEVTYPE_REF };
BOOL bHALExists = FALSE;
BOOL bHALIsWindowedCompatible = FALSE;
BOOL bHALIsDesktopCompatible = FALSE;
BOOL bHALIsSampleCompatible = FALSE;
// Loop through all the adapters on the system (usually, there's just one
// unless more than one graphics card is present).
m_dwNumAdapters=0;
for( UINT iAdapter = 0; iAdapter < m_pD3D->GetAdapterCount(); iAdapter++ )
{
// Fill in adapter info
D3DAdapterInfo* pAdapter = &m_Adapters[m_dwNumAdapters];
m_pD3D->GetAdapterIdentifier( iAdapter, 0, &pAdapter->d3dAdapterIdentifier );
m_pD3D->GetAdapterDisplayMode( iAdapter, &pAdapter->d3ddmDesktop );
pAdapter->dwNumDevices = 0;
pAdapter->dwCurrentDevice = 0;
// Enumerate all display modes on this adapter
D3DDISPLAYMODE modes[100];
D3DFORMAT formats[20];
DWORD dwNumFormats = 0;
DWORD dwNumModes = 0;
DWORD dwNumAdapterModes = m_pD3D->GetAdapterModeCount( iAdapter );
// Add the adapter's current desktop format to the list of formats
formats[dwNumFormats++] = pAdapter->d3ddmDesktop.Format;
for( UINT iMode = 0; iMode < dwNumAdapterModes; iMode++ )
{
// Get the display mode attributes
D3DDISPLAYMODE DisplayMode;
m_pD3D->EnumAdapterModes( iAdapter, iMode, &DisplayMode );
// Filter out low-resolution modes
if( DisplayMode.Width < 640 || DisplayMode.Height < 400 )
continue;
// Check if the mode already exists (to filter out refresh rates)
for( DWORD m=0L; m<dwNumModes; m++ )
{
if( ( modes[m].Width == DisplayMode.Width ) &&
( modes[m].Height == DisplayMode.Height ) &&
( modes[m].Format == DisplayMode.Format ) )
break;
}
// If we found a new mode, add it to the list of modes
if( m == dwNumModes )
{
modes[dwNumModes].Width = DisplayMode.Width;
modes[dwNumModes].Height = DisplayMode.Height;
modes[dwNumModes].Format = DisplayMode.Format;
modes[dwNumModes].RefreshRate = 0;
dwNumModes++;
// Check if the mode's format already exists
for( DWORD f=0; f<dwNumFormats; f++ )
{
if( DisplayMode.Format == formats[f] )
break;
}
// If the format is new, add it to the list
if( f== dwNumFormats )
formats[dwNumFormats++] = DisplayMode.Format;
}
}
// Sort the list of display modes (by format, then width, then height)
qsort( modes, dwNumModes, sizeof(D3DDISPLAYMODE), SortModesCallback );
// Add devices to adapter
for( UINT iDevice = 0; iDevice < dwNumDeviceTypes; iDevice++ )
{
// Fill in device info
D3DDeviceInfo* pDevice;
pDevice = &pAdapter->devices[pAdapter->dwNumDevices];
pDevice->DeviceType = DeviceTypes[iDevice];
m_pD3D->GetDeviceCaps( iAdapter, DeviceTypes[iDevice], &pDevice->d3dCaps );
pDevice->strDesc = strDeviceDescs[iDevice];
pDevice->dwNumModes = 0;
pDevice->dwCurrentMode = 0;
pDevice->bCanDoWindowed = FALSE;
pDevice->bWindowed = FALSE;
pDevice->MultiSampleType = D3DMULTISAMPLE_NONE;
// Examine each format supported by the adapter to see if it will
// work with this device and meets the needs of the application.
BOOL bFormatConfirmed[20];
DWORD dwBehavior[20];
D3DFORMAT fmtDepthStencil[20];
for( DWORD f=0; f<dwNumFormats; f++ )
{
bFormatConfirmed[f] = FALSE;
fmtDepthStencil[f] = D3DFMT_UNKNOWN;
// Skip formats that cannot be used as render targets on this device
if( FAILED( m_pD3D->CheckDeviceType( iAdapter, pDevice->DeviceType,
formats[f], formats[f], FALSE ) ) )
continue;
if( pDevice->DeviceType == D3DDEVTYPE_HAL )
{
// This system has a HAL device
bHALExists = TRUE;
if( pDevice->d3dCaps.Caps2 & D3DCAPS2_CANRENDERWINDOWED )
{
// HAL can run in a window for some mode
bHALIsWindowedCompatible = TRUE;
if( f == 0 )
{
// HAL can run in a window for the current desktop mode
bHALIsDesktopCompatible = TRUE;
}
}
}
// Confirm the device/format for HW vertex processing
if( pDevice->d3dCaps.DevCaps&D3DDEVCAPS_HWTRANSFORMANDLIGHT )
{
if( pDevice->d3dCaps.DevCaps&D3DDEVCAPS_PUREDEVICE )
{
/*
dwBehavior[f] = D3DCREATE_HARDWARE_VERTEXPROCESSING |
D3DCREATE_PUREDEVICE;
*/
dwBehavior[f] = D3DCREATE_HARDWARE_VERTEXPROCESSING;
if( SUCCEEDED( ConfirmDevice( &pDevice->d3dCaps, dwBehavior[f],
formats[f] ) ) )
bFormatConfirmed[f] = FALSE;
}
if ( FALSE == bFormatConfirmed[f] )
{
dwBehavior[f] = D3DCREATE_HARDWARE_VERTEXPROCESSING;
if( SUCCEEDED( ConfirmDevice( &pDevice->d3dCaps, dwBehavior[f],
formats[f] ) ) )
bFormatConfirmed[f] = TRUE;
}
if ( FALSE == bFormatConfirmed[f] )
{
dwBehavior[f] = D3DCREATE_MIXED_VERTEXPROCESSING;
if( SUCCEEDED( ConfirmDevice( &pDevice->d3dCaps, dwBehavior[f],
formats[f] ) ) )
bFormatConfirmed[f] = TRUE;
}
}
// Confirm the device/format for SW vertex processing
if( FALSE == bFormatConfirmed[f] )
{
dwBehavior[f] = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
if( SUCCEEDED( ConfirmDevice( &pDevice->d3dCaps, dwBehavior[f],
formats[f] ) ) )
bFormatConfirmed[f] = TRUE;
}
// Find a suitable depth/stencil buffer format for this device/format
if( bFormatConfirmed[f])
{
if( !FindDepthStencilFormat( iAdapter, pDevice->DeviceType,
formats[f], &fmtDepthStencil[f] ) )
{
bFormatConfirmed[f] = FALSE;
}
}
}
// Add all enumerated display modes with confirmed formats to the
// device's list of valid modes
for( DWORD m=0L; m<dwNumModes; m++ )
{
for( DWORD f=0; f<dwNumFormats; f++ )
{
if( modes[m].Format == formats[f] )
{
if( bFormatConfirmed[f] == TRUE )
{
// Add this mode to the device's list of valid modes
pDevice->modes[pDevice->dwNumModes].Width = modes[m].Width;
pDevice->modes[pDevice->dwNumModes].Height = modes[m].Height;
pDevice->modes[pDevice->dwNumModes].Format = modes[m].Format;
pDevice->modes[pDevice->dwNumModes].dwBehavior = dwBehavior[f];
pDevice->modes[pDevice->dwNumModes].DepthStencilFormat = fmtDepthStencil[f];
pDevice->dwNumModes++;
if( pDevice->DeviceType == D3DDEVTYPE_HAL )
bHALIsSampleCompatible = TRUE;
}
}
}
}
// Select any 640x480 mode for default (but prefer a 16-bit mode)
for( m=0; m<pDevice->dwNumModes; m++ )
{
if( pDevice->modes[m].Width==640 && pDevice->modes[m].Height==480 )
{
pDevice->dwCurrentMode = m;
if( pDevice->modes[m].Format == D3DFMT_R5G6B5 ||
pDevice->modes[m].Format == D3DFMT_X1R5G5B5 ||
pDevice->modes[m].Format == D3DFMT_A1R5G5B5 )
{
break;
}
}
}
// Check if the device is compatible with the desktop display mode
// (which was added initially as formats[0])
if( bFormatConfirmed[0] && (pDevice->d3dCaps.Caps2 & D3DCAPS2_CANRENDERWINDOWED) )
{
pDevice->bCanDoWindowed = TRUE;
pDevice->bWindowed = TRUE;
}
// If valid modes were found, keep this device
if( pDevice->dwNumModes > 0 )
pAdapter->dwNumDevices++;
}
// If valid devices were found, keep this adapter
if( pAdapter->dwNumDevices > 0 )
m_dwNumAdapters++;
}
// Return an error if no compatible devices were found
if( 0L == m_dwNumAdapters )
return S_OK;
// Pick a default device that can render into a window
// (This code assumes that the HAL device comes before the REF
// device in the device array).
m_pD3D->Release();
for( DWORD a=0; a<m_dwNumAdapters; a++ )
{
for( DWORD d=0; d < m_Adapters[a].dwNumDevices; d++ )
{
if( m_Adapters[a].devices[d].bWindowed )
{
m_Adapters[a].dwCurrentDevice = d;
m_dwAdapter = a;
m_bWindowed = TRUE;
return S_OK;
}
}
}
return S_OK;
}
BOOL CEnumD3D::FindDepthStencilFormat(UINT iAdapter, D3DDEVTYPE DeviceType, D3DFORMAT TargetFormat, D3DFORMAT *pDepthStencilFormat)
{
if( m_dwMinDepthBits <= 16 && m_dwMinStencilBits == 0 )
{
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16 ) ) )
{
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
TargetFormat, TargetFormat, D3DFMT_D16 ) ) )
{
*pDepthStencilFormat = D3DFMT_D16;
return TRUE;
}
}
}
if( m_dwMinDepthBits <= 15 && m_dwMinStencilBits <= 1 )
{
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D15S1 ) ) )
{
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
TargetFormat, TargetFormat, D3DFMT_D15S1 ) ) )
{
*pDepthStencilFormat = D3DFMT_D15S1;
return TRUE;
}
}
}
if( m_dwMinDepthBits <= 24 && m_dwMinStencilBits == 0 )
{
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8 ) ) )
{
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
TargetFormat, TargetFormat, D3DFMT_D24X8 ) ) )
{
*pDepthStencilFormat = D3DFMT_D24X8;
return TRUE;
}
}
}
if( m_dwMinDepthBits <= 24 && m_dwMinStencilBits <= 8 )
{
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24S8 ) ) )
{
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
TargetFormat, TargetFormat, D3DFMT_D24S8 ) ) )
{
*pDepthStencilFormat = D3DFMT_D24S8;
return TRUE;
}
}
}
if( m_dwMinDepthBits <= 24 && m_dwMinStencilBits <= 4 )
{
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X4S4 ) ) )
{
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
TargetFormat, TargetFormat, D3DFMT_D24X4S4 ) ) )
{
*pDepthStencilFormat = D3DFMT_D24X4S4;
return TRUE;
}
}
}
if( m_dwMinDepthBits <= 32 && m_dwMinStencilBits == 0 )
{
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32 ) ) )
{
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
TargetFormat, TargetFormat, D3DFMT_D32 ) ) )
{
*pDepthStencilFormat = D3DFMT_D32;
return TRUE;
}
}
}
return FALSE;
}
HRESULT CEnumD3D::ConfirmDevice(D3DCAPS8 *, DWORD, D3DFORMAT)
{
return S_OK;
}

View File

@@ -0,0 +1,95 @@
// EnumD3D.h: interface for the CEnumD3D class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_ENUMD3D_H__9D5F8359_25F1_49DD_8C6A_CADE38529740__INCLUDED_)
#define AFX_ENUMD3D_H__9D5F8359_25F1_49DD_8C6A_CADE38529740__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
#include "List.h"
//-----------------------------------------------------------------------------
// Name: struct D3DModeInfo
// Desc: Structure for holding information about a display mode
//-----------------------------------------------------------------------------
struct D3DModeInfo
{
DWORD Width; // Screen width in this mode
DWORD Height; // Screen height in this mode
D3DFORMAT Format; // Pixel format in this mode
DWORD dwBehavior; // Hardware / Software / Mixed vertex processing
D3DFORMAT DepthStencilFormat; // Which depth/stencil format to use with this mode
};
//-----------------------------------------------------------------------------
// Name: struct D3DDeviceInfo
// Desc: Structure for holding information about a Direct3D device, including
// a list of modes compatible with this device
//-----------------------------------------------------------------------------
struct D3DDeviceInfo
{
// Device data
D3DDEVTYPE DeviceType; // Reference, HAL, etc.
D3DCAPS8 d3dCaps; // Capabilities of this device
const TCHAR* strDesc; // Name of this device
BOOL bCanDoWindowed; // Whether this device can work in windowed mode
// Modes for this device
DWORD dwNumModes;
D3DModeInfo modes[150];
// Current state
DWORD dwCurrentMode;
BOOL bWindowed;
D3DMULTISAMPLE_TYPE MultiSampleType;
};
//-----------------------------------------------------------------------------
// Name: struct D3DAdapterInfo
// Desc: Structure for holding information about an adapter, including a list
// of devices available on this adapter
//-----------------------------------------------------------------------------
struct D3DAdapterInfo
{
// Adapter data
D3DADAPTER_IDENTIFIER8 d3dAdapterIdentifier;
D3DDISPLAYMODE d3ddmDesktop; // Desktop display mode for this adapter
// Devices for this adapter
DWORD dwNumDevices;
D3DDeviceInfo devices[5];
// Current state
DWORD dwCurrentDevice;
};
class CEnumD3D
{
static BOOL m_bWindowed;
static long m_dwMinDepthBits;
static long m_dwMinStencilBits;
public:
static long m_nAdapter,m_nDevice,m_nMode;
static LPDIRECT3D8 m_pD3D;
static DWORD m_dwNumAdapters;
static BOOL m_bUseDepthBuffer;
static DWORD m_dwAdapter;
static D3DAdapterInfo m_Adapters[10];
static HRESULT ConfirmDevice(D3DCAPS8*,DWORD,D3DFORMAT);
static BOOL FindDepthStencilFormat(UINT iAdapter, D3DDEVTYPE DeviceType, D3DFORMAT TargetFormat, D3DFORMAT *pDepthStencilFormat);
static HRESULT Enum();
CEnumD3D();
virtual ~CEnumD3D();
};
#endif // !defined(AFX_ENUMD3D_H__9D5F8359_25F1_49DD_8C6A_CADE38529740__INCLUDED_)

View File

@@ -0,0 +1,19 @@
// Error.cpp: implementation of the CError class.
//
//////////////////////////////////////////////////////////////////////
#include "Error.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CError::CError()
{
}
CError::~CError()
{
}

View File

@@ -0,0 +1,41 @@
// Error.h: interface for the CError class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_ERROR_H__0F1AE97A_A373_4DE7_B36A_23BE292D42B2__INCLUDED_)
#define AFX_ERROR_H__0F1AE97A_A373_4DE7_B36A_23BE292D42B2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <string>
const long MAX_ERRORBUFFER=256;
class CError
{
protected:
char m_strErrormsg[MAX_ERRORBUFFER];
public:
CError();
virtual ~CError();
void SetErrorMsg(char *msg)
{
strcpy(m_strErrormsg,msg);
}
virtual char *GetErrorMsg()
{
char msgtemp[MAX_ERRORBUFFER];
strcpy(msgtemp,"General Error:");
strcat(msgtemp,m_strErrormsg);
strcpy(m_strErrormsg,msgtemp);
return m_strErrormsg;
}
CError(char *msg)
{
SetErrorMsg(msg);
}
};
#endif // !defined(AFX_ERROR_H__0F1AE97A_A373_4DE7_B36A_23BE292D42B2__INCLUDED_)

View File

@@ -0,0 +1,7 @@
#ifndef _EXCEPTION_H
#define _EXCEPTION_H
#include "Error.h"
#include "GraphicLayerError.h"
#include "DeviceInputError.h"
#endif

View File

@@ -0,0 +1,520 @@
// FastMath.cpp: implementation of the CFastMath class.
//
//////////////////////////////////////////////////////////////////////
#include <tchar.h>
#include "FastMath.h"
// This table only works on Little Endian(Byte Order) machine.
unsigned short CFastMath::m_FastHeToBi[0x100] = {
0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730,
0x3830, 0x3930, 0x4130, 0x4230, 0x4330, 0x4430, 0x4530, 0x4630,
0x3031, 0x3131, 0x3231, 0x3331, 0x3431, 0x3531, 0x3631, 0x3731,
0x3831, 0x3931, 0x4131, 0x4231, 0x4331, 0x4431, 0x4531, 0x4631,
0x3032, 0x3132, 0x3232, 0x3332, 0x3432, 0x3532, 0x3632, 0x3732,
0x3832, 0x3932, 0x4132, 0x4232, 0x4332, 0x4432, 0x4532, 0x4632,
0x3033, 0x3133, 0x3233, 0x3333, 0x3433, 0x3533, 0x3633, 0x3733,
0x3833, 0x3933, 0x4133, 0x4233, 0x4333, 0x4433, 0x4533, 0x4633,
0x3034, 0x3134, 0x3234, 0x3334, 0x3434, 0x3534, 0x3634, 0x3734,
0x3834, 0x3934, 0x4134, 0x4234, 0x4334, 0x4434, 0x4534, 0x4634,
0x3035, 0x3135, 0x3235, 0x3335, 0x3435, 0x3535, 0x3635, 0x3735,
0x3835, 0x3935, 0x4135, 0x4235, 0x4335, 0x4435, 0x4535, 0x4635,
0x3036, 0x3136, 0x3236, 0x3336, 0x3436, 0x3536, 0x3636, 0x3736,
0x3836, 0x3936, 0x4136, 0x4236, 0x4336, 0x4436, 0x4536, 0x4636,
0x3037, 0x3137, 0x3237, 0x3337, 0x3437, 0x3537, 0x3637, 0x3737,
0x3837, 0x3937, 0x4137, 0x4237, 0x4337, 0x4437, 0x4537, 0x4637,
0x3038, 0x3138, 0x3238, 0x3338, 0x3438, 0x3538, 0x3638, 0x3738,
0x3838, 0x3938, 0x4138, 0x4238, 0x4338, 0x4438, 0x4538, 0x4638,
0x3039, 0x3139, 0x3239, 0x3339, 0x3439, 0x3539, 0x3639, 0x3739,
0x3839, 0x3939, 0x4139, 0x4239, 0x4339, 0x4439, 0x4539, 0x4639,
0x3041, 0x3141, 0x3241, 0x3341, 0x3441, 0x3541, 0x3641, 0x3741,
0x3841, 0x3941, 0x4141, 0x4241, 0x4341, 0x4441, 0x4541, 0x4641,
0x3042, 0x3142, 0x3242, 0x3342, 0x3442, 0x3542, 0x3642, 0x3742,
0x3842, 0x3942, 0x4142, 0x4242, 0x4342, 0x4442, 0x4542, 0x4642,
0x3043, 0x3143, 0x3243, 0x3343, 0x3443, 0x3543, 0x3643, 0x3743,
0x3843, 0x3943, 0x4143, 0x4243, 0x4343, 0x4443, 0x4543, 0x4643,
0x3044, 0x3144, 0x3244, 0x3344, 0x3444, 0x3544, 0x3644, 0x3744,
0x3844, 0x3944, 0x4144, 0x4244, 0x4344, 0x4444, 0x4544, 0x4644,
0x3045, 0x3145, 0x3245, 0x3345, 0x3445, 0x3545, 0x3645, 0x3745,
0x3845, 0x3945, 0x4145, 0x4245, 0x4345, 0x4445, 0x4545, 0x4645,
0x3046, 0x3146, 0x3246, 0x3346, 0x3446, 0x3546, 0x3646, 0x3746,
0x3846, 0x3946, 0x4146, 0x4246, 0x4346, 0x4446, 0x4546, 0x4646,
};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
unsigned int CFastMath::m_FastSqrtTable[0x10000];
long CFastMath::m_HoldRand = 1L;
CFastMath::CFastMath()
{
}
CFastMath::~CFastMath()
{
}
void CFastMath::Init()
{
unsigned int i;
FastSqrtUnion s;
for (i=0;i<=0x7FFF;i++)
{
s.i = (i << 8) | (0x7F << 23);
s.f = (float)sqrt(s.f);
m_FastSqrtTable[i+0x8000]=(s.i&0x7FFFFF);
s.i = (i << 8) | (0x80 << 23);
s.f = (float)sqrt(s.f);
m_FastSqrtTable[i]=(s.i&0x7FFFFF);
}
}
//
// this function returns the equivalent binary value for an individual character specified in the ascii format
UCHAR CFastMath::BiToHe( char cBin )
{
if( (cBin >= '0') && (cBin <= '9') ) {
return ( cBin - '0' );
} else if( (cBin >= 'A') && (cBin <= 'F') ) {
return ( cBin - 'A' + 0xA );
} if( (cBin >= 'a') && (cBin <= 'f') ) {
return ( cBin -'a' + 0xA );
}
return cBin;
}
void CFastMath::AcToHe(char *szDst, char *szSrc, int iCount)
{
while( iCount-- ) {
*szDst = BiToHe(*szSrc) << 4;
*szSrc++;
*szDst += BiToHe(*szSrc);
*szSrc++;
*szDst++;
}
/*
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><>ƾ<EFBFBD><C6BE><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>۵<EFBFBD><DBB5><EFBFBD><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>(szDst<73><74> <20>ƹ<EFBFBD><C6B9>͵<EFBFBD> <20><><EFBFBD><20>ȵ<EFBFBD>).
<EFBFBD>ٸ<EFBFBD> <20>е<EFBFBD><D0B5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? --<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (2002-08-17)
// while (iCount--) {
// *szDst++ = (BiToHe(*szSrc++) << 4) + BiToHe(*szSrc++);
// }
*/
return;
}
char CFastMath::StrToHex08(char *szSrc)
{
char *pStart = szSrc + 2;
char cHex = 0;
for (int i=0; i<1; i++) {
char c1 = BiToHe(*pStart++);
c1 <<= (8*(7-i)+4);
char c2 = BiToHe(*pStart++);
c2 <<= (8*(7-i));
char cRet = c1 + c2;
cHex += cRet;
}
return cHex;
}
unsigned short CFastMath::StrToHex16(char *szSrc)
{
char *pStart = szSrc + 2;
unsigned short sHex = 0;
for (int i=0; i<2; i++) {
unsigned short s1 = BiToHe(*pStart++);
s1 <<= (8*(1-i)+4);
unsigned short s2 = BiToHe(*pStart++);
s2 <<= (8*(1-i));
unsigned short sRet = s1 + s2;
sHex += sRet;
}
return sHex;
}
// convert string to hexadecimal value
DWORD CFastMath::StrToHex32(char *szSrc)
{
char *pStart = szSrc + 2;
DWORD dwHex = 0;
for (int i=0; i<4; i++) {
DWORD dw1 = BiToHe(*pStart++);
dw1 <<= (8*(3-i)+4);
DWORD dw2 = BiToHe(*pStart++);
dw2 <<= (8*(3-i));
DWORD dwRet = dw1 + dw2;
dwHex += dwRet;
}
return dwHex;
}
// convert string to hexadecimal value
__int64 CFastMath::StrToHex64(char *szSrc)
{
char *pStart = szSrc + 2;
__int64 dlHex = 0;
for (int i=0; i<8; i++) {
__int64 dl1 = BiToHe(*pStart++);
dl1 <<= (8*(7-i)+4);
__int64 dl2 = BiToHe(*pStart++);
dl2 <<= (8*(7-i));
__int64 dlRet = dl1 + dl2;
dlHex += dlRet;
}
return dlHex;
}
char CFastMath::Atoc( char *szSrc )
{
if( strncmp( szSrc, "0x", 2 ) == 0 ) {
return StrToHex08( szSrc );
} else {
return (char) _ttol( szSrc );
}
}
//
// TCHAR *<2A><> <20><>Ĩ<EFBFBD>ô<EFBFBD>! (By Standil)
//
unsigned short CFastMath::Atos( char *szSrc )
{
if( strncmp( szSrc, "0x", 2 ) == 0 ) {
return StrToHex16( szSrc );
} else {
return _ttoi( szSrc );
}
}
//
// TCHAR *<2A><> <20><>Ĩ<EFBFBD>ô<EFBFBD>! (By Standil)
//
unsigned int CFastMath::Atoi( char *szSrc )
{
if( strncmp( szSrc, "0x", 2 ) == 0 ) {
return StrToHex32( szSrc );
} else {
return _ttol( szSrc );
}
}
//
// TCHAR *<2A><> <20><>Ĩ<EFBFBD>ô<EFBFBD>! (By Standil)
//
_int64 CFastMath::Atol64( char *szSrc )
{
if( strncmp( szSrc, "0x", 2 ) == 0 ) {
return StrToHex32( szSrc );
} else {
return _ttoi64( szSrc );
}
}
void CFastMath::SRand( unsigned int seed )
{
m_HoldRand = (long) seed;
}
int CFastMath::Rand( void )
{
return( ((m_HoldRand = m_HoldRand * 214013L + 2531011L) >> 16) & 0x7FFF );
}
///////////////////////////////////////////////////////////////////////////////////////////////
// utility functions
// 0 -0x7FFFFFFF.
DWORD CFastMath::ComplexRandom(int nExtent)
{
static unsigned long x = 1;
static unsigned long c = 0;
static unsigned long a = 2083801278UL;
#define addto(rh,rl,ah,al) (rl) = ((rl) + (al)) & 0xFFFFFFFFUL; \
(rh) = ((rh) + (ah) + (((rl) < (al)) ? 1 : 0)) & 0xFFFFFFFFUL
unsigned long xl = (x & 0xFFFFUL);
unsigned long xh = (x >> 16) & 0xFFFFUL;
unsigned long al = (a & 0xFFFFUL);
unsigned long ah = (a >> 16) & 0xFFFFUL;
unsigned long tmp;
x = c;
c = 0;
tmp = xl * al;
addto(c, x, 0, tmp);
tmp = xl * ah;
addto(c, x, (tmp >> 16), (tmp & 0xFFFFUL) << 16);
tmp = xh * ah;
addto(c, x, tmp, 1);
tmp = xh * al;
addto(c, x, (tmp >> 16), (tmp & 0xFFFFUL) << 16);
if (nExtent < 1)
return 1;
return (x % nExtent); // return x & 0x7FFFFFFFUL;
}
/*
_rand From GNU Libc source
This algorithm is mentioned in the ISO C standard, here extended for 32 bits.
int rand_r (unsigned int *seed)
{
unsigned int next = *seed;
int result;
next *= 1103515245;
next += 12345;
result = (unsigned int) (next / 65536) % 2048;
next *= 1103515245;
next += 12345;
result <<= 10;
result ^= (unsigned int) (next / 65536) % 1024;
next *= 1103515245;
next += 12345;
result <<= 10;
result ^= (unsigned int) (next / 65536) % 1024;
*seed = next;
return result;
}
static double SinTable[] = {
0.000000, 0.017452, 0.034899, 0.052336, 0.069756,
0.087156, 0.104528, 0.121869, 0.139173, 0.156434,
0.173648, 0.190809, 0.207912, 0.224951, 0.241922,
0.258819, 0.275637, 0.292372, 0.309017, 0.325568,
0.342020, 0.358368, 0.374607, 0.390731, 0.406737,
0.422618, 0.438371, 0.453990, 0.469472, 0.484810,
0.500000, 0.515038, 0.529919, 0.544639, 0.559193,
0.573576, 0.587785, 0.601815, 0.615661, 0.629320,
0.642788, 0.656059, 0.669131, 0.681998, 0.694658,
0.707107, 0.719340, 0.731354, 0.743145, 0.754710,
0.766044, 0.777146, 0.788011, 0.798636, 0.809017,
0.819152, 0.829038, 0.838671, 0.848048, 0.857167,
0.866025, 0.874620, 0.882948, 0.891007, 0.898794,
0.906308, 0.913545, 0.920505, 0.927184, 0.933580,
0.939693, 0.945519, 0.951057, 0.956305, 0.961262,
0.965926, 0.970296, 0.974370, 0.978148, 0.981627,
0.984808, 0.987688, 0.990268, 0.992546, 0.994522,
0.996195, 0.997564, 0.998630, 0.999391, 0.999848,
1.000000, 0.999848, 0.999391, 0.998630, 0.997564,
0.996195, 0.994522, 0.992546, 0.990268, 0.987688,
0.984808, 0.981627, 0.978148, 0.974370, 0.970296,
0.965926, 0.961262, 0.956305, 0.951057, 0.945519,
0.939693, 0.933580, 0.927184, 0.920505, 0.913545,
0.906308, 0.898794, 0.891007, 0.882948, 0.874620,
0.866025, 0.857167, 0.848048, 0.838671, 0.829038,
0.819152, 0.809017, 0.798636, 0.788011, 0.777146,
0.766044, 0.754710, 0.743145, 0.731354, 0.719340,
0.707107, 0.694658, 0.681998, 0.669131, 0.656059,
0.642788, 0.629320, 0.615661, 0.601815, 0.587785,
0.573576, 0.559193, 0.544639, 0.529919, 0.515038,
0.500000, 0.484810, 0.469472, 0.453990, 0.438371,
0.422618, 0.406737, 0.390731, 0.374607, 0.358368,
0.342020, 0.325568, 0.309017, 0.292372, 0.275637,
0.258819, 0.241922, 0.224951, 0.207912, 0.190809,
0.173648, 0.156434, 0.139173, 0.121869, 0.104528,
0.087156, 0.069756, 0.052336, 0.034899, 0.017452,
0.000000, -0.017452, -0.034899, -0.052336, -0.069756,
-0.087156, -0.104528, -0.121869, -0.139173, -0.156434,
-0.173648, -0.190809, -0.207912, -0.224951, -0.241922,
-0.258819, -0.275637, -0.292372, -0.309017, -0.325568,
-0.342020, -0.358368, -0.374607, -0.390731, -0.406737,
-0.422618, -0.438371, -0.453990, -0.469472, -0.484810,
-0.500000, -0.515038, -0.529919, -0.544639, -0.559193,
-0.573576, -0.587785, -0.601815, -0.615661, -0.629320,
-0.642788, -0.656059, -0.669131, -0.681998, -0.694658,
-0.707107, -0.719340, -0.731354, -0.743145, -0.754710,
-0.766044, -0.777146, -0.788011, -0.798636, -0.809017,
-0.819152, -0.829038, -0.838671, -0.848048, -0.857167,
-0.866025, -0.874620, -0.882948, -0.891007, -0.898794,
-0.906308, -0.913545, -0.920505, -0.927184, -0.933580,
-0.939693, -0.945519, -0.951057, -0.956305, -0.961262,
-0.965926, -0.970296, -0.974370, -0.978148, -0.981627,
-0.984808, -0.987688, -0.990268, -0.992546, -0.994522,
-0.996195, -0.997564, -0.998630, -0.999391, -0.999848,
-1.000000, -0.999848, -0.999391, -0.998630, -0.997564,
-0.996195, -0.994522, -0.992546, -0.990268, -0.987688,
-0.984808, -0.981627, -0.978148, -0.974370, -0.970296,
-0.965926, -0.961262, -0.956305, -0.951057, -0.945519,
-0.939693, -0.933580, -0.927184, -0.920505, -0.913545,
-0.906308, -0.898794, -0.891007, -0.882948, -0.874620,
-0.866025, -0.857167, -0.848048, -0.838671, -0.829038,
-0.819152, -0.809017, -0.798636, -0.788011, -0.777146,
-0.766044, -0.754710, -0.743145, -0.731354, -0.719340,
-0.707107, -0.694658, -0.681998, -0.669131, -0.656059,
-0.642788, -0.629320, -0.615661, -0.601815, -0.587785,
-0.573576, -0.559193, -0.544639, -0.529919, -0.515038,
-0.500000, -0.484810, -0.469472, -0.453990, -0.438371,
-0.422618, -0.406737, -0.390731, -0.374607, -0.358368,
-0.342020, -0.325568, -0.309017, -0.292372, -0.275637,
-0.258819, -0.241922, -0.224951, -0.207912, -0.190809,
-0.173648, -0.156434, -0.139173, -0.121869, -0.104528,
-0.087156, -0.069756, -0.052336, -0.034899, -0.017452
};
static double CosTable[] = {
1.000000, 0.999848, 0.999391, 0.998630, 0.997564,
0.996195, 0.994522, 0.992546, 0.990268, 0.987688,
0.984808, 0.981627, 0.978148, 0.974370, 0.970296,
0.965926, 0.961262, 0.956305, 0.951057, 0.945519,
0.939693, 0.933580, 0.927184, 0.920505, 0.913545,
0.906308, 0.898794, 0.891007, 0.882948, 0.874620,
0.866025, 0.857167, 0.848048, 0.838671, 0.829038,
0.819152, 0.809017, 0.798636, 0.788011, 0.777146,
0.766044, 0.754710, 0.743145, 0.731354, 0.719340,
0.707107, 0.694658, 0.681998, 0.669131, 0.656059,
0.642788, 0.629320, 0.615661, 0.601815, 0.587785,
0.573576, 0.559193, 0.544639, 0.529919, 0.515038,
0.500000, 0.484810, 0.469472, 0.453990, 0.438371,
0.422618, 0.406737, 0.390731, 0.374607, 0.358368,
0.342020, 0.325568, 0.309017, 0.292372, 0.275637,
0.258819, 0.241922, 0.224951, 0.207912, 0.190809,
0.173648, 0.156434, 0.139173, 0.121869, 0.104528,
0.087156, 0.069756, 0.052336, 0.034899, 0.017452,
0.000000, -0.017452, -0.034899, -0.052336, -0.069756,
-0.087156, -0.104528, -0.121869, -0.139173, -0.156434,
-0.173648, -0.190809, -0.207912, -0.224951, -0.241922,
-0.258819, -0.275637, -0.292372, -0.309017, -0.325568,
-0.342020, -0.358368, -0.374607, -0.390731, -0.406737,
-0.422618, -0.438371, -0.453990, -0.469472, -0.484810,
-0.500000, -0.515038, -0.529919, -0.544639, -0.559193,
-0.573576, -0.587785, -0.601815, -0.615661, -0.629320,
-0.642788, -0.656059, -0.669131, -0.681998, -0.694658,
-0.707107, -0.719340, -0.731354, -0.743145, -0.754710,
-0.766044, -0.777146, -0.788011, -0.798636, -0.809017,
-0.819152, -0.829038, -0.838671, -0.848048, -0.857167,
-0.866025, -0.874620, -0.882948, -0.891007, -0.898794,
-0.906308, -0.913545, -0.920505, -0.927184, -0.933580,
-0.939693, -0.945519, -0.951057, -0.956305, -0.961262,
-0.965926, -0.970296, -0.974370, -0.978148, -0.981627,
-0.984808, -0.987688, -0.990268, -0.992546, -0.994522,
-0.996195, -0.997564, -0.998630, -0.999391, -0.999848,
-1.000000, -0.999848, -0.999391, -0.998630, -0.997564,
-0.996195, -0.994522, -0.992546, -0.990268, -0.987688,
-0.984808, -0.981627, -0.978148, -0.974370, -0.970296,
-0.965926, -0.961262, -0.956305, -0.951057, -0.945519,
-0.939693, -0.933580, -0.927184, -0.920505, -0.913545,
-0.906308, -0.898794, -0.891007, -0.882948, -0.874620,
-0.866025, -0.857167, -0.848048, -0.838671, -0.829038,
-0.819152, -0.809017, -0.798636, -0.788011, -0.777146,
-0.766044, -0.754710, -0.743145, -0.731354, -0.719340,
-0.707107, -0.694658, -0.681998, -0.669131, -0.656059,
-0.642788, -0.629320, -0.615661, -0.601815, -0.587785,
-0.573576, -0.559193, -0.544639, -0.529919, -0.515038,
-0.500000, -0.484810, -0.469472, -0.453990, -0.438371,
-0.422618, -0.406737, -0.390731, -0.374607, -0.358368,
-0.342020, -0.325568, -0.309017, -0.292372, -0.275637,
-0.258819, -0.241922, -0.224951, -0.207912, -0.190809,
-0.173648, -0.156434, -0.139173, -0.121869, -0.104528,
-0.087156, -0.069756, -0.052336, -0.034899, -0.017452,
-0.000000, 0.017452, 0.034899, 0.052336, 0.069756,
0.087156, 0.104528, 0.121869, 0.139173, 0.156434,
0.173648, 0.190809, 0.207912, 0.224951, 0.241922,
0.258819, 0.275637, 0.292372, 0.309017, 0.325568,
0.342020, 0.358368, 0.374607, 0.390731, 0.406737,
0.422618, 0.438371, 0.453990, 0.469472, 0.484810,
0.500000, 0.515038, 0.529919, 0.544639, 0.559193,
0.573576, 0.587785, 0.601815, 0.615661, 0.629320,
0.642788, 0.656059, 0.669131, 0.681998, 0.694658,
0.707107, 0.719340, 0.731354, 0.743145, 0.754710,
0.766044, 0.777146, 0.788011, 0.798636, 0.809017,
0.819152, 0.829038, 0.838671, 0.848048, 0.857167,
0.866025, 0.874620, 0.882948, 0.891007, 0.898794,
0.906308, 0.913545, 0.920505, 0.927184, 0.933580,
0.939693, 0.945519, 0.951057, 0.956305, 0.961262,
0.965926, 0.970296, 0.974370, 0.978148, 0.981627,
0.984808, 0.987688, 0.990268, 0.992546, 0.994522,
0.996195, 0.997564, 0.998630, 0.999391, 0.999848
};
double as_sin( int degree )
{
while( degree < 0 ) degree += 360;
degree = degree%360;
return SinTable[degree];
}
double as_cos( int degree )
{
while( degree < 0 ) degree += 360;
degree = degree%360;
return CosTable[degree];
}
// -90 - 90
int as_asin( double as )
{
double
nearest_diff = 2.0;
int
nearest_index;
for( int i = -90; i <=90; i++ ){
int
index = i;
if( index < 0 ) index += 360;
if( fabs(SinTable[index]-as) < nearest_diff ){
nearest_diff = fabs(SinTable[index]-as);
nearest_index = i;
}
}
return nearest_index;
}
// 0 - 180
int as_acos( double ac )
{
double
nearest_diff = 2.0;
int
nearest_index;
for( int i = 0; i <= 180; i++ ){
if( fabs(CosTable[i]-ac) < nearest_diff ){
nearest_diff = fabs(CosTable[i]-ac);
nearest_index = i;
}
}
return nearest_index;
}
*/

View File

@@ -0,0 +1,137 @@
// FastMath.h: interface for the CFastMath class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_FASTMATH_H__ED69578B_18C1_42EA_9C5E_888DC38101C2__INCLUDED_)
#define AFX_FASTMATH_H__ED69578B_18C1_42EA_9C5E_888DC38101C2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
#include "MathBase.h"
#define FP_BITS(fp) (*(DWORD *)&(fp))
class CFastMath
{
typedef union FastSqrtUnion {
float f;
unsigned int i;
} FastSqrtUnion;
static unsigned int m_FastSqrtTable[0x10000];
static unsigned short m_FastHeToBi[0x100];
static long m_HoldRand;
public:
// constructor and destructor
CFastMath();
virtual ~CFastMath();
static void Init();
inline static float FastSqrt(float n) // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ϴ<EFBFBD> <20>Լ<EFBFBD>.
{
if (FP_BITS(n) == 0)
return 0.0f; // check for square root of 0
FP_BITS(n) = m_FastSqrtTable[(FP_BITS(n) >> 8) & 0xFFFF] | ((((FP_BITS(n) - 0x3F800000) >> 1) + 0x3F800000) & 0x7F800000);
return n;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// converts ascii type of IPX address to hexadecimal format
// returns the equivalent binary value for an individual character specified in the ascii format
static UCHAR BiToHe(char cBin); // SPX, IPX <20>ּ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD>
static void AcToHe(char *szDst, char *szSrc, int iCount); // SPX, IPX <20>ּ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD>
static char StrToHex08(char *szSrc); // convert string to hexa
static unsigned short StrToHex16(char *szSrc); // convert string to hexa
static DWORD StrToHex32(char *szSrc); // convert string to hexa
static _int64 StrToHex64(char *szSrc); // convert string to hexa
static inline void Hex08ToStr(char *szDest, BYTE hex); // convert hexa to string
static inline void Hex16ToStr(char *szDest, WORD hex); // convert hexa to string
static inline void Hex32ToStr(char *szDest, DWORD hex); // convert hexa to string
static inline void Hex64ToStr(char *szDest, DWORD64 hex); // convert hexa to string
static char Atoc(char *szSrc); // ascii to U8
static unsigned short Atos(char *szSrc); // ascii to U16
static unsigned int Atoi(char *szSrc); // ascii to U32
static _int64 Atol64(char *szSrc); // ascii to U64
static void SRand( unsigned int seed );
static int Rand( void );
// <20><><EFBFBD>ϰ<EFBFBD><CFB0><EFBFBD> 0 ~ nExtent - 1<><31> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>´<EFBFBD>.
static DWORD ComplexRandom(int nExtent);
static DWORD AGLRandom(int nExtent) { return ComplexRandom(nExtent); };
};
inline void CFastMath::Hex08ToStr( char *szDest, BYTE hex )
{
*((WORD *) szDest) = m_FastHeToBi[ hex ]; szDest += 2;
*(szDest) = '\0';
}
inline void CFastMath::Hex16ToStr( char *szDest, WORD hex )
{
LPBYTE pSrc = (LPBYTE) &hex;
#ifdef BIG_ENDIAN
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
#else
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
#endif
*(szDest + 4) = '\0';
}
inline void CFastMath::Hex32ToStr( char *szDest, DWORD hex )
{
LPBYTE pSrc = (LPBYTE) &hex;
#ifdef BIG_ENDIAN
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
#else
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
#endif
*(szDest + 8) = '\0';
}
inline void CFastMath::Hex64ToStr( char *szDest, DWORD64 hex )
{
LPBYTE pSrc = (LPBYTE) &hex;
#ifdef BIG_ENDIAN
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 8)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 10)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 12)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 14)) = m_FastHeToBi[ *(pSrc++) ];
#else
*((WORD *) (szDest + 14)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 12)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 10)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 8)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
#endif
*(szDest + 16) = '\0';
}
#endif // !defined(AFX_FASTMATH_H__ED69578B_18C1_42EA_9C5E_888DC38101C2__INCLUDED_)

View File

@@ -0,0 +1,63 @@
// FileLoad.cpp: implementation of the CFileLoad class.
//
//////////////////////////////////////////////////////////////////////
#include "FileLoad.h"
#include <windows.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFileLoad::CFileLoad()
{
}
CFileLoad::~CFileLoad()
{
delete[] m_Data;
}
void CFileLoad::Load(char *strFilename)
{
strcpy(m_strFilename,strFilename);
m_Data=0;
m_Len=0;
FILE *fp=fopen(strFilename,"rb");
if(fp)
{
fseek(fp,0L,SEEK_END);
m_Len=ftell(fp);
if(m_Len)
{
fseek(fp,0L,SEEK_SET);
m_Data=(void*)new unsigned char[m_Len];
if(m_Data)
{
int r=fread(m_Data,m_Len,1,fp);
if(!r)
{
delete m_Data;
m_Data=NULL;
}
}
}
fclose(fp);
}
else
{
MessageBox(NULL,strFilename,0,0);
}
m_ReadLoc=(char*)m_Data;
m_ReadLen=m_Len;
}
void CFileLoad::GetData(void *pData, size_t size)
{
memcpy(pData,m_ReadLoc,size);
m_ReadLoc+=size;
}

View File

@@ -0,0 +1,34 @@
// FileLoad.h: interface for the CFileLoad class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_FILELOAD_H__95D97159_9B6D_4BBC_BD14_1DB1825501BF__INCLUDED_)
#define AFX_FILELOAD_H__95D97159_9B6D_4BBC_BD14_1DB1825501BF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <stdio.h>
#include <string>
#define MAX_NAMEBUFFER 256
class CFileLoad
{
public:
void GetData(void* pData,size_t size);
void Load(char *strFilename);
char m_strFilename[MAX_NAMEBUFFER];
void *m_Data;
int m_Len;
char *m_ReadLoc;
int m_ReadLen;
CFileLoad();
virtual ~CFileLoad();
};
#endif // !defined(AFX_FILELOAD_H__95D97159_9B6D_4BBC_BD14_1DB1825501BF__INCLUDED_)

View File

@@ -0,0 +1,71 @@
// FrameTimer.cpp: implementation of the CFrameTimer class.
//
//////////////////////////////////////////////////////////////////////
#include "FrameTimer.h"
std::vector<float> CFrameTimer::m_fUpdateTimeList;
std::vector<float> CFrameTimer::m_fTimeRemainList;
std::vector<float> CFrameTimer::m_fPerSecondUpdateList;
DWORD CFrameTimer::m_dwTickTime;
DWORD CFrameTimer::m_dwLastUpdateTime;
CFrameTimer g_FrameTimer;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFrameTimer::CFrameTimer()
{
m_dwTickTime = 0xFFFFFFFF;
}
CFrameTimer::~CFrameTimer()
{
}
void CFrameTimer::Create()
{
m_dwTickTime = 0xFFFFFFFF;
}
void CFrameTimer::UpdateTime()
{
if(m_dwTickTime == 0xFFFFFFFF)
{
m_dwTickTime=GetTickCount();
m_dwLastUpdateTime=m_dwTickTime;
}
DWORD dwOldTickTime=m_dwTickTime;
m_dwTickTime=GetTickCount();
DWORD dwIntervalPreTime=m_dwTickTime-dwOldTickTime;
for(int i=0;i<(int)m_fUpdateTimeList.size();i++)
{
m_fUpdateTimeList[i]=(float)dwIntervalPreTime/(1000.0f/m_fPerSecondUpdateList[i]);
m_fUpdateTimeList[i]+=m_fTimeRemainList[i];
m_fTimeRemainList[i]=m_fUpdateTimeList[i]-(int)m_fUpdateTimeList[i];
}
/*
float fUpdateFrameRate=(float)(m_dwTickTime-dwOldTickTime)/(1000.0f/35.0f);
return fUpdateFrameRate;
*/
}
int CFrameTimer::Regist(float fPerSecondUpdate)
{
int iNum = 0;
m_fUpdateTimeList.push_back(0.0f);
m_fTimeRemainList.push_back(0.0f);
m_fPerSecondUpdateList.push_back(fPerSecondUpdate);
iNum = (int)m_fUpdateTimeList.size() - 1;
return iNum;
}
float CFrameTimer::GetUpdateTimer(int nTimer)
{
//return 0.0f;
return m_fUpdateTimeList[nTimer];
}

View File

@@ -0,0 +1,33 @@
// FrameTimer.h: interface for the CFrameTimer class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_FRAMETIMER_H__6C017430_DEBB_4372_B200_70D57C02B061__INCLUDED_)
#define AFX_FRAMETIMER_H__6C017430_DEBB_4372_B200_70D57C02B061__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
#include <vector>
//#include "List.h"
class CFrameTimer
{
public:
static float GetUpdateTimer(int nTimer);
static int Regist(float fPerSecondUpdate);
static void UpdateTime();
static std::vector<float> m_fUpdateTimeList;
static std::vector<float> m_fTimeRemainList;
static std::vector<float> m_fPerSecondUpdateList;
static DWORD m_dwTickTime;
static DWORD m_dwLastUpdateTime;
static void Create();
CFrameTimer();
virtual ~CFrameTimer();
};
#endif // !defined(AFX_FRAMETIMER_H__6C017430_DEBB_4372_B200_70D57C02B061__INCLUDED_)

View File

@@ -0,0 +1,765 @@
// GlareTexture.cpp: implementation of the CGlareTexture class.
//
//////////////////////////////////////////////////////////////////////
#include "GlareTexture.h"
#include "BaseGraphicsLayer.h"
#include "SceneStateMgr.h"
#define CV_WORLDVIEWPROJ_0 0
#define CV_WORLDVIEWPROJ_1 1
#define CV_WORLDVIEWPROJ_2 2
#define CV_WORLDVIEWPROJ_3 3
#define CV_UV_OFFSET_TO_USE 4
#define CV_T0_BASE 8
#define CV_T1_BASE 13
#define CV_T2_BASE 18
#define CV_T3_BASE 23
#define CV_UV_T0_NO_OFFSET 8
#define CV_UV_T0_TYPE1 9
#define CV_UV_T0_TYPE2 10
#define CV_UV_T0_TYPE3 11
#define CV_UV_T0_TYPE4 12
#define CV_UV_T1_NO_OFFSET 13
#define CV_UV_T1_TYPE1 14
#define CV_UV_T1_TYPE2 15
#define CV_UV_T1_TYPE3 16
#define CV_UV_T1_TYPE4 17
#define CV_UV_T2_NO_OFFSET 18
#define CV_UV_T2_TYPE1 19
#define CV_UV_T2_TYPE2 20
#define CV_UV_T2_TYPE3 21
#define CV_UV_T2_TYPE4 22
#define CV_UV_T3_NO_OFFSET 23
#define CV_UV_T3_TYPE1 24
#define CV_UV_T3_TYPE2 25
#define CV_UV_T3_TYPE3 26
#define CV_UV_T3_TYPE4 27
char strBlurVertexShader[]=
"vs.1.1\n"
"dp4 oPos.x, v0, c[0]\n"
"dp4 oPos.y, v0, c[1]\n"
"dp4 oPos.z, v0, c[2]\n"
"dp4 oPos.w, v0, c[3]\n"
"mov a0.x, c[4]\n"
"add oT0, v1, c[a0.x + 8]\n"
"add oT1, v1, c[a0.x + 13]\n"
"add oT2, v1, c[a0.x + 18]\n"
"add oT3, v1, c[a0.x + 23]\n";
char strBlurPixelShader[]=
"ps.1.1\n"
//"def c0, 0.0f, 0.0f, 1.0f, 0.0f\n"
//"def c0, 0.25f, 0.25f, 0.25f, 0.25f\n"
"tex t0\n"
"tex t1\n"
"tex t2\n"
"tex t3\n"
//"mov r0,c0\n";
"mul r0, c0, t0\n"
"mad r0, c0, t1, r0\n"
"mad r0, c0, t2, r0\n"
"mad r0, c0, t3, r0\n";
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LPDIRECT3DSURFACE8 CGlareTexture::m_pRenderZBuffer=NULL;
CGlareTexture::CGlareTexture()
{
}
CGlareTexture::~CGlareTexture()
{
}
void CGlareTexture::GenerateGlareTexture(LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECT3DBASETEXTURE8 pTexture,vector3 vecNeighbor,int nDepth)
{
LPDIRECT3DSURFACE8 m_pTempRenderSurface;
LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
long QUADVERTEX2FVF=D3DFVF_XYZRHW | D3DFVF_TEX4;
/*
CreateAndWriteUVOffsets(m_nSize,m_nSize);
matrix matOldWorld,matOldProjection,matOldView;
pd3dDevice->GetTransform(D3DTS_WORLD,matOldWorld);
pd3dDevice->GetTransform(D3DTS_PROJECTION,matOldProjection);
pd3dDevice->GetTransform(D3DTS_VIEW,matOldView);
*/
//pd3dDevice->EndScene();
////////////////////
/*
D3DXMATRIX matWorld;
D3DXMATRIX matView;
D3DXMATRIX matProj;
D3DXMATRIX matViewProj;
D3DXMATRIX matWorldViewProj;
D3DXVECTOR4 offset(0.0f, 0.0f, 0.0f, 0.0f);
offset.x = 2.0f;
pd3dDevice->SetVertexShaderConstant(CV_UV_OFFSET_TO_USE, &offset, 1);
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
pd3dDevice->SetVertexShader(m_BlurVertexShader);
pd3dDevice->SetStreamSource(0,m_pVertexBuffer,sizeof(QuadVertex));
D3DXVECTOR3 const vEyePt = D3DXVECTOR3( 0.0f, 0.0f, -5.0f );
D3DXVECTOR3 const vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 const vUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUp);
D3DXMatrixOrthoLH(&matProj, 4.0f, 4.0f, 0.2f, 20.0f);
D3DXMatrixMultiply(&matViewProj, &matView, &matProj);
D3DXMatrixScaling(&matWorld, 2.0f, 2.0f, 1.0f);
D3DXMatrixMultiply(&matWorldViewProj, &matWorld, &matViewProj);
D3DXMatrixTranspose(&matWorldViewProj, &matWorldViewProj);
pd3dDevice->SetVertexShaderConstant(CV_WORLDVIEWPROJ_0, &matWorldViewProj(0, 0), 4);
*/
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_LIGHTING,FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_FOGENABLE,FALSE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
pd3dDevice->SetPixelShader(m_BlurPixelShader);
pd3dDevice->SetVertexShader(QUADVERTEX2FVF);
QuadVertex2 pVertex[4];
pVertex[0].v.x=0.0f;
pVertex[1].v.x=0.0f;
pVertex[2].v.x=(float)m_nSize;
pVertex[3].v.x=(float)m_nSize;
pVertex[1].v.y=0.0f;
pVertex[3].v.y=0.0f;
pVertex[0].v.y=(float)m_nSize;
pVertex[2].v.y=(float)m_nSize;
pVertex[0].tu0=0.0f;
pVertex[1].tu0=0.0f;
pVertex[0].tu1=0.0f;
pVertex[1].tu1=0.0f;
pVertex[0].tu2=0.0f;
pVertex[1].tu2=0.0f;
pVertex[0].tu3=0.0f;
pVertex[1].tu3=0.0f;
float fXPerPixel=(1.0f/m_nSize)*0.5f*(800.0f/1024.0f);
float fYPerPixel=(1.0f/m_nSize)*0.5f*(600.0f/1024.0f);
pVertex[3].tu0=800.0f/1024.0f;//-fXPerPixel;
pVertex[2].tu0=800.0f/1024.0f;//-fXPerPixel;
pVertex[3].tu1=800.0f/1024.0f+fXPerPixel*2.0f;
pVertex[2].tu1=800.0f/1024.0f+fXPerPixel*2.0f;
pVertex[3].tu2=800.0f/1024.0f;//-fXPerPixel;
pVertex[2].tu2=800.0f/1024.0f;//-fXPerPixel;
pVertex[3].tu3=800.0f/1024.0f+fXPerPixel*2.0f;
pVertex[2].tu3=800.0f/1024.0f+fXPerPixel*2.0f;
pVertex[1].tv0=0.0f;
pVertex[3].tv0=0.0f;
pVertex[1].tv1=0.0f;
pVertex[3].tv1=0.0f;
pVertex[1].tv2=0.0f;
pVertex[3].tv2=0.0f;
pVertex[1].tv3=0.0f;
pVertex[3].tv3=0.0f;
pVertex[0].tv0=600.0f/1024.0f;//-fYPerPixel;
pVertex[2].tv0=600.0f/1024.0f;//-fYPerPixel;
pVertex[0].tv1=600.0f/1024.0f;//-fYPerPixel;
pVertex[2].tv1=600.0f/1024.0f;//-fYPerPixel;
pVertex[0].tv2=600.0f/1024.0f+fYPerPixel*2.0f;
pVertex[2].tv2=600.0f/1024.0f+fYPerPixel*2.0f;
pVertex[0].tv3=600.0f/1024.0f+fYPerPixel*2.0f;
pVertex[2].tv3=600.0f/1024.0f+fYPerPixel*2.0f;
for(int i=0;i<4;i++)
{
pVertex[i].w=0.1f;
pVertex[i].v.z=0.1f;
}
float fConst[4];
fConst[0]=vecNeighbor.x;
fConst[1]=vecNeighbor.y;
fConst[2]=vecNeighbor.z;
fConst[3]=1.0f;
pd3dDevice->SetPixelShaderConstant(0,fConst, 1);
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
for(i=0;i<nDepth;i++)
{
pd3dDevice->SetRenderTarget(m_pRenderSurface[i%2],m_pRenderZBuffer);
//pd3dDevice->SetRenderTarget(m_pRenderSurface[i%2],NULL);
D3DVIEWPORT8 viewData = { 0, 0, m_nSize, m_nSize, 0.0f, 1.0f };
pd3dDevice->SetViewport(&viewData);
//pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0xFF, 0x0, 0x0 ), 1.0, 0);
//pd3dDevice->BeginScene();
if(i>0)
{
fXPerPixel=(1.0f/m_nSize)*0.5f;
fYPerPixel=(1.0f/m_nSize)*0.5f;
pVertex[3].tu0=1.0f+fXPerPixel;
pVertex[2].tu0=1.0f+fXPerPixel;
pVertex[3].tu1=1.0f+fXPerPixel*2.0f;
pVertex[2].tu1=1.0f+fXPerPixel*2.0f;
pVertex[3].tu2=1.0f+fXPerPixel;
pVertex[2].tu2=1.0f+fXPerPixel;
pVertex[3].tu3=1.0f+fXPerPixel*2.0f;
pVertex[2].tu3=1.0f+fXPerPixel*2.0f;
pVertex[0].tv0=1.0f+fYPerPixel;
pVertex[2].tv0=1.0f+fYPerPixel;
pVertex[0].tv1=1.0f+fYPerPixel;
pVertex[2].tv1=1.0f+fYPerPixel;
pVertex[0].tv2=1.0f+fYPerPixel*2.0f;
pVertex[2].tv2=1.0f+fYPerPixel*2.0f;
pVertex[0].tv3=1.0f+fYPerPixel*2.0f;
pVertex[2].tv3=1.0f+fYPerPixel*2.0f;
}
if(i==0)
{
pd3dDevice->SetTexture(0,pTexture);
pd3dDevice->SetTexture(1,pTexture);
pd3dDevice->SetTexture(2,pTexture);
pd3dDevice->SetTexture(3,pTexture);
}
else
{
pd3dDevice->SetTexture(0,m_pRenderTexture[(i-1)%2]);
pd3dDevice->SetTexture(1,m_pRenderTexture[(i-1)%2]);
pd3dDevice->SetTexture(2,m_pRenderTexture[(i-1)%2]);
pd3dDevice->SetTexture(3,m_pRenderTexture[(i-1)%2]);
}
//pd3dDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(QuadVertex2));
//pd3dDevice->EndScene();
m_nFinalRenderTexture=i%2;
}
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
//pd3dDevice->BeginScene();
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,TRUE);
/*
pd3dDevice->SetTransform(D3DTS_WORLD,matOldWorld);
pd3dDevice->SetTransform(D3DTS_PROJECTION,matOldProjection);
pd3dDevice->SetTransform(D3DTS_VIEW,matOldView);
*/
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
pd3dDevice->SetPixelShader(NULL);
}
void CGlareTexture::Create(int nSize)
{
m_nSize=nSize;
D3DDISPLAYMODE mode;
BaseGraphicsLayer::GetDevice()->GetDisplayMode(&mode);
BaseGraphicsLayer::GetDevice()->CreateTexture(nSize,nSize,1,D3DUSAGE_RENDERTARGET,BaseGraphicsLayer::m_d3dpp.BackBufferFormat,D3DPOOL_DEFAULT,&m_pRenderTexture[0]);
m_pRenderTexture[0]->GetSurfaceLevel(0, &m_pRenderSurface[0]);
BaseGraphicsLayer::GetDevice()->CreateTexture(nSize,nSize,1,D3DUSAGE_RENDERTARGET,BaseGraphicsLayer::m_d3dpp.BackBufferFormat,D3DPOOL_DEFAULT,&m_pRenderTexture[1]);
m_pRenderTexture[1]->GetSurfaceLevel(0, &m_pRenderSurface[1]);
if(m_pRenderZBuffer==NULL)
BaseGraphicsLayer::GetDevice()->CreateDepthStencilSurface(nSize,nSize,BaseGraphicsLayer::m_d3dpp.AutoDepthStencilFormat,D3DMULTISAMPLE_NONE,&m_pRenderZBuffer);
LPD3DXBUFFER pCode;
D3DXAssembleShader(strBlurPixelShader,strlen(strBlurPixelShader),0,NULL,&pCode,NULL);
BaseGraphicsLayer::GetDevice()->CreatePixelShader((DWORD*)pCode->GetBufferPointer(),&m_BlurPixelShader);
pCode->Release();
DWORD Declaration[] =
{
D3DVSD_STREAM( 0 ),
D3DVSD_REG(0,D3DVSDT_FLOAT3), // Position
D3DVSD_REG(1,D3DVSDT_FLOAT2), // Texture Coordinate
D3DVSD_END()
};
D3DXAssembleShader(strBlurVertexShader,strlen(strBlurVertexShader),0,NULL,&pCode,NULL);
BaseGraphicsLayer::GetDevice()->CreateVertexShader( Declaration,
(DWORD*)pCode->GetBufferPointer(),
&m_BlurVertexShader, 0 );
pCode->Release();
BaseGraphicsLayer::GetDevice()->CreateVertexBuffer( 4 * sizeof(QuadVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0, D3DPOOL_DEFAULT, &m_pVertexBuffer);
QuadVertex *pBuff;
if(m_pVertexBuffer)
{
m_pVertexBuffer->Lock(0, 4 * sizeof(QuadVertex),(BYTE**)&pBuff, 0);
for (int i = 0; i < 4; ++i)
{
pBuff->Position = D3DXVECTOR3((i==0 || i==3) ? -1.0f : 1.0f,
(i<2) ? -1.0f : 1.0f,
0.0f);
pBuff->Tex = D3DXVECTOR2((i==0 || i==3) ? 0.0f : 1.0f,
(i<2) ? 1.0f : 0.0f);
/*
pBuff->Tex = D3DXVECTOR2((i==0 || i==3) ? 0.0f : 1024.0f,
(i<2) ? 1024.0f : 0.0f);
*/
pBuff++;
}
m_pVertexBuffer->Unlock();
}
}
void CGlareTexture::CreateAndWriteUVOffsets(int width, int height)
{
float const noOffsetX[4] = { 0.0f, 0.0f, 0.0f, 0.0f};
float const noOffsetY[4] = { 0.0f, 0.0f, 0.0f, 0.0f};
float const kPerTexelWidth = 1.0f/static_cast<float>(width);
float const kPerTexelHeight = 1.0f/static_cast<float>(height);
float s = 0.5f;
float const eps = 10.0e-4f;
float const rotAngle1 = D3DXToRadian( 0.0f );
float const rotAngle2 = rotAngle1 + D3DXToRadian(120.0f);
float const rotAngle3 = rotAngle1 + D3DXToRadian(240.0f);
// Change filter kernel for 9-sample box filtering, but for edge-detection we are
// going to use interpolated texels. Why? Because we detect diagonal edges only
// and the vertical and horizontal filtering seems to help.
float const type1OffsetX[4] = { -s * kPerTexelWidth,
-s * kPerTexelWidth,
s * kPerTexelWidth,
s * kPerTexelWidth };
float const type1OffsetY[4] = { -s * kPerTexelHeight,
s * kPerTexelHeight,
s * kPerTexelHeight,
-s * kPerTexelHeight };
// we have to bring the 16 texel-sample-filter a bit closer to the center to avoid
// separation due to floating point inaccuracies.
float const type2OffsetX[4] = { -.5f * kPerTexelWidth + eps,
-.5f * kPerTexelWidth + eps,
1.5f * kPerTexelWidth - eps,
1.5f * kPerTexelWidth - eps };
float const type2OffsetY[4] = { -.5f * kPerTexelHeight+ eps,
1.5f * kPerTexelHeight- eps,
1.5f * kPerTexelHeight- eps,
-.5f * kPerTexelHeight+ eps };
float const type3OffsetX[4] = {0.0f, sinf(rotAngle1)*kPerTexelWidth,
sinf(rotAngle2)*kPerTexelWidth,
sinf(rotAngle3)*kPerTexelWidth };
float const type3OffsetY[4] = {0.0f, -cosf(rotAngle1)*kPerTexelHeight,
-cosf(rotAngle2)*kPerTexelHeight,
-cosf(rotAngle3)*kPerTexelHeight };
s = 2.0f/3.0f; // same as type 1, except s is different
float const type4OffsetX[4] = { -s * kPerTexelWidth,
-s * kPerTexelWidth,
s * kPerTexelWidth,
s * kPerTexelWidth };
float const type4OffsetY[4] = { -s * kPerTexelHeight,
s * kPerTexelHeight,
s * kPerTexelHeight,
-s * kPerTexelHeight };
// write all these offsets to constant memory
for (int i = 0; i < 8; ++i)
{
D3DXVECTOR4 noOffset( noOffsetX[i], noOffsetY[i], 0.0f, 0.0f);
D3DXVECTOR4 type1Offset(type1OffsetX[i], type1OffsetY[i], 0.0f, 0.0f);
D3DXVECTOR4 type2Offset(type2OffsetX[i], type2OffsetY[i], 0.0f, 0.0f);
D3DXVECTOR4 type3Offset(type3OffsetX[i], type3OffsetY[i], 0.0f, 0.0f);
D3DXVECTOR4 type4Offset(type4OffsetX[i], type4OffsetY[i], 0.0f, 0.0f);
BaseGraphicsLayer::GetDevice()->SetVertexShaderConstant(CV_UV_T0_NO_OFFSET + 5*i, &noOffset, 1);
BaseGraphicsLayer::GetDevice()->SetVertexShaderConstant(CV_UV_T0_TYPE1 + 5*i, &type1Offset, 1);
BaseGraphicsLayer::GetDevice()->SetVertexShaderConstant(CV_UV_T0_TYPE2 + 5*i, &type2Offset, 1);
BaseGraphicsLayer::GetDevice()->SetVertexShaderConstant(CV_UV_T0_TYPE3 + 5*i, &type3Offset, 1);
BaseGraphicsLayer::GetDevice()->SetVertexShaderConstant(CV_UV_T0_TYPE4 + 5*i, &type4Offset, 1);
}
}
void CGlareTexture::ProcedualGenerateGlareTexture(LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECT3DBASETEXTURE8 pTexture, vector3 vecNeighbor, int nDepth)
{
if(pTexture)
m_nFinalRenderTexture=0;
long QUADVERTEX2FVF=D3DFVF_XYZRHW | D3DFVF_TEX4;
LPDIRECT3DSURFACE8 m_pTempRenderSurface;
LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pd3dDevice->SetVertexShader(QUADVERTEX2FVF);
pd3dDevice->SetPixelShader(m_BlurPixelShader);
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_LIGHTING,FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_FOGENABLE,FALSE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
float fConst[4];
fConst[0]=vecNeighbor.x;
fConst[1]=vecNeighbor.y;
fConst[2]=vecNeighbor.z;
fConst[3]=0.27f;
pd3dDevice->SetPixelShaderConstant(0,fConst, 1 );
QuadVertex2 pVertex[4];
pVertex[0].v.x=0.0f;
pVertex[1].v.x=0.0f;
pVertex[2].v.x=(float)m_nSize;
pVertex[3].v.x=(float)m_nSize;
pVertex[1].v.y=0.0f;
pVertex[3].v.y=0.0f;
pVertex[0].v.y=(float)m_nSize;
pVertex[2].v.y=(float)m_nSize;
pVertex[0].tu0=0.0f;
pVertex[1].tu0=0.0f;
pVertex[0].tu1=0.0f;
pVertex[1].tu1=0.0f;
pVertex[0].tu2=0.0f;
pVertex[1].tu2=0.0f;
pVertex[0].tu3=0.0f;
pVertex[1].tu3=0.0f;
pVertex[1].tv0=0.0f;
pVertex[3].tv0=0.0f;
pVertex[1].tv1=0.0f;
pVertex[3].tv1=0.0f;
pVertex[1].tv2=0.0f;
pVertex[3].tv2=0.0f;
pVertex[1].tv3=0.0f;
pVertex[3].tv3=0.0f;
float fXPerPixel=(1.0f/m_nSize)*0.5f*(800.0f/1024.0f);
float fYPerPixel=(1.0f/m_nSize)*0.5f*(600.0f/1024.0f);
//CSceneStateMgr::_SetD3DRenderState(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
if(pTexture==NULL)
{
fXPerPixel=(1.0f/m_nSize)*0.5f;
fYPerPixel=(1.0f/m_nSize)*0.5f;
pVertex[3].tu0=1.0f;
pVertex[2].tu0=1.0f;
pVertex[3].tu1=1.0f;
pVertex[2].tu1=1.0f;
pVertex[3].tu2=1.0f;
pVertex[2].tu2=1.0f;
pVertex[3].tu3=1.0f;
pVertex[2].tu3=1.0f;
pVertex[0].tv0=1.0f;
pVertex[2].tv0=1.0f;
pVertex[0].tv1=1.0f;
pVertex[2].tv1=1.0f;
pVertex[0].tv2=1.0f;
pVertex[2].tv2=1.0f;
pVertex[0].tv3=1.0f;
pVertex[2].tv3=1.0f;
/*
pVertex[3].tu0=1.0f+fXPerPixel;
pVertex[2].tu0=1.0f+fXPerPixel;
pVertex[3].tu1=1.0f+fXPerPixel*2.0f;
pVertex[2].tu1=1.0f+fXPerPixel*2.0f;
pVertex[3].tu2=1.0f+fXPerPixel;
pVertex[2].tu2=1.0f+fXPerPixel;
pVertex[3].tu3=1.0f+fXPerPixel*2.0f;
pVertex[2].tu3=1.0f+fXPerPixel*2.0f;
pVertex[0].tv0=1.0f+fYPerPixel;
pVertex[2].tv0=1.0f+fYPerPixel;
pVertex[0].tv1=1.0f+fYPerPixel;
pVertex[2].tv1=1.0f+fYPerPixel;
pVertex[0].tv2=1.0f+fYPerPixel*2.0f;
pVertex[2].tv2=1.0f+fYPerPixel*2.0f;
pVertex[0].tv3=1.0f+fYPerPixel*2.0f;
pVertex[2].tv3=1.0f+fYPerPixel*2.0f;
*/
for(int i=0;i<nDepth;i++)
{
pd3dDevice->SetRenderTarget(m_pRenderSurface[(m_nFinalRenderTexture+i+1)%2],m_pRenderZBuffer);
pd3dDevice->SetTexture(0,m_pRenderTexture[(m_nFinalRenderTexture+i)%2]);
pd3dDevice->SetTexture(1,m_pRenderTexture[(m_nFinalRenderTexture+i)%2]);
pd3dDevice->SetTexture(2,m_pRenderTexture[(m_nFinalRenderTexture+i)%2]);
pd3dDevice->SetTexture(3,m_pRenderTexture[(m_nFinalRenderTexture+i)%2]);
}
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(QuadVertex2));
m_nFinalRenderTexture=(m_nFinalRenderTexture+i)%2;
//m_nFinalRenderTexture=i%2;
}
else
{
pVertex[3].tu0=800.0f/1024.0f;//-fXPerPixel;
pVertex[2].tu0=800.0f/1024.0f;//-fXPerPixel;
pVertex[3].tu1=800.0f/1024.0f+fXPerPixel*2.0f;
pVertex[2].tu1=800.0f/1024.0f+fXPerPixel*2.0f;
pVertex[3].tu2=800.0f/1024.0f;//-fXPerPixel;
pVertex[2].tu2=800.0f/1024.0f;//-fXPerPixel;
pVertex[3].tu3=800.0f/1024.0f+fXPerPixel*2.0f;
pVertex[2].tu3=800.0f/1024.0f+fXPerPixel*2.0f;
pVertex[0].tv0=600.0f/1024.0f;//-fYPerPixel;
pVertex[2].tv0=600.0f/1024.0f;//-fYPerPixel;
pVertex[0].tv1=600.0f/1024.0f;//-fYPerPixel;
pVertex[2].tv1=600.0f/1024.0f;//-fYPerPixel;
pVertex[0].tv2=600.0f/1024.0f+fYPerPixel*2.0f;
pVertex[2].tv2=600.0f/1024.0f+fYPerPixel*2.0f;
pVertex[0].tv3=600.0f/1024.0f+fYPerPixel*2.0f;
pVertex[2].tv3=600.0f/1024.0f+fYPerPixel*2.0f;
for(int i=0;i<nDepth;i++)
{
pd3dDevice->SetRenderTarget(m_pRenderSurface[i%2],m_pRenderZBuffer);
if(i==0)
{
if(pTexture)
{
pd3dDevice->SetTexture(0,pTexture);
pd3dDevice->SetTexture(1,pTexture);
pd3dDevice->SetTexture(2,pTexture);
pd3dDevice->SetTexture(3,pTexture);
}
else
{
pd3dDevice->SetTexture(0,m_pRenderTexture[m_nFinalRenderTexture]);
pd3dDevice->SetTexture(1,m_pRenderTexture[m_nFinalRenderTexture]);
pd3dDevice->SetTexture(2,m_pRenderTexture[m_nFinalRenderTexture]);
pd3dDevice->SetTexture(3,m_pRenderTexture[m_nFinalRenderTexture]);
}
}
else
{
pd3dDevice->SetTexture(0,m_pRenderTexture[(i-1)%2]);
pd3dDevice->SetTexture(1,m_pRenderTexture[(i-1)%2]);
pd3dDevice->SetTexture(2,m_pRenderTexture[(i-1)%2]);
pd3dDevice->SetTexture(3,m_pRenderTexture[(i-1)%2]);
}
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(QuadVertex2));
m_nFinalRenderTexture=i%2;
}
}
//CSceneStateMgr::_SetD3DRenderState(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
pd3dDevice->SetPixelShader(NULL);
}
void CGlareTexture::GenerateGlareTexture2(LPDIRECT3DDEVICE8 pd3dDevice,LPDIRECT3DBASETEXTURE8 pTexture,vector3 vecNeighbor,int nDepth)
{
LPDIRECT3DSURFACE8 m_pTempRenderSurface;
LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
CreateAndWriteUVOffsets(m_nSize,m_nSize);
matrix matOldWorld,matOldProjection,matOldView;
pd3dDevice->GetTransform(D3DTS_WORLD,matOldWorld);
pd3dDevice->GetTransform(D3DTS_PROJECTION,matOldProjection);
pd3dDevice->GetTransform(D3DTS_VIEW,matOldView);
D3DXMATRIX matWorld;
D3DXMATRIX matView;
D3DXMATRIX matProj;
D3DXMATRIX matViewProj;
D3DXMATRIX matWorldViewProj;
D3DXVECTOR4 offset(0.0f, 0.0f, 0.0f, 0.0f);
offset.x = 2.0f;
pd3dDevice->SetVertexShaderConstant(CV_UV_OFFSET_TO_USE, &offset, 1);
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
pd3dDevice->SetVertexShader(m_BlurVertexShader);
pd3dDevice->SetStreamSource(0,m_pVertexBuffer,sizeof(QuadVertex));
D3DXVECTOR3 const vEyePt = D3DXVECTOR3( 0.0f, 0.0f, -5.0f );
D3DXVECTOR3 const vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 const vUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUp);
D3DXMatrixOrthoLH(&matProj, 4.0f, 4.0f, 0.2f, 20.0f);
D3DXMatrixMultiply(&matViewProj, &matView, &matProj);
D3DXMatrixScaling(&matWorld, 2.0f, 2.0f, 1.0f);
D3DXMatrixMultiply(&matWorldViewProj, &matWorld, &matViewProj);
D3DXMatrixTranspose(&matWorldViewProj, &matWorldViewProj);
pd3dDevice->GetTransform(D3DTS_WORLD,&matWorld);
pd3dDevice->GetTransform(D3DTS_PROJECTION,&matProj);
pd3dDevice->GetTransform(D3DTS_VIEW,&matView);
for(int i=0;i<4;i++)
{
CSceneStateMgr::_SetD3DTextureStageState(i, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(i, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(i, D3DTSS_MIPFILTER, D3DTEXF_NONE);
CSceneStateMgr::_SetD3DTextureStageState(i, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
CSceneStateMgr::_SetD3DTextureStageState(i, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
}
pd3dDevice->SetVertexShaderConstant(CV_WORLDVIEWPROJ_0, &matWorldViewProj(0, 0), 4);
pd3dDevice->SetPixelShader(m_BlurPixelShader);
pd3dDevice->SetVertexShader(m_BlurVertexShader);
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_LIGHTING,FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_FOGENABLE,FALSE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
pd3dDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(QuadVertex));
float fBlurConst[4]={vecNeighbor.x,vecNeighbor.x,vecNeighbor.x,vecNeighbor.x};
pd3dDevice->SetPixelShaderConstant(0,fBlurConst,1);
for( i=0;i<nDepth;i++)
{
//pd3dDevice->SetRenderTarget(m_pRenderSurface[i%2],NULL);
pd3dDevice->SetRenderTarget(m_pRenderSurface[i%2],m_pRenderZBuffer);
//D3DVIEWPORT8 viewData = { 0, 0, m_nSize, m_nSize, 0.0f, 1.0f };
//pd3dDevice->SetViewport(&viewData);
if(i==0)
{
pd3dDevice->SetTexture(0,pTexture);
pd3dDevice->SetTexture(1,pTexture);
pd3dDevice->SetTexture(2,pTexture);
pd3dDevice->SetTexture(3,pTexture);
}
else
{
pd3dDevice->SetTexture(0,m_pRenderTexture[(i-1)%2]);
pd3dDevice->SetTexture(1,m_pRenderTexture[(i-1)%2]);
pd3dDevice->SetTexture(2,m_pRenderTexture[(i-1)%2]);
pd3dDevice->SetTexture(3,m_pRenderTexture[(i-1)%2]);
}
pd3dDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
m_nFinalRenderTexture=i%2;
}
for(i=0;i<4;i++)
{
CSceneStateMgr::_SetD3DTextureStageState(i, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(i, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(i, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
CSceneStateMgr::_SetD3DTextureStageState(i, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
CSceneStateMgr::_SetD3DTextureStageState(i, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
}
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,TRUE);
pd3dDevice->SetTransform(D3DTS_WORLD,matOldWorld);
pd3dDevice->SetTransform(D3DTS_PROJECTION,matOldProjection);
pd3dDevice->SetTransform(D3DTS_VIEW,matOldView);
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
pd3dDevice->SetPixelShader(NULL);
}

View File

@@ -0,0 +1,57 @@
// GlareTexture.h: interface for the CGlareTexture class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_GLARETEXTURE_H__18B36EBC_004F_4F55_A006_DE21B3FC4CCB__INCLUDED_)
#define AFX_GLARETEXTURE_H__18B36EBC_004F_4F55_A006_DE21B3FC4CCB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "RenderTexture.h"
#include "D3DX8.h"
#include "3DMath.h"
class CGlareTexture
{
class QuadVertex
{
public:
D3DXVECTOR3 Position;
D3DXVECTOR2 Tex;
};
class QuadVertex2
{
public:
vector3 v;
float w;
float tu0,tv0;
float tu1,tv1;
float tu2,tv2;
float tu3,tv3;
};
LPDIRECT3DTEXTURE8 m_pRenderTexture[2];
LPDIRECT3DSURFACE8 m_pRenderSurface[2];
static LPDIRECT3DSURFACE8 m_pRenderZBuffer;
DWORD m_BlurPixelShader,m_BlurVertexShader;
LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer;
int m_nSize;
int m_nFinalRenderTexture;
public:
void GenerateGlareTexture2(LPDIRECT3DDEVICE8 pd3dDevice,LPDIRECT3DBASETEXTURE8 pTexture,vector3 vecNeighbor,int nDepth);
void ProcedualGenerateGlareTexture(LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECT3DBASETEXTURE8 pTexture,vector3 vecNeighbor,int nDepth);
LPDIRECT3DTEXTURE8 GetTexture(){return m_pRenderTexture[m_nFinalRenderTexture];};
void CreateAndWriteUVOffsets(int width, int height);
void Create(int nSize);
void GenerateGlareTexture(LPDIRECT3DDEVICE8 pd3dDevice,LPDIRECT3DBASETEXTURE8 pTexture,vector3 vecNeighbor,int nDepth);
CGlareTexture();
virtual ~CGlareTexture();
};
#endif // !defined(AFX_GLARETEXTURE_H__18B36EBC_004F_4F55_A006_DE21B3FC4CCB__INCLUDED_)

View File

@@ -0,0 +1,19 @@
// GraphicLayerError.cpp: implementation of the CGraphicLayerError class.
//
//////////////////////////////////////////////////////////////////////
#include "GraphicLayerError.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CGraphicLayerError::CGraphicLayerError()
{
}
CGraphicLayerError::~CGraphicLayerError()
{
}

View File

@@ -0,0 +1,34 @@
// GraphicLayerError.h: interface for the CGraphicLayerError class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_GRAPHICLAYERERROR_H__D06B571E_F0F8_41E8_AD22_257A312F48E0__INCLUDED_)
#define AFX_GRAPHICLAYERERROR_H__D06B571E_F0F8_41E8_AD22_257A312F48E0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Error.h"
class CGraphicLayerError : public CError
{
public:
CGraphicLayerError();
virtual ~CGraphicLayerError();
char *GetErrorMsg()
{
char msgtemp[MAX_ERRORBUFFER];
strcpy(msgtemp,"Graphics Layer Error:");
strcat(msgtemp,m_strErrormsg);
strcpy(m_strErrormsg,msgtemp);
return m_strErrormsg;
};
CGraphicLayerError(char *msg)
{
SetErrorMsg(msg);
};
};
#endif // !defined(AFX_GRAPHICLAYERERROR_H__D06B571E_F0F8_41E8_AD22_257A312F48E0__INCLUDED_)

View File

@@ -0,0 +1,248 @@
// IMEFont.cpp: implementation of the CIMEFont class.
//
//////////////////////////////////////////////////////////////////////
#include "IMEFont.h"
#include "SceneStateMgr.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CIMEFont::CIMEFont()
{
for(int i=0;i<10;i++)
{
strcpy(m_strPrint[i],"");
strcpy(m_strPrinted[i],"");
}
m_RenderX=0;
m_RenderY=0;
}
CIMEFont::~CIMEFont()
{
if(m_pTexture)
m_pTexture->Release();
}
void CIMEFont::Render(LPDIRECT3DDEVICE8 pd3dDevice)
{
if(isRewirte())
MakeTexture();
m_pVertex[0].v.x=0.0f+m_RenderX;
m_pVertex[1].v.x=0.0f+m_RenderX;
m_pVertex[2].v.x=(float)m_SizeX+m_RenderX;
m_pVertex[3].v.x=(float)m_SizeX+m_RenderX;
m_pVertex[1].v.y=0.0f+m_RenderY;
m_pVertex[3].v.y=0.0f+m_RenderY;
m_pVertex[0].v.y=(float)m_SizeY+m_RenderY;
m_pVertex[2].v.y=(float)m_SizeY+m_RenderY;
m_pVertex[0].tu=0.0f;
m_pVertex[1].tu=0.0f;
m_pVertex[3].tu=1.0f;
m_pVertex[2].tu=1.0f;
m_pVertex[1].tv=0.0f;
m_pVertex[3].tv=0.0f;
m_pVertex[0].tv=1.0f;
m_pVertex[2].tv=1.0f;
for(int i=0;i<4;i++)
{
m_pVertex[i].w=0.1f;
m_pVertex[i].v.z=0.1f;
m_pVertex[i].Diffuse.c=0xffffffff;
m_pVertex[i].Specular.c=0xffffffff;
}
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
CSceneStateMgr::_SetD3DRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
pd3dDevice->SetTexture(0,m_pTexture);
//3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
//3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
//m_CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
//m_CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_POINT );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_POINT );
//m_CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_NONE );
pd3dDevice->SetVertexShader(TLVERTEXFVF);
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,m_pVertex,sizeof(TLVertex));
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
}
void CIMEFont::Create(LPDIRECT3DDEVICE8 pd3dDevice,long sizeX,long sizeY)
{
m_SizeX=sizeX;
m_SizeY=sizeY;
// Chatting Message Font 512,64;
m_cLine=m_SizeY/16;
pd3dDevice->CreateTexture(sizeX,sizeY,1,0,D3DFMT_A4R4G4B4,D3DPOOL_MANAGED,&m_pTexture);
}
void CIMEFont::PrintToTexture(char *str, long line)
{
if( line >=0 && line<m_cLine)
strcpy(m_strPrint[line],str);
}
bool CIMEFont::isRewirte()
{
for(int cLine=0;cLine<m_cLine;cLine++)
{
if( strcmp(m_strPrint[cLine],m_strPrinted[cLine])!=0)
return true;
}
return false;
}
void CIMEFont::MakeTexture()
{
DWORD* pBitmapBits;
BITMAPINFO bmi;
ZeroMemory( &bmi.bmiHeader, sizeof(BITMAPINFOHEADER) );
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = (int)m_SizeX;
bmi.bmiHeader.biHeight = -(int)m_SizeY;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biBitCount = 32;
// Create a DC and a bitmap for the font
HDC hDC = CreateCompatibleDC( NULL );
HBITMAP hbmBitmap = CreateDIBSection( hDC, &bmi, DIB_RGB_COLORS,
(VOID**)&pBitmapBits, NULL, 0 );
SetMapMode( hDC, MM_TEXT );
HFONT hFont=CreateFont(-12,6,0,0,0,FALSE,FALSE,FALSE, CHINESEBIG5_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH, "MingLiu" );
SelectObject( hDC, hbmBitmap );
SelectObject( hDC, hFont );
SetTextColor( hDC, RGB(255,255,255) );
SetBkColor( hDC, 0x00000000 );
SetTextAlign( hDC, TA_LEFT);
for(int cLine=0;cLine<m_cLine;cLine++)
{
ExtTextOut( hDC, 0, cLine*16, ETO_OPAQUE, NULL,m_strPrint[cLine],strlen(m_strPrint[cLine]), NULL );
strcpy(m_strPrinted[cLine],m_strPrint[cLine]);
}
/*
ExtTextOut( hDC, 0, 12, ETO_OPAQUE, NULL,m_strPrint[1],strlen(m_strPrint[1]), NULL );
ExtTextOut( hDC, 0, 24, ETO_OPAQUE, NULL,m_strPrint[2],strlen(m_strPrint[2]), NULL );
ExtTextOut( hDC, 0, 36, ETO_OPAQUE, NULL,m_strPrint[3],strlen(m_strPrint[3]), NULL );
strcpy(m_strPrinted[0],m_strPrint[0]);
strcpy(m_strPrinted[1],m_strPrint[1]);
strcpy(m_strPrinted[2],m_strPrint[2]);
strcpy(m_strPrinted[3],m_strPrint[3]);
*/
//SIZE p;
//GetTextExtentPoint32(hDC,"<22><>",2,&p);
//RECT rcFont={0,0,25*15,4*16};
//DrawText(hDC,strTemp,strlen(strTemp),&rcFont,DT_WORDBREAK|DT_LEFT);
D3DLOCKED_RECT d3dlr;
m_pTexture->LockRect( 0, &d3dlr, 0, 0 );
WORD* pDst16 = (WORD*)d3dlr.pBits;
BYTE bAlpha;
int x,y;
for( y=0;y<m_SizeY; y++ )
{
for( x=0;x<m_SizeX; x++ )
{
bAlpha = (BYTE)((pBitmapBits[m_SizeX*y + x] & 0xff) >> 4);
if (bAlpha > 0)
{
*pDst16++ = (bAlpha << 12) | 0x0fff;
}
else
{
*pDst16++=0x0000;
}
}
}
m_pTexture->UnlockRect(0);
DeleteObject( hbmBitmap );
DeleteDC( hDC );
DeleteObject( hFont );
}
void CIMEFont::Render(LPDIRECT3DDEVICE8 pd3dDevice, DWORD dwColor)
{
if(isRewirte())
MakeTexture();
m_pVertex[0].v.x=0.0f+m_RenderX;
m_pVertex[1].v.x=0.0f+m_RenderX;
m_pVertex[2].v.x=(float)m_SizeX+m_RenderX;
m_pVertex[3].v.x=(float)m_SizeX+m_RenderX;
m_pVertex[1].v.y=0.0f+m_RenderY;
m_pVertex[3].v.y=0.0f+m_RenderY;
m_pVertex[0].v.y=(float)m_SizeY+m_RenderY;
m_pVertex[2].v.y=(float)m_SizeY+m_RenderY;
m_pVertex[0].tu=0.0f;
m_pVertex[1].tu=0.0f;
m_pVertex[3].tu=1.0f;
m_pVertex[2].tu=1.0f;
m_pVertex[1].tv=0.0f;
m_pVertex[3].tv=0.0f;
m_pVertex[0].tv=1.0f;
m_pVertex[2].tv=1.0f;
for(int i=0;i<4;i++)
{
m_pVertex[i].w=0.1f;
m_pVertex[i].v.z=0.1f;
m_pVertex[i].Diffuse.c=dwColor;
m_pVertex[i].Specular.c=dwColor;
}
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
CSceneStateMgr::_SetD3DRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
pd3dDevice->SetTexture(0,m_pTexture);
//3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
//3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
//m_CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
//m_CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_POINT );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_POINT );
//m_CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_NONE );
pd3dDevice->SetVertexShader(TLVERTEXFVF);
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,m_pVertex,sizeof(TLVertex));
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
}

View File

@@ -0,0 +1,45 @@
// IMEFont.h: interface for the CIMEFont class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_IMEFONT_H__C8D7C988_BD4A_4270_AE9D_829679CEB5F4__INCLUDED_)
#define AFX_IMEFONT_H__C8D7C988_BD4A_4270_AE9D_829679CEB5F4__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
#include <d3dx8.h>
#include "Vertex.h"
class CIMEFont
{
TLVertex m_pVertex[4];
char m_strPrint[20][256];
char m_strPrinted[20][256];
int m_cLine;
public:
void Render(LPDIRECT3DDEVICE8 pd3dDevice,DWORD dwColor);
void MakeTexture();
bool isRewirte();
void PrintToTexture(char *str,long line);
void Create(LPDIRECT3DDEVICE8 pd3dDevice,long sizeX,long sizeY);
void Render(LPDIRECT3DDEVICE8 pd3dDevice);
LPDIRECT3DTEXTURE8 m_pTexture;
CIMEFont();
virtual ~CIMEFont();
long m_RenderX,m_RenderY;
long m_SizeX,m_SizeY;
void SetRenderPos(int RenderX,int RenderY)
{
m_RenderX=RenderX;
m_RenderY=RenderY;
};
char* GetPrintText(int nText)
{
return m_strPrint[nText];
};
};
#endif // !defined(AFX_IMEFONT_H__C8D7C988_BD4A_4270_AE9D_829679CEB5F4__INCLUDED_)

View File

@@ -0,0 +1,835 @@
// Intersection.cpp: implementation of the CIntersection class.
//
//////////////////////////////////////////////////////////////////////
#include "Intersection.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CIntersection::CIntersection()
{
}
CIntersection::~CIntersection()
{
}
int CIntersection::PolygonRay(vector3 vecStart, vector3 vecEnd, vector3 *poly,float &fInterLens)
{
/*
vector3 vecDir=(vecEnd-vecStart);
vecDir.Normalize();
vector3 vecPoly[3];
vecPoly[0]=*poly[0];
vecPoly[1]=*poly[1];
vecPoly[2]=*poly[2];
if(PolygonRay2(vecStart,vecDir,vecPoly))
return 1;
return 0;
*/
///*
vector3 n=(poly[1]-poly[0])^(poly[2]-poly[0]);
n.Normalize();
if((fabs(n.x) <= 0.00000001f) &&
(fabs(n.y) <= 0.00000001f) &&
(fabs(n.z) <= 0.00000001f)) {
fInterLens = 1000000.0f;
return 0;
}
vector3 vecDir=(vecEnd-vecStart);
vecDir.Normalize();
float h;
if(fabs((n.x*vecDir.x + n.y*vecDir.y + n.z*vecDir.z)) < 0.00000001f)
{
fInterLens = 1000000.0f;
return 0;
}
else {
h=( (n.x*poly[0].x+n.y*poly[0].y+n.z*poly[0].z) - (n.x*vecStart.x+n.y*vecStart.y+n.z*vecStart.z) )
/ (n.x*vecDir.x + n.y*vecDir.y + n.z*vecDir.z);
fInterLens=h;
}
if(h<0.0f)return 0;
vector3 vecInter=vecEnd-vecStart;
if(vecInter.GetLens() < h)
return 0;
vector3 vecInterpos=vecStart+vecDir*h;
vector3 vecEgde,vecEdgeNormal;
float fHalfPlane;
long pos=0,neg=0;
vecEgde=poly[0]-poly[1];
vecEdgeNormal=vecEgde^n;
vecEdgeNormal.Normalize();
fHalfPlane=(vecInterpos*vecEdgeNormal)-(poly[1]*vecEdgeNormal);
if(fHalfPlane >= 0.001f)
pos++;
if(fHalfPlane <= -0.001f)
neg++;
vecEgde=poly[1]-poly[2];
vecEdgeNormal=vecEgde^n;
vecEdgeNormal.Normalize();
fHalfPlane=(vecInterpos*vecEdgeNormal)-(poly[2]*vecEdgeNormal);
if(fHalfPlane >= 0.001f)
pos++;
if(fHalfPlane <= -0.001f)
neg++;
vecEgde=poly[2]-poly[0];
vecEdgeNormal=vecEgde^n;
vecEdgeNormal.Normalize();
fHalfPlane=(vecInterpos*vecEdgeNormal)-(poly[0]*vecEdgeNormal);
if(fHalfPlane >= 0.001f)
pos++;
if(fHalfPlane <= -0.001f)
neg++;
if (!pos || !neg)
return 1;
return 0;
/*
vecFactor[0]=(vecInterpos-poly[0]);vecFactor[0].Normalize();
vecFactor[1]=(vecInterpos-poly[1]);vecFactor[1].Normalize();
vecFactor[2]=(vecInterpos-poly[2]);vecFactor[2].Normalize();
fAngle[0]=vecFactor[0]*vecFactor[1];
fAngle[1]=vecFactor[1]*vecFactor[2];
fAngle[2]=vecFactor[2]*vecFactor[0];
fAngle[0]=acosf(fAngle[0]);
fAngle[1]=acosf(fAngle[1]);
fAngle[2]=acosf(fAngle[2]);
/*
if( fAngle[0] == 3.14159f ||
fAngle[1] == 3.14159f ||
fAngle[2] == 3.14159f)
return 0;
if(fAngle[0]+fAngle[1]+fAngle[2] >= (3.14159f)*1.7f)
return 1;
return 0;
//*/
}
int CIntersection::PolygonToPolygon(vector3 *vecPoly1, vector3 *vecPoly2)
{
vector3 vecPolyNormal1=(vecPoly1[1]-vecPoly1[0])^(vecPoly1[2]-vecPoly1[1]);
vector3 vecPolyNormal2=(vecPoly2[1]-vecPoly2[0])^(vecPoly2[2]-vecPoly2[1]);
vecPolyNormal1.Normalize();
vecPolyNormal2.Normalize();
float fDistance[3];
fDistance[0]= vecPolyNormal1*(vecPoly2[0]-vecPoly1[0]);
fDistance[1]= vecPolyNormal1*(vecPoly2[1]-vecPoly1[0]);
fDistance[2]= vecPolyNormal1*(vecPoly2[2]-vecPoly1[0]);
if( (fDistance[0] > 0.0f && fDistance[1] > 0.0f && fDistance[2] > 0.0f) )
{
return -1;
}
if( (fDistance[0] < 0.0f && fDistance[1] < 0.0f && fDistance[2] < 0.0f) )
{
return -2;
}
fDistance[0]= vecPolyNormal2*(vecPoly1[0]-vecPoly2[0]);
fDistance[1]= vecPolyNormal2*(vecPoly1[1]-vecPoly2[0]);
fDistance[2]= vecPolyNormal2*(vecPoly1[2]-vecPoly2[0]);
if( (fDistance[0] > 0.0f && fDistance[1] > 0.0f && fDistance[2] > 0.0f) ||
(fDistance[0] < 0.0f && fDistance[1] < 0.0f && fDistance[2] < 0.0f))
return 0;
float fIntersection;
vector3 vecLens;
if(PolygonRay(vecPoly2[0],vecPoly2[1],vecPoly1,fIntersection)==1)
{
vecLens=vecPoly2[0]-vecPoly2[1];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
if(PolygonRay(vecPoly2[1],vecPoly2[2],vecPoly1,fIntersection)==1)
{
vecLens=vecPoly2[1]-vecPoly2[2];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
if(PolygonRay(vecPoly2[2],vecPoly2[0],vecPoly1,fIntersection)==1)
{
vecLens=vecPoly2[2]-vecPoly2[0];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
if(PolygonRay(vecPoly1[0],vecPoly1[1],vecPoly2,fIntersection)==1)
{
vecLens=vecPoly1[0]-vecPoly1[1];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
if(PolygonRay(vecPoly1[1],vecPoly1[2],vecPoly2,fIntersection)==1)
{
vecLens=vecPoly1[1]-vecPoly1[2];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
if(PolygonRay(vecPoly1[2],vecPoly1[0],vecPoly2,fIntersection)==1)
{
vecLens=vecPoly1[2]-vecPoly1[0];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
return 0;
}
int CIntersection::BoxToRay(vector3 vecStart, vector3 vecEnd, vector3 *poly[], float &fIntersection)
{
vector3 n=(*poly[1]-*poly[0])^(*poly[2]-*poly[0]);
n.Normalize();
vector3 vecDir=(vecEnd-vecStart);
vecDir.Normalize();
float h=( (n.x*poly[0]->x+n.y*poly[0]->y+n.z*poly[0]->z) - (n.x*vecStart.x+n.y*vecStart.y+n.z*vecStart.z) )
/ (n.x*vecDir.x + n.y*vecDir.y + n.z*vecDir.z);
fIntersection=h;
if(h<0.0f)return 0;
vector3 vecInterpos=vecStart+vecDir*h;
vector3 vecFactor[4];
float fAngle[4];
vecFactor[0]=(vecInterpos-*poly[0]);vecFactor[0].Normalize();
vecFactor[1]=(vecInterpos-*poly[1]);vecFactor[1].Normalize();
vecFactor[2]=(vecInterpos-*poly[2]);vecFactor[2].Normalize();
vecFactor[3]=(vecInterpos-*poly[3]);vecFactor[3].Normalize();
fAngle[0]=vecFactor[0]*vecFactor[1];
fAngle[1]=vecFactor[1]*vecFactor[2];
fAngle[2]=vecFactor[2]*vecFactor[3];
fAngle[3]=vecFactor[3]*vecFactor[0];
fAngle[0]=acosf(fAngle[0]);
fAngle[1]=acosf(fAngle[1]);
fAngle[2]=acosf(fAngle[2]);
fAngle[3]=acosf(fAngle[3]);
if( fAngle[0] == 3.14159f ||
fAngle[1] == 3.14159f ||
fAngle[2] == 3.14159f ||
fAngle[3] == 3.14159f)
return 0;
if(fAngle[0]+fAngle[1]+fAngle[2]+fAngle[3] >= (3.14159f)*2.0f)
return 1;
return 0;
}
bool CIntersection::PlanePoint(vector3 *pPlane, vector3 &vecPoint)
{
vector3 vecPolyNormal=(pPlane[1]-pPlane[0])^(pPlane[2]-pPlane[1]);
if(vecPolyNormal*(vecPoint-pPlane[0]) > 0.0f)
return true;
return false;
}
int CIntersection::PolygonQuad(vector3 *vecPoly, vector3 *vecQuad)
{
vector3 vecPolyNormal1=(vecPoly[1]-vecPoly[0])^(vecPoly[2]-vecPoly[1]);
vector3 vecPolyNormal2=(vecQuad[1]-vecQuad[0])^(vecQuad[2]-vecQuad[1]);
vecPolyNormal1.Normalize();
vecPolyNormal2.Normalize();
float fDistance[4];
fDistance[0]= vecPolyNormal1*(vecQuad[0]-vecPoly[0]);
fDistance[1]= vecPolyNormal1*(vecQuad[1]-vecPoly[0]);
fDistance[2]= vecPolyNormal1*(vecQuad[2]-vecPoly[0]);
fDistance[3]= vecPolyNormal1*(vecQuad[3]-vecPoly[0]);
if( (fDistance[0] > 0.0f && fDistance[1] > 0.0f && fDistance[2] > 0.0f && fDistance[3] > 0.0f ) )
{
return -1;
}
if( (fDistance[0] < 0.0f && fDistance[1] < 0.0f && fDistance[2] < 0.0f && fDistance[3] > 0.0f ) )
{
return -2;
}
fDistance[0]= vecPolyNormal2*(vecPoly[0]-vecQuad[0]);
fDistance[1]= vecPolyNormal2*(vecPoly[1]-vecQuad[0]);
fDistance[2]= vecPolyNormal2*(vecPoly[2]-vecQuad[0]);
if( (fDistance[0] > 0.0f && fDistance[1] > 0.0f && fDistance[2] > 0.0f) ||
(fDistance[0] < 0.0f && fDistance[1] < 0.0f && fDistance[2] < 0.0f))
return 0;
float fIntersection;
vector3 vecLens;
if(BoxToRay(vecPoly[0],vecPoly[1],&vecQuad,fIntersection)==1)
{
vecLens=vecPoly[0]-vecPoly[1];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
if(BoxToRay(vecPoly[1],vecPoly[2],&vecQuad,fIntersection)==1)
{
vecLens=vecPoly[1]-vecPoly[2];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
if(BoxToRay(vecPoly[2],vecPoly[0],&vecQuad,fIntersection)==1)
{
vecLens=vecPoly[2]-vecPoly[0];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
return 0;
/*
if(PolygonRay(*vecPoly2[2],*vecPoly2[0],vecPoly1,fIntersection)==1)
{
vecLens=*vecPoly2[2]-*vecPoly2[0];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
if(PolygonRay(*vecPoly1[0],*vecPoly1[1],vecPoly2,fIntersection)==1)
{
vecLens=*vecPoly1[0]-*vecPoly1[1];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
if(PolygonRay(*vecPoly1[1],*vecPoly1[2],vecPoly2,fIntersection)==1)
{
vecLens=*vecPoly1[1]-*vecPoly1[2];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
if(PolygonRay(*vecPoly1[2],*vecPoly1[0],vecPoly2,fIntersection)==1)
{
vecLens=*vecPoly1[2]-*vecPoly1[0];
if(vecLens.GetLens()>=fIntersection)
return 1;
}
return 0;
*/
}
float CIntersection::PolygonRay2(vector3 vecStart, vector3 vecEnd, vector3 *poly,float &fInterLens)
{
vector3 n=(poly[1]-poly[0])^(poly[2]-poly[0]);
n.Normalize();
vector3 vecDir=(vecEnd-vecStart);
vecDir.Normalize();
float h=( (n.x*poly[0].x+n.y*poly[0].y+n.z*poly[0].z) - (n.x*vecStart.x+n.y*vecStart.y+n.z*vecStart.z) )
/ (n.x*vecDir.x + n.y*vecDir.y + n.z*vecDir.z);
fInterLens=h;
if(h<0.0f)return 0;
vector3 vecInter=vecEnd-vecStart;
if(vecInter.GetLens() < h)
return 0;
///*
vector3 vecInterpos=vecStart+vecDir*h;
vector3 vecFactor[3];
float fAngle[3];
vecFactor[0]=(vecInterpos-poly[0]);vecFactor[0].Normalize();
vecFactor[1]=(vecInterpos-poly[1]);vecFactor[1].Normalize();
vecFactor[2]=(vecInterpos-poly[2]);vecFactor[2].Normalize();
fAngle[0]=vecFactor[0]*vecFactor[1];
fAngle[1]=vecFactor[1]*vecFactor[2];
fAngle[2]=vecFactor[2]*vecFactor[0];
fAngle[0]=acosf(fAngle[0]);
fAngle[1]=acosf(fAngle[1]);
fAngle[2]=acosf(fAngle[2]);
/*
if( fAngle[0] == 3.14159f ||
fAngle[1] == 3.14159f ||
fAngle[2] == 3.14159f)
return 0;
*/
return fAngle[0]+fAngle[1]+fAngle[2];
}
int CIntersection::PlaneSphere(vector3 &vecLoc, float &fRad, vector3 *pPoly)
{
float x1,y1,z1,x2,y2,z2,x3,y3,z3;
float x4,y4,z4;
x1=pPoly[1].x-pPoly[0].x;
y1=pPoly[1].y-pPoly[0].y;
z1=pPoly[1].z-pPoly[0].z;
x2=pPoly[2].x-pPoly[1].x;
y2=pPoly[2].y-pPoly[1].y;
z2=pPoly[2].z-pPoly[1].z;
x3=y1*z2-z1*y2;
y3=z1*x2-x1*z2;
z3=x1*y2-y1*x2;
float invMag=1.0f/CFastMath::FastSqrt(x3*x3+y3*y3+z3*z3);
x3=x3*invMag;
y3=y3*invMag;
z3=z3*invMag;
x4=vecLoc.x-pPoly[0].x;
y4=vecLoc.y-pPoly[0].y;
z4=vecLoc.z-pPoly[0].z;
float fDistance=x3*x4+y3*y4+z3*z4;
float fAbsDistance=fDistance>0.0f ? fDistance : -fDistance;
if(fRad >= fAbsDistance)
{
return 1;
}
else
{
if(fDistance>0.0f)
return 0;
else
return -1;
}
/*
vector3 vecPolyNormal=(pPoly[1]-pPoly[0])^(pPoly[2]-pPoly[1]);
vecPolyNormal.Normalize();
float fDistance=vecPolyNormal*(vecLoc-pPoly[0]);
float fAbsDis=fabs(fDistance);
if(fRad >= fAbsDis)
{
return 1;
}
else
{
if(fDistance>=0.0f)
return 0;
else
return -1;
}
*/
}
int CIntersection::SplitPolygonPolygon(vector3 *pPolySour, vector3 *pPolyDest, vector3 *pPolyResult)
{
vector3 vecPolySourNormal=(pPolySour[1]-pPolySour[0])^(pPolySour[2]-pPolySour[1]);
vecPolySourNormal.Normalize();
float fDistance[3];
fDistance[0]=vecPolySourNormal*(pPolyDest[0]-pPolySour[0]);
fDistance[1]=vecPolySourNormal*(pPolyDest[1]-pPolySour[0]);
fDistance[2]=vecPolySourNormal*(pPolyDest[2]-pPolySour[0]);
if( (fDistance[0] >= 0.0f && fDistance[1] >= 0.0f && fDistance[2] >= 0.0f) )
{
pPolyResult[0]=pPolyDest[0];
pPolyResult[1]=pPolyDest[1];
pPolyResult[2]=pPolyDest[2];
return 1;
}
if( (fDistance[0] <= 0.0f && fDistance[1] <= 0.0f && fDistance[2] <= 0.0f) )
{
return 0;
}
float fIntersect;
vector3 vecFirstInter,vecSecondInter;
int FrontVector[2]={-1,-1};
int BackVector[2]={-1,-1};
int cFront=0;
int cBack=0;
for(int i=0;i<3;i++)
{
if(fDistance[i] >= 0.0f)
{
FrontVector[cFront]=0;
cFront++;
}
else
{
BackVector[cBack]=0;
cBack++;
}
}
if(cFront==2)
{
PolygonRay(pPolyDest[FrontVector[0]],pPolyDest[BackVector[0]],pPolySour,fIntersect);
vecFirstInter=pPolyDest[BackVector[0]]-pPolyDest[FrontVector[0]];
vecFirstInter.Normalize();
vecFirstInter=pPolyDest[FrontVector[0]]+vecFirstInter*fIntersect;
PolygonRay(pPolyDest[FrontVector[1]],pPolyDest[BackVector[0]],pPolySour,fIntersect);
vecSecondInter=pPolyDest[BackVector[0]]-pPolyDest[FrontVector[1]];
vecSecondInter.Normalize();
vecSecondInter=pPolyDest[FrontVector[1]]+vecFirstInter*fIntersect;
pPolyResult[0]=pPolyDest[FrontVector[0]];
pPolyResult[1]=vecFirstInter;
pPolyResult[2]=vecSecondInter;
pPolyResult[3]=vecFirstInter;
pPolyResult[4]=vecSecondInter;
pPolyResult[5]=pPolyDest[FrontVector[1]];
return 2;
}
else
{
PolygonRay( pPolyDest[FrontVector[0]],pPolyDest[BackVector[0]],pPolySour,fIntersect);
vecFirstInter=pPolyDest[BackVector[0]]-pPolyDest[FrontVector[0]];
vecFirstInter.Normalize();
vecFirstInter=pPolyDest[FrontVector[0]]+vecFirstInter*fIntersect;
PolygonRay( pPolyDest[FrontVector[0]],pPolyDest[BackVector[1]],pPolySour,fIntersect);
vecSecondInter=pPolyDest[BackVector[0]]-pPolyDest[FrontVector[1]];
vecSecondInter.Normalize();
vecSecondInter=pPolyDest[FrontVector[0]]+vecFirstInter*fIntersect;
pPolyResult[0]=pPolyDest[FrontVector[0]];
pPolyResult[1]=vecFirstInter;
pPolyResult[2]=vecSecondInter;
return 1;
}
return 0;
/*
float fIntersect;
vector3 vecFirstInter,vecSecondInter;
if( fDistance[0]==0.0f)
{
if(fDistance[1] > 0.0f)
{
PolygonRay(pPolyDest[1],pPolyDest[2],&pPolySour,fIntersect);
vecFirstInter=pPolyDest[2]-pPolyDest[1];
vecFirstInter.Normalize();
vecFirstInter=pPolyDest[1]+vecFirstInter*fIntersect;
pPolyResult[0]=pPolyDest[0];
pPolyResult[1]=pPolyDest[1];
pPolyResult[2]=vecFirstInter;
}
else
{
PolygonRay(pPolyDest[2],pPolyDest[1],&pPolySour,fIntersect);
vecFirstInter=pPolyDest[1]-pPolyDest[2];
vecFirstInter.Normalize();
vecFirstInter=pPolyDest[2]+vecFirstInter*fIntersect;
pPolyResult[0]=pPolyDest[0];
pPolyResult[1]=vecFirstInter;
pPolyResult[2]=pPolyDest[2];
}
return 1;
}
if( fDistance[1]==0.0f)
{
if(fDistance[2] > 0.0f)
{
PolygonRay(pPolyDest[2],pPolyDest[0],&pPolySour,fIntersect);
vecFirstInter=pPolyDest[0]-pPolyDest[2];
vecFirstInter.Normalize();
vecFirstInter=pPolyDest[2]+vecFirstInter*fIntersect;
pPolyResult[0]=pPolyDest[1];
pPolyResult[1]=vecFirstInter;
pPolyResult[2]=pPolyDest[2];
}
else
{
PolygonRay(pPolyDest[0],pPolyDest[2],&pPolySour,fIntersect);
vecFirstInter=pPolyDest[2]-pPolyDest[0];
vecFirstInter.Normalize();
vecFirstInter=pPolyDest[0]+vecFirstInter*fIntersect;
pPolyResult[0]=pPolyDest[1];
pPolyResult[1]=vecFirstInter;
pPolyResult[2]=pPolyDest[0];
}
return 1;
}
if( fDistance[2]==0.0f)
{
if(fDistance[0] > 0.0f)
{
PolygonRay(pPolyDest[0],pPolyDest[1],&pPolySour,fIntersect);
vecFirstInter=pPolyDest[1]-pPolyDest[0];
vecFirstInter.Normalize();
vecFirstInter=pPolyDest[0]+vecFirstInter*fIntersect;
pPolyResult[0]=pPolyDest[2];
pPolyResult[1]=vecFirstInter;
pPolyResult[2]=pPolyDest[0];
}
else
{
PolygonRay(pPolyDest[1],pPolyDest[0],&pPolySour,fIntersect);
vecFirstInter=pPolyDest[0]-pPolyDest[1];
vecFirstInter.Normalize();
vecFirstInter=pPolyDest[1]+vecFirstInter*fIntersect;
pPolyResult[0]=pPolyDest[2];
pPolyResult[1]=pPolyDest[0];
pPolyResult[2]=vecFirstInter;
}
return 1;
}
if(
*/
}
// return-value 0 is not intersect
// return-value 1 is Sphere in polygon
// return-value 2 is
int CIntersection::PolygonSphere(vector3 &vecCenter, float fRad, vector3 *pPoly,vector3 *vecIntersect,int &cIntersect)
{
vector3 vecPolyNormal=(pPoly[1]-pPoly[0])^(pPoly[2]-pPoly[1]);
vecPolyNormal.Normalize();
float fDistance=vecPolyNormal*(vecCenter-pPoly[0]);
float fAbsDis=fabs(fDistance);
vector3 vecPolyInter;
if(fRad >= fAbsDis)
{
vecPolyNormal=-vecPolyNormal;
float fInter;
///*
if(PolygonRay(vecCenter,vecCenter+vecPolyNormal*fRad,pPoly,fInter)==1)
{
*vecIntersect=vecCenter+vecPolyNormal*fInter;
vecIntersect++;
cIntersect++;
return 3;
}
//*/
/*
if(PolygonRay(vecCenter,vecCenter+vector3(0.0f,-1.0f,0.0f)*fRad*10.0f,pTestPoly,fInter)==1)
{
//if(vecPolyNormal.y > 0.2f )
{
*vecIntersect=vecCenter+vecPolyNormal*fInter;
vecIntersect++;
cIntersect++;
return 1;
}
}
*/
/*
vecPolyInter=pPoly[0]-vecCenter;
if(vecPolyInter.GetLens() <= fRad)
{
*vecIntersect=pPoly[0];
vecIntersect++;
cIntersect++;
return 1;
}
vecPolyInter=pPoly[1]-vecCenter;
if(vecPolyInter.GetLens() <= fRad)
{
*vecIntersect=pPoly[1];
vecIntersect++;
cIntersect++;
return 1;
}
vecPolyInter=pPoly[2]-vecCenter;
if(vecPolyInter.GetLens() <= fRad)
{
*vecIntersect=pPoly[2];
vecIntersect++;
cIntersect++;
return 1;
}
float fMaxInter=0.0f;
float b,c;
float fInterD=0;
vector3 vecOriginCenter;
vecPolyInter=pPoly[1]-pPoly[0];
fMaxInter=vecPolyInter.GetLens();
vecPolyInter.Normalize();
vecOriginCenter=pPoly[0]-vecCenter;
b=vecPolyInter*(vecOriginCenter);
c=vecOriginCenter*vecOriginCenter-(fRad*fRad);
if((b*b-c)>0.0f)
{
fInterD=-b-sqrtf(b*b-c);
if(fInterD >= 0.0f && fInterD <= fMaxInter)
{
*vecIntersect=pPoly[0]+fInterD*vecPolyInter;
vecIntersect++;
cIntersect++;
}
fInterD=-b+sqrtf(b*b-c);
if(fInterD >= 0.0f && fInterD <= fMaxInter)
{
*vecIntersect=pPoly[0]+fInterD*vecPolyInter;
vecIntersect++;
cIntersect++;
}
}
vecPolyInter=pPoly[2]-pPoly[1];
fMaxInter=vecPolyInter.GetLens();
vecPolyInter.Normalize();
vecOriginCenter=pPoly[1]-vecCenter;
b=vecPolyInter*(vecOriginCenter);
c=vecOriginCenter*vecOriginCenter-(fRad*fRad);
if((b*b-c)>0.0f)
{
fInterD=-b-sqrtf(b*b-c);
if(fInterD >= 0.0f && fInterD <= fMaxInter)
{
*vecIntersect=pPoly[1]+fInterD*vecPolyInter;
vecIntersect++;
cIntersect++;
}
fInterD=-b+sqrtf(b*b-c);
if(fInterD >= 0.0f && fInterD <= fMaxInter)
{
*vecIntersect=pPoly[1]+fInterD*vecPolyInter;
vecIntersect++;
cIntersect++;
}
}
vecPolyInter=pPoly[0]-pPoly[2];
fMaxInter=vecPolyInter.GetLens();
vecPolyInter.Normalize();
vecOriginCenter=pPoly[2]-vecCenter;
b=vecPolyInter*(vecOriginCenter);
c=vecOriginCenter*vecOriginCenter-(fRad*fRad);
if((b*b-c)>0.0f)
{
fInterD=-b-sqrtf(b*b-c);
if(fInterD >= 0.0f && fInterD <= fMaxInter)
{
*vecIntersect=pPoly[2]+fInterD*vecPolyInter;
vecIntersect++;
cIntersect++;
}
fInterD=-b+sqrtf(b*b-c);
if(fInterD >= 0.0f && fInterD <= fMaxInter)
{
*vecIntersect=pPoly[2]+fInterD*vecPolyInter;
vecIntersect++;
cIntersect++;
}
}
if(cIntersect!=0)
return 2;
if(PolygonRay(vecCenter,vecCenter+vecPolyNormal*fRad,pTestPoly,fInter)==1)
{
*vecIntersect=vecCenter+vecPolyNormal*fInter;
vecIntersect++;
cIntersect++;
return 3;
}
*/
return 0;
}
return 0;
}
float CIntersection::PlaneAABBBox(vector3 *vecPlane, vector3 &vecNormal, vector3 &vecMaxBox, vector3 &vecMinBox)
{
vector3 vecNearPoint;
if(vecNormal.x > 0.0f)
{
if(vecNormal.y > 0.0f)
{
if(vecNormal.z > 0.0f)
{
vecNearPoint.x=vecMinBox.x;vecNearPoint.y=vecMinBox.y;vecNearPoint.z=vecMinBox.z;
}
else
{
vecNearPoint.x=vecMinBox.x;vecNearPoint.y=vecMinBox.y;vecNearPoint.z=vecMaxBox.z;
}
}
else
{
if(vecNormal.z > 0.0f)
{
vecNearPoint.x=vecMinBox.x;vecNearPoint.y=vecMaxBox.y;vecNearPoint.z=vecMinBox.z;
}
else
{
vecNearPoint.x=vecMinBox.x;vecNearPoint.y=vecMaxBox.y;vecNearPoint.z=vecMaxBox.z;
}
}
}
else
{
if(vecNormal.y > 0.0f)
{
if(vecNormal.z > 0.0f)
{
vecNearPoint.x=vecMaxBox.x;vecNearPoint.y=vecMinBox.y;vecNearPoint.z=vecMinBox.z;
}
else
{
vecNearPoint.x=vecMaxBox.x;vecNearPoint.y=vecMinBox.y;vecNearPoint.z=vecMaxBox.z;
}
}
else
{
if(vecNormal.z > 0.0f)
{
vecNearPoint.x=vecMaxBox.x;vecNearPoint.y=vecMaxBox.y;vecNearPoint.z=vecMinBox.z;
}
else
{
vecNearPoint.x=vecMaxBox.x;vecNearPoint.y=vecMaxBox.y;vecNearPoint.z=vecMaxBox.z;
}
}
}
return vecNormal*(vecNearPoint-vecPlane[0]);
}
float CIntersection::PointFromPlane(vector3 *pPlane, vector3 &vecPoint)
{
vector3 vecPolyNormal=(pPlane[1]-pPlane[0])^(pPlane[2]-pPlane[1]);
vecPolyNormal.Normalize();
return vecPolyNormal*(vecPoint-pPlane[0]);
}
float CIntersection::PointFromPlane(vector3 &pNormal, vector3 &pPlaneOrigin, vector3 &vecPoint)
{
return pNormal*(vecPoint-pPlaneOrigin);
}
int CIntersection::PlaneSphereNormal(vector3 &vecPos, float &fRad, vector3 &vecNormal, vector3 &vecPoly)
{
float x4,y4,z4;
x4=vecPos.x-vecPoly.x;
y4=vecPos.y-vecPoly.y;
z4=vecPos.z-vecPoly.z;
float fDistance=vecNormal.x*x4+vecNormal.y*y4+vecNormal.z*z4;
float fAbsDistance=fDistance>0.0f ? fDistance : -fDistance;
if(fRad >= fAbsDistance)
{
return 1;
}
else
{
if(fDistance>0.0f)
return 0;
else
return -1;
}
}

View File

@@ -0,0 +1,34 @@
// Intersection.h: interface for the CIntersection class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_INTERSECTION_H__2C579563_8B13_41AA_BD24_5DF348664376__INCLUDED_)
#define AFX_INTERSECTION_H__2C579563_8B13_41AA_BD24_5DF348664376__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "3DMath.h"
class CIntersection
{
public:
static int PlaneSphereNormal(vector3 &vecPos,float &fRad,vector3 &vecNormal,vector3 &vecPoly);
static float PointFromPlane(vector3 &pNormal,vector3 &pPlaneOrigin,vector3 &vecPoint);
static float PointFromPlane(vector3 *pPlane,vector3 &vecPoint);
static float PlaneAABBBox(vector3 *vecPlane,vector3 &vecNormal,vector3 &vecMaxBox,vector3 &vecMinBox);
static int PolygonSphere(vector3 &vecCenter,float fRad,vector3 *pPoly,vector3 *vecIntersect,int &cIntersect);
static int SplitPolygonPolygon(vector3 *pPolySour,vector3 *pPolyDest,vector3 *pPolyResult);
static int PlaneSphere(vector3 &vecLoc,float &fRad,vector3 *pPoly);
static float PolygonRay2(vector3 vecStart, vector3 vecEnd, vector3 *poly,float &fInterLens);
static int PolygonQuad(vector3 *vecPoly,vector3 *vecQuad);
static bool PlanePoint(vector3 *pPlane,vector3 &vecPoint);
static int BoxToRay(vector3 vecStart,vector3 vecEnd,vector3 *poly[4],float &fIntersection);
static int PolygonToPolygon(vector3 *vecPoly1,vector3 *vecPoly2);
static int PolygonRay(vector3 vecStart, vector3 vecEnd, vector3 *poly,float &fInterLens);
CIntersection();
virtual ~CIntersection();
};
#endif // !defined(AFX_INTERSECTION_H__2C579563_8B13_41AA_BD24_5DF348664376__INCLUDED_)

View File

@@ -0,0 +1,9 @@
#ifndef _MATHBASE_H
#define _MATHBASE_H
#include <math.h>
#define EPSILON 0.04f
typedef unsigned char COLORVALUE;
#endif

View File

@@ -0,0 +1,24 @@
// RenderDevice.cpp: implementation of the CRenderDevice class.
//
//////////////////////////////////////////////////////////////////////
#include "RenderDevice.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRenderDevice::CRenderDevice()
{
}
CRenderDevice::~CRenderDevice()
{
}
void CRenderDevice::Init(LPDIRECT3DDEVICE8 pd3dDevice)
{
}

View File

@@ -0,0 +1,32 @@
// RenderDevice.h: interface for the CRenderDevice class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_RENDERDEVICE_H__30AB566D_E435_4433_A0C2_7491B2733FB3__INCLUDED_)
#define AFX_RENDERDEVICE_H__30AB566D_E435_4433_A0C2_7491B2733FB3__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
#include "3DMath.h"
enum RenderState
{
};
class CRenderDevice
{
LPDIRECT3DDEVICE8 m_pd3dDevice;
public:
matrix m_matWorld[4],m_matView,m_matProj;
LPDIRECT3DDEVICE8 GetDeivce(){return m_pd3dDevice;};
void Init(LPDIRECT3DDEVICE8 pd3dDevice);
CRenderDevice();
virtual ~CRenderDevice();
};
#endif // !defined(AFX_RENDERDEVICE_H__30AB566D_E435_4433_A0C2_7491B2733FB3__INCLUDED_)

View File

@@ -0,0 +1,308 @@
// RenderEnvTexture.cpp: implementation of the CRenderEnvTexture class.
//
//////////////////////////////////////////////////////////////////////
//#include "DXUtil.h"
#include "RenderEnvTexture.h"
#include "BaseGraphicsLayer.h"
#include "SceneStateMgr.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#define CUBEMAP_RESOLUTION 256
////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~
D3DXMATRIX D3DUtil_GetCubeMapViewMatrix( DWORD dwFace )
{
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vLookDir;
D3DXVECTOR3 vUpDir;
switch( dwFace )
{
case D3DCUBEMAP_FACE_POSITIVE_X:
vLookDir = D3DXVECTOR3( 1.0f, 0.0f, 0.0f );
vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
break;
case D3DCUBEMAP_FACE_NEGATIVE_X:
vLookDir = D3DXVECTOR3(-1.0f, 0.0f, 0.0f );
vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
break;
case D3DCUBEMAP_FACE_POSITIVE_Y:
vLookDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
vUpDir = D3DXVECTOR3( 0.0f, 0.0f,-1.0f );
break;
case D3DCUBEMAP_FACE_NEGATIVE_Y:
vLookDir = D3DXVECTOR3( 0.0f,-1.0f, 0.0f );
vUpDir = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
break;
case D3DCUBEMAP_FACE_POSITIVE_Z:
vLookDir = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
break;
case D3DCUBEMAP_FACE_NEGATIVE_Z:
vLookDir = D3DXVECTOR3( 0.0f, 0.0f,-1.0f );
vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
break;
}
// Set the view transform for this cubemap surface
D3DXMATRIX matView;
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookDir, &vUpDir );
return matView;
}
CRenderEnvTexture::CRenderEnvTexture()
{
}
CRenderEnvTexture::~CRenderEnvTexture()
{
}
void CRenderEnvTexture::RenderCubeMap(LPDIRECT3DDEVICE8 pd3dDevice)
{
/////////<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!!!!!!!!!!!!!!///////////////
HRESULT hr;
// Set the projection matrix for a field of view of 90 degrees
D3DXMATRIX matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2.0f , 1.0f, 1.0f, 100.0f );
D3DXMATRIX matOldView,matOldProjection;
pd3dDevice->GetTransform(D3DTS_VIEW,&matOldView);
pd3dDevice->GetTransform(D3DTS_PROJECTION,&matOldProjection);
// Get the current view matrix, to concat it with the cubemap view vectors
D3DXMATRIX matViewDir( matOldView);
matViewDir._41 = 0.0f; matViewDir._42 = 0.0f; matViewDir._43 = 0.0f;
// Render the six cube faces into the environment map
if(m_bCube)
hr = m_pRenderToEnvMap->BeginCube( m_pCubeMap );
else
hr = m_pRenderToEnvMap->BeginSphere( m_pSphereMap );
CSceneStateMgr::_SetD3DRenderState( D3DRS_ZFUNC, D3DCMP_ALWAYS );
for( UINT i = 0; i < 6; i++ )
{
m_pRenderToEnvMap->Face( (D3DCUBEMAP_FACES) i );
// Set the view transform for this cubemap surface
D3DXMATRIX matView;
matView = D3DUtil_GetCubeMapViewMatrix( (D3DCUBEMAP_FACES) i );
D3DXMatrixMultiply( &matView, &matViewDir, &matView );
//D3DXMatrixMultiply( &matView, &matView,&matViewDir);
// Render the scene (except for the teapot)
//RenderScene( &matView, &matProj, FALSE );
pd3dDevice->SetTransform(D3DTS_VIEW,&matView);
pd3dDevice->SetTransform(D3DTS_PROJECTION,&matProj);
switch(i)
{
case 0:
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
//RenderSkymap(pd3dDevice);
break;
case 1:
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
//RenderSkymap(pd3dDevice);
break;
case 2:
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
break;
case 3:
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
break;
case 4:
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
//RenderSkymap(pd3dDevice);
break;
case 5:
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
//RenderSkymap(pd3dDevice);
break;
}
RenderSkymap(pd3dDevice);
}
CSceneStateMgr::_SetD3DRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
m_pRenderToEnvMap->End();
pd3dDevice->SetTransform(D3DTS_VIEW,&matOldView);
pd3dDevice->SetTransform(D3DTS_PROJECTION,&matOldProjection);
}
void CRenderEnvTexture::RenderSkymap(LPDIRECT3DDEVICE8 pd3dDevice)
{
//D3DXMATRIX matWorld;
//D3DXMatrixScaling( &matWorld, 1.0f, 1.0f, 1.0f );
matrix matWorld;
matWorld.MakeIdent();
pd3dDevice->SetTransform(D3DTS_WORLD,matWorld);
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
//pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_MIRROR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_MIRROR );
// Always pass Z-test, so we can avoid clearing color and depth buffers
//CSceneStateMgr::_SetD3DRenderState( D3DRS_ZFUNC, D3DCMP_ALWAYS );
////////////////////
/////Render Sky Box/
////////////////////
float fSize=10.0f;
LVertex Vertex[4];
WORD Indices[6];
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
CSceneStateMgr::_SetD3DTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
pd3dDevice->SetTexture(1,NULL);
CSceneStateMgr::_SetD3DRenderState( D3DRS_LIGHTING,FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_FOGENABLE,FALSE);
Indices[0]=0;
Indices[1]=2;
Indices[2]=1;
Indices[3]=0;
Indices[4]=3;
Indices[5]=2;
Vertex[0].v=vector3(-fSize,-fSize,fSize);
Vertex[0].tu=0.0f;
Vertex[0].tv=1.0f;
Vertex[1].v=vector3(fSize,-fSize,fSize);
Vertex[1].tu=1.0f;
Vertex[1].tv=1.0f;
Vertex[2].v=vector3(fSize,-fSize,-fSize);
Vertex[2].tu=1.0f;
Vertex[2].tv=0.0f;
Vertex[3].v=vector3(-fSize,-fSize,-fSize);
Vertex[3].tu=0.0f;
Vertex[3].tv=0.0f;
Vertex[0].diff.c=Vertex[1].diff.c=Vertex[2].diff.c=Vertex[3].diff.c=0xffffffff;
pd3dDevice->SetVertexShader(LVERTEXFVF);
pd3dDevice->SetTexture(0,m_SkyTexture[4].GetTexture());
pd3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
0,4,2,Indices,D3DFMT_INDEX16,Vertex, sizeof(LVertex));
Vertex[0].v=vector3(-fSize,-fSize,fSize);
Vertex[0].tu=0.0;
Vertex[0].tv=1.0;
Vertex[1].v=vector3(fSize,-fSize,fSize);
Vertex[1].tu=1.0;
Vertex[1].tv=1.0;
Vertex[2].v=vector3(fSize,fSize,fSize);
Vertex[2].tu=1.0;
Vertex[2].tv=0.0;
Vertex[3].v=vector3(-fSize,fSize,fSize);
Vertex[3].tu=0.0;
Vertex[3].tv=0.0;
pd3dDevice->SetTexture(0,m_SkyTexture[0].GetTexture());
pd3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
0,4,2,Indices,D3DFMT_INDEX16,Vertex, sizeof(LVertex));
Vertex[0].v=vector3(fSize,-fSize,fSize);
Vertex[1].v=vector3(fSize,-fSize,-fSize);
Vertex[2].v=vector3(fSize,fSize,-fSize);
Vertex[3].v=vector3(fSize,fSize,fSize);
Vertex[0].diff.c=Vertex[1].diff.c=Vertex[2].diff.c=Vertex[3].diff.c=0xffff0000;
pd3dDevice->SetTexture(0,m_SkyTexture[1].GetTexture());
pd3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
0,4,2,Indices,D3DFMT_INDEX16,Vertex, sizeof(LVertex));
Vertex[0].v=vector3(fSize,-fSize,-fSize);
Vertex[1].v=vector3(-fSize,-fSize,-fSize);
Vertex[2].v=vector3(-fSize,fSize,-fSize);
Vertex[3].v=vector3(fSize,fSize,-fSize);
Vertex[0].diff.c=Vertex[1].diff.c=Vertex[2].diff.c=Vertex[3].diff.c=0xffffff00;
pd3dDevice->SetTexture(0,m_SkyTexture[2].GetTexture());
pd3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
0,4,2,Indices,D3DFMT_INDEX16,Vertex, sizeof(LVertex));
Vertex[0].v=vector3(-fSize,-fSize,-fSize);
Vertex[1].v=vector3(-fSize,-fSize,fSize);
Vertex[2].v=vector3(-fSize,fSize,fSize);
Vertex[3].v=vector3(-fSize,fSize,-fSize);
Vertex[0].diff.c=Vertex[1].diff.c=Vertex[2].diff.c=Vertex[3].diff.c=0xff0000ff;
pd3dDevice->SetTexture(0,m_SkyTexture[3].GetTexture());
pd3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
0,4,2,Indices,D3DFMT_INDEX16,Vertex, sizeof(LVertex));
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
CSceneStateMgr::_SetD3DRenderState( D3DRS_FOGENABLE,TRUE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
//CSceneStateMgr::_SetD3DRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
}
void CRenderEnvTexture::Create(LPDIRECT3DDEVICE8 pd3dDevice,char strSkyTexturename[256],char strTexturePath[256],bool bCube)
{
D3DDISPLAYMODE mode;
BaseGraphicsLayer::GetDevice()->GetDisplayMode(&mode);
m_bCube=bCube;
D3DXCreateRenderToEnvMap(pd3dDevice,CUBEMAP_RESOLUTION,mode.Format,TRUE,D3DFMT_D16,&m_pRenderToEnvMap);
if(m_bCube)
{
D3DXCreateCubeTexture(pd3dDevice,CUBEMAP_RESOLUTION,1,D3DUSAGE_RENDERTARGET,mode.Format,D3DPOOL_DEFAULT,&m_pCubeMap);
}
else
{
D3DXCreateTexture(pd3dDevice,CUBEMAP_RESOLUTION,CUBEMAP_RESOLUTION,1,D3DUSAGE_RENDERTARGET,mode.Format,D3DPOOL_DEFAULT,&m_pSphereMap);
}
CTexture::SetPath(strTexturePath);
char strTextureName[256];
for(int i=1;i<6;i++)
{
sprintf(strTextureName,"%s%d.dds",strSkyTexturename,i);
m_SkyTexture[i-1].Load(strTextureName);
}
}

View File

@@ -0,0 +1,38 @@
// RenderEnvTexture.h: interface for the CRenderEnvTexture class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_RENDERENVTEXTURE_H__39EF09BE_861F_466D_9D47_63BFFE575865__INCLUDED_)
#define AFX_RENDERENVTEXTURE_H__39EF09BE_861F_466D_9D47_63BFFE575865__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <D3DX8.h>
#include "Vertex.h"
#include "Texture.h"
class CRenderEnvTexture
{
ID3DXRenderToEnvMap* m_pRenderToEnvMap;
CTexture m_SkyTexture[6];
bool m_bCube;
public:
IDirect3DCubeTexture8* m_pCubeMap;
IDirect3DTexture8* m_pSphereMap;
void Create(LPDIRECT3DDEVICE8 pd3dDevice,char strSkyTexturename[256],char strTexturePath[256],bool bCube=true);
void RenderSkymap(LPDIRECT3DDEVICE8 pd3dDevice);
void RenderCubeMap(LPDIRECT3DDEVICE8 pd3dDevice);
LPDIRECT3DBASETEXTURE8 GetTexture()
{
if(m_bCube)
return (LPDIRECT3DBASETEXTURE8)m_pCubeMap;
return (LPDIRECT3DBASETEXTURE8)m_pSphereMap;
};
CRenderEnvTexture();
virtual ~CRenderEnvTexture();
};
#endif // !defined(AFX_RENDERENVTEXTURE_H__39EF09BE_861F_466D_9D47_63BFFE575865__INCLUDED_)

View File

@@ -0,0 +1,43 @@
// RenderTargetTexture.cpp: implementation of the CRenderTargetTexture class.
//
//////////////////////////////////////////////////////////////////////
#include "RenderTargetTexture.h"
#include "BaseGraphicsLayer.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LPDIRECT3DTEXTURE8 CRenderTargetTexture::m_pTexture;
CRenderTargetTexture::CRenderTargetTexture()
{
}
CRenderTargetTexture::~CRenderTargetTexture()
{
}
void CRenderTargetTexture::Create(LPDIRECT3DDEVICE8 pd3dDevice,int nSizeX,int nSizeY)
{
pd3dDevice->CreateTexture(nSizeX,nSizeY,1,0,BaseGraphicsLayer::m_d3dpp.BackBufferFormat,D3DPOOL_DEFAULT,&m_pTexture);
}
LPDIRECT3DTEXTURE8 CRenderTargetTexture::GetTexture(LPDIRECT3DDEVICE8 pd3dDevice,RECT rcCopy)
{
LPDIRECT3DSURFACE8 pSurface;
m_pTexture->GetSurfaceLevel(0,&pSurface);
LPDIRECT3DSURFACE8 pBackBuffer;
pd3dDevice->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&pBackBuffer);
POINT pt={0,0};
pd3dDevice->CopyRects(pBackBuffer,&rcCopy,1,pSurface,&pt);
pSurface->Release();
pBackBuffer->Release();
return m_pTexture;
}

View File

@@ -0,0 +1,25 @@
// RenderTargetTexture.h: interface for the CRenderTargetTexture class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_RENDERTARGETTEXTURE_H__2704A75E_C01D_4D6D_86C0_08F1D6E224AB__INCLUDED_)
#define AFX_RENDERTARGETTEXTURE_H__2704A75E_C01D_4D6D_86C0_08F1D6E224AB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
class CRenderTargetTexture
{
static LPDIRECT3DTEXTURE8 m_pTexture;
public:
static LPDIRECT3DTEXTURE8 GetTexture(LPDIRECT3DDEVICE8 pd3dDevice,RECT rcCopy);
static void Create(LPDIRECT3DDEVICE8 pd3dDevice,int nSizeX,int nSizeY);
CRenderTargetTexture();
virtual ~CRenderTargetTexture();
};
#endif // !defined(AFX_RENDERTARGETTEXTURE_H__2704A75E_C01D_4D6D_86C0_08F1D6E224AB__INCLUDED_)

View File

@@ -0,0 +1,116 @@
// RenderTexture.cpp: implementation of the CRenderTexture class.
//
//////////////////////////////////////////////////////////////////////
#include "RenderTexture.h"
#include "BaseGraphicsLayer.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LPDIRECT3DSURFACE8 CRenderTexture::m_pRenderZBuffer;
LPDIRECT3DTEXTURE8 CRenderTexture::m_pCopyLockTexture;
LPDIRECT3DSURFACE8 CRenderTexture::m_pCopyLockSurface;
CRenderTexture::CRenderTexture()
{
m_pRenderTexture=NULL;
m_pRenderSurface=NULL;
}
CRenderTexture::~CRenderTexture()
{
if(m_pRenderTexture)
m_pRenderTexture->Release();
if(m_pRenderSurface)
m_pRenderSurface->Release();
if(m_pRenderZBuffer)
{
m_pRenderZBuffer->Release();
m_pRenderZBuffer=NULL;
}
}
void CRenderTexture::Create(long SizeX,long SizeY)
{
if(SizeX==0 || SizeY==0)
return;
D3DDISPLAYMODE mode;
//BaseGraphicsLayer::GetDevice()->GetDisplayMode(&mode);
BaseGraphicsLayer::GetDevice()->CreateTexture(SizeX,SizeY,1,D3DUSAGE_RENDERTARGET,BaseGraphicsLayer::m_d3dpp.BackBufferFormat,D3DPOOL_DEFAULT,&m_pRenderTexture);
if(m_pRenderTexture==NULL)
{
SizeX=0;
SizeY=0;
return;
}
m_pRenderTexture->GetSurfaceLevel(0, &m_pRenderSurface);
m_SizeX = SizeX;
m_Sizey = SizeY;
if(m_pRenderZBuffer==NULL)
{
BaseGraphicsLayer::GetDevice()->CreateDepthStencilSurface(SizeX,SizeY,BaseGraphicsLayer::m_d3dpp.AutoDepthStencilFormat,D3DMULTISAMPLE_NONE,&m_pRenderZBuffer);
BaseGraphicsLayer::GetDevice()->CreateTexture(SizeX,SizeY,1,0,BaseGraphicsLayer::m_d3dpp.BackBufferFormat,D3DPOOL_MANAGED,&m_pCopyLockTexture);
m_pCopyLockTexture->GetSurfaceLevel(0,&m_pCopyLockSurface);
}
}
void CRenderTexture::Begin(LPDIRECT3DDEVICE8 pd3dDevice)
{
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
pd3dDevice->GetViewport(&m_pTempViewPort);
pd3dDevice->SetRenderTarget(m_pRenderSurface,m_pRenderZBuffer);
//pd3dDevice->SetRenderTarget(m_pRenderSurface,m_pTempRenderZBuffer);
}
void CRenderTexture::End(LPDIRECT3DDEVICE8 pd3dDevice)
{
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
m_pTempRenderSurface->Release();
m_pTempRenderZBuffer->Release();
pd3dDevice->SetViewport(&m_pTempViewPort);
//pd3dDevice->GetViewport(&m_pTempViewPort);
}
void* CRenderTexture::Lock()
{
D3DLOCKED_RECT pRect;
//m_pRenderTexture->LockRect(0,&pRect,NULL,D3DLOCK_READONLY);
D3DDISPLAYMODE mode;
BaseGraphicsLayer::GetDevice()->GetDisplayMode(&mode);
RECT rect;
rect.left=0;
rect.right=m_SizeX;
rect.top=0;
rect.bottom=m_Sizey;
POINT pt;
pt.x=0;
pt.y=0;
BaseGraphicsLayer::GetDevice()->CopyRects(m_pRenderSurface,&rect,1,m_pCopyLockSurface,&pt);
m_pCopyLockSurface->LockRect(&pRect,NULL,NULL);//D3DLOCK_READONLY);
return pRect.pBits;
//return (void*)
}
void CRenderTexture::Unlock()
{
m_pCopyLockSurface->UnlockRect();
RECT rect;
rect.left=0;
rect.right=m_SizeX;
rect.top=0;
rect.bottom=m_Sizey;
POINT pt;
pt.x=0;
pt.y=0;
BaseGraphicsLayer::GetDevice()->CopyRects(m_pCopyLockSurface,&rect,1,m_pRenderSurface,&pt);
}

View File

@@ -0,0 +1,40 @@
// RenderTexture.h: interface for the CRenderTexture class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_RENDERTEXTURE_H__0EC50F46_F5C3_4873_AC41_9702AF503767__INCLUDED_)
#define AFX_RENDERTEXTURE_H__0EC50F46_F5C3_4873_AC41_9702AF503767__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3dx8.h>
#include "List.h"
class CRenderTexture
{
LPDIRECT3DTEXTURE8 m_pRenderTexture;
LPDIRECT3DSURFACE8 m_pRenderSurface;
static LPDIRECT3DSURFACE8 m_pRenderZBuffer;
static LPDIRECT3DTEXTURE8 m_pCopyLockTexture;
static LPDIRECT3DSURFACE8 m_pCopyLockSurface;
LPDIRECT3DSURFACE8 m_pTempRenderSurface;
LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
D3DVIEWPORT8 m_pTempViewPort;
public:
void Unlock();
void* Lock();
void Begin(LPDIRECT3DDEVICE8 pd3dDevice);
void End(LPDIRECT3DDEVICE8 pd3dDevice);
LPDIRECT3DTEXTURE8 GetTexture(){return m_pRenderTexture;};
LPDIRECT3DSURFACE8 GetSurface(){return m_pRenderSurface;};
long m_SizeX,m_Sizey;
void Create(long SizeX,long SizeY);
CRenderTexture();
virtual ~CRenderTexture();
};
#endif // !defined(AFX_RENDERTEXTURE_H__0EC50F46_F5C3_4873_AC41_9702AF503767__INCLUDED_)

View File

@@ -0,0 +1,170 @@
// RenderTextureMipmap.cpp: implementation of the CRenderTextureMipmap class.
//
//////////////////////////////////////////////////////////////////////
#include "BaseGraphicsLayer.h"
#include "RenderTextureMipmap.h"
#include "Vertex.h"
#include "SceneStateMgr.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRenderTextureMipmap::CRenderTextureMipmap()
{
}
CRenderTextureMipmap::~CRenderTextureMipmap()
{
}
void CRenderTextureMipmap::Create(int nSizeX, int nSizeY)
{
D3DDISPLAYMODE mode;
BaseGraphicsLayer::GetDevice()->GetDisplayMode(&mode);
//BaseGraphicsLayer::GetDevice()->CreateTexture(SizeX,SizeY,1,D3DUSAGE_RENDERTARGET,mode.Format,D3DPOOL_DEFAULT,&m_pRenderTexture);
//m_pRenderTexture->GetSurfaceLevel(0, &m_pRenderSurface);
BaseGraphicsLayer::GetDevice()->CreateDepthStencilSurface(nSizeX,nSizeY,BaseGraphicsLayer::m_d3dpp.AutoDepthStencilFormat,D3DMULTISAMPLE_NONE,&m_pRenderZBuffer);
m_nSize=nSizeX;
LPDIRECT3DTEXTURE8 pMipmapTexture;
LPDIRECT3DSURFACE8 pRenderSurface;
for(int i=nSizeX;i>=32;i=i>>1)
{
BaseGraphicsLayer::GetDevice()->CreateTexture(i,i,1,D3DUSAGE_RENDERTARGET,mode.Format,D3DPOOL_DEFAULT,&pMipmapTexture);
pMipmapTexture->GetSurfaceLevel(0, &pRenderSurface);
m_pRenderTextureList.Add(pMipmapTexture);
m_pRenderSurfaceList.Add(pRenderSurface);
break;
}
/*
for(int i=nSizeX;i>=32;i=i>>1)
{
CRenderTexture *AddNode=new CRenderTexture();
AddNode->Create(i,i);
m_TextureMipmap.Add(AddNode);
}
*/
}
LPDIRECT3DTEXTURE8 CRenderTextureMipmap::GetTexture(int nTexture)
{
if(m_pRenderTextureList.num>0)
{
return m_pRenderTextureList[nTexture];
}
return NULL;
}
void CRenderTextureMipmap::GenerateMipmap(LPDIRECT3DDEVICE8 pd3dDevice)
{
pd3dDevice->EndScene();
LPDIRECT3DSURFACE8 m_pTempRenderSurface;
LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG1,D3DTA_TEXTURE);
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG2,D3DTA_DIFFUSE);
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLOROP,D3DTOP_SELECTARG1);
CSceneStateMgr::_SetD3DTextureStageState( 1, D3DTSS_COLOROP,D3DTOP_DISABLE);
CSceneStateMgr::_SetD3DTextureStageState( 2, D3DTSS_COLOROP,D3DTOP_DISABLE);
CSceneStateMgr::_SetD3DTextureStageState( 3, D3DTSS_COLOROP,D3DTOP_DISABLE);
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_LIGHTING,FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_FOGENABLE,FALSE);
TLVertex pVertex[4];
int TextureSize=m_nSize>>1;
pVertex[0].v.x=0.0f;
pVertex[1].v.x=0.0f;
pVertex[2].v.x=(float)TextureSize;
pVertex[3].v.x=(float)TextureSize;
pVertex[1].v.y=0.0f;
pVertex[3].v.y=0.0f;
pVertex[0].v.y=(float)TextureSize;
pVertex[2].v.y=(float)TextureSize;
pVertex[0].tu=0.0f;
pVertex[1].tu=0.0f;
pVertex[3].tu=1.0f;
pVertex[2].tu=1.0f;
pVertex[1].tv=0.0f;
pVertex[3].tv=0.0f;
pVertex[0].tv=1.0f;
pVertex[2].tv=1.0f;
for(int i=0;i<4;i++)
{
pVertex[i].w=0.1f;
pVertex[i].v.z=0.1f;
pVertex[i].Diffuse.c=0xffff0000;
pVertex[i].Specular.c=0xffffffff;
}
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
pd3dDevice->SetTexture(1,NULL);
pd3dDevice->SetVertexShader(TLVERTEXFVF);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
for(i=1;i<m_pRenderTextureList.num;i++,TextureSize=TextureSize>>1)
{
pVertex[2].v.x=(float)TextureSize;
pVertex[3].v.x=(float)TextureSize;
pVertex[0].v.y=(float)TextureSize;
pVertex[2].v.y=(float)TextureSize;
pd3dDevice->SetRenderTarget(m_pRenderSurfaceList[i],m_pTempRenderZBuffer);
pd3dDevice->BeginScene();
pd3dDevice->Clear(0,NULL,D3DCLEAR_TARGET,0xffffffff,1.0f,0);
pd3dDevice->SetTexture(0,m_pRenderTextureList[0]);
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(TLVertex));
pd3dDevice->EndScene();
}
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,TRUE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
m_pTempRenderSurface->Release();
m_pTempRenderZBuffer->Release();
pd3dDevice->BeginScene();
}
LPDIRECT3DSURFACE8 CRenderTextureMipmap::GetSurface()
{
if(m_pRenderSurfaceList.num>0)
{
return m_pRenderSurfaceList[0];
}
return NULL;
}

View File

@@ -0,0 +1,33 @@
// RenderTextureMipmap.h: interface for the CRenderTextureMipmap class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_RENDERTEXTUREMIPMAP_H__C4579775_6CD9_4F2B_A3CC_7E128F86C7D3__INCLUDED_)
#define AFX_RENDERTEXTUREMIPMAP_H__C4579775_6CD9_4F2B_A3CC_7E128F86C7D3__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "RenderTexture.h"
#include "List.h"
class CRenderTextureMipmap
{
List<LPDIRECT3DTEXTURE8> m_pRenderTextureList;
List<LPDIRECT3DSURFACE8> m_pRenderSurfaceList;
LPDIRECT3DSURFACE8 m_pRenderZBuffer;
int m_nSize;
public:
LPDIRECT3DSURFACE8 GetSurface();
void GenerateMipmap(LPDIRECT3DDEVICE8 pd3dDevice);
LPDIRECT3DTEXTURE8 GetTexture(int nTexture=0);
LPDIRECT3DSURFACE8 GetZBuffer(){return m_pRenderZBuffer;};
int GetTextureCount(){return m_pRenderTextureList.num;};
void Create(int nSizeX,int nSizeY);
CRenderTextureMipmap();
virtual ~CRenderTextureMipmap();
};
#endif // !defined(AFX_RENDERTEXTUREMIPMAP_H__C4579775_6CD9_4F2B_A3CC_7E128F86C7D3__INCLUDED_)

View File

@@ -0,0 +1,75 @@
// ShadowMap.cpp: implementation of the CShadowMap class.
//
//////////////////////////////////////////////////////////////////////
#include "ShadowMap.h"
#include "BaseGraphicsLayer.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//LPDIRECT3DSURFACE8 CShadowMap::m_pShadowMapColorSurface=NULL;
//LPDIRECT3DSURFACE8 CShadowMap::m_pShadowMapZSurface=NULL;
//LPDIRECT3DTEXTURE8 CShadowMap::m_pShadowMapColorTexture=NULL;
//LPDIRECT3DTEXTURE8 CShadowMap::m_pShadowMapZTexture=NULL;
LPDIRECT3DSURFACE8 CShadowMap::m_pTempRenderSurface;
LPDIRECT3DSURFACE8 CShadowMap::m_pTempRenderZBuffer;
D3DVIEWPORT8 CShadowMap::m_pTempViewPort;
//D3DVIEWPORT8 CShadowMap::m_Viewport;
CShadowMap::CShadowMap()
{
}
CShadowMap::~CShadowMap()
{
}
void CShadowMap::Create(long SizeX, long SizeY)
{
if( BaseGraphicsLayer::m_d3dpp.BackBufferFormat==D3DFMT_A8R8G8B8 ||
BaseGraphicsLayer::m_d3dpp.BackBufferFormat==D3DFMT_X8R8G8B8 )
{
BaseGraphicsLayer::GetDevice()->CreateTexture(SizeX,SizeY,1,D3DUSAGE_RENDERTARGET,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&m_pShadowMapColorTexture);
BaseGraphicsLayer::GetDevice()->CreateTexture(SizeX,SizeY,1,D3DUSAGE_DEPTHSTENCIL,D3DFMT_D24S8,D3DPOOL_DEFAULT,&m_pShadowMapZTexture);
}
if( BaseGraphicsLayer::m_d3dpp.BackBufferFormat==D3DFMT_R5G6B5)
{
BaseGraphicsLayer::GetDevice()->CreateTexture(SizeX,SizeY,1,D3DUSAGE_RENDERTARGET,D3DFMT_R5G6B5,D3DPOOL_DEFAULT,&m_pShadowMapColorTexture);
BaseGraphicsLayer::GetDevice()->CreateTexture(SizeX,SizeY,1,D3DUSAGE_DEPTHSTENCIL,D3DFMT_D16,D3DPOOL_DEFAULT,&m_pShadowMapZTexture);
}
m_pShadowMapColorTexture->GetSurfaceLevel(0,&m_pShadowMapColorSurface);
m_pShadowMapZTexture->GetSurfaceLevel(0,&m_pShadowMapZSurface);
m_Viewport.X=0;
m_Viewport.Y=0;
m_Viewport.Width=SizeX;
m_Viewport.Height=SizeY;
m_Viewport.MinZ=0.0f;
m_Viewport.MaxZ=1.0f;
}
void CShadowMap::Begin(LPDIRECT3DDEVICE8 pd3dDevice)
{
pd3dDevice->GetViewport(&m_pTempViewPort);
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
pd3dDevice->SetRenderTarget(m_pShadowMapColorSurface,m_pShadowMapZSurface);
pd3dDevice->SetViewport(&m_Viewport);
}
void CShadowMap::End(LPDIRECT3DDEVICE8 pd3dDevice)
{
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
pd3dDevice->SetViewport(&m_pTempViewPort);
m_pTempRenderSurface->Release();
m_pTempRenderZBuffer->Release();
}

View File

@@ -0,0 +1,36 @@
// ShadowMap.h: interface for the CShadowMap class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_SHADOWMAP_H__13E99194_5645_4093_87D0_B4BCD22B0562__INCLUDED_)
#define AFX_SHADOWMAP_H__13E99194_5645_4093_87D0_B4BCD22B0562__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3dx8.h>
class CShadowMap
{
public:
void End(LPDIRECT3DDEVICE8 pd3dDevice);
void Begin(LPDIRECT3DDEVICE8 pd3dDevice);
LPDIRECT3DSURFACE8 m_pShadowMapColorSurface,m_pShadowMapZSurface;
LPDIRECT3DTEXTURE8 m_pShadowMapColorTexture,m_pShadowMapZTexture;
static LPDIRECT3DSURFACE8 m_pTempRenderSurface;
static LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
static D3DVIEWPORT8 m_pTempViewPort;
D3DVIEWPORT8 m_Viewport;
LPDIRECT3DTEXTURE8 GetShadowMapZTexture(){return m_pShadowMapZTexture;};
LPDIRECT3DTEXTURE8 GetShadowMapColorTexture(){return m_pShadowMapColorTexture;};
void Create(long SizeX,long SizeY);
CShadowMap();
virtual ~CShadowMap();
};
#endif // !defined(AFX_SHADOWMAP_H__13E99194_5645_4093_87D0_B4BCD22B0562__INCLUDED_)

View File

@@ -0,0 +1,228 @@
#include "Sphere.h"
#include <math.h>
#include <exception>
#include <d3dx8.h>
#include <stdio.h>
#include <matrix.h>
#include "SceneStateMgr.h"
using namespace std;
////////////////////////////////////////////////////////////////////////////
//
struct CUSTOMVERTEX
{
FLOAT x, y, z; // The untransformed, 3D position for the vertex
DWORD color; // The vertex color
};
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
////////////////////////////////////////////////////////////////////////////
//
static void Error( const char * Msg, ... )
{
char szBuffer[1024];
va_list args;
va_start( args, Msg );
vsprintf( szBuffer, Msg, args );
va_end( args );
throw bad_exception( szBuffer );
}
static void Error( const char * str, HRESULT hr )
{
Error( "%s, ErrorCode : 0x%x", str, hr );
}
////////////////////////////////////////////////////////////////////////////
//
CSphere::CSphere()
: m_pd3dDevice( NULL )
, m_pVB( NULL )
, m_uiRings( 0 )
, m_uiSegments( 0 )
, m_fPosX( 0.0f )
, m_fPosY( 0.0f )
, m_fPosZ( 0.0f )
, m_fRadius( 0.0f )
, m_fRed( 0.0f )
, m_fGreen( 0.0f )
, m_fBlue( 0.0f )
, m_uiSphereVertices( 0 )
, m_ucTransparency( 80 )
{
}
////////////////////////////////////////////////////////////////////////////
//
CSphere::~CSphere()
{
Destroy();
}
////////////////////////////////////////////////////////////////////////////
//
void CSphere::Create( IDirect3DDevice8 * pd3dDevice, unsigned rings, unsigned segments )
{
m_pd3dDevice = pd3dDevice;
m_uiRings = rings;
m_uiSegments = segments;
m_uiSphereVertices = ( 2 * m_uiRings * ( m_uiSegments + 1 ) );
HRESULT hr = m_pd3dDevice->CreateVertexBuffer( m_uiSphereVertices * sizeof( CUSTOMVERTEX ),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_MANAGED, &m_pVB );
if( FAILED( hr ) )
{
Error( "CreateVertexBuffer Failed!!(CSphere::Create)", hr );
}
CUSTOMVERTEX* pVertices;
hr = m_pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 );
if( FAILED( hr ) )
Error( "VertexBuffer Lock Failed!!(CSphere::Create) ErrorCode : 0x%x", hr );
float fDeltaRingAngle = ( D3DX_PI / m_uiRings );
float fDeltaSegAngle = ( 2.0f * D3DX_PI / m_uiSegments );
for( DWORD ring = 0; ring < m_uiRings; ring++ )
{
float r0 = sinf( (ring+0) * fDeltaRingAngle );
float r1 = sinf( (ring+1) * fDeltaRingAngle );
float y0 = cosf( (ring+0) * fDeltaRingAngle );
float y1 = cosf( (ring+1) * fDeltaRingAngle );
for( DWORD seg = 0; seg < m_uiSegments; seg++ )
{
pVertices->x = r0 * sinf( seg * fDeltaSegAngle );
pVertices->y = y0;
pVertices->z = r0 * cosf( seg * fDeltaSegAngle );
pVertices->color = 0xffffffff;
pVertices++;
pVertices->x = r1 * sinf( seg * fDeltaSegAngle );
pVertices->y = y1;
pVertices->z = r1 * cosf( seg * fDeltaSegAngle );
pVertices->color = 0xffffffff;
pVertices++;
}
}
m_pVB->Unlock();
}
////////////////////////////////////////////////////////////////////////////
//
void CSphere::Destroy()
{
m_pd3dDevice = NULL;
if( m_pVB )
{
m_pVB->Release();
m_pVB = NULL;
}
m_uiRings = m_uiSegments = 0;
}
////////////////////////////////////////////////////////////////////////////
//
void CSphere::SetPosition( float x, float y, float z )
{
m_fPosX = x;
m_fPosY = y;
m_fPosZ = z;
}
////////////////////////////////////////////////////////////////////////////
//
void CSphere::SetColor( float r, float g, float b )
{
m_fRed = r;
m_fGreen = g;
m_fBlue = b;
}
////////////////////////////////////////////////////////////////////////////
//
HRESULT SetShader( LPDIRECT3DDEVICE8 pd3dDevice, DWORD color )
{
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,color);
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TFACTOR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
CSceneStateMgr::_SetD3DTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
CSceneStateMgr::_SetD3DTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
CSceneStateMgr::_SetD3DTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
CSceneStateMgr::_SetD3DTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
DWORD dwNumPasses;
return pd3dDevice->ValidateDevice( &dwNumPasses );
}
void CSphere::Render()
{
// HRESULT hr = m_pd3dDevice->BeginScene();
// if( FAILED( hr ) )
// Error( "BeginScene Failed!!( CSphere::Render )", hr );
D3DXMATRIX matWorld, oldMatrix, scaleMat, moveMat;
m_pd3dDevice->GetTransform( D3DTS_WORLD, &oldMatrix );
D3DXMatrixScaling( &scaleMat, m_fRadius, m_fRadius, m_fRadius );
D3DXMatrixTranslation( &moveMat, m_fPosX, m_fPosY, m_fPosZ );
D3DXMatrixMultiply( &matWorld, &scaleMat, &moveMat );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
//D3DMATERIAL8 material = { 0xff0000ff, 0x00000000, 0x00000000, 0x00000000, 0.0f };
//m_pd3dDevice->SetMaterial( &material );
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
CSceneStateMgr::_SetD3DRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
CSceneStateMgr::_SetD3DRenderState( D3DRS_FILLMODE,D3DFILL_WIREFRAME);
DWORD color = 0;
color |= ( m_ucTransparency << 24 );
color |= ( int( m_fRed * 255 ) << 16 ); //Red
color |= ( int( m_fGreen * 255 ) << 8 ); //Green
color |= ( int( m_fBlue * 255 ) << 0 ); //Blue
SetShader( m_pd3dDevice, color );
m_pd3dDevice->SetStreamSource( 0, m_pVB, sizeof(CUSTOMVERTEX) );
m_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, m_uiSphereVertices - 2 );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &oldMatrix );
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE, FALSE);
CSceneStateMgr::_SetD3DRenderState( D3DRS_FILLMODE,D3DFILL_SOLID);
// m_pd3dDevice->EndScene();
}
////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,38 @@
#ifndef _Sphere_H_
#define _Sphere_H_
struct IDirect3DVertexBuffer8;
struct IDirect3DDevice8;
////////////////////////////////////////////////////////////////////////////
//
class CSphere
{
IDirect3DDevice8 * m_pd3dDevice;
IDirect3DVertexBuffer8 * m_pVB;
unsigned m_uiRings, m_uiSegments; //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><EFBFBD><E6B5B5> <20><><EFBFBD><EFBFBD>
float m_fRed, m_fGreen, m_fBlue;
unsigned m_uiSphereVertices;
unsigned char m_ucTransparency;
public:
CSphere();
~CSphere();
void Create( IDirect3DDevice8 *, unsigned rings, unsigned segments );
void Destroy();
void SetPosition( float x, float y, float z );
void SetTransparency( unsigned char t ) { m_ucTransparency = t; }
void SetRadius( float radius ) { m_fRadius = radius; }
void SetColor( float r, float g, float b );
void Render();
float m_fPosX, m_fPosY, m_fPosZ, m_fRadius;
};
////////////////////////////////////////////////////////////////////////////
#endif

View File

@@ -0,0 +1,37 @@
// StateLog.cpp: implementation of the CStateLog class.
//
//////////////////////////////////////////////////////////////////////
#include "StateLog.h"
#include <Windows.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
FILE *CStateLog::m_fp;
CStateLog::CStateLog()
{
m_fp=NULL;
}
CStateLog::~CStateLog()
{
fclose(m_fp);
}
void CStateLog::Create(char *strFilename)
{
m_fp=fopen(strFilename,"wt");
if(m_fp==NULL)
MessageBox(NULL,"Create Logfile failed",0,0);
}
void CStateLog::Message(char *strMessage, char *strFilename, int strLine)
{
if(m_fp==NULL)
{
CStateLog::Create("c:\\MP_Client.log");
}
fprintf(m_fp,"%-30s _Filename_: %-20s _Line_: %6d\n",strMessage,strFilename,strLine);
}

View File

@@ -0,0 +1,27 @@
// StateLog.h: interface for the CStateLog class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_STATELOG_H__1E93C2C5_AF70_4A6C_8AF2_2B66D46A1A36__INCLUDED_)
#define AFX_STATELOG_H__1E93C2C5_AF70_4A6C_8AF2_2B66D46A1A36__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <stdio.h>
class CStateLog
{
static FILE *m_fp;
public:
static void Message(char *strMessage,char *strFilename,int strLine);
static void Create(char *strFilename);
CStateLog();
virtual ~CStateLog();
};
#define LogMessage(Msg) CStateLog::Message(Msg,__FILE__,__LINE__)
#endif // !defined(AFX_STATELOG_H__1E93C2C5_AF70_4A6C_8AF2_2B66D46A1A36__INCLUDED_)

View File

@@ -0,0 +1,652 @@
// Texture.cpp: implementation of the CTexture class.
//
//////////////////////////////////////////////////////////////////////
#include "Texture.h"
#include "3DMath.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
typedef LPDIRECT3DTEXTURE8 DXTEXTURE;
LPDIRECT3DDEVICE8 CTexture::m_pd3dDevice;
char CTexture::m_strPath[TEXTURENAMEBUFFER];
CTextureContainer CTexture::m_TextureContainer;
int CTexture::m_SkipMipLevel=0;
unsigned char *CTexture::m_pReadBuffer=NULL;
int GetNumberOfBits( int mask )
{
for( int nBits = 0; mask; nBits++ )
mask = mask & ( mask - 1 );
return nBits;
}
CTexture::CTexture()
{
strcpy(m_strName,"");
m_pddTexture=NULL;
m_bCreateEmpty=false;
if(m_pReadBuffer==NULL)
{
int nSize=1398256*4;
m_pReadBuffer=new unsigned char[nSize];
}
}
CTexture::~CTexture()
{
if(m_bCreateEmpty)
{
m_pddTexture->Release();
}
Unload();
}
void CTexture::Init(LPDIRECT3DDEVICE8 pd3dDevice)
{
m_pd3dDevice=pd3dDevice;
strcpy(m_strPath,"");
}
void CTexture::LoadNotMessage(char *filename,DWORD stage)
{
if(strcmp(filename,"")==0)
return;
strcpy(m_strName,filename);
m_stage=stage;
int nUsedText=m_TextureContainer.FindTexture(filename);
if(nUsedText>=0)
{
m_pddTexture=m_TextureContainer.AddUsedTexture(nUsedText);
if(m_pddTexture)
{
D3DSURFACE_DESC ddsc;
((LPDIRECT3DTEXTURE8)m_pddTexture)->GetLevelDesc(0,&ddsc);
m_dwWidth=ddsc.Width;
m_dwHeight=ddsc.Height;
return;
}
}
//LPDIRECT3DBASETEXTURE8 pddsTemp = NULL;
m_pddTexture=NULL;
if(strstr(m_strPath,"Interface")==0)
{
if(ReadDDSTextureNotMessage(m_pddTexture,0) == -1)
m_pddTexture = NULL;
}
else
{
if(ReadDDSTextureNotMessage(m_pddTexture,1) == -1)
m_pddTexture = NULL;
}
m_TextureContainer.AddTexture(filename,m_pddTexture);
//pddsTemp->Release();
//pddsTemp=NULL;
}
void CTexture::LoadNotCache(char *filename,DWORD stage)
{
if(strcmp(filename,"")==0)
return;
strcpy(m_strName,filename);
m_stage=stage;
//LPDIRECT3DBASETEXTURE8 pddsTemp = NULL;
m_pddTexture=NULL;
if(strstr(m_strPath,"Interface")==0)
{
ReadDDSTexture( m_pddTexture ,0);
}
else
{
ReadDDSTexture( m_pddTexture ,1);
}
//pddsTemp->Release();
//pddsTemp=NULL;
}
void CTexture::Load(char *filename, DWORD stage)
{
if(strcmp(filename,"")==0)
return;
strcpy(m_strName,filename);
m_stage=stage;
int nUsedText=m_TextureContainer.FindTexture(filename);
if(nUsedText>=0)
{
m_pddTexture=m_TextureContainer.AddUsedTexture(nUsedText);
if(m_pddTexture)
{
D3DSURFACE_DESC ddsc;
((LPDIRECT3DTEXTURE8)m_pddTexture)->GetLevelDesc(0,&ddsc);
m_dwWidth=ddsc.Width;
m_dwHeight=ddsc.Height;
return;
}
}
//LPDIRECT3DBASETEXTURE8 pddsTemp = NULL;
m_pddTexture=NULL;
if(strstr(m_strPath,"Interface")==0)
{
ReadDDSTexture( m_pddTexture ,0);
}
else
{
ReadDDSTexture( m_pddTexture ,1);
}
m_TextureContainer.AddTexture(filename,m_pddTexture);
//pddsTemp->Release();
//pddsTemp=NULL;
}
int CTexture::ReadDDSTextureNotMessage(LPDIRECT3DBASETEXTURE8 &pddsTemp,int nMethod)
{
char strFullName[TEXTURENAMEBUFFER];
memset(strFullName, 0, TEXTURENAMEBUFFER);
if(strcmp(m_strPath, ""))
{
strcpy(strFullName,m_strPath);
strcat(strFullName,"\\");
}
strcat(strFullName,m_strName);
int lens=strlen(strFullName);
strFullName[lens-1]='s';
strFullName[lens-2]='d';
strFullName[lens-3]='d';
if(nMethod)
{
FILE* fp=fopen(strFullName,"rb");
if(fp==NULL)
{
return -1;
/* char msg[256];
sprintf(msg,"File not found %s",strFullName);
MessageBox(NULL,msg,0,0);*/
}
DWORD dwMagic;
DDS_HEADER ddsh;
LPDIRECT3DTEXTURE8 pmiptex = NULL;
fread(&dwMagic,sizeof(dwMagic),1,fp);
fread(&ddsh,sizeof(ddsh),1,fp);
if (ddsh.dwSize != sizeof(ddsh))
CGraphicLayerError("CTexture:ReadDDSTexture , This is not dds format");
DWORD dwWidth = ddsh.dwWidth;
DWORD dwHeight = ddsh.dwHeight;
DWORD numMips = ddsh.dwMipMapCount;
DWORD dwDepth=0;
m_dwWidth=ddsh.dwWidth;
m_dwHeight=ddsh.dwHeight;
if (numMips == 0)
numMips = 1;
if (ddsh.dwHeaderFlags & DDS_HEADER_FLAGS_VOLUME)
dwDepth = ddsh.dwDepth;
else
dwDepth = 0;
D3DFORMAT fmt;
if (ddsh.ddspf.dwFourCC == D3DFMT_DXT1)
fmt = D3DFMT_DXT1;
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT2)
fmt = D3DFMT_DXT2;
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT3)
fmt = D3DFMT_DXT3;
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT4)
fmt = D3DFMT_DXT4;
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT5)
fmt = D3DFMT_DXT5;
else if (ddsh.ddspf.dwFlags == DDS_RGBA && ddsh.ddspf.dwRGBBitCount == 32 && ddsh.ddspf.dwABitMask == 0xff000000)
fmt = D3DFMT_A8R8G8B8;
else if (ddsh.ddspf.dwFlags == DDS_RGB && ddsh.ddspf.dwRGBBitCount == 24)
fmt = D3DFMT_R8G8B8;
else if (ddsh.ddspf.dwFlags == DDS_RGB && ddsh.ddspf.dwRGBBitCount == 16 && ddsh.ddspf.dwGBitMask == 0x000007e0)
fmt = D3DFMT_R5G6B5;
else if (ddsh.ddspf.dwFlags == DDS_RGBA && ddsh.ddspf.dwRGBBitCount == 16 && ddsh.ddspf.dwABitMask == 0x00008000)
fmt = D3DFMT_A1R5G5B5;
else if (ddsh.ddspf.dwFlags == DDS_RGBA && ddsh.ddspf.dwRGBBitCount == 16 && ddsh.ddspf.dwABitMask == 0x0000f000)
fmt = D3DFMT_A4R4G4B4;
else
return -1;
if (FAILED(m_pd3dDevice->CreateTexture(dwWidth>>m_SkipMipLevel, dwHeight>>m_SkipMipLevel, numMips-m_SkipMipLevel, 0, fmt, D3DPOOL_MANAGED, &pmiptex)))
{
CGraphicLayerError("CTexture:ReadDDSTexture , CreateTexture is failed");
}
if (FAILED(LoadAllMipSurfaces(pmiptex, numMips, fp)))
{
fclose(fp);
pddsTemp = NULL;
return -1;
/*MessageBox(NULL,"LoadAllMipSurface Load Failed",0,0);
MessageBox(NULL,strFullName,0,0);
CGraphicLayerError("CTexture:ReadDDSTexture , LoadAllMipSurfaces is failed");*/
}
fclose(fp);
pddsTemp = pmiptex;
}
else
{
HANDLE hFile;
hFile=CreateFile(strFullName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if( hFile==INVALID_HANDLE_VALUE)
{
pddsTemp = NULL;
return -1;
/* char msg[256];
sprintf(msg,"File not found %s",strFullName);
MessageBox(NULL,msg,0,0);*/
}
DWORD dwTextureFileSize=GetFileSize(hFile,NULL);
//unsigned char *pFileBuffer=new unsigned char[dwTextureFileSize];
DWORD dwReaded;
ReadFile(hFile,m_pReadBuffer,dwTextureFileSize,&dwReaded,NULL);
CloseHandle(hFile);
DWORD dwMagic=MAKEFOURCC('D','D','S',' ');
DWORD *p=(DWORD*)m_pReadBuffer;
*p=dwMagic;
LPDIRECT3DTEXTURE8 pmiptex = NULL;
HRESULT hr=D3DXCreateTextureFromFileInMemory(m_pd3dDevice,m_pReadBuffer,dwTextureFileSize,&pmiptex);
pddsTemp = pmiptex;
}
return 0;
}
void CTexture::ReadDDSTexture(LPDIRECT3DBASETEXTURE8 &pddsTemp,int nMethod)
{
char strFullName[TEXTURENAMEBUFFER];
memset(strFullName, 0, TEXTURENAMEBUFFER);
if(strcmp(m_strPath, ""))
{
strcpy(strFullName,m_strPath);
strcat(strFullName,"\\");
}
strcat(strFullName,m_strName);
int lens=strlen(strFullName);
strFullName[lens-1]='s';
strFullName[lens-2]='d';
strFullName[lens-3]='d';
if(nMethod)
{
FILE* fp=fopen(strFullName,"rb");
if(fp==NULL)
{
char msg[256];
sprintf(msg,"File not found %s",strFullName);
MessageBox(NULL,msg,0,0);
}
DWORD dwMagic;
DDS_HEADER ddsh;
LPDIRECT3DTEXTURE8 pmiptex = NULL;
fread(&dwMagic,sizeof(dwMagic),1,fp);
fread(&ddsh,sizeof(ddsh),1,fp);
if (ddsh.dwSize != sizeof(ddsh))
CGraphicLayerError("CTexture:ReadDDSTexture , This is not dds format");
DWORD dwWidth = ddsh.dwWidth;
DWORD dwHeight = ddsh.dwHeight;
DWORD numMips = ddsh.dwMipMapCount;
DWORD dwDepth=0;
m_dwWidth=ddsh.dwWidth;
m_dwHeight=ddsh.dwHeight;
if (numMips == 0)
numMips = 1;
if (ddsh.dwHeaderFlags & DDS_HEADER_FLAGS_VOLUME)
dwDepth = ddsh.dwDepth;
else
dwDepth = 0;
D3DFORMAT fmt;
if (ddsh.ddspf.dwFourCC == D3DFMT_DXT1)
fmt = D3DFMT_DXT1;
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT2)
fmt = D3DFMT_DXT2;
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT3)
fmt = D3DFMT_DXT3;
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT4)
fmt = D3DFMT_DXT4;
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT5)
fmt = D3DFMT_DXT5;
else if (ddsh.ddspf.dwFlags == DDS_RGBA && ddsh.ddspf.dwRGBBitCount == 32 && ddsh.ddspf.dwABitMask == 0xff000000)
fmt = D3DFMT_A8R8G8B8;
else if (ddsh.ddspf.dwFlags == DDS_RGB && ddsh.ddspf.dwRGBBitCount == 24)
fmt = D3DFMT_R8G8B8;
else if (ddsh.ddspf.dwFlags == DDS_RGB && ddsh.ddspf.dwRGBBitCount == 16 && ddsh.ddspf.dwGBitMask == 0x000007e0)
fmt = D3DFMT_R5G6B5;
else if (ddsh.ddspf.dwFlags == DDS_RGBA && ddsh.ddspf.dwRGBBitCount == 16 && ddsh.ddspf.dwABitMask == 0x00008000)
fmt = D3DFMT_A1R5G5B5;
else if (ddsh.ddspf.dwFlags == DDS_RGBA && ddsh.ddspf.dwRGBBitCount == 16 && ddsh.ddspf.dwABitMask == 0x0000f000)
fmt = D3DFMT_A4R4G4B4;
else
return;
if (FAILED(m_pd3dDevice->CreateTexture(dwWidth>>m_SkipMipLevel, dwHeight>>m_SkipMipLevel, numMips-m_SkipMipLevel, 0, fmt, D3DPOOL_MANAGED, &pmiptex)))
{
CGraphicLayerError("CTexture:ReadDDSTexture , CreateTexture is failed");
}
if (FAILED(LoadAllMipSurfaces(pmiptex, numMips, fp)))
{
MessageBox(NULL,"LoadAllMipSurface Load Failed",0,0);
MessageBox(NULL,strFullName,0,0);
CGraphicLayerError("CTexture:ReadDDSTexture , LoadAllMipSurfaces is failed");
}
fclose(fp);
pddsTemp = pmiptex;
}
else
{
HANDLE hFile;
hFile=CreateFile(strFullName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if( hFile==INVALID_HANDLE_VALUE)
{
char msg[256];
sprintf(msg,"File not found %s",strFullName);
MessageBox(NULL,msg,0,0);
}
DWORD dwTextureFileSize=GetFileSize(hFile,NULL);
//unsigned char *pFileBuffer=new unsigned char[dwTextureFileSize];
DWORD dwReaded;
ReadFile(hFile,m_pReadBuffer,dwTextureFileSize,&dwReaded,NULL);
CloseHandle(hFile);
DWORD dwMagic=MAKEFOURCC('D','D','S',' ');
DWORD *p=(DWORD*)m_pReadBuffer;
*p=dwMagic;
LPDIRECT3DTEXTURE8 pmiptex = NULL;
HRESULT hr=D3DXCreateTextureFromFileInMemory(m_pd3dDevice,m_pReadBuffer,dwTextureFileSize,&pmiptex);
pddsTemp = pmiptex;
}
}
void CTexture::DeleteTexture()
{
if(m_pddTexture)
m_TextureContainer.DeleteTexture(m_strName);
}
void CTexture::CreateEmpty(long lSx, long lSy,D3DFORMAT format,D3DPOOL pool,long mip)
{
LPDIRECT3DTEXTURE8 pddEmpty;
m_pd3dDevice->CreateTexture(lSx,lSy,mip,0,format,pool,&pddEmpty);
m_pddTexture=pddEmpty;
m_bCreateEmpty=true;
m_dwWidth=lSx;
m_dwHeight=lSy;
}
void CTexture::FillColor(DWORD color)
{
D3DSURFACE_DESC sd;
LPDIRECT3DTEXTURE8 pddEmpty;
pddEmpty=(LPDIRECT3DTEXTURE8)m_pddTexture;
pddEmpty->GetLevelDesc(0,&sd);
D3DLOCKED_RECT lr;
pddEmpty->LockRect(0,&lr,NULL,0);
DWORD *pSurface=(DWORD*)lr.pBits;
//color light;//=color(rand()%255,rand()%255,rand()%255);
//color asdf;
/*
unsigned char r,g,b;
r=(rand()%200)+55;
g=rand()%255;
b=rand()%255;
*/
for(DWORD ix=0;ix<sd.Width;ix++)
{
for(DWORD iy=0;iy<sd.Height;iy++)
{
//pSurface[ix+iy*sd.Width]=D3DCOLOR_ARGB(0xff,r,g,b);
//pSurface[ix+iy*sd.Width]=D3DCOLOR_ARGB(0xff,255,0,0);
pSurface[ix+iy*sd.Width]=color;
//pSurface[ix+iy*sd.Width]=ix*(255.0f/32.0f);
//pSurface[ix+iy*sd.Width]=Clight.c;
}
}
pddEmpty->UnlockRect(0);
}
HRESULT CTexture::LoadAllMipSurfaces(LPDIRECT3DBASETEXTURE8 ptex,long numMips, FILE *fp)
{
HRESULT hr;
LPDIRECT3DSURFACE8 psurf;
D3DSURFACE_DESC sd;
D3DLOCKED_RECT lr;
LPDIRECT3DTEXTURE8 pmiptex = NULL;
DWORD dwBytesPerRow;
pmiptex = (LPDIRECT3DTEXTURE8)ptex;
long iLevel;
for (iLevel = 0; iLevel < numMips; iLevel++)
{
if (pmiptex != NULL)
hr = pmiptex->GetSurfaceLevel(iLevel-m_SkipMipLevel, &psurf);
if (FAILED(hr))
return hr;
psurf->GetDesc(&sd);
switch (sd.Format)
{
case D3DFMT_DXT1:
case D3DFMT_DXT2:
case D3DFMT_DXT3:
case D3DFMT_DXT4:
case D3DFMT_DXT5:
dwBytesPerRow = 0; // magic value indicates texture's memory is contiguous
break;
case D3DFMT_A8R8G8B8:
dwBytesPerRow = 4 * sd.Width;
break;
case D3DFMT_R8G8B8:
dwBytesPerRow = 3 * sd.Width;
break;
case D3DFMT_A1R5G5B5:
case D3DFMT_A4R4G4B4:
case D3DFMT_R5G6B5:
dwBytesPerRow = 2 * sd.Width;
break;
default:
return E_FAIL;
}
if (pmiptex != NULL)
hr = pmiptex->LockRect(iLevel, &lr, NULL, 0);
if (FAILED(hr))
return hr;
if (dwBytesPerRow == 0)
{
fread(lr.pBits,sd.Size,1,fp);
}
else
{
DWORD yp;
BYTE* pbDest = (BYTE*)lr.pBits;
for (yp = 0; yp < sd.Height; yp++)
{
fread(pbDest,dwBytesPerRow,1,fp);
pbDest += lr.Pitch;
}
}
if (pmiptex != NULL)
hr = pmiptex->UnlockRect(iLevel);
ReleasePpo(&psurf);
}
return S_OK;
}
void* CTexture::Lock()
{
LPDIRECT3DTEXTURE8 pddEmpty;
pddEmpty=(LPDIRECT3DTEXTURE8)m_pddTexture;
D3DLOCKED_RECT lr;
pddEmpty->LockRect(0,&lr,NULL,0);
return lr.pBits;
}
void CTexture::Unlock()
{
LPDIRECT3DTEXTURE8 pddEmpty;
pddEmpty=(LPDIRECT3DTEXTURE8)m_pddTexture;
pddEmpty->UnlockRect(0);
}
void CTexture::Unload()
{
if(m_pddTexture)
m_TextureContainer.DeleteTexture(m_strName);
m_pddTexture=NULL;
}
void CTexture::ChangeTextureIntension( byte *pImage, int iSize, float fColorFactor) { // Texture Color <20>󵵺<EFBFBD>ȭ (D3DFMT_R8G8B8 <20><>)
int i;
for( i=0; i < iSize / 3; i++ )
{
float fScale = 1.0f;
float fTmp = 0.0f;
float fR = 0.0f;
float fG = 0.0f;
float fB = 0.0f;
fR = (float)pImage[0];
fG = (float)pImage[1];
fB = (float)pImage[2];
fR = fR * fColorFactor / 255.0f;
fG = fG * fColorFactor / 255.0f;
fB = fB * fColorFactor / 255.0f;
if( ( fR > 1.0f ) && ( fTmp = ( 1.0f / fR ) ) < fScale )
fScale = fTmp;
if( ( fG > 1.0f ) && ( fTmp = ( 1.0f / fG ) ) < fScale )
fScale = fTmp;
if( ( fB > 1.0f ) && ( fTmp = ( 1.0f / fB ) ) < fScale )
fScale = fTmp;
fScale *= 255.0f;
fR *= fScale;
fG *= fScale;
fB *= fScale;
pImage[0] = ( byte )fR;
pImage[1] = ( byte )fG;
pImage[2] = ( byte )fB;
pImage +=3;
}
}
void CTexture::CreateEmptyTexture( unsigned int uiX, unsigned int uiY, unsigned int uiMip,D3DFORMAT dFormat, D3DPOOL dPool) {
DXTEXTURE lpEmptyTexture;
HRESULT hr = m_pd3dDevice->CreateTexture( uiX,uiY,uiMip,0,dFormat,dPool,&lpEmptyTexture);
if(hr == D3DERR_INVALIDCALL)
MessageBox(NULL,"Err1","error",MB_OK);
else if(hr == D3DERR_OUTOFVIDEOMEMORY)
MessageBox(NULL,"Err2","error",MB_OK);
else if(hr == E_OUTOFMEMORY)
MessageBox(NULL,"Err3","error",MB_OK);
m_pddTexture = lpEmptyTexture;
m_dwWidth = uiX;
m_dwHeight = uiY;
}
void CTexture::FillTexture( byte * pByte) {
D3DSURFACE_DESC dTextureSurf;
DXTEXTURE lpEmptyTexture;
lpEmptyTexture = (DXTEXTURE)m_pddTexture;
lpEmptyTexture->GetLevelDesc( 0, &dTextureSurf );
D3DLOCKED_RECT lRect;
HRESULT hr = lpEmptyTexture->LockRect( 0, &lRect, NULL, 0);
if(hr == D3DERR_INVALIDCALL)
MessageBox(NULL,"te","tt",MB_OK);
byte *pSurface = (byte *)lRect.pBits;
unsigned int iImageSize = dTextureSurf.Size;//dTextureSurf.Width * dTextureSurf.Height;
memcpy( pSurface,pByte,sizeof(byte) * iImageSize);
lpEmptyTexture->UnlockRect( 0 );
}
void CTexture::SetBitTexture( int iWidth, int iHeight, WORD* pSrc )
{
D3DSURFACE_DESC dTextureSurf ;
DXTEXTURE lpEmptyTexture ;
D3DLOCKED_RECT lRect ;
lpEmptyTexture = ( DXTEXTURE )m_pddTexture ;
lpEmptyTexture->GetLevelDesc( 0, &dTextureSurf ) ;
HRESULT hr = lpEmptyTexture->LockRect( 0, &lRect, NULL, 0 ) ;
if ( hr == D3DERR_INVALIDCALL )
MessageBox( NULL,"te","tt",MB_OK ) ;
WORD* pSurface = ( WORD * )lRect.pBits ;
// unsigned int iImageSize = dTextureSurf.Size;//dTextureSurf.Width * dTextureSurf.Height;
// memset( pSurface, 0, sizeof(WORD) * iImageSize ) ;
BYTE* pbyTempBuff = ( BYTE* )pSrc ;
WORD* pwTempBuff = ( WORD* )( pbyTempBuff + 1 ) ;
int CurSrc = 0 ;
int CurDest = 0 ;
for ( DWORD ix = 0 ;ix < iHeight ; ix ++ )
{
CurDest = dTextureSurf.Width * ix ;
for ( DWORD iy = 0 ; iy < iWidth ;iy ++ )
{
pSurface[ CurDest ] = pwTempBuff[ CurSrc ] ;
++ CurDest ;
++ CurSrc ;
}
}
lpEmptyTexture->UnlockRect( 0 ) ;
}
void CTexture::DeleteAllCashTexture()
{
m_TextureContainer.DeleteAllTexture();
}

View File

@@ -0,0 +1,167 @@
// Texture.h: interface for the CTexture class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TEXTURE_H__B7D0E82F_58D8_45F7_85FB_A4EF64205953__INCLUDED_)
#define AFX_TEXTURE_H__B7D0E82F_58D8_45F7_85FB_A4EF64205953__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
//#include <d3d.h>
#include "list.h"
#include "TextureContainer.h"
#include "Exception.h"
#ifndef ReleasePpo
#define ReleasePpo(ppo) \
if (*(ppo) != NULL) \
{ \
(*(ppo))->Release(); \
*(ppo) = NULL; \
} \
else (VOID)0
#endif
/*
struct DDS_PIXELFORMAT
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwFourCC;
DWORD dwRGBBitCount;
DWORD dwRBitMask;
DWORD dwGBitMask;
DWORD dwBBitMask;
DWORD dwABitMask;
};
struct DDS_HEADER
{
DWORD dwSize;
DWORD dwHeaderFlags;
DWORD dwHeight;
DWORD dwWidth;
DWORD dwPitchOrLinearSize;
DWORD dwDepth; // only if DDS_HEADER_FLAGS_VOLUME is set in dwHeaderFlags
DWORD dwMipMapCount;
DWORD dwReserved1[11];
DDS_PIXELFORMAT ddspf;
DWORD dwSurfaceFlags;
DWORD dwCubemapFlags;
DWORD dwReserved2[3];
};
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
#define DDS_RGB 0x00000040 // DDPF_RGB
#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
const DDS_PIXELFORMAT DDSPF_DXT1 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
const DDS_PIXELFORMAT DDSPF_DXT2 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 };
const DDS_PIXELFORMAT DDSPF_DXT3 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 };
const DDS_PIXELFORMAT DDSPF_DXT4 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 };
const DDS_PIXELFORMAT DDSPF_DXT5 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 };
const DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
const DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00007c00, 0x000003e0, 0x0000001f, 0x00008000 };
const DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0000f000, 0x000000f0, 0x0000000f, 0x0000f000 };
const DDS_PIXELFORMAT DDSPF_R8G8B8 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 };
const DDS_PIXELFORMAT DDSPF_R5G6B5 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 };
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
#define DDS_SURFACE_FLAGS_MIPMAP 0x00400008 // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
#define DDS_SURFACE_FLAGS_CUBEMAP 0x00000008 // DDSCAPS_COMPLEX
#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
#define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY
#define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY
#define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ
#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ
#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\
DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\
DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ )
#define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME
*/
#include "dds.h"
class CTexture
{
bool m_bCreateEmpty;
DWORD m_stage;
static unsigned char *m_pReadBuffer;
protected:
static LPDIRECT3DDEVICE8 m_pd3dDevice;
static CTextureContainer m_TextureContainer;
static char m_strPath[TEXTURENAMEBUFFER];
public:
static int m_SkipMipLevel;
void Unload();
LPDIRECT3DBASETEXTURE8 m_pddTexture;
char m_strName[TEXTURENAMEBUFFER];
long m_dwWidth,m_dwHeight;
void Unlock();
void* Lock();
HRESULT LoadAllMipSurfaces(LPDIRECT3DBASETEXTURE8 ptex, long numMips, FILE *fp);
void FillColor(DWORD color);
void SetMipmapSkipLevel(int nSkip){m_SkipMipLevel=nSkip;};
void CreateEmpty(long lSx,long lSy,D3DFORMAT format=D3DFMT_A8R8G8B8,D3DPOOL pool=D3DPOOL_MANAGED,long mip=0);
void DeleteTexture();
static void SetPath(char *strPath){strcpy(m_strPath,strPath);};
LPDIRECT3DBASETEXTURE8 GetTexture(){return m_pddTexture;};
void ReadDDSTexture( LPDIRECT3DBASETEXTURE8& pddsTemp,int nMethod );
virtual void Load(char *filename,DWORD stage=0);
void LoadNotCache(char *filename,DWORD stage=0);
static void Init(LPDIRECT3DDEVICE8 pd3dDevice);
CTexture();
// <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD>
static void DeleteAllCashTexture();
static void ChangeTextureIntension( byte *pImage, int iSize, float fColorFactor);
void CreateEmptyTexture( unsigned int uiX, unsigned int uiY, unsigned int uiMip,D3DFORMAT dFormat, D3DPOOL dPool);
void FillTexture( byte * pByte);
virtual void LoadNotMessage(char *filename,DWORD stage=0); // Load Func, Not Error Message(Glare <20><>)
int ReadDDSTextureNotMessage(LPDIRECT3DBASETEXTURE8 &pddsTemp,int nMethod);
virtual ~CTexture();
// <20><>ȯ <20>߰<EFBFBD>
void SetBitTexture( int iWidth, int iHeight, WORD* pSrc ) ;
};
#endif // !defined(AFX_TEXTURE_H__B7D0E82F_58D8_45F7_85FB_A4EF64205953__INCLUDED_)

View File

@@ -0,0 +1,66 @@
// TextureContainer.cpp: implementation of the CTextureContainer class.
//
//////////////////////////////////////////////////////////////////////
#include "TextureContainer.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTextureContainer::CTextureContainer()
{
}
CTextureContainer::~CTextureContainer()
{
DeleteAllTexture();
}
void CTextureContainer::AddTexture(const char *strTextName, const LPDIRECT3DBASETEXTURE8 pddTexture)
{
m_TextureList.Add(new TextureNode(strTextName,pddTexture));
}
int CTextureContainer::FindTexture(char *strTextName)
{
for(int i=0;i<m_TextureList.num;i++)
{
if(strcmp(m_TextureList[i]->m_strTextureName,strTextName)==0)
return i;
}
return -1;
}
LPDIRECT3DBASETEXTURE8 CTextureContainer::AddUsedTexture(int nUsed)
{
m_TextureList[nUsed]->m_nUsed++;
return m_TextureList[nUsed]->m_pddsTexture;
}
void CTextureContainer::DeleteTexture(char *strTextName)
{
for(int i=0;i<m_TextureList.num;i++)
{
if(strcmp(m_TextureList[i]->m_strTextureName,strTextName)==0)
{
if(--m_TextureList[i]->m_nUsed==0)
{
TextureNode *temp=m_TextureList[i];
m_TextureList.DelIndex(i);
delete temp;
return;
}
}
}
}
void CTextureContainer::DeleteAllTexture()
{
for(int i=0;i<m_TextureList.num;i++)
{
delete m_TextureList[i];
}
m_TextureList.num=0;
}

View File

@@ -0,0 +1,51 @@
// TextureContainer.h: interface for the CTextureContainer class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TEXTURECONTAINER_H__54E7CE78_FE22_4D67_8E7C_F04CFF06DE90__INCLUDED_)
#define AFX_TEXTURECONTAINER_H__54E7CE78_FE22_4D67_8E7C_F04CFF06DE90__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
#include <string>
#include "list.h"
#include "Exception.h"
const long TEXTURENAMEBUFFER=256;
class CTextureContainer
{
class TextureNode {
public:
long m_nUsed;
char m_strTextureName[TEXTURENAMEBUFFER];
LPDIRECT3DBASETEXTURE8 m_pddsTexture;
TextureNode(const char *strName,const LPDIRECT3DBASETEXTURE8 pddTexture)
{
m_nUsed=1;
strcpy(m_strTextureName,strName);
m_pddsTexture=pddTexture;
};
~TextureNode()
{
if(m_pddsTexture != NULL) {
if(m_pddsTexture->Release()!=0)
throw CGraphicLayerError("TextureNode: ~TextureNode ,This texture used other memory,as yet");
}
};
};
List<TextureNode*> m_TextureList;
public:
void DeleteAllTexture();
void DeleteTexture(char *strTextName);
LPDIRECT3DBASETEXTURE8 AddUsedTexture(int nUsed);
int FindTexture(char *strTextName);
void AddTexture(const char *strTextName, const LPDIRECT3DBASETEXTURE8 pddTexture);
CTextureContainer();
virtual ~CTextureContainer();
};
#endif // !defined(AFX_TEXTURECONTAINER_H__54E7CE78_FE22_4D67_8E7C_F04CFF06DE90__INCLUDED_)

View File

@@ -0,0 +1,208 @@
/*
// VECTOR.h: interface for the VECTOR class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_VECTOR_H__10479201_0625_493F_9ABD_2DB66EC951B3__INCLUDED_)
#define AFX_VECTOR_H__10479201_0625_493F_9ABD_2DB66EC951B3__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
*/
#ifndef _VECTOR3_H
#define _VECTOR3_H
#include "MathBase.h"
#include "FastMath.h"
#pragma warning( disable : 4786 )
#define vector3mul(a,b) a.x*b.x+a.y*b.y+a.z*b.z
struct vector3
{
union
{
struct
{
float x,y,z;
};
float v[3];
};
vector3(){};
vector3(float xp,float yp,float zp)
{
x=xp;
y=yp;
z=zp;
};
vector3& operator+=(const vector3& in);
vector3& operator-=(const vector3& in);
vector3& operator*=(const float& in);
vector3& operator/=(const float& in);
vector3 operator-();
// Return the magnitude of a point
float Mag() const;
void Normalize() ;
vector3 Normalized() const;
float GetLens()
{
float fTest=x*x+y*y+z*z;
/*
if(fabsf(fTest)<=0.001f)
{
return 0.0f;
}
*/
return sqrtf(fTest);
//return CFastMath::FastSqrt(x*x+y*y+z*z);
};
void Identity() { x = 0.0f; y = 0.0f; z = 0.0f; };
/*
static const vector3 Zero;
static const vector3 i;
static const vector3 j;
static const vector3 k;
*/
};
/*
const vector3 vector3::Zero( 0.f,0.f,0.f );
const vector3 vector3::i( 1.f, 0.f, 0.f );
const vector3 vector3::j( 0.f, 1.f, 0.f );
const vector3 vector3::k( 0.f, 0.f, 1.f );
*/
inline vector3& vector3::operator+=(const vector3& in)
{
x+=in.x;
y+=in.y;
z+=in.z;
return *this;
}
inline vector3& vector3::operator-=(const vector3& in)
{
x-=in.x;
y-=in.y;
z-=in.z;
return *this;
}
inline vector3& vector3::operator*=(const float& in)
{
x*=in;
y*=in;
z*=in;
return *this;
}
inline vector3& vector3::operator/=(const float& in)
{
float inv=1.0f/in;
x*=inv;
y*=inv;
z*=inv;
return *this;
}
inline vector3 vector3::operator -()
{
return vector3(-x,-y,-z);
}
inline const vector3 operator+(vector3 const &a,vector3 const &b)
{
return vector3(a.x+b.x,a.y+b.y,a.z+b.z);
}
inline const vector3 operator-(vector3 const &a,vector3 const &b)
{
return vector3(a.x-b.x,a.y-b.y,a.z-b.z);
}
inline const vector3 operator*(vector3 const &a,float const &b)
{
return vector3(a.x*b,a.y*b,a.z*b);
}
inline const vector3 operator*(float const &a,vector3 const &b)
{
return vector3(a*b.x,a*b.y,a*b.z);
}
inline const vector3 operator/(vector3 const &a,float const &b)
{
float inv=1.0f/b;
return vector3(a.x*inv,a.y*inv,a.z*inv);
}
inline const vector3 operator^(vector3 const &a,vector3 const &b)
{
return vector3( (a.y*b.z-a.z*b.y),
(a.z*b.x-a.x*b.z),
(a.x*b.y-a.y*b.x));
}
inline const float operator*(vector3 const &a,vector3 const &b)
{
return a.x*b.x+a.y*b.y+a.z*b.z;
}
inline bool operator==(vector3 const &a,vector3 const &b)
{
if(fabs(a.x-b.x)<EPSILON)
{
if(fabs(a.y-b.y)<EPSILON)
{
if(fabs(a.z-b.z)<EPSILON)
{
return true;
}
}
}
return false;
}
inline float vector3::Mag() const
{
//x*b.x+a.y*b.y+a.z*b.z
//return CFastMath::FastSqrt( x*x+y*y+z*z );
//vector3mul
float fTest=x*x+y*y+z*z;
/*
if(fabsf(fTest)<=0.01f)
{
return 0.0f;
}
*/
return sqrtf(fTest);
}
inline void vector3::Normalize()
{
float fMag=Mag();
/*if(fMag<=0.001f)
return;
*/
if(fMag <= 0.00000001f)
{
(*this).x = 0.0f;
(*this).y = 0.0f;
(*this).z = 0.0f;
return;
}
float invMag = 1.0f/fMag;
//float invMag = 1.0/sqrt(x*x+y*y+z*z);
//float Mag=sqrt(x*x+y*y+z*z);
//float invMag=1.0/Mag;
(*this) *= invMag;
}
inline vector3 vector3::Normalized() const
{
float fMag = Mag();
if(fMag <= 0.00000001f)
return vector3(0.0f,0.0f,0.0f);
float invMag = 1.f/fMag;
return (*this) * invMag;
}
#endif
//#endif // !defined(AFX_vector3_H__10479201_0625_493F_9ABD_2DB66EC951B3__INCLUDED_)

View File

@@ -0,0 +1,197 @@
#ifndef _VERTEX_H
#define _VERTEX_H
#include "3DMath.h"
#include <d3d.h>
const long MultiFVF=D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2 ;
class MultiVertex{
public:
vector3 v;
color diff;
color spec;
float tu,tv;
float tu1,tv1;
};
//const long SectorFVF=D3DFVF_XYZ | D3DFVF_NORMAL |D3DFVF_SPECULAR| D3DFVF_TEX2 ;
const long SectorFVF=D3DFVF_XYZ | D3DFVF_TEX1 ;
class SectorVertex{
public:
vector3 v;
//vector3 n;
//color spec;
float tu,tv;
//float tu1,tv1;
};
const long LightFVF=D3DFVF_XYZ | D3DFVF_NORMAL |D3DFVF_SPECULAR| D3DFVF_TEX1 ;
class LightVertex{
public:
vector3 v;
vector3 n;
color spec;
float tu,tv;
};
const long DetailFVF=D3DFVF_XYZ | D3DFVF_NORMAL |D3DFVF_TEX2 ;
class DetailVertex
{
public:
vector3 v;
vector3 n;
float tu,tv;
float tu1,tv1;
};
const long SimpleFVF=D3DFVF_XYZ | D3DFVF_DIFFUSE|D3DFVF_SPECULAR |D3DFVF_TEX2;
class SimpleVertex {
public:
vector3 v;
color diff;
color spec;
float tu,tv;
float tu1,tv1;
};
const long TLVERTEXFVF=D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1;
class TLVertex
{
public:
vector3 v;
float w;
color Diffuse;
color Specular;
float tu,tv;
};
const long TLVERTEX2FVF=D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2;
class TLVertex2
{
public:
vector3 v;
float w;
color Diffuse;
color Specular;
float tu,tv;
float tu1,tv1;
};
const long LVERTEXFVF=D3DFVF_XYZ | D3DFVF_DIFFUSE|D3DFVF_SPECULAR |D3DFVF_TEX1;
class LVertex
{
public:
vector3 v;
color diff;
color spec;
float tu,tv;
};
const long TTVERTEXFVF=D3DFVF_XYZ|D3DFVF_DIFFUSE;
class TTVertex
{
public:
vector3 v;
color diff;
};
const long BSPVERTEXFVF=D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX2| D3DFVF_TEXCOORDSIZE3(1);
class BspVertex
{
public:
vector3 v;
vector3 normal;
color diff;
float tu,tv;
float tu1,tv1;
vector3 u;
};
const long BSPSHADOWVERTEX=D3DFVF_XYZB1|D3DFVF_NORMAL;
class BspShadowVertex
{
public:
vector3 v;
float fWeight;
vector3 n;
};
const long GRASSVERTEXFVF=D3DFVF_XYZB1|D3DFVF_DIFFUSE|D3DFVF_TEX1;
class GrassVertex
{
public:
vector3 v;
float fWeight;
color diff;
float tu,tv;
};
const long TREEVERTEXFVF=D3DFVF_XYZB1|D3DFVF_NORMAL|D3DFVF_TEX1;
class TreeVertex
{
public:
vector3 v;
float fWeight;
vector3 n;
float tu,tv;
};
class Dot3Vertex
{
public:
vector3 v;
vector3 Normal;
vector3 Diffuse;
float tu,tv;
vector3 s;
vector3 t;
vector3 SxT;
};
const long BUMPVERTEXFVF=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2 | D3DFVF_TEXCOORDSIZE3(1);
class BumpVertex
{
public:
vector3 v;
vector3 n;
float tu,tv;
vector3 u;
};
const long BUMPVERTEX2FVF=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX3 | D3DFVF_TEXCOORDSIZE3(2);
class BumpVertex2
{
public:
vector3 v;
vector3 n;
float tu,tv;
float tu1,tv1;
vector3 u;
};
const long BUMPVERTEXSTFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2 |
D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE3(1) | D3DFVF_TEXCOORDSIZE3(2);
// s<><73> t vector<6F><72> 3D tex-coord<72><64> ó<><C3B3>
class BumpVertexST
{
public:
vector3 v;
vector3 n;
float tu, tv;
vector3 s;
vector3 t;
};
#endif

View File

@@ -0,0 +1,68 @@
// VertexBuffer.cpp: implementation of the CVertexBuffer class.
//
//////////////////////////////////////////////////////////////////////
#include "VertexBuffer.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LPDIRECT3D8 CVertexBuffer::m_pD3D;
CVertexBuffer::CVertexBuffer()
{
m_pVertexBuffer=NULL;
}
CVertexBuffer::~CVertexBuffer()
{
if(m_pVertexBuffer->Release()!=0)
throw CGraphicLayerError("CVertexBuffer:~CVertexBuffer, This vertex-buffer is used other Object , as yet");
}
void CVertexBuffer::Create()
{
/*
m_pd3dDevice->CreateVertexBuffer( m_dwNumDolphinVertices * sizeof(D3DVERTEX),
D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED,
&m_pDolphinVB1 );
if(m_pVertexBuffer)
{
if(FAEILED(m_pd3dDevice->CreateVertexBuffer(m_nVertex*sizeof(),
D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED,
&m_pVertexBuffer)))
{
throw CGraphicLayerError("CVertexBuffer:Create, Vertex-Buffer Create Failed");
}
}
*/
}
void CVertexBuffer::Render(LPDIRECT3DDEVICE8 pd3dDevice,WORD *pIndices,long &nIndices)
{
/*
m_pd3dDevice->SetVertexShader( m_dwDolphinVertexShader );
m_pd3dDevice->SetStreamSource( 0, m_pDolphinVB1, sizeof(D3DVERTEX) );
m_pd3dDevice->SetStreamSource( 1, m_pDolphinVB2, sizeof(D3DVERTEX) );
m_pd3dDevice->SetStreamSource( 2, m_pDolphinVB3, sizeof(D3DVERTEX) );
m_pd3dDevice->SetIndices( m_pDolphinIB, 0 );
m_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,
0, m_dwNumDolphinVertices,
0, m_dwNumDolphinFaces );
pd3dDevice->DrawIndexedPrimitiveVB( D3DPT_TRIANGLELIST,
m_pVertexBuffer, 0,
m_nVertex, pIndices,
nIndices*3, D3DDP_WAIT );
/*
HRESULT hr=
pd3dDevice->DrawIndexedPrimitiveVB( D3DPT_TRIANGLELIST,
m_pVertexBuffer, 0,
m_nVertex, pIndices,
0, D3DDP_WAIT );
*/
}

View File

@@ -0,0 +1,28 @@
// VertexBuffer.h: interface for the CVertexBuffer class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_VERTEXBUFFER_H__17331CD7_3932_4E36_8DE5_FB7F04C996AA__INCLUDED_)
#define AFX_VERTEXBUFFER_H__17331CD7_3932_4E36_8DE5_FB7F04C996AA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
#include "Exception.h"
class CVertexBuffer
{
static LPDIRECT3D8 m_pD3D;
public:
void Render(LPDIRECT3DDEVICE8 pd3dDevice,WORD *pIndices,long &nIndices);
DWORD m_nVertex;
LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer;
DWORD m_FVF;
void Create();
CVertexBuffer();
virtual ~CVertexBuffer();
};
#endif // !defined(AFX_VERTEXBUFFER_H__17331CD7_3932_4E36_8DE5_FB7F04C996AA__INCLUDED_)

View File

@@ -0,0 +1,857 @@
// ViewCamera.cpp: implementation of the CViewCamera class.
//
//////////////////////////////////////////////////////////////////////
#include "ViewCamera.h"
#include "Vertex.h"
#include <d3dx8.h>
#define KeyPressed( key ) HIBYTE( GetAsyncKeyState( key ) )
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CViewCamera::CViewCamera()
{
m_CameraMode=0;
m_matView.MakeIdent();
m_matPosition.MakeIdent();
m_fRotx=m_fRoty=m_fRotz=0.0f;
m_cFade=-1;
m_dwTickTime=-1;
}
CViewCamera::~CViewCamera()
{
}
void CViewCamera::BuildFrustum(float fAspect, float fFov,float fNearPlane,float fFarPlane)
{
//fFarPlane=1000.0f;
m_fAspect=fAspect;
m_fFov=fFov;
m_fFarPlane=fFarPlane;
m_fNearPlane=100.0f;
vector3 vecTopLeft,vecTopRight,vecBottomLeft,vecBottomRight;
//float fFrustumHeight=fFarPlane*tanf(fFov*0.5f);
//float fFrustumWidth=fFrustumHeight*fAspect;
float fFrustumWidth=fFarPlane*tanf(fFov*0.5f);
float fFrustumHeight=fFrustumWidth*fAspect;
//fFrustumHeight*=0.8f;
//fFrustumWidth*=0.8f;
vecTopLeft.y=fFrustumHeight;
vecTopLeft.x=-fFrustumWidth;
vecTopLeft.z=fFarPlane;
vecTopRight.y=fFrustumHeight;
vecTopRight.x=fFrustumWidth;
vecTopRight.z=fFarPlane;
vecBottomLeft.y=-fFrustumHeight;
vecBottomLeft.x=-fFrustumWidth;
vecBottomLeft.z=fFarPlane;
vecBottomRight.y=-fFrustumHeight;
vecBottomRight.x=fFrustumWidth;
vecBottomRight.z=fFarPlane;
//m_vecFrustumTop[0]=vector3(0.0f,0.0f,-1000.0f);
m_vecFrustumTop[0]=vector3(0.0f,0.0f,0.0f);
m_vecFrustumTop[1]=vecTopRight;
m_vecFrustumTop[2]=vecTopLeft;
//m_vecFrustumBottom[0]=vector3(0.0f,0.0f,-1000.0f);
m_vecFrustumBottom[0]=vector3(0.0f,0.0f,0.0f);
m_vecFrustumBottom[1]=vecBottomLeft;
m_vecFrustumBottom[2]=vecBottomRight;
//m_vecFrustumLeft[0]=vector3(0.0f,0.0f,-1000.0f);
m_vecFrustumLeft[0]=vector3(0.0f,0.0f,0.0f);
m_vecFrustumLeft[1]=vecTopLeft;
m_vecFrustumLeft[2]=vecBottomLeft;
//m_vecFrustumRight[0]=vector3(0.0f,0.0f,-1000.0f);
m_vecFrustumRight[0]=vector3(0.0f,0.0f,0.0f);
m_vecFrustumRight[1]=vecBottomRight;
m_vecFrustumRight[2]=vecTopRight;
m_vecFrustumNear[0]=vector3(0.0f,0.0f,0.0f)+vector3(0.0f,0.0f,fNearPlane);
m_vecFrustumNear[1]=vector3(0.0f,100.0f,0.0f)+vector3(0.0f,0.0f,fNearPlane);
m_vecFrustumNear[2]=vector3(100.0f,0.0f,0.0f)+vector3(0.0f,0.0f,fNearPlane);
}
void CViewCamera::Render(LPDIRECT3DDEVICE8 pd3dDevice)
{
/*
if(m_cFade==-1)
return;
m_pVertex[0].v.x=0.0f;m_pVertex[1].v.x=0.0f;
m_pVertex[2].v.x=800.0f;m_pVertex[3].v.x=800.0f;
m_pVertex[1].v.y=0.0f;m_pVertex[3].v.y=0.0f;
m_pVertex[0].v.y=600.0f;m_pVertex[2].v.y=600.0f;
m_pVertex[0].tu=0.0f;m_pVertex[1].tu=0.0f;m_pVertex[3].tu=1.0f;m_pVertex[2].tu=1.0f;
m_pVertex[1].tv=0.0f;m_pVertex[3].tv=0.0f;m_pVertex[0].tv=1.0f;m_pVertex[2].tv=1.0f;
color NowDiffuseColor;
if(m_FadeInitValue+(m_AdderFadeValue)*m_cFade>255)
{
m_cFade=255;
NowDiffuseColor.c=0xffffffff;
}
else if(m_FadeInitValue+(m_AdderFadeValue)*m_cFade<0)
{
m_cFade=255;
NowDiffuseColor.c=0x0;
}
else
{
NowDiffuseColor.a=m_FadeInitValue+(m_AdderFadeValue)*m_cFade;
NowDiffuseColor.r=m_FadeInitValue+(m_AdderFadeValue)*m_cFade;
NowDiffuseColor.g=m_FadeInitValue+(m_AdderFadeValue)*m_cFade;
NowDiffuseColor.b=m_FadeInitValue+(m_AdderFadeValue)*m_cFade;
}
for(int i=0;i<4;i++)
{
m_pVertex[i].w=0.1f;m_pVertex[i].v.z=0.1f;
m_pVertex[i].Specular.c=0x0;
m_pVertex[i].Diffuse.c=NowDiffuseColor.c;
}
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pd3dDevice->SetTexture(0,NULL);
pd3dDevice->SetTexture(1,NULL);
pd3dDevice->SetRenderState( D3DRS_LIGHTING,FALSE);
pd3dDevice->SetRenderState( D3DRS_FOGENABLE,FALSE);
pd3dDevice->SetVertexShader(TLVERTEXFVF);
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,m_pVertex,sizeof(TLVertex));
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
pd3dDevice->SetRenderState( D3DRS_LIGHTING,TRUE);
pd3dDevice->SetRenderState( D3DRS_FOGENABLE,TRUE);
if(m_cFade++>=255)
{
m_cFade=-1;
}
*/
/*
pd3dDevice->SetTexture(0,NULL);
pd3dDevice->SetTexture(1,NULL);
matrix mat;
mat.MakeIdent();
pd3dDevice->SetTransform(D3DTS_WORLD,(D3DMATRIX*)&mat);
pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
pd3dDevice->SetVertexShader(LVERTEXFVF);
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
pd3dDevice->SetRenderState( D3DRS_LIGHTING,FALSE);
//Top Render data
LVertex FrustumVertex[3];
FrustumVertex[0].v=m_vecFrustumTop[0];
FrustumVertex[1].v=m_vecFrustumTop[1];
FrustumVertex[2].v=m_vecFrustumTop[2];
FrustumVertex[0].spec.c=0x0;
FrustumVertex[0].diff.c=0xff0000ff;
FrustumVertex[1].spec.c=0x0;
FrustumVertex[1].diff.c=0xff0000ff;
FrustumVertex[2].spec.c=0x0;
FrustumVertex[2].diff.c=0xff0000ff;
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,1,FrustumVertex,sizeof(LVertex));
//Top Render data
FrustumVertex[0].v=m_vecFrustumBottom[0];
FrustumVertex[1].v=m_vecFrustumBottom[1];
FrustumVertex[2].v=m_vecFrustumBottom[2];
FrustumVertex[0].spec.c=0x0;
FrustumVertex[0].diff.c=0xffff0000;
FrustumVertex[1].spec.c=0x0;
FrustumVertex[1].diff.c=0xffff0000;
FrustumVertex[2].spec.c=0x0;
FrustumVertex[2].diff.c=0xffff0000;
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,1,FrustumVertex,sizeof(LVertex));
//
FrustumVertex[0].v=m_vecFrustumLeft[0];
FrustumVertex[1].v=m_vecFrustumLeft[1];
FrustumVertex[2].v=m_vecFrustumLeft[2];
FrustumVertex[0].spec.c=0x0;
FrustumVertex[0].diff.c=0xff000000;
FrustumVertex[1].spec.c=0x0;
FrustumVertex[1].diff.c=0xff000000;
FrustumVertex[2].spec.c=0x0;
FrustumVertex[2].diff.c=0xff000000;
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,1,FrustumVertex,sizeof(LVertex));
//
FrustumVertex[0].v=m_vecFrustumRight[0];
FrustumVertex[1].v=m_vecFrustumRight[1];
FrustumVertex[2].v=m_vecFrustumRight[2];
FrustumVertex[0].spec.c=0x0;
FrustumVertex[0].diff.c=0xff00ff00;
FrustumVertex[1].spec.c=0x0;
FrustumVertex[1].diff.c=0xff00ff00;
FrustumVertex[2].spec.c=0x0;
FrustumVertex[2].diff.c=0xff00ff00;
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,1,FrustumVertex,sizeof(LVertex));
pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
pd3dDevice->SetRenderState( D3DRS_LIGHTING,TRUE);
//*/
}
void CViewCamera::MoveFrustum()
{
float fFrustumHeight=m_fFarPlane*tanf(m_fFov*0.5f);
float fFrustumWidth=fFrustumHeight*(1.0f/m_fAspect);
vector3 vecTopLeft,vecTopRight,vecBottomLeft,vecBottomRight,vecCenterAxisX,vecCenterAxisY,vecCenter;
matrix matHeight,matWidth;
matHeight.Translation(vector3(fFrustumWidth,fFrustumHeight,m_fFarPlane));
matHeight=matHeight*m_matPosition;
vecTopRight=matHeight.GetLoc();
matHeight.Translation(vector3(-fFrustumWidth,fFrustumHeight,m_fFarPlane));
matHeight=matHeight*m_matPosition;
vecTopLeft=matHeight.GetLoc();
matHeight.Translation(vector3(fFrustumWidth,-fFrustumHeight,m_fFarPlane));
matHeight=matHeight*m_matPosition;
vecBottomRight=matHeight.GetLoc();
matHeight.Translation(vector3(-fFrustumWidth,-fFrustumHeight,m_fFarPlane));
matHeight=matHeight*m_matPosition;
vecBottomLeft=matHeight.GetLoc();
matHeight.Translation(vector3(fFrustumWidth,0.0f,m_fFarPlane));
matHeight=matHeight*m_matPosition;
vecCenterAxisX=matHeight.GetLoc();
matHeight.Translation(vector3(0.0f,fFrustumHeight,m_fFarPlane));
matHeight=matHeight*m_matPosition;
vecCenterAxisY=matHeight.GetLoc();
matHeight.Translation(vector3(0.0f,0.0f,m_fFarPlane));
matHeight=matHeight*m_matPosition;
vecCenter=matHeight.GetLoc();
m_vecFrustumTop[0]=m_matPosition.GetLoc();
m_vecFrustumTop[1]=vecCenter;
m_vecFrustumTop[2]=vecCenterAxisY;
m_vecCenterAxis[0]=(m_vecFrustumTop[1]-m_vecFrustumTop[0])^(m_vecFrustumTop[2]-m_vecFrustumTop[1]);
m_vecCenterAxis[0].Normalize();
m_vecCenterAxis[0]=-m_vecCenterAxis[0];
m_vecFrustumTop[0]=m_matPosition.GetLoc();
m_vecFrustumTop[1]=vecCenter;
m_vecFrustumTop[2]=vecCenterAxisX;
m_vecCenterAxis[1]=(m_vecFrustumTop[1]-m_vecFrustumTop[0])^(m_vecFrustumTop[2]-m_vecFrustumTop[1]);
m_vecCenterAxis[1].Normalize();
m_vecCenterAxis[1]=-m_vecCenterAxis[1];
m_vecFrustumTop[0]=m_matPosition.GetLoc();
m_vecFrustumTop[1]=vecTopRight;
m_vecFrustumTop[2]=vecTopLeft;
m_vecFrustumNormal[0]=(m_vecFrustumTop[1]-m_vecFrustumTop[0])^(m_vecFrustumTop[2]-m_vecFrustumTop[1]);
m_vecFrustumNormal[0].Normalize();
m_vecFrustumBottom[0]=m_matPosition.GetLoc();
m_vecFrustumBottom[1]=vecBottomLeft;
m_vecFrustumBottom[2]=vecBottomRight;
m_vecFrustumNormal[1]=(m_vecFrustumBottom[1]-m_vecFrustumBottom[0])^(m_vecFrustumBottom[2]-m_vecFrustumBottom[1]);
m_vecFrustumNormal[1].Normalize();
m_vecFrustumLeft[0]=m_matPosition.GetLoc();
m_vecFrustumLeft[1]=vecTopLeft;
m_vecFrustumLeft[2]=vecBottomLeft;
m_vecFrustumNormal[2]=(m_vecFrustumLeft[1]-m_vecFrustumLeft[0])^(m_vecFrustumLeft[2]-m_vecFrustumLeft[1]);
m_vecFrustumNormal[2].Normalize();
m_vecFrustumRight[0]=m_matPosition.GetLoc();
m_vecFrustumRight[1]=vecBottomRight;
m_vecFrustumRight[2]=vecTopRight;
m_vecFrustumNormal[3]=(m_vecFrustumRight[1]-m_vecFrustumRight[0])^(m_vecFrustumRight[2]-m_vecFrustumRight[1]);
m_vecFrustumNormal[3].Normalize();
/*
m_vecFrustumNear[1]=;
m_vecFrustumNear[2]=;
*/
matrix matNear[3];
matNear[0].Translation(vector3(0.0f,0.0f,0.0f)+vector3(0.0f,0.0f,m_fNearPlane));
matNear[1].Translation(vector3(100.0f,0.0f,0.0f)+vector3(0.0f,0.0f,m_fNearPlane));
matNear[2].Translation(vector3(0.0f,100.0f,0.0f)+vector3(0.0f,0.0f,m_fNearPlane));
matNear[0]=matNear[0]*m_matPosition;
matNear[1]=matNear[1]*m_matPosition;
matNear[2]=matNear[2]*m_matPosition;
m_vecFrustumNear[0]=matNear[0].GetLoc();
m_vecFrustumNear[1]=matNear[1].GetLoc();
m_vecFrustumNear[2]=matNear[2].GetLoc();
/*
vector3 vecTopLeft,vecTopRight,vecBottomLeft,vecBottomRight;
vecTopLeft.y=fFrustumHeight;
vecTopLeft.x=-fFrustumWidth;
vecTopLeft.z=fFarPlane;
vecTopRight.y=fFrustumHeight;
vecTopRight.x=fFrustumWidth;
vecTopRight.z=fFarPlane;
vecBottomLeft.y=-fFrustumHeight;
vecBottomLeft.x=-fFrustumWidth;
vecBottomLeft.z=fFarPlane;
vecBottomRight.y=-fFrustumHeight;
vecBottomRight.x=fFrustumWidth;
vecBottomRight.z=fFarPlane;
m_vecFrustumTop[0]=vector3(0.0f,0.0f,-1000.0f);
m_vecFrustumTop[1]=vecTopRight;
m_vecFrustumTop[2]=vecTopLeft;
m_vecFrustumBottom[0]=vector3(0.0f,0.0f,-1000.0f);
m_vecFrustumBottom[1]=vecBottomLeft;
m_vecFrustumBottom[2]=vecBottomRight;
m_vecFrustumLeft[0]=vector3(0.0f,0.0f,-1000.0f);
m_vecFrustumLeft[1]=vecTopLeft;
m_vecFrustumLeft[2]=vecBottomLeft;
m_vecFrustumRight[0]=vector3(0.0f,0.0f,-1000.0f);
m_vecFrustumRight[1]=vecBottomRight;
m_vecFrustumRight[2]=vecTopRight;
*/
/*
matrix matPlaneTrans;
matPlaneTrans.Translation(m_vecFrustumTop[0]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumTop[0]=matPlaneTrans.GetLoc();
matPlaneTrans.Translation(m_vecFrustumTop[1]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumTop[1]=matPlaneTrans.GetLoc();
matPlaneTrans.Translation(m_vecFrustumTop[2]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumTop[2]=matPlaneTrans.GetLoc();
//
matPlaneTrans.Translation(m_vecFrustumBottom[0]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumBottom[0]=matPlaneTrans.GetLoc();
matPlaneTrans.Translation(m_vecFrustumBottom[1]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumBottom[1]=matPlaneTrans.GetLoc();
matPlaneTrans.Translation(m_vecFrustumBottom[2]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumBottom[2]=matPlaneTrans.GetLoc();
//
matPlaneTrans.Translation(m_vecFrustumLeft[0]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumLeft[0]=matPlaneTrans.GetLoc();
matPlaneTrans.Translation(m_vecFrustumLeft[1]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumLeft[1]=matPlaneTrans.GetLoc();
matPlaneTrans.Translation(m_vecFrustumLeft[2]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumLeft[2]=matPlaneTrans.GetLoc();
//
matPlaneTrans.Translation(m_vecFrustumRight[0]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumRight[0]=matPlaneTrans.GetLoc();
matPlaneTrans.Translation(m_vecFrustumRight[1]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumRight[1]=matPlaneTrans.GetLoc();
matPlaneTrans.Translation(m_vecFrustumRight[2]);
matPlaneTrans=m_matPosition*matPlaneTrans;
m_vecFrustumRight[2]=matPlaneTrans.GetLoc();
*/
}
void CViewCamera::InterfaceFreelook(int MouseX, int MouseY)
{
if(m_isAnimateCamera)
{
PlayAnimate();
return;
}
D3DXMATRIX *matPosition=(D3DXMATRIX*)GetMatPosition();
float fDeltaY=MouseX/300.0f;
float fDeltaX=MouseY/300.0f;
D3DXVECTOR3 vecT(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 vecR(0.0f, 0.0f, 0.0f);
D3DXMATRIX matT, matR;
D3DXQUATERNION qR;
if(KeyPressed(VK_MENU))
return;
if(KeyPressed(VK_SHIFT))
{
if(KeyPressed('A') || KeyPressed(VK_LEFT)) vecT.x -= 341.0f; // Slide Left
if(KeyPressed('D') || KeyPressed(VK_RIGHT)) vecT.x += 341.0f; // Slide Right
if(KeyPressed(VK_DOWN)) vecT.y += 341.0f; // Slide Down
if(KeyPressed(VK_UP)) vecT.y -= 341.0f; // Slide Up
if(KeyPressed('W')) vecT.z += 341.0f; // Move Forward
if(KeyPressed('S')) vecT.z -= 341.0f; // Move Backward
if(KeyPressed(VK_NUMPAD4)) fDeltaY+=0.008f;
if(KeyPressed(VK_NUMPAD6)) fDeltaY-=0.008f;
if(KeyPressed(VK_NUMPAD8)) fDeltaX-=0.008f;
if(KeyPressed(VK_NUMPAD2)) fDeltaX+=0.008f;
}
else
{
if(KeyPressed('A') || KeyPressed(VK_LEFT) ) vecT.x -= 1.0f; // Slide Left
if(KeyPressed('D') || KeyPressed(VK_RIGHT)) vecT.x += 1.0f; // Slide Right
if(KeyPressed(VK_DOWN)) vecT.y += 1.0f; // Slide Down
if(KeyPressed(VK_UP)) vecT.y -= 1.0f; // Slide Up
if(KeyPressed('W'))
vecT.z += 1.0f; // Move Forward
if(KeyPressed('S'))
vecT.z -= 1.0f; // Move Backward
if(KeyPressed(VK_NUMPAD4)) fDeltaY+=0.008f;
if(KeyPressed(VK_NUMPAD6)) fDeltaY-=0.008f;
if(KeyPressed(VK_NUMPAD8)) fDeltaX-=0.008f;
if(KeyPressed(VK_NUMPAD2)) fDeltaX+=0.008f;
}
D3DXMatrixTranslation(&matT, vecT.x, vecT.y, vecT.z);
D3DXMatrixMultiply(matPosition, &matT, matPosition);
float fRotationX=GetRotationX();
float fRotationY=GetRotationY();
D3DXQuaternionRotationYawPitchRoll(&qR, 0.0f,-fRotationX ,0.0f);
D3DXMatrixRotationQuaternion(&matR, &qR);
D3DXMatrixMultiply(matPosition, &matR, matPosition);
fRotationX-=fDeltaX;
fRotationY-=fDeltaY;
D3DXQuaternionRotationYawPitchRoll(&qR,-fDeltaY,fRotationX, 0.0f);
D3DXMatrixRotationQuaternion(&matR, &qR);
D3DXMatrixMultiply(matPosition, &matR, matPosition);
SetRotaitionX(fRotationX);
SetRotaitionY(fRotationY);
SetVecPosition(vector3(GetMatPosition()->_41,GetMatPosition()->_42,GetMatPosition()->_43));
/*
matrix matView;
float fViewHeight=70000;
matView.CameraLookAt(vector3(30000.0f/2.0f,fViewHeight,30000.0f/2.0f),vector3(30000.0f/2.0f,0.0f,30000.0f/2.0f),vector3(0.0f,0.0f,1.0f));
//*/
matrix *matPos=GetMatPosition();
matrix matInv;
matInv.Inverse(*matPos);
SetMatView(matInv);
//matPos->Inverse(matView);
//SetMatView(matView);
if(KeyPressed(VK_SPACE))
{
}
else
{
MoveFrustum();
}
}
void CViewCamera::InterfaceCharlook(int MouseX, int MouseY, float fCharMove)
{
if(m_isAnimateCamera)
{
PlayAnimate();
return;
}
/*
D3DXMATRIX *matPosition=(D3DXMATRIX*)GetMatPosition();
float fRoty=(float)MouseX/300.0f;
float fRotx=(float)MouseY/300.0f;
D3DXVECTOR3 vecT(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 vecR(-fRotx,-fRoty, 0.0f);
//if(KeyPressed('W'))
vecT.z += fCharMove;
D3DXMATRIX matT, matR;
D3DXQUATERNION qR;
D3DXQuaternionRotationYawPitchRoll(&qR, 0, -m_fRotx, 0);
D3DXMatrixRotationQuaternion(&matR, &qR);
D3DXMatrixMultiply(m_matExtraPosition, &matR, m_matExtraPosition);
D3DXMatrixTranslation(&matT, vecT.x, vecT.y, vecT.z);
D3DXMatrixMultiply(m_matExtraPosition, &matT, m_matExtraPosition);
m_fRotx+=vecR.x;
m_fRoty+=vecR.y;
m_fRotz+=vecR.z;
D3DXQuaternionRotationYawPitchRoll(&qR, vecR.y, m_fRotx, vecR.z);
D3DXMatrixRotationQuaternion(&matR, &qR);
D3DXMatrixMultiply(m_matExtraPosition, &matR, m_matExtraPosition);
D3DXMatrixTranslation(&matT,0.0f,0.0f,-350.0f);
D3DXMatrixMultiply(matPosition, &matT, m_matExtraPosition);
SetVecPosition(vector3(GetMatPosition()->_41,GetMatPosition()->_42,GetMatPosition()->_43));
matrix *matPos=GetMatPosition();
matrix matInv;
matInv.Inverse(*matPos);
SetMatView(matInv);
MoveFrustum();
*/
}
void CViewCamera::InterfaceCharlook2(int MouseX, int MouseY)
{
if(m_isAnimateCamera)
{
PlayAnimate();
return;
}
m_fRotx+=(float)MouseY/300.0f;
m_fRoty+=(float)MouseX/300.0f;
if(m_fRotx > 3.14159f/2.0f-0.3f)
m_fRotx=3.14159f/2.0f-0.3f;
if(m_fRotx < -3.14159f/2.0f+0.7f)
m_fRotx=-3.14159f/2.0f+0.7f;
//DXMATRIX matT, matR;
matrix matRotation,matResult;
D3DXQUATERNION qR;
matResult.Translation(vector3(0.0f,0.0f,-1.0f));
D3DXQuaternionRotationYawPitchRoll(&qR,m_fRoty,m_fRotx,0.0f);
D3DXMatrixRotationQuaternion(matRotation,&qR);
matResult=matResult*matRotation;
m_vecCameraPosition=matResult.GetLoc();
/*
m_fRotx=3.1415f;
m_fRoty=3.1415f;
matrix matRotY,matRotX,matResult;
matRotY.YRotation(m_fRoty);
matRotX.XRotation(m_fRotx);
matResult.Translation(vector3(1.0f,0.0f,0.0f));
matResult=matResult*matRotY;
vector3 vecRotY=matRotY.GetLoc();
vecRotY^
*/
}
void CViewCamera::InterfaceFreeCamera(int MouseX, int MouseY)
{
if(m_isAnimateCamera)
{
PlayAnimate();
return;
}
//InterfaceFreelook(-MouseX,-MouseY);
}
void CViewCamera::LookAt(vector3 vecPos, vector3 vecTarget, vector3 vecUp)
{
/*m_matView.CameraLookAt(vecPos,vecTarget,vecUp);
m_matPosition.Inverse(m_matView);
MoveFrustum();
*/
vector3 vecNewUp = vector3(0.0f,1.0f,0.0f);
D3DXMatrixLookAtLH((D3DXMATRIX *)(&m_matView),(D3DXVECTOR3 *)(&vecPos),(D3DXVECTOR3 *)&vecTarget,(D3DXVECTOR3 *)&vecNewUp);
m_matPosition.Inverse(m_matView);
MoveFrustum();
m_vecPosition = vector3(m_matPosition._41,m_matPosition._42,m_matPosition._43);
D3DXVECTOR3* pZBasis = (D3DXVECTOR3*) &m_matPosition._31;
m_fRoty = atan2f( pZBasis->x, pZBasis->z );
float fLen = sqrtf(pZBasis->z*pZBasis->z + pZBasis->x*pZBasis->x);
m_fRotx = -atan2f( pZBasis->y, fLen );
m_fRotz = 0.0f;
//m_matView=m_matStackView;
//m_matPosition=m_matStackPosition;
}
void CViewCamera::PlayAnimate()
{
if(m_dwTickTime==-1)
{
m_dwTickTime=GetTickCount();
m_dwLastUpdateTime=m_dwTickTime;
return ;
}
DWORD dwOldTickTime=m_dwTickTime;
m_dwTickTime=GetTickCount();
m_fNowAniTime+=(float)(m_dwTickTime-dwOldTickTime);
float fNode=(m_fNowAniTime/m_fTotalAniTime)*100.0f;
bool bNodeFound=false;
for(int cNode=1;cNode<m_CameraAnimateList.num;cNode++)
{
if( m_CameraAnimateList[cNode-1].m_Time <= fNode &&
fNode <=m_CameraAnimateList[cNode].m_Time)
{
bNodeFound=true;
break;
}
}
float fInter;
if(bNodeFound==false)
{
m_isAnimateCamera=false;
m_dwTickTime=-1;
//return;
cNode=m_CameraAnimateList.num-1;
fInter=1.0f;
if(m_CameraAnimateList.num==0)
return;
}
else
{
fInter=(fNode-m_CameraAnimateList[cNode-1].m_Time)/(m_CameraAnimateList[cNode].m_Time-m_CameraAnimateList[cNode-1].m_Time);
}
vector3 vecNowCameraPosition,vecCameraInter;
vecCameraInter=m_CameraAnimateList[cNode].m_vecPos-m_CameraAnimateList[cNode-1].m_vecPos;
vecNowCameraPosition=m_CameraAnimateList[cNode-1].m_vecPos+fInter*vecCameraInter;
D3DXQUATERNION qResult,q1,q2;
q1.x=m_CameraAnimateList[cNode-1].m_qAngle.x;
q1.y=m_CameraAnimateList[cNode-1].m_qAngle.y;
q1.z=m_CameraAnimateList[cNode-1].m_qAngle.z;
q1.w=m_CameraAnimateList[cNode-1].m_qAngle.w;
q2.x=m_CameraAnimateList[cNode].m_qAngle.x;
q2.y=m_CameraAnimateList[cNode].m_qAngle.y;
q2.z=m_CameraAnimateList[cNode].m_qAngle.z;
q2.w=m_CameraAnimateList[cNode].m_qAngle.w;
matrix matRot;
D3DXQuaternionSlerp(&qResult,&q1,&q2,fInter);
D3DXMatrixRotationQuaternion(matRot,&qResult);
matrix matViewPos;
matViewPos.Translation(vecNowCameraPosition);
matViewPos=matRot*matViewPos;
m_matView.Inverse(matViewPos);
m_matPosition=matViewPos;
MoveFrustum();
m_vecPosition.x=m_matPosition._41;
m_vecPosition.y=m_matPosition._42;
m_vecPosition.z=m_matPosition._43;
/*
vector3 vecNowCameraPosition,vecCameraInter;
vecCameraInter=m_CameraAnimateList[cNode].m_vecPos-m_CameraAnimateList[cNode-1].m_vecPos;
vecNowCameraPosition=m_CameraAnimateList[cNode-1].m_vecPos+fInter*vecCameraInter;
//float fUpdateFrameRate=(float)(m_dwTickTime-dwOldTickTime)/(1000.0f/35.0f);
float fRad;
matrix matRot,matTrans;
vector3 vecNowTarget,vecTargetAxis;
if(m_CameraAnimateList[cNode].m_vecTarget == m_CameraAnimateList[cNode-1].m_vecTarget)
{
vecNowTarget=m_CameraAnimateList[cNode].m_vecTarget;
}
else
{
m_CameraAnimateList[cNode].m_vecTarget.Normalize();
m_CameraAnimateList[cNode-1].m_vecTarget.Normalize();
vecTargetAxis=m_CameraAnimateList[cNode].m_vecTarget^m_CameraAnimateList[cNode-1].m_vecTarget;
fRad=acosf(m_CameraAnimateList[cNode-1].m_vecTarget*m_CameraAnimateList[cNode].m_vecTarget);
matRot.AxisAngle(vecTargetAxis,-fInter*fRad);
matTrans.Translation(m_CameraAnimateList[cNode-1].m_vecTarget);
matTrans=matTrans*matRot;
vecNowTarget=matTrans.GetLoc();
}
vector3 vecNowUp,vecUpAxis;
m_CameraAnimateList[cNode].m_vecUp.Normalize();
m_CameraAnimateList[cNode-1].m_vecUp.Normalize();
if(m_CameraAnimateList[cNode].m_vecUp == m_CameraAnimateList[cNode-1].m_vecUp)
{
vecNowUp=m_CameraAnimateList[cNode].m_vecUp;
}
else
{
vecUpAxis=m_CameraAnimateList[cNode].m_vecUp^m_CameraAnimateList[cNode-1].m_vecUp;
fRad=acosf(m_CameraAnimateList[cNode-1].m_vecUp*m_CameraAnimateList[cNode].m_vecUp);
matRot.AxisAngle(vecUpAxis,-fInter*fRad);
matTrans.Translation(m_CameraAnimateList[cNode-1].m_vecUp);
matTrans=matTrans*matRot;
vecNowUp=matTrans.GetLoc();
}
LookAt(vecNowCameraPosition,vecNowCameraPosition+vecNowTarget,vecNowUp);
*/
}
void CViewCamera::StartPlay()
{
m_isAnimateCamera=true;
m_fNowAniTime=0.0f;
m_dwTickTime=-1;
}
void CViewCamera::Load(char *strFilename)
{
CameraNode AddNode;
FILE *fp=fopen(strFilename,"r");
if(fp==NULL)
return;
while(fscanf(fp,"%d %f %f %f, %f %f %f %f \n",&AddNode.m_Time,
&AddNode.m_vecPos.x,
&AddNode.m_vecPos.y,
&AddNode.m_vecPos.z,
&AddNode.m_qAngle.x,
&AddNode.m_qAngle.y,
&AddNode.m_qAngle.z,
&AddNode.m_qAngle.w)==8)
{
m_CameraAnimateList.Add(AddNode);
}
}
void CViewCamera::Save(char *strFilename)
{
FILE *fp=fopen(strFilename,"w");
for(int i=0;i<m_CameraAnimateList.num;i++)
{
fprintf(fp,"%d %f %f %f, %f %f %f %f \n",
m_CameraAnimateList[i].m_Time,
m_CameraAnimateList[i].m_vecPos.x,
m_CameraAnimateList[i].m_vecPos.y,
m_CameraAnimateList[i].m_vecPos.z,
m_CameraAnimateList[i].m_qAngle.x,
m_CameraAnimateList[i].m_qAngle.y,
m_CameraAnimateList[i].m_qAngle.z,
m_CameraAnimateList[i].m_qAngle.w);
}
fclose(fp);
}
void CViewCamera::Unload()
{
m_CameraAnimateList.num=0;
}
void CViewCamera::EndPlay()
{
m_isAnimateCamera=false;
}
vector3 CViewCamera::GetViewTowardVector()
{
D3DXMATRIX *matPosition=(D3DXMATRIX*)GetMatPosition();
D3DXMATRIX matT,matResult;
D3DXVECTOR3 vecT(0.0f, 0.0f, 1.0f);
D3DXMatrixTranslation(&matT, vecT.x, vecT.y, vecT.z);
D3DXMatrixMultiply(&matResult, &matT, matPosition);
vector3 vecOld,vecNew;
vecOld=vector3(matPosition->_41,matPosition->_42,matPosition->_43);
vecNew=vector3(matResult._41,matResult._42,matResult._43);
return vecNew-vecOld;
}
vector3 CViewCamera::GetViewUpVector()
{
D3DXMATRIX *matPosition=(D3DXMATRIX*)GetMatPosition();
D3DXMATRIX matT,matResult;
D3DXVECTOR3 vecT(0.0f, 1.0f, 0.0f);
D3DXMatrixTranslation(&matT, vecT.x, vecT.y, vecT.z);
D3DXMatrixMultiply(&matResult, &matT, matPosition);
vector3 vecOld,vecNew;
vecOld=vector3(matPosition->_41,matPosition->_42,matPosition->_43);
vecNew=vector3(matResult._41,matResult._42,matResult._43);
return vecNew-vecOld;
}

View File

@@ -0,0 +1,129 @@
// ViewCamera.h: interface for the CViewCamera class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_VIEWCAMERA_H__AB40CC30_EEEA_4FA1_96CE_A7CB0153A3CA__INCLUDED_)
#define AFX_VIEWCAMERA_H__AB40CC30_EEEA_4FA1_96CE_A7CB0153A3CA__INCLUDED_
#include "VECTOR.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "3DMath.h"
#include <d3d.h>
#include "List.h"
#include "Vertex.h"
class CViewCamera
{
vector3 m_vecPosition;
long m_CameraMode;
public:
vector3 GetViewTowardVector();
vector3 GetViewUpVector();
void EndPlay();
void Unload();
// Render for Fade In/Out Func & Memver variable
TLVertex m_pVertex[4];
char m_AdderFadeValue;
unsigned char m_FadeInitValue;
int m_cFade;
void SetFade(char AdderFadeValue,unsigned char FadeInitValue)
{
m_AdderFadeValue=AdderFadeValue;
m_FadeInitValue=FadeInitValue;
m_cFade=0;
};
int GetFadeCount(){return m_cFade;};
//
class CameraNode{
public:
vector3 m_vecPos;
vector3 m_vecTarget;
vector3 m_vecUp;
quaternion m_qAngle;
long m_Time;
};
float m_fTotalAniTime;
void SetTotalAniTime(float fTotalAniTime){m_fTotalAniTime=fTotalAniTime;};
float GetTotalAniTime(){return m_fTotalAniTime;};
bool GetAnimateCamera(){return m_isAnimateCamera;};
List<CameraNode>* GetCameraList(){return &m_CameraAnimateList;};
void Save(char *strFilename);
void Load(char *strFilename);
void StartPlay();
void PlayAnimate();
void LookAt(vector3 vecPos,vector3 vecTarget,vector3 vecUp);
void InterfaceFreeCamera(int MouseX,int MouseY);
bool m_isAnimateCamera;
bool GetIsAnimateCamera(){return m_isAnimateCamera;};
DWORD m_dwTickTime,m_dwLastUpdateTime;
float m_fNowAniTime;
List<CameraNode> m_CameraAnimateList;
//
vector3 m_vecFrustumTop[3];
vector3 m_vecFrustumBottom[3];
vector3 m_vecFrustumLeft[3];
vector3 m_vecFrustumRight[3];
vector3 m_vecFrustumNormal[4];
vector3 m_vecFrustumNear[3];
vector3 m_vecCenterAxis[2];
float m_fRotx,m_fRoty,m_fRotz;
float m_fAspect,m_fFov,m_fFarPlane,m_fNearPlane;
vector3 m_vecCameraPosition;
matrix m_matView;
matrix m_matPosition;
matrix m_matStackView,m_matStackPosition;
float m_fStackRotx,m_fStackRoty,m_fStackRotz;
vector3 m_vecStackPos;
void SaveViewMatrix()
{
m_matStackView=m_matView;
m_matStackPosition=m_matPosition;
m_fStackRotx=m_fRotx;
m_fStackRoty=m_fRoty;
m_fStackRotz=m_fRotz;
m_vecStackPos=m_vecPosition;
};
void LoadViewMatrix()
{
m_matView=m_matStackView;
m_matPosition=m_matStackPosition;
m_fRotx=m_fStackRotx;
m_fRoty=m_fStackRoty;
m_fRotz=m_fStackRotz;
m_vecPosition=m_vecStackPos;
MoveFrustum();
};
void InterfaceCharlook2(int MouseX,int MouseY);
void InterfaceCharlook(int MouseX,int MouseY,float fCharMove);
void InterfaceFreelook(int MouseX,int MouseY);
void MoveFrustum();
void Render(LPDIRECT3DDEVICE8 pd3dDevice);
void BuildFrustum(float fAspect,float fFov,float fNearPlane,float fFarPlane);
vector3 *GetPosition(){return &m_vecPosition;};
D3DMATRIX* GetMatView(){return (D3DMATRIX*)(&m_matView);};
matrix* GetMatPosition(){return &m_matPosition;};
float GetRotationX(){return m_fRotx;};
float GetRotationY(){return m_fRoty;};
float GetRotationZ(){return m_fRotz;};
void SetRotaitionX(float fRotX){m_fRotx=fRotX;};
void SetRotaitionY(float fRotY){m_fRoty=fRotY;};
void SetRotaitionZ(float fRotZ){m_fRotz=fRotZ;};
void SetVecPosition(vector3 vecPos){m_vecPosition=vecPos;};
void SetMatView(matrix &mat){m_matView=mat;};
void SetMatPosition(matrix &mat){m_matPosition=mat;};
CViewCamera();
virtual ~CViewCamera();
};
#endif // !defined(AFX_VIEWCAMERA_H__AB40CC30_EEEA_4FA1_96CE_A7CB0153A3CA__INCLUDED_)

View File

@@ -0,0 +1,42 @@
/* ************************************************
WBValue :: WBEngine's value type define
************************************************** */
#ifndef __WBVALUE_H__
#define __WBVALUE_H__
#include <d3dx8.h>
#include <assert.h>
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
//#include "WBLog.h"
#include "RBitSet.h"
#define WBRAD 0.0174532925f
#define WORD_MAX 65536
#define FEPSILON 1e-12
//enum WBPLAN { LEFT_P,RIGHT_P,TOP_P,BOTTOM_P,NEAR_P,FAR_P};
//enum WBAXIS {X,Y,Z};
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
#define SUCCEEDED(Status) ((HRESULT)(Status) >= 0)
#define FAILED(Status) ((HRESULT)(Status)<0)
#define MIN( p, q ) ( ( ( p )<( q ) )?( p ):( q ) )
#define MAX( p, q ) ( ( ( p )<( q ) )?( q ):( p ) )
#define RANDOM_FLOAT ( ( ( float )rand( ) )/RAND_MAX )
const float FINFINITY = FLT_MAX;
const double DINFINITY = DBL_MAX;
inline DWORD FtoDW( float f ) { return *((DWORD*)&f); }
#endif

View File

@@ -0,0 +1,189 @@
// WinInput.cpp: implementation of the CWinInput class.
//
//////////////////////////////////////////////////////////////////////
#include "BaseGraphicsLayer.h"
#include "WinInput.h"
CWinInput g_DeviceInput;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CWinInput::CWinInput()
{
m_ptPreMousePos.x = m_ptMousePos.x = 0;
m_ptPreMousePos.y = m_ptMousePos.y = 0;
Init();
m_bFocus = TRUE;
m_hWnd = 0;
m_hEditWnd = 0;
m_lCursorCount = 0;
}
CWinInput::~CWinInput()
{
}
void CWinInput::UpdateInfo()
{
m_ptPreMousePos = m_ptMousePos;
GetCursorPos(&m_ptMousePos);
if(m_hWnd && m_hEditWnd && GetFocus() != m_hWnd && GetFocus() != m_hEditWnd)
{
Init();
m_bFocus = FALSE;
return;
}
if(g_DeviceInput.InRect(0, 0, BaseGraphicsLayer::m_lScreenSx, BaseGraphicsLayer::m_lScreenSy))
{
m_ptMovePos.x = m_ptPreMousePos.x - m_ptMousePos.x;
m_ptMovePos.y = m_ptPreMousePos.y - m_ptMousePos.y;
memcpy(m_aryKeyOldState, m_aryKeyState, 256);
ZeroMemory(m_aryKeyState, 256);
for(int i = 0; i < 256; i++)
{
if(HIBYTE(GetAsyncKeyState(i))) m_aryKeyState[i] = (char)0x80;
}
m_bLButtonOldState = m_bLButtonState;
if(m_aryKeyState[VK_LBUTTON]) m_bLButtonState = TRUE; else m_bLButtonState = FALSE;
m_bLButtonDBClick = FALSE;
if(m_bLButtonDBState)
{
m_bLButtonDBClick = TRUE;
}
m_bLButtonDBState = FALSE;
m_bRButtonOldState = m_bRButtonState;
if(m_aryKeyState[VK_RBUTTON])
m_bRButtonState = TRUE;
else
m_bRButtonState = FALSE;
m_bRButtonDBClick = FALSE;
if(m_bRButtonDBState)
{
m_bRButtonDBClick = TRUE;
}
m_bRButtonDBState = FALSE;
m_bMButtonOldState = m_bMButtonState;
if(m_aryKeyState[VK_MBUTTON]) m_bMButtonState = TRUE; else m_bMButtonState = FALSE;
m_lMMoveZ = m_lMStoreMoveZ;
m_lMStoreMoveZ = 0;
/* if(GetIsRightMousePress())
{
POINT ptMousePos;
GetCursorPos(&ptMousePos);
m_lRStoreMoveX = ptMousePos.x - 400;
m_lRStoreMoveY = ptMousePos.y - 300;
SetCursorPos(400, 300);
}
m_lRMoveX = m_lRStoreMoveX;
m_lRMoveY = m_lRStoreMoveY;
m_lRMoveZ = m_lRStoreMoveZ;
m_lRStoreMoveX = m_lRStoreMoveY = m_lRStoreMoveZ = 0;
if(GetIsMiddleMousePress())
{
POINT ptMousePos;
GetCursorPos(&ptMousePos);
m_lMStoreMoveX = ptMousePos.x - 400;
m_lMStoreMoveY = ptMousePos.y - 300;
SetCursorPos(400, 300);
}
m_lMMoveX = m_lMStoreMoveX;
m_lMMoveY = m_lMStoreMoveY;
m_lMMoveZ = m_lMStoreMoveZ;
m_lMStoreMoveX = m_lMStoreMoveY = m_lMStoreMoveZ = 0;*/
if(m_bFocus == FALSE)
{
//::SetFocus(*m_hWnd);
m_bFocus = TRUE;
}
} else
{
Init();
m_bFocus = FALSE;
}
}
void CWinInput::GetMouseState(unsigned int uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case 0x020A: // WM_MOUSEWHEEL
{
m_lMStoreMoveZ = ((short)HIWORD(wParam)) / 120;
}
break;
case WM_LBUTTONDBLCLK:
m_bLButtonDBState = TRUE;
break;
case WM_RBUTTONDBLCLK:
m_bRButtonDBState = TRUE;
break;
/* case WM_RBUTTONDOWN:
m_lMStoreX = LOWORD(lParam);
m_lMStoreY = HIWORD(lParam);
SetCursorPos(400, 300);
ShowCursor(FALSE);
case WM_RBUTTONUP:
// SetCursorPos(m_lMStoreX, m_lMStoreY);
// ShowCursor(TRUE);
break;*/
case WM_MBUTTONDBLCLK:
m_bMButtonDBState = TRUE;
break;
/* case WM_MBUTTONDOWN:
m_lMStoreX = LOWORD(lParam);
m_lMStoreY = HIWORD(lParam);
SetCursorPos(400, 300);
ShowCursor(FALSE);
case WM_MBUTTONUP:
// SetCursorPos(m_lMStoreX, m_lMStoreY);
// ShowCursor(TRUE);
break;*/
}
}
void CWinInput::Init()
{
m_bLButtonOldState = m_bLButtonState = m_bLButtonDBState = FALSE;
m_bRButtonOldState = m_bRButtonState = m_bRButtonDBState = FALSE;
m_bMButtonOldState = m_bMButtonState = m_bMButtonDBState = FALSE;
m_bLButtonDBClick = m_bRButtonDBClick = m_bMButtonDBClick = FALSE;
m_ptMovePos.x = 0;
m_ptMovePos.y = 0;
m_lRStoreMoveX = m_lRStoreMoveY = m_lRStoreMoveZ = 0;
m_lMStoreMoveX = m_lMStoreMoveY = m_lMStoreMoveZ = 0;
ShowCursor(TRUE);
}

View File

@@ -0,0 +1,144 @@
// WinInput.h: interface for the CWinInput class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_WININPUT_H__79336117_D3DE_4260_99DD_86D3F9B4B1A6__INCLUDED_)
#define AFX_WININPUT_H__79336117_D3DE_4260_99DD_86D3F9B4B1A6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <windows.h>
class CWinInput
{
protected:
POINT m_ptPreMousePos, m_ptMousePos;
HWND m_hWnd;
HWND m_hEditWnd;
BOOL m_bFocus;
BOOL m_bLButtonDBClick;
BOOL m_bRButtonDBClick;
BOOL m_bMButtonDBClick;
BOOL m_bLButtonState, m_bLButtonOldState, m_bLButtonDBState;
BOOL m_bRButtonState, m_bRButtonOldState, m_bRButtonDBState;
BOOL m_bMButtonState, m_bMButtonOldState, m_bMButtonDBState;
long m_lEStoreX, m_lEStoreY;
long m_lMStoreX, m_lMStoreY;
long m_lRStoreMoveX, m_lRStoreMoveY, m_lRStoreMoveZ;
long m_lMStoreMoveX, m_lMStoreMoveY, m_lMStoreMoveZ;
long m_lCursorCount;
char m_aryKeyState[256];
char m_aryKeyOldState[256];
public:
CWinInput();
~CWinInput();
POINT m_ptMovePos;
long m_lRMoveX, m_lRMoveY, m_lRMoveZ;
long m_lMMoveX, m_lMMoveY, m_lMMoveZ;
long GetCount(void) { return m_lCursorCount; }
long ShowCursor(BOOL bShow)
{
if(bShow)
{
if(m_lCursorCount < 0)
{
for(;;)
{
m_lCursorCount = ::ShowCursor(TRUE);
if(m_lCursorCount >= 0) break;
}
}
} else
{
if(m_lCursorCount > -1)
{
for(;;)
{
m_lCursorCount = ::ShowCursor(FALSE);
if(m_lCursorCount <= -1) break;
}
}
}
return m_lCursorCount;
}
void SetHwnd(HWND hWnd) { m_hWnd = hWnd; }
void SetEditHwnd(HWND hWnd) { m_hEditWnd = hWnd; }
POINT *GetMousePosition(void) { return &m_ptMousePos; }
void GetMouseState(unsigned int uMsg, WPARAM wParam, LPARAM lParam);
void UpdateInfo(void);
void Init(void);
BOOL InRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2)
{
if(x1 <= m_ptMousePos.x && m_ptMousePos.x <= x2 && y1 <= m_ptMousePos.y && m_ptMousePos.y <= y2)
return TRUE;
else
return FALSE;
}
BOOL InRect(RECT &rcRect)
{
if(rcRect.left <= m_ptMousePos.x && m_ptMousePos.x <= rcRect.right &&
rcRect.top <= m_ptMousePos.y && m_ptMousePos.y <= rcRect.bottom)
return TRUE;
else
return FALSE;
}
BOOL GetIsLeftMouseDBClick() { return m_bLButtonDBClick; }
BOOL GetIsRightMouseDBClick() { return m_bRButtonDBClick; }
BOOL GetIsMiddleMouseDBClick() { return m_bMButtonDBClick; }
BOOL GetIsLeftMouseUp() { if(!m_bLButtonState && m_bLButtonOldState) return TRUE; else return FALSE; }
BOOL GetIsRightMouseUp() { if(!m_bRButtonState && m_bRButtonOldState) return TRUE; else return FALSE; }
BOOL GetIsMiddleMouseUp() { if(!m_bMButtonState && m_bMButtonOldState) return TRUE; else return FALSE; }
BOOL GetIsLeftMouseDown() { if(m_bLButtonState && !m_bLButtonOldState && !m_bLButtonDBClick) return TRUE; else return FALSE; }
BOOL GetIsRightMouseDown()
{
if(m_bRButtonState && !m_bRButtonOldState && !m_bRButtonDBClick)
return TRUE;
else
return FALSE;
}
BOOL GetIsMiddleMouseDown()
{
if(m_bMButtonState && !m_bMButtonOldState && !m_bMButtonDBClick)
return TRUE;
else
return FALSE;
}
BOOL GetIsLeftMousePress() { if(m_bLButtonState) return TRUE; else return FALSE; }
BOOL GetIsRightMousePress()
{
if(m_bRButtonState)
return TRUE;
else
return FALSE;
}
BOOL GetIsMiddleMousePress() { if(m_bMButtonState) return TRUE; else return FALSE; }
BOOL GetIsFocus(void) { return m_bFocus; }
BOOL KeyDown(int KeyCode) { if((m_aryKeyState[KeyCode] & 0x80) && !(m_aryKeyOldState[KeyCode] & 0x80)) return TRUE; else return FALSE; }
BOOL KeyHold(int KeyCode) { if(m_aryKeyState[KeyCode] & 0x80) return TRUE; else return FALSE; }
BOOL KeyUp(int KeyCode) { if(!(m_aryKeyState[KeyCode] & 0x80) && (m_aryKeyOldState[KeyCode] & 0x80)) return TRUE; else return FALSE; }
void InitKey(int KeyCode) { m_aryKeyState[KeyCode] = 0; m_aryKeyOldState[KeyCode] = 0; }
void SetCursorPos(int X, int Y)
{
::SetCursorPos(X, Y);
m_ptMousePos.x = X;
m_ptMousePos.y = Y;
}
};
extern CWinInput g_DeviceInput;
#endif // !defined(AFX_WININPUT_H__79336117_D3DE_4260_99DD_86D3F9B4B1A6__INCLUDED_)

View File

@@ -0,0 +1,376 @@
# Microsoft Developer Studio Project File - Name="Zalla3D Base Class" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=Zalla3D Base Class - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Zalla3D Base Class.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Zalla3D Base Class.mak" CFG="Zalla3D Base Class - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Zalla3D Base Class - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "Zalla3D Base Class - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/Zalla3D Base Class", BAAAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "Zalla3D Base Class - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FAcs /YX /FD /c
# ADD BASE RSC /l 0x412 /d "NDEBUG"
# ADD RSC /l 0x412 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Zalla3D Base Class - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x412 /d "_DEBUG"
# ADD RSC /l 0x412 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "Zalla3D Base Class - Win32 Release"
# Name "Zalla3D Base Class - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\BaseGraphicsLayer.cpp
# End Source File
# Begin Source File
SOURCE=.\color.cpp
# End Source File
# Begin Source File
SOURCE=.\ConvertTexture.cpp
# End Source File
# Begin Source File
SOURCE=.\d3dfont.cpp
# End Source File
# Begin Source File
SOURCE=.\DeviceInput.cpp
# End Source File
# Begin Source File
SOURCE=.\DeviceInputError.cpp
# End Source File
# Begin Source File
SOURCE=.\dxutil.cpp
# End Source File
# Begin Source File
SOURCE=.\EnumD3D.cpp
# End Source File
# Begin Source File
SOURCE=.\Error.cpp
# End Source File
# Begin Source File
SOURCE=.\FastMath.cpp
# End Source File
# Begin Source File
SOURCE=.\FileLoad.cpp
# End Source File
# Begin Source File
SOURCE=.\FrameTimer.cpp
# End Source File
# Begin Source File
SOURCE=.\GlareTexture.cpp
# End Source File
# Begin Source File
SOURCE=.\GraphicLayerError.cpp
# End Source File
# Begin Source File
SOURCE=.\IMEFont.cpp
# End Source File
# Begin Source File
SOURCE=.\Intersection.cpp
# End Source File
# Begin Source File
SOURCE=.\matrix.cpp
# End Source File
# Begin Source File
SOURCE=.\RenderDevice.cpp
# End Source File
# Begin Source File
SOURCE=.\RenderEnvTexture.cpp
# End Source File
# Begin Source File
SOURCE=.\RenderTargetTexture.cpp
# End Source File
# Begin Source File
SOURCE=.\RenderTexture.cpp
# End Source File
# Begin Source File
SOURCE=.\RenderTextureMipmap.cpp
# End Source File
# Begin Source File
SOURCE=.\ShadowMap.cpp
# End Source File
# Begin Source File
SOURCE=.\Sphere.cpp
# End Source File
# Begin Source File
SOURCE=.\StateLog.cpp
# End Source File
# Begin Source File
SOURCE=.\Texture.cpp
# End Source File
# Begin Source File
SOURCE=.\TextureContainer.cpp
# End Source File
# Begin Source File
SOURCE=.\VertexBuffer.cpp
# End Source File
# Begin Source File
SOURCE=.\ViewCamera.cpp
# End Source File
# Begin Source File
SOURCE=.\WinInput.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\3DMath.h
# End Source File
# Begin Source File
SOURCE=.\BaseGraphicsLayer.h
# End Source File
# Begin Source File
SOURCE=.\color.h
# End Source File
# Begin Source File
SOURCE=.\ConvertTexture.h
# End Source File
# Begin Source File
SOURCE=.\d3dfont.h
# End Source File
# Begin Source File
SOURCE=.\dds.h
# End Source File
# Begin Source File
SOURCE=.\DebugClass.h
# End Source File
# Begin Source File
SOURCE=.\DeviceInput.h
# End Source File
# Begin Source File
SOURCE=.\DeviceInputError.h
# End Source File
# Begin Source File
SOURCE=.\dxutil.h
# End Source File
# Begin Source File
SOURCE=.\EnumD3D.h
# End Source File
# Begin Source File
SOURCE=.\Error.h
# End Source File
# Begin Source File
SOURCE=.\Exception.h
# End Source File
# Begin Source File
SOURCE=.\FastMath.h
# End Source File
# Begin Source File
SOURCE=.\FileLoad.h
# End Source File
# Begin Source File
SOURCE=.\FrameTimer.h
# End Source File
# Begin Source File
SOURCE=.\GlareTexture.h
# End Source File
# Begin Source File
SOURCE=.\GraphicLayerError.h
# End Source File
# Begin Source File
SOURCE=.\IMEFont.h
# End Source File
# Begin Source File
SOURCE=.\Intersection.h
# End Source File
# Begin Source File
SOURCE=.\list.h
# End Source File
# Begin Source File
SOURCE=.\MathBase.h
# End Source File
# Begin Source File
SOURCE=.\matrix.h
# End Source File
# Begin Source File
SOURCE=.\quaternion.h
# End Source File
# Begin Source File
SOURCE=.\queue.h
# End Source File
# Begin Source File
SOURCE=.\RenderDevice.h
# End Source File
# Begin Source File
SOURCE=.\RenderEnvTexture.h
# End Source File
# Begin Source File
SOURCE=.\RenderTargetTexture.h
# End Source File
# Begin Source File
SOURCE=.\RenderTexture.h
# End Source File
# Begin Source File
SOURCE=.\RenderTextureMipmap.h
# End Source File
# Begin Source File
SOURCE=.\ShadowMap.h
# End Source File
# Begin Source File
SOURCE=.\Sphere.h
# End Source File
# Begin Source File
SOURCE=.\StateLog.h
# End Source File
# Begin Source File
SOURCE=.\Texture.h
# End Source File
# Begin Source File
SOURCE=.\TextureContainer.h
# End Source File
# Begin Source File
SOURCE=.\VECTOR.h
# End Source File
# Begin Source File
SOURCE=.\Vertex.h
# End Source File
# Begin Source File
SOURCE=.\VertexBuffer.h
# End Source File
# Begin Source File
SOURCE=.\ViewCamera.h
# End Source File
# Begin Source File
SOURCE=.\WBValue.h
# End Source File
# Begin Source File
SOURCE=.\WinInput.h
# End Source File
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,245 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "C3DBSPCompiler"="..\C3DBSPCompiler\C3DBSPCompiler.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Zalla3D Base Class
End Project Dependency
}}}
###############################################################################
Project: "CharacterActionControl"="..\CharacterActionControl\CharacterActionControl.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "ClientSetup"="..\ClientSetup\ClientSetup.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Zalla3D Base Class
End Project Dependency
Begin Project Dependency
Project_Dep_Name Zalla3D SceneClass
End Project Dependency
}}}
###############################################################################
Project: "Effect"="..\effect\Effect.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Zalla3D Base Class
End Project Dependency
}}}
###############################################################################
Project: "GlobalScript"="..\GLOBALSCRIPT\GlobalScript.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name ScriptEngine
End Project Dependency
}}}
###############################################################################
Project: "NeoRylClient"="..\NeoRylClient\NeoRylClient.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Effect
End Project Dependency
Begin Project Dependency
Project_Dep_Name Zalla3D SceneClass
End Project Dependency
Begin Project Dependency
Project_Dep_Name CharacterActionControl
End Project Dependency
Begin Project Dependency
Project_Dep_Name GlobalScript
End Project Dependency
}}}
###############################################################################
Project: "RYLUpdateManager"="..\RYLUpdateManager\RYLUpdateManager.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Zalla3D SceneClass
End Project Dependency
}}}
###############################################################################
Project: "RarLib"="..\RarLib\RarLib.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "RylClient1"="..\RylClient1\RylClient1.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Zalla3D Base Class
End Project Dependency
Begin Project Dependency
Project_Dep_Name Zalla3D SceneClass
End Project Dependency
}}}
###############################################################################
Project: "ScriptEngine"="..\ScriptEngine\ScriptEngine.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "SoundLib"="..\SoundLib\SoundLib.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "WorldCreator"="..\WorldCreator\WorldCreator.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Zalla3D SceneClass
End Project Dependency
Begin Project Dependency
Project_Dep_Name CharacterActionControl
End Project Dependency
}}}
###############################################################################
Project: "Z3D_SetupDirectX"="..\Z3D_SetupDirectX\Z3D_SetupDirectX.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "Zalla3D Base Class"=".\Zalla3D Base Class.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "Zalla3D SceneClass"="..\Zallad3D SceneClass\Zalla3D SceneClass.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Effect
End Project Dependency
Begin Project Dependency
Project_Dep_Name SoundLib
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,850 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: Zalla3D Base Class - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP3E.tmp" with contents
[
/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Debug/Zalla3D Base Class.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"C:\Ryl\ZALLA3D BASECLASS\BaseGraphicsLayer.cpp"
"C:\Ryl\ZALLA3D BASECLASS\d3dfont.cpp"
"C:\Ryl\ZALLA3D BASECLASS\GlareTexture.cpp"
"C:\Ryl\ZALLA3D BASECLASS\IMEFont.cpp"
"C:\Ryl\ZALLA3D BASECLASS\RenderEnvTexture.cpp"
"C:\Ryl\ZALLA3D BASECLASS\RenderTextureMipmap.cpp"
"C:\Ryl\ZALLA3D BASECLASS\Sphere.cpp"
]
Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP3E.tmp"
Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP3F.tmp" with contents
[
/nologo /out:"Debug\Zalla3D Base Class.lib"
".\Debug\BaseGraphicsLayer.obj"
".\Debug\color.obj"
".\Debug\ConvertTexture.obj"
".\Debug\d3dfont.obj"
".\Debug\DeviceInput.obj"
".\Debug\DeviceInputError.obj"
".\Debug\dxutil.obj"
".\Debug\EnumD3D.obj"
".\Debug\Error.obj"
".\Debug\FastMath.obj"
".\Debug\FileLoad.obj"
".\Debug\FrameTimer.obj"
".\Debug\GlareTexture.obj"
".\Debug\GraphicLayerError.obj"
".\Debug\IMEFont.obj"
".\Debug\Intersection.obj"
".\Debug\matrix.obj"
".\Debug\RenderDevice.obj"
".\Debug\RenderEnvTexture.obj"
".\Debug\RenderTargetTexture.obj"
".\Debug\RenderTexture.obj"
".\Debug\RenderTextureMipmap.obj"
".\Debug\ShadowMap.obj"
".\Debug\Sphere.obj"
".\Debug\StateLog.obj"
".\Debug\Texture.obj"
".\Debug\TextureContainer.obj"
".\Debug\VertexBuffer.obj"
".\Debug\ViewCamera.obj"
".\Debug\WinInput.obj"
]
Creating command line "link.exe -lib @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP3F.tmp"
<h3>Output Window</h3>
Compiling...
BaseGraphicsLayer.cpp
c:\ryl\zallad3d sceneclass\boidscene.h(15) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(31) : see previous definition of 'MIN'
c:\ryl\zallad3d sceneclass\boidscene.h(16) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(32) : see previous definition of 'MAX'
c:\dx90sdk\include\d3dx9.h(21) : note C6311: c:\dx90sdk\include\d3dx8.h(33) : see previous definition of 'D3DX_DEFAULT'
c:\dx90sdk\include\d3dx9math.h(88) : error C2011: 'D3DXVECTOR2' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(162) : error C2011: 'D3DXVECTOR3' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(237) : error C2011: 'D3DXVECTOR4' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(310) : error C2011: 'D3DXMATRIX' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(378) : error C2011: '_D3DXMATRIXA16' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(424) : error C2011: 'D3DXQUATERNION' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(470) : error C2011: 'D3DXPLANE' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(511) : error C2011: 'D3DXCOLOR' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(785) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(785) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(786) : error C2733: second C linkage of overloaded function 'D3DXVec3Project' not allowed
c:\dx90sdk\include\d3dx9math.h(785) : see declaration of 'D3DXVec3Project'
c:\dx90sdk\include\d3dx9math.h(790) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(790) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(791) : error C2733: second C linkage of overloaded function 'D3DXVec3Unproject' not allowed
c:\dx90sdk\include\d3dx9math.h(790) : see declaration of 'D3DXVec3Unproject'
c:\dx90sdk\include\d3dx9math.h(795) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(795) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(1308) : error C2011: 'ID3DXMatrixStack' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(1741) : error C2061: syntax error : identifier 'LPDIRECT3DCUBETEXTURE9'
c:\dx90sdk\include\d3dx9math.inl(67) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(79) : error C2511: 'D3DXVECTOR2::D3DXVECTOR2' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx8math.h(43) : see declaration of 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx9math.inl(90) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(98) : error C2084: function '__thiscall D3DXVECTOR2::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(104) : error C2084: function '__thiscall D3DXVECTOR2::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(111) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator +=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(119) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator -=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(127) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(135) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(145) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(151) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(152) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(158) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(159) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(164) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(165) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(170) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(171) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(176) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(178) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(184) : error C2084: function 'struct D3DXVECTOR2 __cdecl operator *(float,const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(185) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(190) : error C2084: function 'int __thiscall D3DXVECTOR2::operator ==(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(196) : error C2084: function 'int __thiscall D3DXVECTOR2::operator !=(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(267) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(280) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const struct _D3DVECTOR &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(288) : error C2511: 'D3DXVECTOR3::D3DXVECTOR3' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx8math.h(86) : see declaration of 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx9math.inl(299) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(309) : error C2084: function '__thiscall D3DXVECTOR3::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(315) : error C2084: function '__thiscall D3DXVECTOR3::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(323) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator +=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(332) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator -=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(341) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(350) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(362) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(368) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(369) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(376) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(377) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(382) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(383) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(388) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(389) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(394) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(396) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(402) : error C2084: function 'struct D3DXVECTOR3 __cdecl operator *(float,const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(403) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(409) : error C2084: function 'int __thiscall D3DXVECTOR3::operator ==(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(415) : error C2084: function 'int __thiscall D3DXVECTOR3::operator !=(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(499) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(513) : error C2511: 'D3DXVECTOR4::D3DXVECTOR4' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx8math.h(130) : see declaration of 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx9math.inl(524) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(534) : error C2084: function '__thiscall D3DXVECTOR4::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(540) : error C2084: function '__thiscall D3DXVECTOR4::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(548) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator +=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(558) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator -=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(568) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(578) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(591) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(597) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(598) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(605) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(606) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(611) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(612) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(617) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(618) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(623) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(625) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(631) : error C2084: function 'struct D3DXVECTOR4 __cdecl operator *(float,const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(632) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(638) : error C2084: function 'int __thiscall D3DXVECTOR4::operator ==(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(644) : error C2084: function 'int __thiscall D3DXVECTOR4::operator !=(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(720) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(731) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const struct _D3DMATRIX &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(737) : error C2511: 'D3DXMATRIX::D3DXMATRIX' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXMATRIX'
c:\dx90sdk\include\d3dx8math.h(174) : see declaration of 'D3DXMATRIX'
c:\dx90sdk\include\d3dx9math.inl(751) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(763) : error C2084: function 'float &__thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int)' already has a body
c:\dx90sdk\include\d3dx9math.inl(769) : error C2084: function 'float __thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(777) : error C2084: function '__thiscall D3DXMATRIX::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : error C2084: function '__thiscall D3DXMATRIX::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : fatal error C1003: error count exceeds 100; stopping compilation
d3dfont.cpp
c:\ryl\zallad3d sceneclass\boidscene.h(15) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(31) : see previous definition of 'MIN'
c:\ryl\zallad3d sceneclass\boidscene.h(16) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(32) : see previous definition of 'MAX'
c:\dx90sdk\include\d3dx9.h(21) : note C6311: c:\dx90sdk\include\d3dx8.h(33) : see previous definition of 'D3DX_DEFAULT'
c:\dx90sdk\include\d3dx9math.h(88) : error C2011: 'D3DXVECTOR2' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(162) : error C2011: 'D3DXVECTOR3' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(237) : error C2011: 'D3DXVECTOR4' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(310) : error C2011: 'D3DXMATRIX' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(378) : error C2011: '_D3DXMATRIXA16' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(424) : error C2011: 'D3DXQUATERNION' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(470) : error C2011: 'D3DXPLANE' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(511) : error C2011: 'D3DXCOLOR' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(785) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(785) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(786) : error C2733: second C linkage of overloaded function 'D3DXVec3Project' not allowed
c:\dx90sdk\include\d3dx9math.h(785) : see declaration of 'D3DXVec3Project'
c:\dx90sdk\include\d3dx9math.h(790) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(790) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(791) : error C2733: second C linkage of overloaded function 'D3DXVec3Unproject' not allowed
c:\dx90sdk\include\d3dx9math.h(790) : see declaration of 'D3DXVec3Unproject'
c:\dx90sdk\include\d3dx9math.h(795) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(795) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(1308) : error C2011: 'ID3DXMatrixStack' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(1741) : error C2061: syntax error : identifier 'LPDIRECT3DCUBETEXTURE9'
c:\dx90sdk\include\d3dx9math.inl(67) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(79) : error C2511: 'D3DXVECTOR2::D3DXVECTOR2' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx8math.h(43) : see declaration of 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx9math.inl(90) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(98) : error C2084: function '__thiscall D3DXVECTOR2::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(104) : error C2084: function '__thiscall D3DXVECTOR2::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(111) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator +=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(119) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator -=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(127) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(135) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(145) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(151) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(152) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(158) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(159) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(164) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(165) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(170) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(171) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(176) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(178) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(184) : error C2084: function 'struct D3DXVECTOR2 __cdecl operator *(float,const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(185) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(190) : error C2084: function 'int __thiscall D3DXVECTOR2::operator ==(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(196) : error C2084: function 'int __thiscall D3DXVECTOR2::operator !=(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(267) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(280) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const struct _D3DVECTOR &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(288) : error C2511: 'D3DXVECTOR3::D3DXVECTOR3' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx8math.h(86) : see declaration of 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx9math.inl(299) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(309) : error C2084: function '__thiscall D3DXVECTOR3::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(315) : error C2084: function '__thiscall D3DXVECTOR3::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(323) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator +=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(332) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator -=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(341) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(350) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(362) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(368) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(369) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(376) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(377) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(382) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(383) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(388) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(389) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(394) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(396) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(402) : error C2084: function 'struct D3DXVECTOR3 __cdecl operator *(float,const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(403) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(409) : error C2084: function 'int __thiscall D3DXVECTOR3::operator ==(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(415) : error C2084: function 'int __thiscall D3DXVECTOR3::operator !=(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(499) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(513) : error C2511: 'D3DXVECTOR4::D3DXVECTOR4' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx8math.h(130) : see declaration of 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx9math.inl(524) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(534) : error C2084: function '__thiscall D3DXVECTOR4::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(540) : error C2084: function '__thiscall D3DXVECTOR4::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(548) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator +=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(558) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator -=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(568) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(578) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(591) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(597) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(598) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(605) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(606) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(611) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(612) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(617) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(618) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(623) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(625) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(631) : error C2084: function 'struct D3DXVECTOR4 __cdecl operator *(float,const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(632) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(638) : error C2084: function 'int __thiscall D3DXVECTOR4::operator ==(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(644) : error C2084: function 'int __thiscall D3DXVECTOR4::operator !=(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(720) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(731) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const struct _D3DMATRIX &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(737) : error C2511: 'D3DXMATRIX::D3DXMATRIX' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXMATRIX'
c:\dx90sdk\include\d3dx8math.h(174) : see declaration of 'D3DXMATRIX'
c:\dx90sdk\include\d3dx9math.inl(751) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(763) : error C2084: function 'float &__thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int)' already has a body
c:\dx90sdk\include\d3dx9math.inl(769) : error C2084: function 'float __thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(777) : error C2084: function '__thiscall D3DXMATRIX::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : error C2084: function '__thiscall D3DXMATRIX::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : fatal error C1003: error count exceeds 100; stopping compilation
GlareTexture.cpp
c:\ryl\zallad3d sceneclass\boidscene.h(15) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(31) : see previous definition of 'MIN'
c:\ryl\zallad3d sceneclass\boidscene.h(16) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(32) : see previous definition of 'MAX'
c:\dx90sdk\include\d3dx9.h(21) : note C6311: c:\dx90sdk\include\d3dx8.h(33) : see previous definition of 'D3DX_DEFAULT'
c:\dx90sdk\include\d3dx9math.h(88) : error C2011: 'D3DXVECTOR2' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(162) : error C2011: 'D3DXVECTOR3' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(237) : error C2011: 'D3DXVECTOR4' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(310) : error C2011: 'D3DXMATRIX' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(378) : error C2011: '_D3DXMATRIXA16' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(424) : error C2011: 'D3DXQUATERNION' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(470) : error C2011: 'D3DXPLANE' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(511) : error C2011: 'D3DXCOLOR' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(785) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(785) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(786) : error C2733: second C linkage of overloaded function 'D3DXVec3Project' not allowed
c:\dx90sdk\include\d3dx9math.h(785) : see declaration of 'D3DXVec3Project'
c:\dx90sdk\include\d3dx9math.h(790) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(790) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(791) : error C2733: second C linkage of overloaded function 'D3DXVec3Unproject' not allowed
c:\dx90sdk\include\d3dx9math.h(790) : see declaration of 'D3DXVec3Unproject'
c:\dx90sdk\include\d3dx9math.h(795) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(795) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(1308) : error C2011: 'ID3DXMatrixStack' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(1741) : error C2061: syntax error : identifier 'LPDIRECT3DCUBETEXTURE9'
c:\dx90sdk\include\d3dx9math.inl(67) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(79) : error C2511: 'D3DXVECTOR2::D3DXVECTOR2' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx8math.h(43) : see declaration of 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx9math.inl(90) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(98) : error C2084: function '__thiscall D3DXVECTOR2::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(104) : error C2084: function '__thiscall D3DXVECTOR2::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(111) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator +=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(119) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator -=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(127) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(135) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(145) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(151) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(152) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(158) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(159) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(164) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(165) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(170) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(171) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(176) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(178) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(184) : error C2084: function 'struct D3DXVECTOR2 __cdecl operator *(float,const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(185) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(190) : error C2084: function 'int __thiscall D3DXVECTOR2::operator ==(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(196) : error C2084: function 'int __thiscall D3DXVECTOR2::operator !=(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(267) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(280) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const struct _D3DVECTOR &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(288) : error C2511: 'D3DXVECTOR3::D3DXVECTOR3' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx8math.h(86) : see declaration of 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx9math.inl(299) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(309) : error C2084: function '__thiscall D3DXVECTOR3::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(315) : error C2084: function '__thiscall D3DXVECTOR3::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(323) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator +=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(332) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator -=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(341) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(350) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(362) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(368) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(369) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(376) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(377) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(382) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(383) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(388) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(389) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(394) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(396) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(402) : error C2084: function 'struct D3DXVECTOR3 __cdecl operator *(float,const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(403) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(409) : error C2084: function 'int __thiscall D3DXVECTOR3::operator ==(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(415) : error C2084: function 'int __thiscall D3DXVECTOR3::operator !=(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(499) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(513) : error C2511: 'D3DXVECTOR4::D3DXVECTOR4' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx8math.h(130) : see declaration of 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx9math.inl(524) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(534) : error C2084: function '__thiscall D3DXVECTOR4::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(540) : error C2084: function '__thiscall D3DXVECTOR4::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(548) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator +=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(558) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator -=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(568) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(578) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(591) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(597) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(598) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(605) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(606) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(611) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(612) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(617) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(618) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(623) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(625) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(631) : error C2084: function 'struct D3DXVECTOR4 __cdecl operator *(float,const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(632) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(638) : error C2084: function 'int __thiscall D3DXVECTOR4::operator ==(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(644) : error C2084: function 'int __thiscall D3DXVECTOR4::operator !=(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(720) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(731) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const struct _D3DMATRIX &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(737) : error C2511: 'D3DXMATRIX::D3DXMATRIX' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXMATRIX'
c:\dx90sdk\include\d3dx8math.h(174) : see declaration of 'D3DXMATRIX'
c:\dx90sdk\include\d3dx9math.inl(751) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(763) : error C2084: function 'float &__thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int)' already has a body
c:\dx90sdk\include\d3dx9math.inl(769) : error C2084: function 'float __thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(777) : error C2084: function '__thiscall D3DXMATRIX::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : error C2084: function '__thiscall D3DXMATRIX::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : fatal error C1003: error count exceeds 100; stopping compilation
IMEFont.cpp
c:\ryl\zallad3d sceneclass\boidscene.h(15) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(31) : see previous definition of 'MIN'
c:\ryl\zallad3d sceneclass\boidscene.h(16) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(32) : see previous definition of 'MAX'
c:\dx90sdk\include\d3dx9.h(21) : note C6311: c:\dx90sdk\include\d3dx8.h(33) : see previous definition of 'D3DX_DEFAULT'
c:\dx90sdk\include\d3dx9math.h(88) : error C2011: 'D3DXVECTOR2' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(162) : error C2011: 'D3DXVECTOR3' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(237) : error C2011: 'D3DXVECTOR4' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(310) : error C2011: 'D3DXMATRIX' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(378) : error C2011: '_D3DXMATRIXA16' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(424) : error C2011: 'D3DXQUATERNION' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(470) : error C2011: 'D3DXPLANE' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(511) : error C2011: 'D3DXCOLOR' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(785) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(785) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(786) : error C2733: second C linkage of overloaded function 'D3DXVec3Project' not allowed
c:\dx90sdk\include\d3dx9math.h(785) : see declaration of 'D3DXVec3Project'
c:\dx90sdk\include\d3dx9math.h(790) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(790) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(791) : error C2733: second C linkage of overloaded function 'D3DXVec3Unproject' not allowed
c:\dx90sdk\include\d3dx9math.h(790) : see declaration of 'D3DXVec3Unproject'
c:\dx90sdk\include\d3dx9math.h(795) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(795) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(1308) : error C2011: 'ID3DXMatrixStack' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(1741) : error C2061: syntax error : identifier 'LPDIRECT3DCUBETEXTURE9'
c:\dx90sdk\include\d3dx9math.inl(67) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(79) : error C2511: 'D3DXVECTOR2::D3DXVECTOR2' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx8math.h(43) : see declaration of 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx9math.inl(90) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(98) : error C2084: function '__thiscall D3DXVECTOR2::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(104) : error C2084: function '__thiscall D3DXVECTOR2::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(111) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator +=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(119) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator -=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(127) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(135) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(145) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(151) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(152) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(158) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(159) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(164) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(165) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(170) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(171) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(176) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(178) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(184) : error C2084: function 'struct D3DXVECTOR2 __cdecl operator *(float,const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(185) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(190) : error C2084: function 'int __thiscall D3DXVECTOR2::operator ==(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(196) : error C2084: function 'int __thiscall D3DXVECTOR2::operator !=(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(267) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(280) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const struct _D3DVECTOR &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(288) : error C2511: 'D3DXVECTOR3::D3DXVECTOR3' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx8math.h(86) : see declaration of 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx9math.inl(299) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(309) : error C2084: function '__thiscall D3DXVECTOR3::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(315) : error C2084: function '__thiscall D3DXVECTOR3::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(323) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator +=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(332) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator -=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(341) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(350) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(362) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(368) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(369) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(376) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(377) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(382) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(383) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(388) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(389) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(394) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(396) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(402) : error C2084: function 'struct D3DXVECTOR3 __cdecl operator *(float,const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(403) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(409) : error C2084: function 'int __thiscall D3DXVECTOR3::operator ==(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(415) : error C2084: function 'int __thiscall D3DXVECTOR3::operator !=(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(499) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(513) : error C2511: 'D3DXVECTOR4::D3DXVECTOR4' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx8math.h(130) : see declaration of 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx9math.inl(524) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(534) : error C2084: function '__thiscall D3DXVECTOR4::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(540) : error C2084: function '__thiscall D3DXVECTOR4::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(548) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator +=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(558) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator -=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(568) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(578) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(591) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(597) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(598) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(605) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(606) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(611) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(612) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(617) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(618) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(623) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(625) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(631) : error C2084: function 'struct D3DXVECTOR4 __cdecl operator *(float,const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(632) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(638) : error C2084: function 'int __thiscall D3DXVECTOR4::operator ==(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(644) : error C2084: function 'int __thiscall D3DXVECTOR4::operator !=(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(720) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(731) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const struct _D3DMATRIX &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(737) : error C2511: 'D3DXMATRIX::D3DXMATRIX' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXMATRIX'
c:\dx90sdk\include\d3dx8math.h(174) : see declaration of 'D3DXMATRIX'
c:\dx90sdk\include\d3dx9math.inl(751) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(763) : error C2084: function 'float &__thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int)' already has a body
c:\dx90sdk\include\d3dx9math.inl(769) : error C2084: function 'float __thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(777) : error C2084: function '__thiscall D3DXMATRIX::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : error C2084: function '__thiscall D3DXMATRIX::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : fatal error C1003: error count exceeds 100; stopping compilation
RenderEnvTexture.cpp
c:\ryl\zallad3d sceneclass\boidscene.h(15) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(31) : see previous definition of 'MIN'
c:\ryl\zallad3d sceneclass\boidscene.h(16) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(32) : see previous definition of 'MAX'
c:\dx90sdk\include\d3dx9.h(21) : note C6311: c:\dx90sdk\include\d3dx8.h(33) : see previous definition of 'D3DX_DEFAULT'
c:\dx90sdk\include\d3dx9math.h(88) : error C2011: 'D3DXVECTOR2' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(162) : error C2011: 'D3DXVECTOR3' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(237) : error C2011: 'D3DXVECTOR4' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(310) : error C2011: 'D3DXMATRIX' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(378) : error C2011: '_D3DXMATRIXA16' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(424) : error C2011: 'D3DXQUATERNION' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(470) : error C2011: 'D3DXPLANE' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(511) : error C2011: 'D3DXCOLOR' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(785) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(785) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(786) : error C2733: second C linkage of overloaded function 'D3DXVec3Project' not allowed
c:\dx90sdk\include\d3dx9math.h(785) : see declaration of 'D3DXVec3Project'
c:\dx90sdk\include\d3dx9math.h(790) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(790) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(791) : error C2733: second C linkage of overloaded function 'D3DXVec3Unproject' not allowed
c:\dx90sdk\include\d3dx9math.h(790) : see declaration of 'D3DXVec3Unproject'
c:\dx90sdk\include\d3dx9math.h(795) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(795) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(1308) : error C2011: 'ID3DXMatrixStack' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(1741) : error C2061: syntax error : identifier 'LPDIRECT3DCUBETEXTURE9'
c:\dx90sdk\include\d3dx9math.inl(67) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(79) : error C2511: 'D3DXVECTOR2::D3DXVECTOR2' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx8math.h(43) : see declaration of 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx9math.inl(90) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(98) : error C2084: function '__thiscall D3DXVECTOR2::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(104) : error C2084: function '__thiscall D3DXVECTOR2::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(111) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator +=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(119) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator -=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(127) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(135) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(145) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(151) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(152) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(158) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(159) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(164) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(165) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(170) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(171) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(176) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(178) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(184) : error C2084: function 'struct D3DXVECTOR2 __cdecl operator *(float,const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(185) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(190) : error C2084: function 'int __thiscall D3DXVECTOR2::operator ==(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(196) : error C2084: function 'int __thiscall D3DXVECTOR2::operator !=(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(267) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(280) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const struct _D3DVECTOR &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(288) : error C2511: 'D3DXVECTOR3::D3DXVECTOR3' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx8math.h(86) : see declaration of 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx9math.inl(299) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(309) : error C2084: function '__thiscall D3DXVECTOR3::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(315) : error C2084: function '__thiscall D3DXVECTOR3::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(323) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator +=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(332) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator -=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(341) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(350) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(362) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(368) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(369) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(376) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(377) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(382) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(383) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(388) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(389) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(394) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(396) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(402) : error C2084: function 'struct D3DXVECTOR3 __cdecl operator *(float,const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(403) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(409) : error C2084: function 'int __thiscall D3DXVECTOR3::operator ==(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(415) : error C2084: function 'int __thiscall D3DXVECTOR3::operator !=(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(499) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(513) : error C2511: 'D3DXVECTOR4::D3DXVECTOR4' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx8math.h(130) : see declaration of 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx9math.inl(524) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(534) : error C2084: function '__thiscall D3DXVECTOR4::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(540) : error C2084: function '__thiscall D3DXVECTOR4::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(548) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator +=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(558) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator -=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(568) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(578) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(591) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(597) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(598) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(605) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(606) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(611) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(612) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(617) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(618) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(623) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(625) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(631) : error C2084: function 'struct D3DXVECTOR4 __cdecl operator *(float,const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(632) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(638) : error C2084: function 'int __thiscall D3DXVECTOR4::operator ==(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(644) : error C2084: function 'int __thiscall D3DXVECTOR4::operator !=(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(720) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(731) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const struct _D3DMATRIX &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(737) : error C2511: 'D3DXMATRIX::D3DXMATRIX' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXMATRIX'
c:\dx90sdk\include\d3dx8math.h(174) : see declaration of 'D3DXMATRIX'
c:\dx90sdk\include\d3dx9math.inl(751) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(763) : error C2084: function 'float &__thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int)' already has a body
c:\dx90sdk\include\d3dx9math.inl(769) : error C2084: function 'float __thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(777) : error C2084: function '__thiscall D3DXMATRIX::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : error C2084: function '__thiscall D3DXMATRIX::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : fatal error C1003: error count exceeds 100; stopping compilation
RenderTextureMipmap.cpp
c:\ryl\zallad3d sceneclass\boidscene.h(15) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(31) : see previous definition of 'MIN'
c:\ryl\zallad3d sceneclass\boidscene.h(16) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(32) : see previous definition of 'MAX'
c:\dx90sdk\include\d3dx9.h(21) : note C6311: c:\dx90sdk\include\d3dx8.h(33) : see previous definition of 'D3DX_DEFAULT'
c:\dx90sdk\include\d3dx9math.h(88) : error C2011: 'D3DXVECTOR2' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(162) : error C2011: 'D3DXVECTOR3' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(237) : error C2011: 'D3DXVECTOR4' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(310) : error C2011: 'D3DXMATRIX' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(378) : error C2011: '_D3DXMATRIXA16' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(424) : error C2011: 'D3DXQUATERNION' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(470) : error C2011: 'D3DXPLANE' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(511) : error C2011: 'D3DXCOLOR' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(785) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(785) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(786) : error C2733: second C linkage of overloaded function 'D3DXVec3Project' not allowed
c:\dx90sdk\include\d3dx9math.h(785) : see declaration of 'D3DXVec3Project'
c:\dx90sdk\include\d3dx9math.h(790) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(790) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(791) : error C2733: second C linkage of overloaded function 'D3DXVec3Unproject' not allowed
c:\dx90sdk\include\d3dx9math.h(790) : see declaration of 'D3DXVec3Unproject'
c:\dx90sdk\include\d3dx9math.h(795) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(795) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(1308) : error C2011: 'ID3DXMatrixStack' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(1741) : error C2061: syntax error : identifier 'LPDIRECT3DCUBETEXTURE9'
c:\dx90sdk\include\d3dx9math.inl(67) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(79) : error C2511: 'D3DXVECTOR2::D3DXVECTOR2' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx8math.h(43) : see declaration of 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx9math.inl(90) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(98) : error C2084: function '__thiscall D3DXVECTOR2::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(104) : error C2084: function '__thiscall D3DXVECTOR2::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(111) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator +=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(119) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator -=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(127) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(135) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(145) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(151) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(152) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(158) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(159) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(164) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(165) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(170) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(171) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(176) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(178) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(184) : error C2084: function 'struct D3DXVECTOR2 __cdecl operator *(float,const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(185) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(190) : error C2084: function 'int __thiscall D3DXVECTOR2::operator ==(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(196) : error C2084: function 'int __thiscall D3DXVECTOR2::operator !=(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(267) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(280) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const struct _D3DVECTOR &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(288) : error C2511: 'D3DXVECTOR3::D3DXVECTOR3' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx8math.h(86) : see declaration of 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx9math.inl(299) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(309) : error C2084: function '__thiscall D3DXVECTOR3::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(315) : error C2084: function '__thiscall D3DXVECTOR3::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(323) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator +=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(332) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator -=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(341) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(350) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(362) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(368) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(369) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(376) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(377) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(382) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(383) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(388) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(389) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(394) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(396) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(402) : error C2084: function 'struct D3DXVECTOR3 __cdecl operator *(float,const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(403) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(409) : error C2084: function 'int __thiscall D3DXVECTOR3::operator ==(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(415) : error C2084: function 'int __thiscall D3DXVECTOR3::operator !=(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(499) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(513) : error C2511: 'D3DXVECTOR4::D3DXVECTOR4' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx8math.h(130) : see declaration of 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx9math.inl(524) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(534) : error C2084: function '__thiscall D3DXVECTOR4::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(540) : error C2084: function '__thiscall D3DXVECTOR4::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(548) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator +=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(558) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator -=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(568) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(578) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(591) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(597) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(598) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(605) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(606) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(611) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(612) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(617) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(618) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(623) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(625) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(631) : error C2084: function 'struct D3DXVECTOR4 __cdecl operator *(float,const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(632) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(638) : error C2084: function 'int __thiscall D3DXVECTOR4::operator ==(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(644) : error C2084: function 'int __thiscall D3DXVECTOR4::operator !=(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(720) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(731) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const struct _D3DMATRIX &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(737) : error C2511: 'D3DXMATRIX::D3DXMATRIX' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXMATRIX'
c:\dx90sdk\include\d3dx8math.h(174) : see declaration of 'D3DXMATRIX'
c:\dx90sdk\include\d3dx9math.inl(751) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(763) : error C2084: function 'float &__thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int)' already has a body
c:\dx90sdk\include\d3dx9math.inl(769) : error C2084: function 'float __thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(777) : error C2084: function '__thiscall D3DXMATRIX::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : error C2084: function '__thiscall D3DXMATRIX::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : fatal error C1003: error count exceeds 100; stopping compilation
Sphere.cpp
c:\ryl\zallad3d sceneclass\boidscene.h(15) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(31) : see previous definition of 'MIN'
c:\ryl\zallad3d sceneclass\boidscene.h(16) : note C6311: c:\ryl\zalla3d baseclass\wbvalue.h(32) : see previous definition of 'MAX'
c:\dx90sdk\include\d3dx9.h(21) : note C6311: c:\dx90sdk\include\d3dx8.h(33) : see previous definition of 'D3DX_DEFAULT'
c:\dx90sdk\include\d3dx9math.h(88) : error C2011: 'D3DXVECTOR2' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(162) : error C2011: 'D3DXVECTOR3' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(237) : error C2011: 'D3DXVECTOR4' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(310) : error C2011: 'D3DXMATRIX' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(378) : error C2011: '_D3DXMATRIXA16' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(424) : error C2011: 'D3DXQUATERNION' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(470) : error C2011: 'D3DXPLANE' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(511) : error C2011: 'D3DXCOLOR' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(785) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(785) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(786) : error C2733: second C linkage of overloaded function 'D3DXVec3Project' not allowed
c:\dx90sdk\include\d3dx9math.h(785) : see declaration of 'D3DXVec3Project'
c:\dx90sdk\include\d3dx9math.h(790) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(790) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(791) : error C2733: second C linkage of overloaded function 'D3DXVec3Unproject' not allowed
c:\dx90sdk\include\d3dx9math.h(790) : see declaration of 'D3DXVec3Unproject'
c:\dx90sdk\include\d3dx9math.h(795) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(795) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2143: syntax error : missing ',' before '*'
c:\dx90sdk\include\d3dx9math.h(800) : error C2059: syntax error : '*'
c:\dx90sdk\include\d3dx9math.h(1308) : error C2011: 'ID3DXMatrixStack' : 'struct' type redefinition
c:\dx90sdk\include\d3dx9math.h(1741) : error C2061: syntax error : identifier 'LPDIRECT3DCUBETEXTURE9'
c:\dx90sdk\include\d3dx9math.inl(67) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(79) : error C2511: 'D3DXVECTOR2::D3DXVECTOR2' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx8math.h(43) : see declaration of 'D3DXVECTOR2'
c:\dx90sdk\include\d3dx9math.inl(90) : error C2084: function '__thiscall D3DXVECTOR2::D3DXVECTOR2(float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(98) : error C2084: function '__thiscall D3DXVECTOR2::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(104) : error C2084: function '__thiscall D3DXVECTOR2::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(111) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator +=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(119) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator -=(const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(127) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(135) : error C2084: function 'struct D3DXVECTOR2 &__thiscall D3DXVECTOR2::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(145) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(151) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(152) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(158) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator +(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(159) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(164) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator -(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(165) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(170) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(171) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(176) : error C2084: function 'struct D3DXVECTOR2 __thiscall D3DXVECTOR2::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(178) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(184) : error C2084: function 'struct D3DXVECTOR2 __cdecl operator *(float,const struct D3DXVECTOR2 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(185) : error C2264: 'D3DXVECTOR2::D3DXVECTOR2' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(190) : error C2084: function 'int __thiscall D3DXVECTOR2::operator ==(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(196) : error C2084: function 'int __thiscall D3DXVECTOR2::operator !=(const struct D3DXVECTOR2 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(267) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(280) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(const struct _D3DVECTOR &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(288) : error C2511: 'D3DXVECTOR3::D3DXVECTOR3' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx8math.h(86) : see declaration of 'D3DXVECTOR3'
c:\dx90sdk\include\d3dx9math.inl(299) : error C2084: function '__thiscall D3DXVECTOR3::D3DXVECTOR3(float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(309) : error C2084: function '__thiscall D3DXVECTOR3::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(315) : error C2084: function '__thiscall D3DXVECTOR3::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(323) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator +=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(332) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator -=(const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(341) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(350) : error C2084: function 'struct D3DXVECTOR3 &__thiscall D3DXVECTOR3::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(362) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(368) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(369) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(376) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator +(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(377) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(382) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator -(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(383) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(388) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(389) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(394) : error C2084: function 'struct D3DXVECTOR3 __thiscall D3DXVECTOR3::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(396) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(402) : error C2084: function 'struct D3DXVECTOR3 __cdecl operator *(float,const struct D3DXVECTOR3 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(403) : error C2264: 'D3DXVECTOR3::D3DXVECTOR3' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(409) : error C2084: function 'int __thiscall D3DXVECTOR3::operator ==(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(415) : error C2084: function 'int __thiscall D3DXVECTOR3::operator !=(const struct D3DXVECTOR3 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(499) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(513) : error C2511: 'D3DXVECTOR4::D3DXVECTOR4' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx8math.h(130) : see declaration of 'D3DXVECTOR4'
c:\dx90sdk\include\d3dx9math.inl(524) : error C2084: function '__thiscall D3DXVECTOR4::D3DXVECTOR4(float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(534) : error C2084: function '__thiscall D3DXVECTOR4::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(540) : error C2084: function '__thiscall D3DXVECTOR4::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(548) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator +=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(558) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator -=(const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(568) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator *=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(578) : error C2084: function 'struct D3DXVECTOR4 &__thiscall D3DXVECTOR4::operator /=(float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(591) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(597) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(598) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(605) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator +(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(606) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(611) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator -(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(612) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(617) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator *(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(618) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(623) : error C2084: function 'struct D3DXVECTOR4 __thiscall D3DXVECTOR4::operator /(float) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(625) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(631) : error C2084: function 'struct D3DXVECTOR4 __cdecl operator *(float,const struct D3DXVECTOR4 &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(632) : error C2264: 'D3DXVECTOR4::D3DXVECTOR4' : error in function definition or declaration; function not called
c:\dx90sdk\include\d3dx9math.inl(638) : error C2084: function 'int __thiscall D3DXVECTOR4::operator ==(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(644) : error C2084: function 'int __thiscall D3DXVECTOR4::operator !=(const struct D3DXVECTOR4 &) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(720) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const float *)' already has a body
c:\dx90sdk\include\d3dx9math.inl(731) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(const struct _D3DMATRIX &)' already has a body
c:\dx90sdk\include\d3dx9math.inl(737) : error C2511: 'D3DXMATRIX::D3DXMATRIX' : overloaded member function 'void (const struct D3DXFLOAT16 *)' not found in 'D3DXMATRIX'
c:\dx90sdk\include\d3dx8math.h(174) : see declaration of 'D3DXMATRIX'
c:\dx90sdk\include\d3dx9math.inl(751) : error C2084: function '__thiscall D3DXMATRIX::D3DXMATRIX(float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)' already has a body
c:\dx90sdk\include\d3dx9math.inl(763) : error C2084: function 'float &__thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int)' already has a body
c:\dx90sdk\include\d3dx9math.inl(769) : error C2084: function 'float __thiscall D3DXMATRIX::operator ()(unsigned int,unsigned int) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(777) : error C2084: function '__thiscall D3DXMATRIX::operator`float *'(void)' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : error C2084: function '__thiscall D3DXMATRIX::operator`const float *'(void) const' already has a body
c:\dx90sdk\include\d3dx9math.inl(783) : fatal error C1003: error count exceeds 100; stopping compilation
Error executing cl.exe.
<h3>Results</h3>
Zalla3D Base Class.lib - 714 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@@ -0,0 +1,100 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CharacterActionControl", "..\CharacterActionControl\CharacterActionControl.vcproj", "{40ED5612-AF42-4665-A994-5FE9DF7A6E03}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Effect", "..\effect\Effect.vcproj", "{B08E1F16-8219-4F90-BE5B-76B055215BA1}"
ProjectSection(ProjectDependencies) = postProject
{D2E30B37-4EB0-4554-B918-0FFB4B2844BA} = {D2E30B37-4EB0-4554-B918-0FFB4B2844BA}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GlobalScript", "..\GLOBALSCRIPT\GlobalScript.vcproj", "{A4A01C64-042F-471E-A1B9-A08B4BFB1359}"
ProjectSection(ProjectDependencies) = postProject
{30D487ED-F7EA-49F3-90E0-A1D5D8498E32} = {30D487ED-F7EA-49F3-90E0-A1D5D8498E32}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScriptEngine", "..\ScriptEngine\ScriptEngine.vcproj", "{30D487ED-F7EA-49F3-90E0-A1D5D8498E32}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SoundLib", "..\SoundLib\SoundLib.vcproj", "{F76B5963-D6DE-49E6-9F3E-80C6709C5346}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WorldCreator", "..\WorldCreator\WorldCreator.vcproj", "{F633AA39-39EB-4E88-A343-A1E9B823CB20}"
ProjectSection(ProjectDependencies) = postProject
{40ED5612-AF42-4665-A994-5FE9DF7A6E03} = {40ED5612-AF42-4665-A994-5FE9DF7A6E03}
{A08DF3CC-B092-4179-9B79-F915D5C3437E} = {A08DF3CC-B092-4179-9B79-F915D5C3437E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Zalla3D Base Class", "Zalla3D Base Class.vcproj", "{D2E30B37-4EB0-4554-B918-0FFB4B2844BA}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Zalla3D SceneClass", "..\Zallad3D SceneClass\Zalla3D SceneClass.vcproj", "{A08DF3CC-B092-4179-9B79-F915D5C3437E}"
ProjectSection(ProjectDependencies) = postProject
{F76B5963-D6DE-49E6-9F3E-80C6709C5346} = {F76B5963-D6DE-49E6-9F3E-80C6709C5346}
{B08E1F16-8219-4F90-BE5B-76B055215BA1} = {B08E1F16-8219-4F90-BE5B-76B055215BA1}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
For_WorldCreator = For_WorldCreator
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{40ED5612-AF42-4665-A994-5FE9DF7A6E03}.Debug.ActiveCfg = Debug|Win32
{40ED5612-AF42-4665-A994-5FE9DF7A6E03}.Debug.Build.0 = Debug|Win32
{40ED5612-AF42-4665-A994-5FE9DF7A6E03}.For_WorldCreator.ActiveCfg = Debug|Win32
{40ED5612-AF42-4665-A994-5FE9DF7A6E03}.For_WorldCreator.Build.0 = Debug|Win32
{40ED5612-AF42-4665-A994-5FE9DF7A6E03}.Release.ActiveCfg = Release|Win32
{40ED5612-AF42-4665-A994-5FE9DF7A6E03}.Release.Build.0 = Release|Win32
{B08E1F16-8219-4F90-BE5B-76B055215BA1}.Debug.ActiveCfg = Debug|Win32
{B08E1F16-8219-4F90-BE5B-76B055215BA1}.Debug.Build.0 = Debug|Win32
{B08E1F16-8219-4F90-BE5B-76B055215BA1}.For_WorldCreator.ActiveCfg = Release|Win32
{B08E1F16-8219-4F90-BE5B-76B055215BA1}.For_WorldCreator.Build.0 = Release|Win32
{B08E1F16-8219-4F90-BE5B-76B055215BA1}.Release.ActiveCfg = Release|Win32
{B08E1F16-8219-4F90-BE5B-76B055215BA1}.Release.Build.0 = Release|Win32
{A4A01C64-042F-471E-A1B9-A08B4BFB1359}.Debug.ActiveCfg = Debug|Win32
{A4A01C64-042F-471E-A1B9-A08B4BFB1359}.Debug.Build.0 = Debug|Win32
{A4A01C64-042F-471E-A1B9-A08B4BFB1359}.For_WorldCreator.ActiveCfg = Release|Win32
{A4A01C64-042F-471E-A1B9-A08B4BFB1359}.For_WorldCreator.Build.0 = Release|Win32
{A4A01C64-042F-471E-A1B9-A08B4BFB1359}.Release.ActiveCfg = Release|Win32
{A4A01C64-042F-471E-A1B9-A08B4BFB1359}.Release.Build.0 = Release|Win32
{30D487ED-F7EA-49F3-90E0-A1D5D8498E32}.Debug.ActiveCfg = Debug|Win32
{30D487ED-F7EA-49F3-90E0-A1D5D8498E32}.Debug.Build.0 = Debug|Win32
{30D487ED-F7EA-49F3-90E0-A1D5D8498E32}.For_WorldCreator.ActiveCfg = Release|Win32
{30D487ED-F7EA-49F3-90E0-A1D5D8498E32}.For_WorldCreator.Build.0 = Release|Win32
{30D487ED-F7EA-49F3-90E0-A1D5D8498E32}.Release.ActiveCfg = Release|Win32
{30D487ED-F7EA-49F3-90E0-A1D5D8498E32}.Release.Build.0 = Release|Win32
{F76B5963-D6DE-49E6-9F3E-80C6709C5346}.Debug.ActiveCfg = Debug|Win32
{F76B5963-D6DE-49E6-9F3E-80C6709C5346}.Debug.Build.0 = Debug|Win32
{F76B5963-D6DE-49E6-9F3E-80C6709C5346}.For_WorldCreator.ActiveCfg = Debug|Win32
{F76B5963-D6DE-49E6-9F3E-80C6709C5346}.For_WorldCreator.Build.0 = Debug|Win32
{F76B5963-D6DE-49E6-9F3E-80C6709C5346}.Release.ActiveCfg = Release|Win32
{F76B5963-D6DE-49E6-9F3E-80C6709C5346}.Release.Build.0 = Release|Win32
{F633AA39-39EB-4E88-A343-A1E9B823CB20}.Debug.ActiveCfg = Debug|Win32
{F633AA39-39EB-4E88-A343-A1E9B823CB20}.Debug.Build.0 = Debug|Win32
{F633AA39-39EB-4E88-A343-A1E9B823CB20}.For_WorldCreator.ActiveCfg = Release|Win32
{F633AA39-39EB-4E88-A343-A1E9B823CB20}.For_WorldCreator.Build.0 = Release|Win32
{F633AA39-39EB-4E88-A343-A1E9B823CB20}.Release.ActiveCfg = Release|Win32
{F633AA39-39EB-4E88-A343-A1E9B823CB20}.Release.Build.0 = Release|Win32
{D2E30B37-4EB0-4554-B918-0FFB4B2844BA}.Debug.ActiveCfg = Debug|Win32
{D2E30B37-4EB0-4554-B918-0FFB4B2844BA}.Debug.Build.0 = Debug|Win32
{D2E30B37-4EB0-4554-B918-0FFB4B2844BA}.For_WorldCreator.ActiveCfg = Release|Win32
{D2E30B37-4EB0-4554-B918-0FFB4B2844BA}.For_WorldCreator.Build.0 = Release|Win32
{D2E30B37-4EB0-4554-B918-0FFB4B2844BA}.Release.ActiveCfg = Release|Win32
{D2E30B37-4EB0-4554-B918-0FFB4B2844BA}.Release.Build.0 = Release|Win32
{A08DF3CC-B092-4179-9B79-F915D5C3437E}.Debug.ActiveCfg = Debug|Win32
{A08DF3CC-B092-4179-9B79-F915D5C3437E}.Debug.Build.0 = Debug|Win32
{A08DF3CC-B092-4179-9B79-F915D5C3437E}.For_WorldCreator.ActiveCfg = For_WorldCreator|Win32
{A08DF3CC-B092-4179-9B79-F915D5C3437E}.For_WorldCreator.Build.0 = For_WorldCreator|Win32
{A08DF3CC-B092-4179-9B79-F915D5C3437E}.Release.ActiveCfg = Release|Win32
{A08DF3CC-B092-4179-9B79-F915D5C3437E}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

Binary file not shown.

View File

@@ -0,0 +1,794 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="Zalla3D Base Class"
ProjectGUID="{0D5E2812-B8D4-4B9C-B4EA-8A319339EA9A}"
SccProjectName="&quot;$/Zalla3D Base Class&quot;, BAAAAAAA"
SccLocalPath=".">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\ZALLA3D BASECLASS;..\Effect;..\CHARACTERACTIONCONTROL;..\SoundLib;..\CaldronBase;..\Zallad3D SceneClass"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/Zalla3D Base Class.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Debug\Zalla3D_Base_Class.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1042"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\ZALLA3D BASECLASS;..\Effect;..\CHARACTERACTIONCONTROL;..\SoundLib;..\CaldronBase;..\Zallad3D SceneClass"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/Zalla3D Base Class.pch"
AssemblerOutput="2"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Release\Zalla3D_Base_Class.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1042"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="BaseGraphicsLayer.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="color.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="ConvertTexture.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="d3dfont.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="DeviceInput.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="DeviceInputError.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="dxutil.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="EnumD3D.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="Error.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="FastMath.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="FileLoad.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="FrameTimer.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="GlareTexture.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="GraphicLayerError.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="IMEFont.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="Intersection.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="matrix.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="RenderDevice.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="RenderEnvTexture.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="RenderTargetTexture.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="RenderTexture.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="RenderTextureMipmap.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="ShadowMap.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="Sphere.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="StateLog.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="Texture.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="TextureContainer.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="VertexBuffer.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="ViewCamera.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="WinInput.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="3DMath.h">
</File>
<File
RelativePath="BaseGraphicsLayer.h">
</File>
<File
RelativePath="color.h">
</File>
<File
RelativePath="ConvertTexture.h">
</File>
<File
RelativePath="d3dfont.h">
</File>
<File
RelativePath="dds.h">
</File>
<File
RelativePath="DebugClass.h">
</File>
<File
RelativePath="DeviceInput.h">
</File>
<File
RelativePath="DeviceInputError.h">
</File>
<File
RelativePath="dxutil.h">
</File>
<File
RelativePath="EnumD3D.h">
</File>
<File
RelativePath="Error.h">
</File>
<File
RelativePath="Exception.h">
</File>
<File
RelativePath="FastMath.h">
</File>
<File
RelativePath="FileLoad.h">
</File>
<File
RelativePath="FrameTimer.h">
</File>
<File
RelativePath="GlareTexture.h">
</File>
<File
RelativePath="GraphicLayerError.h">
</File>
<File
RelativePath="IMEFont.h">
</File>
<File
RelativePath="Intersection.h">
</File>
<File
RelativePath="list.h">
</File>
<File
RelativePath="MathBase.h">
</File>
<File
RelativePath="matrix.h">
</File>
<File
RelativePath="quaternion.h">
</File>
<File
RelativePath="queue.h">
</File>
<File
RelativePath="RenderDevice.h">
</File>
<File
RelativePath="RenderEnvTexture.h">
</File>
<File
RelativePath="RenderTargetTexture.h">
</File>
<File
RelativePath="RenderTexture.h">
</File>
<File
RelativePath="RenderTextureMipmap.h">
</File>
<File
RelativePath="ShadowMap.h">
</File>
<File
RelativePath="Sphere.h">
</File>
<File
RelativePath="StateLog.h">
</File>
<File
RelativePath="Texture.h">
</File>
<File
RelativePath="TextureContainer.h">
</File>
<File
RelativePath="VECTOR.h">
</File>
<File
RelativePath="Vertex.h">
</File>
<File
RelativePath="VertexBuffer.h">
</File>
<File
RelativePath="ViewCamera.h">
</File>
<File
RelativePath="WBValue.h">
</File>
<File
RelativePath="WinInput.h">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
}

View File

@@ -0,0 +1,9 @@
// color.cpp: implementation of the color class.
//
//////////////////////////////////////////////////////////////////////
#include "color.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,229 @@
#ifndef _COLOR_H
#define _COLOR_H
#include "MathBase.h"
#pragma warning( disable : 4244 )
struct color
{
union{
struct
{
COLORVALUE b,g,r,a;
};
long c;
};
color(){};
color(COLORVALUE inr,COLORVALUE ing,COLORVALUE inb,COLORVALUE ina=255)
{
r=inr;
g=ing;
b=inb;
a=ina;
};
static color Interpolation(color FirstColor,color LastColor,float fInterval)
{
color resultColor;
if(fInterval>1.0f)
fInterval=fInterval-(int)fInterval;
int ElementColor;
int IntervalColor;
ElementColor=LastColor.r-FirstColor.r;
IntervalColor=((float)ElementColor*fInterval);
resultColor.r=FirstColor.r+IntervalColor;
ElementColor=LastColor.g-FirstColor.g;
IntervalColor=((float)ElementColor*fInterval);
resultColor.g=FirstColor.g+IntervalColor;
ElementColor=LastColor.b-FirstColor.b;
IntervalColor=((float)ElementColor*fInterval);
resultColor.b=FirstColor.b+IntervalColor;
ElementColor=LastColor.a-FirstColor.a;
IntervalColor=((float)ElementColor*fInterval);
resultColor.a=FirstColor.a+IntervalColor;
return resultColor;
};
color& operator += ( const color& in );
color& operator -= ( const color& in );
color& operator *= ( const color& in );
color& operator /= ( const color& in );
color& operator *= ( const float& in );
color& operator /= ( const float& in );
};
inline color& color::operator += ( const color& in )
{
r += in.r;
g += in.g;
b += in.b;
a += in.a;
return *this;
}
inline color& color::operator -= ( const color& in )
{
r -= in.r;
g -= in.g;
b -= in.b;
a -= in.a;
return *this;
}
inline color& color::operator *= ( const color& in )
{
r *= in.r;
g *= in.g;
b *= in.b;
a *= in.a;
return *this;
}
inline color& color::operator /= ( const color& in )
{
r /= in.r;
g /= in.g;
b /= in.b;
a /= in.a;
return *this;
}
inline color& color::operator *= ( const float& in )
{
r *= in;
g *= in;
b *= in;
a *= in;
return *this;
}
inline color& color::operator /= ( const float& in )
{
float inv = 1.f / in;
r *= inv;
g *= inv;
b *= inv;
a *= inv;
return *this;
}
inline color operator+(color const &a, color const &b)
{
COLORVALUE inr,ing,inb,ina;
if(a.r+b.r > 0xff)
inr=0xff;
else
inr=a.r+b.r;
if(a.g+b.g > 0xff)
ing=0xff;
else
ing=a.g+b.g;
if(a.b+b.b > 0xff)
inb=0xff;
else
inb=a.b+b.b;
if(a.a+b.a > 0xff)
ina=0xff;
else
ina=a.a+b.a;
return color(inr,ing,inb,ina);
};
inline color operator-(color const &a, color const &b)
{
return color
(
a.r-b.r,
a.g-b.g,
a.b-b.b,
a.a-b.a
);
};
inline color operator*(color const &a, float const &b)
{
return color
(
a.r*b,
a.g*b,
a.b*b,
a.a*b
);
};
/**
* Scales a color by a float : ret = a * b
*/
inline color operator*(float const &a, color const &b)
{
return color
(
a*b.r,
a*b.g,
a*b.b,
a*b.a
);
};
/**
* Divides a color by a float : ret = a / b
*/
inline color operator/(color const &a, float const &b)
{
float inv = 1.f / b;
return color
(
a.r*inv,
a.g*inv,
a.b*inv,
a.a*inv
);
};
/**
* Divides a color by a color (piecewise): ret = a / b
*/
inline color operator/(color const &a, color const &b)
{
return color
(
a.r / b.r,
a.g / b.g,
a.b / b.b,
a.a / b.a
);
};
/**
* Multiplies a color by a color (piecewise): ret = a / b
*/
inline color operator*(color const &a, color const &b)
{
return color
(
a.r * b.r,
a.g * b.g,
a.b * b.b,
a.a * b.a
);
};
/**
* color Equality, epsilon used due to numerical imprecision
*/
inline bool operator==(color const &a, color const &b)
{
if(abs(a.r-b.r)<EPSILON)
if(abs(a.g-b.g)<EPSILON)
if(abs(a.b-b.b)<EPSILON)
if(abs(a.a-b.a)<EPSILON)
return true;
return false;
};
#endif

View File

@@ -0,0 +1,664 @@
//-----------------------------------------------------------------------------
// File: D3DFont.cpp
//
// Desc: Texture-based font class
//
// Copyright (c) 1999-2000 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <stdio.h>
#include <tchar.h>
#include <D3DX8.h>
#include "D3DFont.h"
#include "SceneStateMgr.h"
//#include "D3DUtil.h"
//#include "DXUtil.h"
//-----------------------------------------------------------------------------
// Custom vertex types for rendering text
//-----------------------------------------------------------------------------
#define MAX_NUM_VERTICES 50*6
struct FONT2DVERTEX { D3DXVECTOR4 p; DWORD color; FLOAT tu, tv; };
struct FONT3DVERTEX { D3DXVECTOR3 p; D3DXVECTOR3 n; FLOAT tu, tv; };
#define D3DFVF_FONT2DVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1)
#define D3DFVF_FONT3DVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
inline FONT2DVERTEX InitFont2DVertex( const D3DXVECTOR4& p, D3DCOLOR color,
FLOAT tu, FLOAT tv )
{
FONT2DVERTEX v; v.p = p; v.color = color; v.tu = tu; v.tv = tv;
return v;
}
inline FONT3DVERTEX InitFont3DVertex( const D3DXVECTOR3& p, const D3DXVECTOR3& n,
FLOAT tu, FLOAT tv )
{
FONT3DVERTEX v; v.p = p; v.n = n; v.tu = tu; v.tv = tv;
return v;
}
//-----------------------------------------------------------------------------
// Name: CD3DFont()
// Desc: Font class constructor
//-----------------------------------------------------------------------------
CD3DFont::CD3DFont( TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags )
{
_tcscpy( m_strFontName, strFontName );
m_dwFontHeight = dwHeight;
m_dwFontFlags = dwFlags;
m_pd3dDevice = NULL;
m_pTexture = NULL;
m_pVB = NULL;
m_dwSavedStateBlock = 0L;
m_dwDrawTextStateBlock = 0L;
}
//-----------------------------------------------------------------------------
// Name: ~CD3DFont()
// Desc: Font class destructor
//-----------------------------------------------------------------------------
CD3DFont::~CD3DFont()
{
InvalidateDeviceObjects();
DeleteDeviceObjects();
}
//-----------------------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: Initializes device-dependent objects, including the vertex buffer used
// for rendering text and the texture map which stores the font image.
//-----------------------------------------------------------------------------
HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice )
{
HRESULT hr;
// Keep a local copy of the device
m_pd3dDevice = pd3dDevice;
// Establish the font and texture size
m_fTextScale = 1.0f; // Draw fonts into texture without scaling
// Large fonts need larger textures
if( m_dwFontHeight > 40 )
m_dwTexWidth = m_dwTexHeight = 1024;
else if( m_dwFontHeight > 20 )
m_dwTexWidth = m_dwTexHeight = 512;
else
m_dwTexWidth = m_dwTexHeight = 256;
// If requested texture is too big, use a smaller texture and smaller font,
// and scale up when rendering.
D3DCAPS8 d3dCaps;
m_pd3dDevice->GetDeviceCaps( &d3dCaps );
if( m_dwTexWidth > d3dCaps.MaxTextureWidth )
{
m_fTextScale = (FLOAT)d3dCaps.MaxTextureWidth / (FLOAT)m_dwTexWidth;
m_dwTexWidth = m_dwTexHeight = d3dCaps.MaxTextureWidth;
}
// Create a new texture for the font
hr = m_pd3dDevice->CreateTexture( m_dwTexWidth, m_dwTexHeight, 1,
0, D3DFMT_A4R4G4B4,
D3DPOOL_MANAGED, &m_pTexture );
if( FAILED(hr) )
return hr;
// Prepare to create a bitmap
DWORD* pBitmapBits;
BITMAPINFO bmi;
ZeroMemory( &bmi.bmiHeader, sizeof(BITMAPINFOHEADER) );
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = (int)m_dwTexWidth;
bmi.bmiHeader.biHeight = -(int)m_dwTexHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biBitCount = 32;
// Create a DC and a bitmap for the font
HDC hDC = CreateCompatibleDC( NULL );
HBITMAP hbmBitmap = CreateDIBSection( hDC, &bmi, DIB_RGB_COLORS,
(VOID**)&pBitmapBits, NULL, 0 );
SetMapMode( hDC, MM_TEXT );
// Create a font. By specifying ANTIALIASED_QUALITY, we might get an
// antialiased font, but this is not guaranteed.
INT nHeight = -MulDiv( m_dwFontHeight,
(INT)(GetDeviceCaps(hDC, LOGPIXELSY) * m_fTextScale), 72 );
DWORD dwBold = (m_dwFontFlags&D3DFONT_BOLD) ? FW_BOLD : FW_NORMAL;
DWORD dwItalic = (m_dwFontFlags&D3DFONT_ITALIC) ? TRUE : FALSE;
HFONT hFont = CreateFont( nHeight, 0, 0, 0, dwBold, dwItalic,
FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
VARIABLE_PITCH, m_strFontName );
if( NULL==hFont )
return E_FAIL;
SelectObject( hDC, hbmBitmap );
SelectObject( hDC, hFont );
// Set text properties
SetTextColor( hDC, RGB(255,255,255) );
SetBkColor( hDC, 0x00000000 );
SetTextAlign( hDC, TA_TOP );
// Loop through all printable character and output them to the bitmap..
// Meanwhile, keep track of the corresponding tex coords for each character.
DWORD x = 0;
DWORD y = 0;
TCHAR str[2] = _T("x");
SIZE size;
for( TCHAR c=32; c<127; c++ )
{
str[0] = c;
GetTextExtentPoint32( hDC, str, 1, &size );
if( (DWORD)(x+size.cx+1) > m_dwTexWidth )
{
x = 0;
y += size.cy+1;
}
ExtTextOut( hDC, x+0, y+0, ETO_OPAQUE, NULL, str, 1, NULL );
m_fTexCoords[c-32][0] = ((FLOAT)(x+0))/m_dwTexWidth;
m_fTexCoords[c-32][1] = ((FLOAT)(y+0))/m_dwTexHeight;
m_fTexCoords[c-32][2] = ((FLOAT)(x+0+size.cx))/m_dwTexWidth;
m_fTexCoords[c-32][3] = ((FLOAT)(y+0+size.cy))/m_dwTexHeight;
x += size.cx+1;
}
// Lock the surface and write the alpha values for the set pixels
D3DLOCKED_RECT d3dlr;
m_pTexture->LockRect( 0, &d3dlr, 0, 0 );
WORD* pDst16 = (WORD*)d3dlr.pBits;
BYTE bAlpha; // 4-bit measure of pixel intensity
for( y=0; y < m_dwTexHeight; y++ )
{
for( x=0; x < m_dwTexWidth; x++ )
{
bAlpha = (BYTE)((pBitmapBits[m_dwTexWidth*y + x] & 0xff) >> 4);
if (bAlpha > 0)
{
*pDst16++ = (bAlpha << 12) | 0x0fff;
}
else
{
*pDst16++ = 0x0000;
}
}
}
// Done updating texture, so clean up used objects
m_pTexture->UnlockRect(0);
DeleteObject( hbmBitmap );
DeleteDC( hDC );
DeleteObject( hFont );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: RestoreDeviceObjects()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CD3DFont::RestoreDeviceObjects()
{
HRESULT hr;
// Create vertex buffer for the letters
if( FAILED( hr = m_pd3dDevice->CreateVertexBuffer( MAX_NUM_VERTICES*sizeof(FONT2DVERTEX),
D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
D3DPOOL_DEFAULT, &m_pVB ) ) )
{
return hr;
}
// Create the state blocks for rendering text
for( UINT which=0; which<2; which++ )
{
m_pd3dDevice->BeginStateBlock();
m_pd3dDevice->SetTexture( 0, m_pTexture );
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
CSceneStateMgr::_SetD3DRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHATESTENABLE, TRUE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHAREF, 0x08 );
CSceneStateMgr::_SetD3DRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
CSceneStateMgr::_SetD3DRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
CSceneStateMgr::_SetD3DRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
CSceneStateMgr::_SetD3DRenderState( D3DRS_ZENABLE, FALSE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_STENCILENABLE, FALSE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_CLIPPING, TRUE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_EDGEANTIALIAS, FALSE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_CLIPPLANEENABLE, FALSE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_VERTEXBLEND, FALSE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE );
CSceneStateMgr::_SetD3DRenderState( D3DRS_FOGENABLE, FALSE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_POINT );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_POINT );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_NONE );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
CSceneStateMgr::_SetD3DTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
CSceneStateMgr::_SetD3DTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
if( which==0 )
m_pd3dDevice->EndStateBlock( &m_dwSavedStateBlock );
else
m_pd3dDevice->EndStateBlock( &m_dwDrawTextStateBlock );
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InvalidateDeviceObjects()
// Desc: Destroys all device-dependent objects
//-----------------------------------------------------------------------------
HRESULT CD3DFont::InvalidateDeviceObjects()
{
if(m_pVB!=NULL)
{
m_pVB->Release();
m_pVB=NULL;
}
// Delete the state blocks
if( m_pd3dDevice )
{
if( m_dwSavedStateBlock )
m_pd3dDevice->DeleteStateBlock( m_dwSavedStateBlock );
if( m_dwDrawTextStateBlock )
m_pd3dDevice->DeleteStateBlock( m_dwDrawTextStateBlock );
}
m_dwSavedStateBlock = 0L;
m_dwDrawTextStateBlock = 0L;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DeleteDeviceObjects()
// Desc: Destroys all device-dependent objects
//-----------------------------------------------------------------------------
HRESULT CD3DFont::DeleteDeviceObjects()
{
if(m_pTexture)
{
m_pTexture->Release();
m_pTexture=NULL;
}
m_pd3dDevice = NULL;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: GetTextExtent()
// Desc: Get the dimensions of a text string
//-----------------------------------------------------------------------------
HRESULT CD3DFont::GetTextExtent( TCHAR* strText, SIZE* pSize )
{
if( NULL==strText || NULL==pSize )
return E_FAIL;
FLOAT fRowWidth = 0.0f;
FLOAT fRowHeight = (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight;
FLOAT fWidth = 0.0f;
FLOAT fHeight = fRowHeight;
while( *strText )
{
TCHAR c = *strText++;
if( c == _T('\n') )
{
fRowWidth = 0.0f;
fHeight += fRowHeight;
}
if( c < _T(' ') )
continue;
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT tx2 = m_fTexCoords[c-32][2];
fRowWidth += (tx2-tx1)*m_dwTexWidth;
if( fRowWidth > fWidth )
fWidth = fRowWidth;
}
pSize->cx = (int)fWidth;
pSize->cy = (int)fHeight;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DrawTextScaled()
// Desc: Draws scaled 2D text. Note that x and y are in viewport coordinates
// (ranging from -1 to +1). fXScale and fYScale are the size fraction
// relative to the entire viewport. For example, a fXScale of 0.25 is
// 1/8th of the screen width. This allows you to output text at a fixed
// fraction of the viewport, even if the screen or window size changes.
//-----------------------------------------------------------------------------
HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
TCHAR* strText, DWORD dwFlags )
{
if( m_pd3dDevice == NULL )
return E_FAIL;
// Set up renderstate
m_pd3dDevice->CaptureStateBlock( m_dwSavedStateBlock );
m_pd3dDevice->ApplyStateBlock( m_dwDrawTextStateBlock );
m_pd3dDevice->SetVertexShader( D3DFVF_FONT2DVERTEX );
m_pd3dDevice->SetStreamSource( 0, m_pVB, sizeof(FONT2DVERTEX) );
// Set filter states
if( dwFlags & D3DFONT_FILTERED )
{
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
}
D3DVIEWPORT8 vp;
m_pd3dDevice->GetViewport( &vp );
FLOAT sx = (x+1.0f)*vp.Width/2;
FLOAT sy = (y-1.0f)*vp.Height/2;
FLOAT sz = z;
FLOAT rhw = 1.0f;
FLOAT fStartX = sx;
FLOAT fLineHeight = ( m_fTexCoords[0][3] - m_fTexCoords[0][1] ) * m_dwTexHeight;
// Fill vertex buffer
FONT2DVERTEX* pVertices;
DWORD dwNumTriangles = 0L;
m_pVB->Lock( 0, 0, (BYTE**)&pVertices, D3DLOCK_DISCARD );
while( *strText )
{
TCHAR c = *strText++;
if( c == _T('\n') )
{
sx = fStartX;
sy += fYScale*vp.Height;
}
if( c < _T(' ') )
continue;
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT ty1 = m_fTexCoords[c-32][1];
FLOAT tx2 = m_fTexCoords[c-32][2];
FLOAT ty2 = m_fTexCoords[c-32][3];
FLOAT w = (tx2-tx1)*m_dwTexWidth;
FLOAT h = (ty2-ty1)*m_dwTexHeight;
w *= (fXScale*vp.Height)/fLineHeight;
h *= (fYScale*vp.Height)/fLineHeight;
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx1, ty2 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx1, ty1 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx2, ty2 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx2, ty1 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx2, ty2 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx1, ty1 );
dwNumTriangles += 2;
if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) )
{
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
m_pVB->Lock( 0, 0, (BYTE**)&pVertices, D3DLOCK_DISCARD );
dwNumTriangles = 0L;
}
sx += w;
}
// Unlock and render the vertex buffer
m_pVB->Unlock();
if( dwNumTriangles > 0 )
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
// Restore the modified renderstates
m_pd3dDevice->ApplyStateBlock( m_dwSavedStateBlock );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DrawText()
// Desc: Draws 2D text
//-----------------------------------------------------------------------------
HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
TCHAR* strText, DWORD dwFlags )
{
if( m_pd3dDevice == NULL )
return E_FAIL;
// Setup renderstate
m_pd3dDevice->CaptureStateBlock( m_dwSavedStateBlock );
m_pd3dDevice->ApplyStateBlock( m_dwDrawTextStateBlock );
m_pd3dDevice->SetVertexShader( D3DFVF_FONT2DVERTEX );
m_pd3dDevice->SetStreamSource( 0, m_pVB, sizeof(FONT2DVERTEX) );
// Set filter states
if( dwFlags & D3DFONT_FILTERED )
{
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
}
FLOAT fStartX = sx;
// Fill vertex buffer
FONT2DVERTEX* pVertices = NULL;
DWORD dwNumTriangles = 0;
m_pVB->Lock( 0, 0, (BYTE**)&pVertices, D3DLOCK_DISCARD );
while( *strText )
{
TCHAR c = *strText++;
if( c == _T('\n') )
{
sx = fStartX;
sy += (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight;
}
if( c < _T(' ') )
continue;
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT ty1 = m_fTexCoords[c-32][1];
FLOAT tx2 = m_fTexCoords[c-32][2];
FLOAT ty2 = m_fTexCoords[c-32][3];
FLOAT w = (tx2-tx1) * m_dwTexWidth / m_fTextScale;
FLOAT h = (ty2-ty1) * m_dwTexHeight / m_fTextScale;
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx1, ty2 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx1, ty1 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx2, ty2 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx2, ty1 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx2, ty2 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx1, ty1 );
dwNumTriangles += 2;
if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) )
{
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
pVertices = NULL;
m_pVB->Lock( 0, 0, (BYTE**)&pVertices, D3DLOCK_DISCARD );
dwNumTriangles = 0L;
}
sx += w;
}
// Unlock and render the vertex buffer
m_pVB->Unlock();
if( dwNumTriangles > 0 )
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
// Restore the modified renderstates
m_pd3dDevice->ApplyStateBlock( m_dwSavedStateBlock );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: Render3DText()
// Desc: Renders 3D text
//-----------------------------------------------------------------------------
HRESULT CD3DFont::Render3DText( TCHAR* strText, DWORD dwFlags )
{
if( m_pd3dDevice == NULL )
return E_FAIL;
// Setup renderstate
m_pd3dDevice->CaptureStateBlock( m_dwSavedStateBlock );
m_pd3dDevice->ApplyStateBlock( m_dwDrawTextStateBlock );
m_pd3dDevice->SetVertexShader( D3DFVF_FONT3DVERTEX );
m_pd3dDevice->SetStreamSource( 0, m_pVB, sizeof(FONT3DVERTEX) );
// Set filter states
if( dwFlags & D3DFONT_FILTERED )
{
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
CSceneStateMgr::_SetD3DTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
}
// Position for each text element
FLOAT x = 0.0f;
FLOAT y = 0.0f;
// Center the text block at the origin
if( dwFlags & D3DFONT_CENTERED )
{
SIZE sz;
GetTextExtent( strText, &sz );
x = -(((FLOAT)sz.cx)/10.0f)/2.0f;
y = -(((FLOAT)sz.cy)/10.0f)/2.0f;
}
// Turn off culling for two-sided text
if( dwFlags & D3DFONT_TWOSIDED )
CSceneStateMgr::_SetD3DRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
FLOAT fStartX = x;
TCHAR c;
// Fill vertex buffer
FONT3DVERTEX* pVertices;
DWORD dwVertex = 0L;
DWORD dwNumTriangles = 0L;
m_pVB->Lock( 0, 0, (BYTE**)&pVertices, D3DLOCK_DISCARD );
while( c = *strText++ )
{
if( c == '\n' )
{
x = fStartX;
y -= (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight/10.0f;
}
if( c < 32 )
continue;
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT ty1 = m_fTexCoords[c-32][1];
FLOAT tx2 = m_fTexCoords[c-32][2];
FLOAT ty2 = m_fTexCoords[c-32][3];
FLOAT w = (tx2-tx1) * m_dwTexWidth / ( 10.0f * m_fTextScale );
FLOAT h = (ty2-ty1) * m_dwTexHeight / ( 10.0f * m_fTextScale );
*pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+0,0), D3DXVECTOR3(0,0,-1), tx1, ty2 );
*pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 );
*pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 );
*pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+h,0), D3DXVECTOR3(0,0,-1), tx2, ty1 );
*pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 );
*pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 );
dwNumTriangles += 2;
if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) )
{
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
m_pVB->Lock( 0, 0, (BYTE**)&pVertices, D3DLOCK_DISCARD );
dwNumTriangles = 0L;
}
x += w;
}
// Unlock and render the vertex buffer
m_pVB->Unlock();
if( dwNumTriangles > 0 )
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
// Restore the modified renderstates
m_pd3dDevice->ApplyStateBlock( m_dwSavedStateBlock );
return S_OK;
}

View File

@@ -0,0 +1,77 @@
//-----------------------------------------------------------------------------
// File: D3DFont.h
//
// Desc: Texture-based font class
//
// Copyright (c) 1999-2000 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#ifndef D3DFONT_H
#define D3DFONT_H
#include <tchar.h>
#include <D3D8.h>
// Font creation flags
#define D3DFONT_BOLD 0x0001
#define D3DFONT_ITALIC 0x0002
// Font rendering flags
#define D3DFONT_CENTERED 0x0001
#define D3DFONT_TWOSIDED 0x0002
#define D3DFONT_FILTERED 0x0004
//-----------------------------------------------------------------------------
// Name: class CD3DFont
// Desc: Texture-based font class for doing text in a 3D scene.
//-----------------------------------------------------------------------------
class CD3DFont
{
TCHAR m_strFontName[80]; // Font properties
DWORD m_dwFontHeight;
DWORD m_dwFontFlags;
LPDIRECT3DDEVICE8 m_pd3dDevice; // A D3DDevice used for rendering
LPDIRECT3DTEXTURE8 m_pTexture; // The d3d texture for this font
LPDIRECT3DVERTEXBUFFER8 m_pVB; // VertexBuffer for rendering text
DWORD m_dwTexWidth; // Texture dimensions
DWORD m_dwTexHeight;
FLOAT m_fTextScale;
FLOAT m_fTexCoords[128-32][4];
// Stateblocks for setting and restoring render states
DWORD m_dwSavedStateBlock;
DWORD m_dwDrawTextStateBlock;
public:
// 2D and 3D text drawing functions
HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor,
TCHAR* strText, DWORD dwFlags=0L );
HRESULT DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
TCHAR* strText, DWORD dwFlags=0L );
HRESULT Render3DText( TCHAR* strText, DWORD dwFlags=0L );
// Function to get extent of text
HRESULT GetTextExtent( TCHAR* strText, SIZE* pSize );
// Initializing and destroying device-dependent objects
HRESULT InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice );
HRESULT RestoreDeviceObjects();
HRESULT InvalidateDeviceObjects();
HRESULT DeleteDeviceObjects();
// Constructor / destructor
CD3DFont( TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
~CD3DFont();
};
#endif

View File

@@ -0,0 +1,100 @@
// dds.h
//
// This header defines constants and structures that are useful when parsing
// DDS files. DDS files were originally designed to use several structures
// and constants that are native to DirectDraw and are defined in ddraw.h,
// such as DDSURFACEDESC2 and DDSCAPS2. This file defines similar
// (compatible) constants and structures so that one can use DDS files
// without needing to include ddraw.h.
#ifndef _DDS_H_
#define _DDS_H_
struct DDS_PIXELFORMAT
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwFourCC;
DWORD dwRGBBitCount;
DWORD dwRBitMask;
DWORD dwGBitMask;
DWORD dwBBitMask;
DWORD dwABitMask;
};
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
#define DDS_RGB 0x00000040 // DDPF_RGB
#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
const DDS_PIXELFORMAT DDSPF_DXT1 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
const DDS_PIXELFORMAT DDSPF_DXT2 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 };
const DDS_PIXELFORMAT DDSPF_DXT3 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 };
const DDS_PIXELFORMAT DDSPF_DXT4 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 };
const DDS_PIXELFORMAT DDSPF_DXT5 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 };
const DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
const DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00007c00, 0x000003e0, 0x0000001f, 0x00008000 };
const DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0000f000, 0x000000f0, 0x0000000f, 0x0000f000 };
const DDS_PIXELFORMAT DDSPF_R8G8B8 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 };
const DDS_PIXELFORMAT DDSPF_R5G6B5 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 };
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
#define DDS_SURFACE_FLAGS_MIPMAP 0x00400008 // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
#define DDS_SURFACE_FLAGS_CUBEMAP 0x00000008 // DDSCAPS_COMPLEX
#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
#define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY
#define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY
#define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ
#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ
#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\
DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\
DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ )
#define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME
struct DDS_HEADER
{
DWORD dwSize;
DWORD dwHeaderFlags;
DWORD dwHeight;
DWORD dwWidth;
DWORD dwPitchOrLinearSize;
DWORD dwDepth; // only if DDS_HEADER_FLAGS_VOLUME is set in dwHeaderFlags
DWORD dwMipMapCount;
DWORD dwReserved1[11];
DDS_PIXELFORMAT ddspf;
DWORD dwSurfaceFlags;
DWORD dwCubemapFlags;
DWORD dwReserved2[3];
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,171 @@
//-----------------------------------------------------------------------------
// File: DSUtil.h
//
// Desc:
//
// Copyright (c) 1999-2000 Microsoft Corp. All rights reserved.
//-----------------------------------------------------------------------------
#ifndef DSUTIL_H
#define DSUTIL_H
#include <windows.h>
#include <mmsystem.h>
#include <mmreg.h>
#include <dsound.h>
//-----------------------------------------------------------------------------
// Classes used by this header
//-----------------------------------------------------------------------------
class CSoundManager;
class CSound;
class CStreamingSound;
class CWaveFile;
//-----------------------------------------------------------------------------
// Typing macros
//-----------------------------------------------------------------------------
#define WAVEFILE_READ 1
#define WAVEFILE_WRITE 2
#define DSUtil_StopSound(s) { if(s) s->Stop(); }
#define DSUtil_PlaySound(s) { if(s) s->Play( 0, 0 ); }
#define DSUtil_PlaySoundLooping(s) { if(s) s->Play( 0, DSBPLAY_LOOPING ); }
//-----------------------------------------------------------------------------
// Name: class CSoundManager
// Desc:
//-----------------------------------------------------------------------------
class CSoundManager
{
protected:
LPDIRECTSOUND8 m_pDS;
public:
CSoundManager();
~CSoundManager();
HRESULT Initialize( HWND hWnd, DWORD dwCoopLevel, DWORD dwPrimaryChannels, DWORD dwPrimaryFreq, DWORD dwPrimaryBitRate );
inline LPDIRECTSOUND8 GetDirectSound() { return m_pDS; }
HRESULT SetPrimaryBufferFormat( DWORD dwPrimaryChannels, DWORD dwPrimaryFreq, DWORD dwPrimaryBitRate );
HRESULT Get3DListenerInterface( LPDIRECTSOUND3DLISTENER* ppDSListener );
HRESULT Create( CSound** ppSound, LPTSTR strWaveFileName, DWORD dwCreationFlags = 0, GUID guid3DAlgorithm = GUID_NULL, DWORD dwNumBuffers = 1 );
HRESULT CreateFromMemory( CSound** ppSound, BYTE* pbData, ULONG ulDataSize, LPWAVEFORMATEX pwfx, DWORD dwCreationFlags = 0, GUID guid3DAlgorithm = GUID_NULL, DWORD dwNumBuffers = 1 );
HRESULT CreateStreaming( CStreamingSound** ppStreamingSound, LPTSTR strWaveFileName, DWORD dwCreationFlags, GUID guid3DAlgorithm, DWORD dwNotifyCount, DWORD dwNotifySize, HANDLE hNotifyEvent );
};
//-----------------------------------------------------------------------------
// Name: class CSound
// Desc: Encapsulates functionality of a DirectSound buffer.
//-----------------------------------------------------------------------------
class CSound
{
protected:
LPDIRECTSOUNDBUFFER* m_apDSBuffer;
DWORD m_dwDSBufferSize;
CWaveFile* m_pWaveFile;
DWORD m_dwNumBuffers;
HRESULT RestoreBuffer( LPDIRECTSOUNDBUFFER pDSB, BOOL* pbWasRestored );
public:
CSound( LPDIRECTSOUNDBUFFER* apDSBuffer, DWORD dwDSBufferSize, DWORD dwNumBuffers, CWaveFile* pWaveFile );
virtual ~CSound();
HRESULT Get3DBufferInterface( DWORD dwIndex, LPDIRECTSOUND3DBUFFER* ppDS3DBuffer );
HRESULT FillBufferWithSound( LPDIRECTSOUNDBUFFER pDSB, BOOL bRepeatWavIfBufferLarger );
LPDIRECTSOUNDBUFFER GetFreeBuffer();
LPDIRECTSOUNDBUFFER GetBuffer( DWORD dwIndex );
HRESULT Play( DWORD dwPriority, DWORD dwFlags );
HRESULT Stop();
HRESULT Reset();
BOOL IsSoundPlaying();
};
//-----------------------------------------------------------------------------
// Name: class CStreamingSound
// Desc: Encapsulates functionality to play a wave file with DirectSound.
// The Create() method loads a chunk of wave file into the buffer,
// and as sound plays more is written to the buffer by calling
// HandleWaveStreamNotification() whenever hNotifyEvent is signaled.
//-----------------------------------------------------------------------------
class CStreamingSound : public CSound
{
protected:
DWORD m_dwLastPlayPos;
DWORD m_dwPlayProgress;
DWORD m_dwNotifySize;
DWORD m_dwNextWriteOffset;
BOOL m_bFillNextNotificationWithSilence;
public:
CStreamingSound( LPDIRECTSOUNDBUFFER pDSBuffer, DWORD dwDSBufferSize, CWaveFile* pWaveFile, DWORD dwNotifySize );
~CStreamingSound();
HRESULT HandleWaveStreamNotification( BOOL bLoopedPlay );
HRESULT Reset();
};
//-----------------------------------------------------------------------------
// Name: class CWaveFile
// Desc: Encapsulates reading or writing sound data to or from a wave file
//-----------------------------------------------------------------------------
class CWaveFile
{
public:
WAVEFORMATEX* m_pwfx; // Pointer to WAVEFORMATEX structure
HMMIO m_hmmio; // MM I/O handle for the WAVE
MMCKINFO m_ck; // Multimedia RIFF chunk
MMCKINFO m_ckRiff; // Use in opening a WAVE file
DWORD m_dwSize; // The size of the wave file
MMIOINFO m_mmioinfoOut;
DWORD m_dwFlags;
BOOL m_bIsReadingFromMemory;
BYTE* m_pbData;
BYTE* m_pbDataCur;
ULONG m_ulDataSize;
CHAR* m_pResourceBuffer;
protected:
HRESULT ReadMMIO();
HRESULT WriteMMIO( WAVEFORMATEX *pwfxDest );
public:
CWaveFile();
~CWaveFile();
HRESULT Open( LPTSTR strFileName, WAVEFORMATEX* pwfx, DWORD dwFlags );
HRESULT OpenFromMemory( BYTE* pbData, ULONG ulDataSize, WAVEFORMATEX* pwfx, DWORD dwFlags );
HRESULT Close();
HRESULT Read( BYTE* pBuffer, DWORD dwSizeToRead, DWORD* pdwSizeRead );
HRESULT Write( UINT nSizeToWrite, BYTE* pbData, UINT* pnSizeWrote );
DWORD GetSize();
HRESULT ResetFile();
WAVEFORMATEX* GetFormat() { return m_pwfx; };
};
#endif // DSUTIL_H

View File

@@ -0,0 +1,616 @@
//-----------------------------------------------------------------------------
// File: DXUtil.cpp
//
// Desc: Shortcut macros and functions for using DX objects
//
//
// Copyright (c) 1997-2000 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#include <windows.h>
#include <mmsystem.h>
#include <tchar.h>
#include <stdio.h>
#include <stdarg.h>
#include "DXUtil.h"
//-----------------------------------------------------------------------------
// Name: DXUtil_GetDXSDKMediaPath()
// Desc: Returns the DirectX SDK media path
//-----------------------------------------------------------------------------
const TCHAR* DXUtil_GetDXSDKMediaPath()
{
static TCHAR strNull[2] = _T("");
static TCHAR strPath[MAX_PATH];
DWORD dwType;
DWORD dwSize = MAX_PATH;
HKEY hKey;
// Open the appropriate registry key
LONG lResult = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
_T("Software\\Microsoft\\DirectX"),
0, KEY_READ, &hKey );
if( ERROR_SUCCESS != lResult )
return strNull;
lResult = RegQueryValueEx( hKey, _T("DX8SDK Samples Path"), NULL,
&dwType, (BYTE*)strPath, &dwSize );
RegCloseKey( hKey );
if( ERROR_SUCCESS != lResult )
return strNull;
_tcscat( strPath, _T("\\Media\\") );
return strPath;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_FindMediaFile()
// Desc: Returns a valid path to a DXSDK media file
//-----------------------------------------------------------------------------
HRESULT DXUtil_FindMediaFile( TCHAR* strPath, TCHAR* strFilename )
{
HANDLE file;
if( NULL==strFilename || NULL==strPath )
return E_INVALIDARG;
// Check if the file exists in the current directory
_tcscpy( strPath, strFilename );
file = CreateFile( strPath, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL );
if( INVALID_HANDLE_VALUE != file )
{
CloseHandle( file );
return S_OK;
}
// Check if the file exists in the current directory
_stprintf( strPath, _T("%s%s"), DXUtil_GetDXSDKMediaPath(), strFilename );
file = CreateFile( strPath, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL );
if( INVALID_HANDLE_VALUE != file )
{
CloseHandle( file );
return S_OK;
}
// On failure, just return the file as the path
_tcscpy( strPath, strFilename );
return E_FAIL;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_ReadStringRegKey()
// Desc: Helper function to read a registry key string
//-----------------------------------------------------------------------------
HRESULT DXUtil_ReadStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue,
DWORD dwLength, TCHAR* strDefault )
{
DWORD dwType;
if( ERROR_SUCCESS != RegQueryValueEx( hKey, strRegName, 0, &dwType,
(BYTE*)strValue, &dwLength ) )
{
_tcscpy( strValue, strDefault );
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_WriteStringRegKey()
// Desc: Helper function to write a registry key string
//-----------------------------------------------------------------------------
HRESULT DXUtil_WriteStringRegKey( HKEY hKey, TCHAR* strRegName,
TCHAR* strValue )
{
if( ERROR_SUCCESS != RegSetValueEx( hKey, strRegName, 0, REG_SZ,
(BYTE*)strValue,
(_tcslen(strValue)+1)*sizeof(TCHAR) ) )
return E_FAIL;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_ReadIntRegKey()
// Desc: Helper function to read a registry key int
//-----------------------------------------------------------------------------
HRESULT DXUtil_ReadIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD* pdwValue,
DWORD dwDefault )
{
DWORD dwType;
DWORD dwLength = sizeof(DWORD);
if( ERROR_SUCCESS != RegQueryValueEx( hKey, strRegName, 0, &dwType,
(BYTE*)pdwValue, &dwLength ) )
{
*pdwValue = dwDefault;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_WriteIntRegKey()
// Desc: Helper function to write a registry key int
//-----------------------------------------------------------------------------
HRESULT DXUtil_WriteIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD dwValue )
{
if( ERROR_SUCCESS != RegSetValueEx( hKey, strRegName, 0, REG_DWORD,
(BYTE*)&dwValue, sizeof(DWORD) ) )
return E_FAIL;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_ReadBoolRegKey()
// Desc: Helper function to read a registry key BOOL
//-----------------------------------------------------------------------------
HRESULT DXUtil_ReadBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL* pbValue,
BOOL bDefault )
{
DWORD dwType;
DWORD dwLength = sizeof(BOOL);
if( ERROR_SUCCESS != RegQueryValueEx( hKey, strRegName, 0, &dwType,
(BYTE*)pbValue, &dwLength ) )
{
*pbValue = bDefault;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_WriteBoolRegKey()
// Desc: Helper function to write a registry key BOOL
//-----------------------------------------------------------------------------
HRESULT DXUtil_WriteBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL bValue )
{
if( ERROR_SUCCESS != RegSetValueEx( hKey, strRegName, 0, REG_DWORD,
(BYTE*)&bValue, sizeof(BOOL) ) )
return E_FAIL;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_ReadGuidRegKey()
// Desc: Helper function to read a registry key guid
//-----------------------------------------------------------------------------
HRESULT DXUtil_ReadGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID* pGuidValue,
GUID& guidDefault )
{
DWORD dwType;
DWORD dwLength = sizeof(GUID);
if( ERROR_SUCCESS != RegQueryValueEx( hKey, strRegName, 0, &dwType,
(LPBYTE) pGuidValue, &dwLength ) )
{
*pGuidValue = guidDefault;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_WriteGuidRegKey()
// Desc: Helper function to write a registry key guid
//-----------------------------------------------------------------------------
HRESULT DXUtil_WriteGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID guidValue )
{
if( ERROR_SUCCESS != RegSetValueEx( hKey, strRegName, 0, REG_BINARY,
(BYTE*)&guidValue, sizeof(GUID) ) )
return E_FAIL;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_Timer()
// Desc: Performs timer opertations. Use the following commands:
// TIMER_RESET - to reset the timer
// TIMER_START - to start the timer
// TIMER_STOP - to stop (or pause) the timer
// TIMER_ADVANCE - to advance the timer by 0.1 seconds
// TIMER_GETABSOLUTETIME - to get the absolute system time
// TIMER_GETAPPTIME - to get the current time
// TIMER_GETELAPSEDTIME - to get the time that elapsed between
// TIMER_GETELAPSEDTIME calls
//-----------------------------------------------------------------------------
FLOAT __stdcall DXUtil_Timer( TIMER_COMMAND command )
{
static BOOL m_bTimerInitialized = FALSE;
static BOOL m_bUsingQPF = FALSE;
static LONGLONG m_llQPFTicksPerSec = 0;
// Initialize the timer
if( FALSE == m_bTimerInitialized )
{
m_bTimerInitialized = TRUE;
// Use QueryPerformanceFrequency() to get frequency of timer. If QPF is
// not supported, we will timeGetTime() which returns milliseconds.
LARGE_INTEGER qwTicksPerSec;
m_bUsingQPF = QueryPerformanceFrequency( &qwTicksPerSec );
if( m_bUsingQPF )
m_llQPFTicksPerSec = qwTicksPerSec.QuadPart;
}
if( m_bUsingQPF )
{
static LONGLONG m_llStopTime = 0;
static LONGLONG m_llLastElapsedTime = 0;
static LONGLONG m_llBaseTime = 0;
double fTime;
double fElapsedTime;
LARGE_INTEGER qwTime;
// Get either the current time or the stop time, depending
// on whether we're stopped and what command was sent
if( m_llStopTime != 0 && command != TIMER_START && command != TIMER_GETABSOLUTETIME)
qwTime.QuadPart = m_llStopTime;
else
QueryPerformanceCounter( &qwTime );
// Return the elapsed time
if( command == TIMER_GETELAPSEDTIME )
{
fElapsedTime = (double) ( qwTime.QuadPart - m_llLastElapsedTime ) / (double) m_llQPFTicksPerSec;
m_llLastElapsedTime = qwTime.QuadPart;
return (FLOAT) fElapsedTime;
}
// Return the current time
if( command == TIMER_GETAPPTIME )
{
double fAppTime = (double) ( qwTime.QuadPart - m_llBaseTime ) / (double) m_llQPFTicksPerSec;
return (FLOAT) fAppTime;
}
// Reset the timer
if( command == TIMER_RESET )
{
m_llBaseTime = qwTime.QuadPart;
m_llLastElapsedTime = qwTime.QuadPart;
return 0.0f;
}
// Start the timer
if( command == TIMER_START )
{
m_llBaseTime += qwTime.QuadPart - m_llStopTime;
m_llStopTime = 0;
m_llLastElapsedTime = qwTime.QuadPart;
return 0.0f;
}
// Stop the timer
if( command == TIMER_STOP )
{
m_llStopTime = qwTime.QuadPart;
m_llLastElapsedTime = qwTime.QuadPart;
return 0.0f;
}
// Advance the timer by 1/10th second
if( command == TIMER_ADVANCE )
{
m_llStopTime += m_llQPFTicksPerSec/10;
return 0.0f;
}
if( command == TIMER_GETABSOLUTETIME )
{
fTime = qwTime.QuadPart / (double) m_llQPFTicksPerSec;
return (FLOAT) fTime;
}
return -1.0f; // Invalid command specified
}
else
{
// Get the time using timeGetTime()
static double m_fLastElapsedTime = 0.0;
static double m_fBaseTime = 0.0;
static double m_fStopTime = 0.0;
double fTime;
double fElapsedTime;
// Get either the current time or the stop time, depending
// on whether we're stopped and what command was sent
if( m_fStopTime != 0.0 && command != TIMER_START && command != TIMER_GETABSOLUTETIME)
fTime = m_fStopTime;
else
fTime = timeGetTime() * 0.001;
// Return the elapsed time
if( command == TIMER_GETELAPSEDTIME )
{
fElapsedTime = (double) (fTime - m_fLastElapsedTime);
m_fLastElapsedTime = fTime;
return (FLOAT) fElapsedTime;
}
// Return the current time
if( command == TIMER_GETAPPTIME )
{
return (FLOAT) (fTime - m_fBaseTime);
}
// Reset the timer
if( command == TIMER_RESET )
{
m_fBaseTime = fTime;
m_fLastElapsedTime = fTime;
return 0.0f;
}
// Start the timer
if( command == TIMER_START )
{
m_fBaseTime += fTime - m_fStopTime;
m_fStopTime = 0.0f;
m_fLastElapsedTime = fTime;
return 0.0f;
}
// Stop the timer
if( command == TIMER_STOP )
{
m_fStopTime = fTime;
return 0.0f;
}
// Advance the timer by 1/10th second
if( command == TIMER_ADVANCE )
{
m_fStopTime += 0.1f;
return 0.0f;
}
if( command == TIMER_GETABSOLUTETIME )
{
return (FLOAT) fTime;
}
return -1.0f; // Invalid command specified
}
}
//-----------------------------------------------------------------------------
// Name: DXUtil_ConvertAnsiStringToWide()
// Desc: This is a UNICODE conversion utility to convert a CHAR string into a
// WCHAR string. cchDestChar defaults -1 which means it
// assumes strDest is large enough to store strSource
//-----------------------------------------------------------------------------
VOID DXUtil_ConvertAnsiStringToWide( WCHAR* wstrDestination, const CHAR* strSource,
int cchDestChar )
{
if( wstrDestination==NULL || strSource==NULL )
return;
if( cchDestChar == -1 )
cchDestChar = strlen(strSource)+1;
MultiByteToWideChar( CP_ACP, 0, strSource, -1,
wstrDestination, cchDestChar-1 );
wstrDestination[cchDestChar-1] = 0;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_ConvertWideStringToAnsi()
// Desc: This is a UNICODE conversion utility to convert a WCHAR string into a
// CHAR string. cchDestChar defaults -1 which means it
// assumes strDest is large enough to store strSource
//-----------------------------------------------------------------------------
VOID DXUtil_ConvertWideStringToAnsi( CHAR* strDestination, const WCHAR* wstrSource,
int cchDestChar )
{
if( strDestination==NULL || wstrSource==NULL )
return;
if( cchDestChar == -1 )
cchDestChar = wcslen(wstrSource)+1;
WideCharToMultiByte( CP_ACP, 0, wstrSource, -1, strDestination,
cchDestChar-1, NULL, NULL );
strDestination[cchDestChar-1] = 0;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_ConvertGenericStringToAnsi()
// Desc: This is a UNICODE conversion utility to convert a TCHAR string into a
// CHAR string. cchDestChar defaults -1 which means it
// assumes strDest is large enough to store strSource
//-----------------------------------------------------------------------------
VOID DXUtil_ConvertGenericStringToAnsi( CHAR* strDestination, const TCHAR* tstrSource,
int cchDestChar )
{
if( strDestination==NULL || tstrSource==NULL )
return;
#ifdef _UNICODE
DXUtil_ConvertWideStringToAnsi( strDestination, tstrSource, cchDestChar );
#else
if( cchDestChar == -1 )
strcpy( strDestination, tstrSource );
else
strncpy( strDestination, tstrSource, cchDestChar );
#endif
}
//-----------------------------------------------------------------------------
// Name: DXUtil_ConvertGenericStringToWide()
// Desc: This is a UNICODE conversion utility to convert a TCHAR string into a
// WCHAR string. cchDestChar defaults -1 which means it
// assumes strDest is large enough to store strSource
//-----------------------------------------------------------------------------
VOID DXUtil_ConvertGenericStringToWide( WCHAR* wstrDestination, const TCHAR* tstrSource,
int cchDestChar )
{
if( wstrDestination==NULL || tstrSource==NULL )
return;
#ifdef _UNICODE
if( cchDestChar == -1 )
wcscpy( wstrDestination, tstrSource );
else
wcsncpy( wstrDestination, tstrSource, cchDestChar );
#else
DXUtil_ConvertAnsiStringToWide( wstrDestination, tstrSource, cchDestChar );
#endif
}
//-----------------------------------------------------------------------------
// Name: DXUtil_ConvertAnsiStringToGeneric()
// Desc: This is a UNICODE conversion utility to convert a CHAR string into a
// TCHAR string. cchDestChar defaults -1 which means it
// assumes strDest is large enough to store strSource
//-----------------------------------------------------------------------------
VOID DXUtil_ConvertAnsiStringToGeneric( TCHAR* tstrDestination, const CHAR* strSource,
int cchDestChar )
{
if( tstrDestination==NULL || strSource==NULL )
return;
#ifdef _UNICODE
DXUtil_ConvertAnsiStringToWide( tstrDestination, strSource, cchDestChar );
#else
if( cchDestChar == -1 )
strcpy( tstrDestination, strSource );
else
strncpy( tstrDestination, strSource, cchDestChar );
#endif
}
//-----------------------------------------------------------------------------
// Name: DXUtil_ConvertAnsiStringToGeneric()
// Desc: This is a UNICODE conversion utility to convert a WCHAR string into a
// TCHAR string. cchDestChar defaults -1 which means it
// assumes strDest is large enough to store strSource
//-----------------------------------------------------------------------------
VOID DXUtil_ConvertWideStringToGeneric( TCHAR* tstrDestination, const WCHAR* wstrSource,
int cchDestChar )
{
if( tstrDestination==NULL || wstrSource==NULL )
return;
#ifdef _UNICODE
if( cchDestChar == -1 )
wcscpy( tstrDestination, wstrSource );
else
wcsncpy( tstrDestination, wstrSource, cchDestChar );
#else
DXUtil_ConvertWideStringToAnsi( tstrDestination, wstrSource, cchDestChar );
#endif
}
//-----------------------------------------------------------------------------
// Name: _DbgOut()
// Desc: Outputs a message to the debug stream
//-----------------------------------------------------------------------------
HRESULT _DbgOut( TCHAR* strFile, DWORD dwLine, HRESULT hr, TCHAR* strMsg )
{
TCHAR buffer[256];
wsprintf( buffer, _T("%s(%ld): "), strFile, dwLine );
OutputDebugString( buffer );
OutputDebugString( strMsg );
if( hr )
{
wsprintf( buffer, _T("(hr=%08lx)\n"), hr );
OutputDebugString( buffer );
}
OutputDebugString( _T("\n") );
return hr;
}
//-----------------------------------------------------------------------------
// Name: DXUtil_Trace()
// Desc: Outputs to the debug stream a formatted string with a variable-
// argument list.
//-----------------------------------------------------------------------------
VOID DXUtil_Trace( TCHAR* strMsg, ... )
{
#if defined(DEBUG) | defined(_DEBUG)
TCHAR strBuffer[512];
va_list args;
va_start(args, strMsg);
_vsntprintf( strBuffer, 512, strMsg, args );
va_end(args);
OutputDebugString( strBuffer );
#endif
}

View File

@@ -0,0 +1,103 @@
//-----------------------------------------------------------------------------
// File: DXUtil.h
//
// Desc: Helper functions and typing shortcuts for DirectX programming.
//
// Copyright (c) 1997-2000 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#ifndef DXUTIL_H
#define DXUTIL_H
//-----------------------------------------------------------------------------
// Miscellaneous helper functions
//-----------------------------------------------------------------------------
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
//-----------------------------------------------------------------------------
// Name: DXUtil_GetDXSDKMediaPath() and DXUtil_FindMediaFile()
// Desc: Returns the DirectX SDK path, as stored in the system registry
// during the SDK install.
//-----------------------------------------------------------------------------
const TCHAR* DXUtil_GetDXSDKMediaPath();
HRESULT DXUtil_FindMediaFile( TCHAR* strPath, TCHAR* strFilename );
//-----------------------------------------------------------------------------
// Name: DXUtil_Read*RegKey() and DXUtil_Write*RegKey()
// Desc: Helper functions to read/write a string registry key
//-----------------------------------------------------------------------------
HRESULT DXUtil_WriteStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue );
HRESULT DXUtil_WriteIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD dwValue );
HRESULT DXUtil_WriteGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID guidValue );
HRESULT DXUtil_WriteBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL bValue );
HRESULT DXUtil_ReadStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue, DWORD dwLength, TCHAR* strDefault );
HRESULT DXUtil_ReadIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD* pdwValue, DWORD dwDefault );
HRESULT DXUtil_ReadGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID* pGuidValue, GUID& guidDefault );
HRESULT DXUtil_ReadBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL* pbValue, BOOL bDefault );
//-----------------------------------------------------------------------------
// Name: DXUtil_Timer()
// Desc: Performs timer opertations. Use the following commands:
// TIMER_RESET - to reset the timer
// TIMER_START - to start the timer
// TIMER_STOP - to stop (or pause) the timer
// TIMER_ADVANCE - to advance the timer by 0.1 seconds
// TIMER_GETABSOLUTETIME - to get the absolute system time
// TIMER_GETAPPTIME - to get the current time
// TIMER_GETELAPSEDTIME - to get the time that elapsed between
// TIMER_GETELAPSEDTIME calls
//-----------------------------------------------------------------------------
enum TIMER_COMMAND { TIMER_RESET, TIMER_START, TIMER_STOP, TIMER_ADVANCE,
TIMER_GETABSOLUTETIME, TIMER_GETAPPTIME, TIMER_GETELAPSEDTIME };
FLOAT __stdcall DXUtil_Timer( TIMER_COMMAND command );
//-----------------------------------------------------------------------------
// UNICODE support for converting between CHAR, TCHAR, and WCHAR strings
//-----------------------------------------------------------------------------
VOID DXUtil_ConvertAnsiStringToWide( WCHAR* wstrDestination, const CHAR* strSource, int cchDestChar = -1 );
VOID DXUtil_ConvertWideStringToAnsi( CHAR* strDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
VOID DXUtil_ConvertGenericStringToAnsi( CHAR* strDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
VOID DXUtil_ConvertGenericStringToWide( WCHAR* wstrDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
VOID DXUtil_ConvertAnsiStringToGeneric( TCHAR* tstrDestination, const CHAR* strSource, int cchDestChar = -1 );
VOID DXUtil_ConvertWideStringToGeneric( TCHAR* tstrDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
//-----------------------------------------------------------------------------
// Debug printing support
//-----------------------------------------------------------------------------
VOID DXUtil_Trace( TCHAR* strMsg, ... );
HRESULT _DbgOut( TCHAR*, DWORD, HRESULT, TCHAR* );
#if defined(DEBUG) | defined(_DEBUG)
#define DXTRACE DXUtil_Trace
#else
#define DXTRACE sizeof
#endif
#if defined(DEBUG) | defined(_DEBUG)
#define DEBUG_MSG(str) _DbgOut( __FILE__, (DWORD)__LINE__, 0, str )
#else
#define DEBUG_MSG(str) (0L)
#endif
#endif // DXUTIL_H

View File

@@ -0,0 +1,143 @@
/*
* A generic template list class.
* Fairly typical of the list example you would
* find in any c++ book.
*/
#ifndef GENERIC_LIST_H
#define GENERIC_LIST_H
#pragma warning( disable : 4786 )
#include <assert.h>
#include <stdio.h>
template <class Type> class List {
public:
List(int s=0);
~List();
void Insert(Type t,int n);
void allocate(int s);
void SetSize(int s);
void Pack();
void Add(Type);
void AddUnique(Type);
int Contains(Type);
void Remove(Type);
void DelIndex(int i);
Type * element;
int num;
int array_size;
Type &operator[](int i){assert(i>=0 && i<num); return element[i];}
};
template <class Type>
List<Type>::List(int s){
num=0;
array_size = 0;
element = NULL;
if(s) {
allocate(s);
}
}
template <class Type>
List<Type>::~List<Type>(){
num=0;
delete [] element;
}
template <class Type>
void List<Type>::allocate(int s){
assert(s>0);
assert(s>=num);
Type *old = element;
array_size =s;
element = new Type[array_size];
assert(element);
for(int i=0;i<num;i++){
element[i]=old[i];
}
if(old)
delete [] old;
}
template <class Type>
void List<Type>::SetSize(int s){
if(s==0) { if(element) delete element;}
else { allocate(s); }
num=s;
}
template <class Type>
void List<Type>::Pack(){
allocate(num);
}
template <class Type>
void List<Type>::Add(Type t){
assert(num<=array_size);
if(num==array_size) {
allocate((array_size)?array_size *2:16);
}
//int i;
//for(i=0;i<num;i++) {
// dissallow duplicates
// assert(element[i] != t);
//}
element[num++] = t;
}
template <class Type>
int List<Type>::Contains(Type t){
int i;
int count=0;
for(i=0;i<num;i++) {
if(element[i] == t) count++;
}
return count;
}
template <class Type>
void List<Type>::AddUnique(Type t){
if(!Contains(t)) Add(t);
}
template <class Type>
void List<Type>::DelIndex(int i){
assert(i<num);
num--;
while(i<num){
element[i] = element[i+1];
i++;
}
}
template <class Type>
void List<Type>::Remove(Type t){
int i;
for(i=0;i<num;i++) {
if(element[i] == t) {
break;
}
}
DelIndex(i);
for(i=0;i<num;i++) {
assert(element[i] != t);
}
}
template <class Type>
void List<Type>::Insert(Type t,int n){
if(num==0)
Add(t);
else
{
Add(element[num-1]);
for(int i=num-1;i>n;i--)
{
element[i+1]=element[i];
}
element[n]=t;
}
}
#endif

View File

@@ -0,0 +1,319 @@
// matrix.cpp: implementation of the matrix class.
//
//////////////////////////////////////////////////////////////////////
#include "matrix.h"
#include <math.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
void matrix::XRotation(float theta)
{
float c = (float) cos(theta);
float s = (float) sin(theta);
MakeIdent();
_22 = c;
_23 = s;
_32 = -s;
_33 = c;
}
void matrix::YRotation(float theta)
{
float c = (float) cos(theta);
float s = (float) sin(theta);
MakeIdent();
_11 = c;
_13 = -s;
_31 = s;
_33 = c;
}
void matrix::ZRotation(float theta)
{
float c = (float) cos(theta);
float s = (float) sin(theta);
MakeIdent();
_11 = c;
_12 = s;
_21 = -s;
_22 = c;
}
void matrix::MakeIdent()
{
_11 = 1.f; _22 = 1.f; _33 = 1.f; _44 = 1.f;
_12 = 0.f; _13 = 0.f; _14 = 0.f; _21 = 0.f;
_23 = 0.f; _24 = 0.f; _31 = 0.f; _32 = 0.f;
_34 = 0.f; _41 = 0.f; _42 = 0.f; _43 = 0.f;
}
void matrix::AxisAngle(const vector3& inaxis, float angle)
{
vector3 axis = inaxis.Normalized();
float s=sinf(angle);
float c=cosf(angle);
float x=axis.x,y=axis.y,z=axis.z;
_11 = x*x*(1-c)+c;
_21 = x*y*(1-c)-(z*s);
_31 = x*z*(1-c)+(y*s);
_41 = 0;
_12 = y*x*(1-c)+(z*s);
_22 = y*y*(1-c)+c;
_32 = y*z*(1-c)-(x*s);
_42 = 0;
_13 = z*x*(1-c)-(y*s);
_23 = z*y*(1-c)+(x*s);
_33 = z*z*(1-c)+c;
_43 = 0;
_14 = 0;
_24 = 0;
_34 = 0;
_44 = 1;
}
void matrix::CameraLookAt(const vector3 &loc, const vector3 &lookAt, const vector3 &inUp)
{
vector3 viewVec=lookAt-loc;
float mag=viewVec.Mag();
viewVec/=mag;
//vector3 viewVec=lookAt;
float fDot=inUp*viewVec;
vector3 upVec=inUp-fDot*viewVec;
upVec.Normalize();
vector3 rightVec=upVec^viewVec;
_11 = rightVec.x; _12 = upVec.x; _13 = viewVec.x;
_21 = rightVec.y; _22 = upVec.y; _23 = viewVec.y;
_31 = rightVec.z; _32 = upVec.z; _33 = viewVec.z;
_41 = - (loc * rightVec);
_42 = - (loc * upVec);
_43 = - (loc * viewVec);
_14 = 0;
_24 = 0;
_34 = 0;
_44 = 1;
}
void matrix::Translation(const vector3 &loc)
{
MakeIdent();
_41=loc.x;
_42=loc.y;
_43=loc.z;
}
void matrix::Inverse(const matrix &in)
{
if( fabs(in._44 - 1.0f) > .001f)
return;
if( fabs(in._14) > .001f || fabs(in._24) > .001f || fabs(in._34) > .001f )
return;
float fDetInv = 1.0f / ( in._11 * ( in._22 * in._33 - in._23 * in._32 ) -
in._12 * ( in._21 * in._33 - in._23 * in._31 ) +
in._13 * ( in._21 * in._32 - in._22 * in._31 ) );
_11 = fDetInv * ( in._22 * in._33 - in._23 * in._32 );
_12 = -fDetInv * ( in._12 * in._33 - in._13 * in._32 );
_13 = fDetInv * ( in._12 * in._23 - in._13 * in._22 );
_14 = 0.0f;
_21 = -fDetInv * ( in._21 * in._33 - in._23 * in._31 );
_22 = fDetInv * ( in._11 * in._33 - in._13 * in._31 );
_23 = -fDetInv * ( in._11 * in._23 - in._13 * in._21 );
_24 = 0.0f;
_31 = fDetInv * ( in._21 * in._32 - in._22 * in._31 );
_32 = -fDetInv * ( in._11 * in._32 - in._12 * in._31 );
_33 = fDetInv * ( in._11 * in._22 - in._12 * in._21 );
_34 = 0.0f;
_41 = -( in._41 * _11 + in._42 * _21 + in._43 * _31 );
_42 = -( in._41 * _12 + in._42 * _22 + in._43 * _32 );
_43 = -( in._41 * _13 + in._42 * _23 + in._43 * _33 );
_44 = 1.0f;
/*
_11 = in._11;
_12 = in._21;
_13 = in._31;
_21 = in._12;
_22 = in._22;
_23 = in._32;
_31 = in._13;
_32 = in._23;
_33 = in._33;
_14 = 0;
_24 = 0;
_34 = 0;
_44 = 1;
// now get the new translation vector
vector3 temp=in.GetLoc();
_41 = -(temp.x * in._11 + temp.y * in._12 + temp.z * in._13);
_42 = -(temp.x * in._21 + temp.y * in._22 + temp.z * in._23);
_43 = -(temp.x * in._31 + temp.y * in._32 + temp.z * in._33);
*/
}
const vector3 matrix::GetLoc() const
{
return vector3(_41,_42,_43);
}
void matrix::MakeProjection(float fFov, float fAspect, float fNear, float fFar)
{
if( fabs(fFar-fNear) <0.01f)
return;
if( fabs(sin(fFov/2)) < 0.01f)
return;
float w=fAspect*(cosf(fFov/2)/sinf(fFov/2));
float h=1.0f*(cosf(fFov/2)/sinf(fFov/2));
float Q=fFar/(fFar-fNear);
ZeroMemory( this, sizeof(matrix) );
_11 = w;
_22 = h;
_33 = Q;
_34 = 1.0f;
_43 = -Q*fNear;
}
matrix operator*(matrix const &a, matrix const &b)
{
matrix out; // temporary matrix4 for storing result
for (int j = 0; j < 4; j++) // transform by columns first
for (int i = 0; i < 4; i++) // then by rows
out.m[i][j] = a.m[i][0] * b.m[0][j] + a.m[i][1] * b.m[1][j] +
a.m[i][2] * b.m[2][j] + a.m[i][3] * b.m[3][j];
return out;
};
vector3 operator*(matrix const &a,vector3 const &b)
{
vector3 vecResult;
vecResult.x=a._11*b.x + a._12*b.y + a._13*b.z + a._14*1.0f;
vecResult.y=a._21*b.x + a._22*b.y + a._23*b.z + a._24*1.0f;
vecResult.z=a._31*b.x + a._32*b.y + a._33*b.z + a._34*1.0f;
return vecResult;
}
bool operator==(matrix const &a,matrix const &b)
{
if( a._11 == b._11 && a._12 == b._12 && a._13 == b._13 && a._14 == b._14 &&
a._21 == b._21 && a._22 == b._22 && a._23 == b._13 && a._24 == b._24 &&
a._31 == b._31 && a._32 == b._32 && a._33 == b._13 && a._34 == b._34 &&
a._41 == b._41 && a._42 == b._42 && a._43 == b._13 && a._44 == b._44)
return true;
return false;
}
void matrix::Rotation(vector3 vecDir, float fAngle)
{
float fCos=cosf(fAngle);
float fSin=sinf(fAngle);
vecDir.Normalize();
vector3 v=vecDir;
_11 = ( v.x * v.x ) * ( 1.0f - fCos ) + fCos;
_12 = ( v.x * v.y ) * ( 1.0f - fCos ) - (v.z * fSin);
_13 = ( v.x * v.z ) * ( 1.0f - fCos ) + (v.y * fSin);
_21 = ( v.y * v.x ) * ( 1.0f - fCos ) + (v.z * fSin);
_22 = ( v.y * v.y ) * ( 1.0f - fCos ) + fCos ;
_23 = ( v.y * v.z ) * ( 1.0f - fCos ) - (v.x * fSin);
_31 = ( v.z * v.x ) * ( 1.0f - fCos ) - (v.y * fSin);
_32 = ( v.z * v.y ) * ( 1.0f - fCos ) + (v.x * fSin);
_33 = ( v.z * v.z ) * ( 1.0f - fCos ) + fCos;
_14 = _24 = _34 = 0.0f;
_41 = _42 = _43 = 0.0f;
_44 = 1.0f;
}
void matrix::MakeAdjustedProjectionMatrix(float fFov, float fAspect, float fNear, float fFar, float fPixDx, float fPixDy, float fVPWidth, float fVPHeight)
{
float h = 1.0f * ( cosf(fFov/2)/sinf(fFov/2) );
float fTop = fNear/h;
float fBottom = -fTop;
float fRight = fTop * fAspect;
float fLeft = -fRight;
float fXWSize = fRight - fLeft;
float fYWSize = fTop - fBottom;
float fDx = -( fPixDx*fXWSize/fVPWidth );
float fDy = -( fPixDy*fYWSize/fVPHeight );
SetFrustumMatrix(fLeft+fDx, fRight+fDx, fTop+fDy, fBottom+fDy, fNear,fFar);
}
void matrix::SetFrustumMatrix(float fLeft, float fRight, float fTop, float fBottom, float fNearPlane, float fFarPlane)
{
float Q = fFarPlane / ( fFarPlane - fNearPlane );
ZeroMemory(this,sizeof(matrix));
_11 = ( 2.0f*fNearPlane )/( fRight - fLeft );
_22 = ( 2.0f*fNearPlane )/( fTop - fBottom );
_31 = ( fRight + fLeft )/ (fRight - fLeft );
_32 = ( fTop + fBottom )/ (fTop - fBottom );
_33 = Q;
_34 = 1.0f;
_43 = -Q*fNearPlane;
}
void matrix::MakeNoProjection(float fFov, float fSizeX, float fSizeY, float fFarPlane, float fNearPlane)
{
ZeroMemory(this,sizeof(matrix));
_11=2.0f/fSizeX;
_22=2.0f/fSizeY;
_33=1.0f/(fFarPlane-fNearPlane);
_43=-1.0f*fNearPlane/(fFarPlane-fNearPlane);
_44=1.0f;
}
void matrix::Transpose()
{
float t_12,t_13,t_14,t_23,t_24,t_34;
t_12=_12;
t_13=_13;
t_14=_14;
t_23=_23;
t_24=_24;
t_34=_34;
_12=_21;
_13=_31;
_14=_41;
_23=_32;
_24=_42;
_34=_43;
_21=t_12;
_31=t_13;
_41=t_14;
_32=t_23;
_42=t_24;
_43=t_34;
}

View File

@@ -0,0 +1,85 @@
// matrix.h: interface for the matrix class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MATRIX_H__D1E5A204_11BB_4B9E_902D_D684D3D34E3B__INCLUDED_)
#define AFX_MATRIX_H__D1E5A204_11BB_4B9E_902D_D684D3D34E3B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <d3d8.h>
#include <d3dx8.h>
#include "MathBase.h"
#include "vector.h"
//#include <math.h>
//#include "vector.h"
struct matrix
{
union
{
struct
{
float _11, _12, _13, _14;
float _21, _22, _23, _24;
float _31, _32, _33, _34;
float _41, _42, _43, _44;
};
float m[4][4];
};
matrix(){};
matrix(
float in11, float in12, float in13, float in14,
float in21, float in22, float in23, float in24,
float in31, float in32, float in33, float in34,
float in41, float in42, float in43, float in44 )
{
_11 = in11; _12 = in12; _13 = in13; _14 = in14;
_21 = in21; _22 = in22; _23 = in23; _24 = in24;
_31 = in31; _32 = in32; _33 = in33; _34 = in34;
_41 = in41; _42 = in42; _43 = in43; _44 = in44;
};
static matrix Identity;
public:
void Transpose();
void MakeNoProjection(float fFov,float fSizeX,float fSizeY,float fFarPlane,float fNearPlane);
void SetFrustumMatrix(float fLeft,float fRight,float fTop,float fBottom,float fNearPlane,float fFarPlane );
void MakeAdjustedProjectionMatrix(float fFov,float fAspect,float fNear,float fFar,float fPixDx,float fPixDy,float fVPWidth,float fVPHeight);
void Rotation(vector3 vecDir,float fAngle);
void MakeProjection(float fFov,float fAspect,float fNear,float fFar);
const vector3 GetLoc() const;
void Inverse(const matrix& in);
void Translation(const vector3 &loc);
void CameraLookAt( const vector3& loc, const vector3& lookAt, const vector3& inUp );
void AxisAngle(const vector3& inaxis,float angle);
void MakeIdent();
void ZRotation(float theta);
void YRotation(float theta);
void XRotation(float theta);
operator D3DMATRIX* ()
{
return (D3DMATRIX*)(this);
}
operator D3DXMATRIX* ()
{
return (D3DXMATRIX*)(this);
}
};
matrix operator*(matrix const &a, matrix const &b);
vector3 operator*(matrix const &a,vector3 const &b);
bool operator==(matrix const &a,matrix const &b);
inline void Multiply( matrix& result, matrix& a, matrix& b )
{
int i, j;
for (j = 0; j < 4; j++) // transform by columns first
for (i = 0; i < 4; i++) // then by rows
result.m[i][j] = a.m[i][0] * b.m[0][j] + a.m[i][1] * b.m[1][j] +
a.m[i][2] * b.m[2][j] + a.m[i][3] * b.m[3][j];
}
#endif // !defined(AFX_MATRIX_H__D1E5A204_11BB_4B9E_902D_D684D3D34E3B__INCLUDED_)

View File

@@ -0,0 +1,277 @@
/***************************************************************************************************
**
** profile.cpp
**
** Real-Time Hierarchical Profiling for Game Programming Gems 3
**
** by Greg Hjelstrom & Byon Garrabrant
**
***************************************************************************************************/
#include "profile.h"
inline void Profile_Get_Ticks(_int64 * ticks)
{
__asm
{
push edx;
push ecx;
mov ecx,ticks;
_emit 0Fh
_emit 31h
mov [ecx],eax;
mov [ecx+4],edx;
pop ecx;
pop edx;
}
}
inline float Profile_Get_Tick_Rate(void)
{
static float _CPUFrequency = -1.0f;
if (_CPUFrequency == -1.0f) {
__int64 curr_rate = 0;
::QueryPerformanceFrequency ((LARGE_INTEGER *)&curr_rate);
_CPUFrequency = (float)curr_rate;
}
return _CPUFrequency;
}
/***************************************************************************************************
**
** CProfileNode
**
***************************************************************************************************/
/***********************************************************************************************
* INPUT: *
* name - pointer to a static string which is the name of this profile node *
* parent - parent pointer *
* *
* WARNINGS: *
* The name is assumed to be a static pointer, only the pointer is stored and compared for *
* efficiency reasons. *
*=============================================================================================*/
CProfileNode::CProfileNode( const char * name, CProfileNode * parent ) :
Name( name ),
TotalCalls( 0 ),
TotalTime( 0 ),
StartTime( 0 ),
RecursionCounter( 0 ),
Parent( parent ),
Child( NULL ),
Sibling( NULL )
{
Reset();
}
CProfileNode::~CProfileNode( void )
{
delete Child;
delete Sibling;
}
/***********************************************************************************************
* INPUT: *
* name - static string pointer to the name of the node we are searching for *
* *
* WARNINGS: *
* All profile names are assumed to be static strings so this function uses pointer compares *
* to find the named node. *
*=============================================================================================*/
CProfileNode * CProfileNode::Get_Sub_Node( const char * name )
{
// Try to find this sub node
CProfileNode * child = Child;
while ( child ) {
if ( child->Name == name ) {
return child;
}
child = child->Sibling;
}
// We didn't find it, so add it
CProfileNode * node = new CProfileNode( name, this );
node->Sibling = Child;
Child = node;
return node;
}
void CProfileNode::Reset( void )
{
TotalCalls = 0;
TotalTime = 0.0f;
if ( Child ) {
Child->Reset();
}
if ( Sibling ) {
Sibling->Reset();
}
}
void CProfileNode::Call( void )
{
TotalCalls++;
if (RecursionCounter++ == 0) {
Profile_Get_Ticks(&StartTime);
}
}
bool CProfileNode::Return( void )
{
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
__int64 time;
Profile_Get_Ticks(&time);
time-=StartTime;
TotalTime += (float)time / Profile_Get_Tick_Rate();
}
return ( RecursionCounter == 0 );
}
/***************************************************************************************************
**
** CProfileIterator
**
***************************************************************************************************/
CProfileIterator::CProfileIterator( CProfileNode * start )
{
CurrentParent = start;
CurrentChild = CurrentParent->Get_Child();
}
void CProfileIterator::First(void)
{
CurrentChild = CurrentParent->Get_Child();
}
void CProfileIterator::Next(void)
{
CurrentChild = CurrentChild->Get_Sibling();
}
bool CProfileIterator::Is_Done(void)
{
return CurrentChild == NULL;
}
void CProfileIterator::Enter_Child( int index )
{
CurrentChild = CurrentParent->Get_Child();
while ( (CurrentChild != NULL) && (index != 0) ) {
index--;
CurrentChild = CurrentChild->Get_Sibling();
}
if ( CurrentChild != NULL ) {
CurrentParent = CurrentChild;
CurrentChild = CurrentParent->Get_Child();
}
}
void CProfileIterator::Enter_Parent( void )
{
if ( CurrentParent->Get_Parent() != NULL ) {
CurrentParent = CurrentParent->Get_Parent();
}
CurrentChild = CurrentParent->Get_Child();
}
/***************************************************************************************************
**
** CProfileManager
**
***************************************************************************************************/
CProfileNode CProfileManager::Root( "Root", NULL );
CProfileNode * CProfileManager::CurrentNode = &CProfileManager::Root;
int CProfileManager::FrameCounter = 0;
__int64 CProfileManager::ResetTime = 0;
/***********************************************************************************************
* CProfileManager::Start_Profile -- Begin a named profile *
* *
* Steps one level deeper into the tree, if a child already exists with the specified name *
* then it accumulates the profiling; otherwise a new child node is added to the profile tree. *
* *
* INPUT: *
* name - name of this profiling record *
* *
* WARNINGS: *
* The string used is assumed to be a static string; pointer compares are used throughout *
* the profiling code for efficiency. *
*=============================================================================================*/
void CProfileManager::Start_Profile( const char * name )
{
if (name != CurrentNode->Get_Name()) {
CurrentNode = CurrentNode->Get_Sub_Node( name );
}
CurrentNode->Call();
}
/***********************************************************************************************
* CProfileManager::Stop_Profile -- Stop timing and record the results. *
*=============================================================================================*/
void CProfileManager::Stop_Profile( void )
{
// Return will indicate whether we should back up to our parent (we may
// be profiling a recursive function)
if (CurrentNode->Return()) {
CurrentNode = CurrentNode->Get_Parent();
}
}
/***********************************************************************************************
* CProfileManager::Reset -- Reset the contents of the profiling system *
* *
* This resets everything except for the tree structure. All of the timing data is reset. *
*=============================================================================================*/
void CProfileManager::Reset( void )
{
Root.Reset();
FrameCounter = 0;
Profile_Get_Ticks(&ResetTime);
}
/***********************************************************************************************
* CProfileManager::Increment_Frame_Counter -- Increment the frame counter *
*=============================================================================================*/
void CProfileManager::Increment_Frame_Counter( void )
{
FrameCounter++;
}
/***********************************************************************************************
* CProfileManager::Get_Time_Since_Reset -- returns the elapsed time since last reset *
*=============================================================================================*/
float CProfileManager::Get_Time_Since_Reset( void )
{
__int64 time;
Profile_Get_Ticks(&time);
time -= ResetTime;
return (float)time / Profile_Get_Tick_Rate();
}

View File

@@ -0,0 +1,132 @@
/***************************************************************************************************
**
** profile.h
**
** Real-Time Hierarchical Profiling for Game Programming Gems 3
**
** by Greg Hjelstrom & Byon Garrabrant
**
***************************************************************************************************/
/*
** A node in the Profile Hierarchy Tree
*/
#include <windows.h>
class CProfileNode {
public:
CProfileNode( const char * name, CProfileNode * parent );
~CProfileNode( void );
CProfileNode * Get_Sub_Node( const char * name );
CProfileNode * Get_Parent( void ) { return Parent; }
CProfileNode * Get_Sibling( void ) { return Sibling; }
CProfileNode * Get_Child( void ) { return Child; }
void Reset( void );
void Call( void );
bool Return( void );
const char * Get_Name( void ) { return Name; }
int Get_Total_Calls( void ) { return TotalCalls; }
float Get_Total_Time( void ) { return TotalTime; }
protected:
const char * Name;
int TotalCalls;
float TotalTime;
__int64 StartTime;
int RecursionCounter;
CProfileNode * Parent;
CProfileNode * Child;
CProfileNode * Sibling;
};
/*
** An iterator to navigate through the tree
*/
class CProfileIterator
{
public:
// Access all the children of the current parent
void First(void);
void Next(void);
bool Is_Done(void);
void Enter_Child( int index ); // Make the given child the new parent
void Enter_Largest_Child( void ); // Make the largest child the new parent
void Enter_Parent( void ); // Make the current parent's parent the new parent
// Access the current child
const char * Get_Current_Name( void ) { return CurrentChild->Get_Name(); }
int Get_Current_Total_Calls( void ) { return CurrentChild->Get_Total_Calls(); }
float Get_Current_Total_Time( void ) { return CurrentChild->Get_Total_Time(); }
// Access the current parent
const char * Get_Current_Parent_Name( void ) { return CurrentParent->Get_Name(); }
int Get_Current_Parent_Total_Calls( void ) { return CurrentParent->Get_Total_Calls(); }
float Get_Current_Parent_Total_Time( void ) { return CurrentParent->Get_Total_Time(); }
CProfileNode * GetParentPtr() {return CurrentParent;}
CProfileNode * GetChildPtr() { return CurrentChild;}
protected:
CProfileNode * CurrentParent;
CProfileNode * CurrentChild;
CProfileIterator( CProfileNode * start );
friend class CProfileManager;
};
/*
** The Manager for the Profile system
*/
class CProfileManager {
public:
static void Start_Profile( const char * name );
static void Stop_Profile( void );
static void Reset( void );
static void Increment_Frame_Counter( void );
static int Get_Frame_Count_Since_Reset( void ) { return FrameCounter; }
static float Get_Time_Since_Reset( void );
static CProfileIterator * Get_Iterator( void ) { return new CProfileIterator( &Root ); }
static void Release_Iterator( CProfileIterator * iterator ) { delete iterator; }
private:
static CProfileNode Root;
static CProfileNode * CurrentNode;
static int FrameCounter;
static __int64 ResetTime;
};
/*
** ProfileSampleClass is a simple way to profile a function's scope
** Use the PROFILE macro at the start of scope to time
*/
class CProfileSample {
public:
CProfileSample( const char * name )
{
CProfileManager::Start_Profile( name );
}
~CProfileSample( void )
{
CProfileManager::Stop_Profile();
}
};
#ifdef DEBUG
#define PROFILE( name ) CProfileSample __profile( name )
#else
#define PROFILE( name )
#endif

View File

@@ -0,0 +1,116 @@
// quaternion.h: interface for the quaternion class.
//
// Only for unit quaternions( norm(q) = 1 )
//
// result with non-unit quaternion by this routine is undefined
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_QUATERNION_H__B048AE81_B0A6_11D4_AD2B_0000E8EB4C69__INCLUDED_)
#define AFX_QUATERNION_H__B048AE81_B0A6_11D4_AD2B_0000E8EB4C69__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "MathBase.h"
struct quaternion
{
union
{
struct
{
float x, y, z, w;
};
float v[4];
};
quaternion() {};
quaternion( float fx, float fy, float fz, float fw )
{
x = fx;
y = fy;
z = fz;
w = fw;
}
// initialize to identity quaternion
void Identity()
{
x = y = z = 0.0f;
w = 1.0f;
}
quaternion& operator*=(const quaternion& op);
quaternion operator-()
{
return quaternion( -x, -y, -z, -w );
}
// perform quaternion rotation on vector
//void RotateVector( vector3& vec );
// perform axis-angle tpye rotation
void Pitch( float a )
{
quaternion x( sinf(a/2), 0.0f, 0.0f, cosf(a/2) );
(*this) *= x;
}
void Yaw( float a )
{
quaternion x( 0.0f, sinf(a/2), 0.0f, cosf(a/2) );
(*this) *= x;
}
void Roll( float a )
{
quaternion x( 0.0f, 0.0f, sinf(a/2), cosf(a/2) );
(*this) *= x;
}
};
// 'this = op * this', not 'this = this * op'
// due to the relation between rotation matrix&quaternion
inline quaternion& quaternion::operator*=(const quaternion& op)
{
float fx, fy,fz, fw;
fw = op.w*w - op.x*x - op.y*y - op.z*z;
fx = op.w*x + op.x*w + op.y*z - op.z*y;
fy = op.w*y - op.x*z + op.y*w + op.z*x;
fz = op.w*z + op.x*y - op.y*x + op.z*w;
w = fw;
x = fx;
y = fy;
z = fz;
return *this;
}
// 'result = op2 * op1', not 'result = op1 * op2'
// due to the inverse-relation between rotation matrix&quaternion
inline void Multiply( quaternion& result, quaternion& op1, quaternion& op2 )
{
result.w = op2.w*op1.w - op2.x*op1.x - op2.y*op1.y - op2.z*op1.z;
result.x = op2.w*op1.x + op2.x*op1.w + op2.y*op1.z - op2.z*op1.y;
result.y = op2.w*op1.y - op2.x*op1.z + op2.y*op1.w + op2.z*op1.x;
result.z = op2.w*op1.z + op2.x*op1.y - op2.y*op1.x + op2.z*op1.w;
}
// 'result = op2 * op1', not 'result = op1 * op2'
// due to the inverse-relation between rotation matrix&quaternion
inline const quaternion operator*( quaternion& op1, quaternion& op2 )
{
quaternion result;
result.w = op2.w*op1.w - op2.x*op1.x - op2.y*op1.y - op2.z*op1.z;
result.x = op2.w*op1.x + op2.x*op1.w + op2.y*op1.z - op2.z*op1.y;
result.y = op2.w*op1.y - op2.x*op1.z + op2.y*op1.w + op2.z*op1.x;
result.z = op2.w*op1.z + op2.x*op1.y - op2.y*op1.x + op2.z*op1.w;
return result;
}
#endif // !defined(AFX_QUATERNION_H__B048AE81_B0A6_11D4_AD2B_0000E8EB4C69__INCLUDED_)

View File

@@ -0,0 +1,85 @@
#ifndef GENERIC_QUEUE_H
#define GENERIC_QUEUE_H
#include <assert.h>
#include <stdio.h>
#pragma warning( disable : 4786 )
template <class Type> class Queue {
public:
Queue(int s=-1);
~Queue();
void Enqueue(Type);
Type Dequeue();
void allocate(int s);
void LockSize(int s){lock_size=s;};
Type *element;
int num;
int array_size;
int lock_size;
Type &operator[](int i){assert(i>=0 && i<num);return element[i];}
};
template <class Type> Queue<Type>::Queue(int s){
num=0;
array_size=0;
element=NULL;
lock_size=s;
}
template <class Type> Queue<Type>::~Queue(){
num=0;
delete element;
}
template <class Type> void Queue<Type>::allocate(int s){
assert(s>0);
assert(s>=num);
Type *old=element;
array_size=s;
element=new Type[array_size];
assert(element);
for(int i=0;i<num;i++)
{
element[i]=old[i];
}
if(old) delete old;
}
template <class Type> void Queue<Type>::Enqueue(Type t)
{
if(lock_size==-1)
{
assert(num<=array_size);
if(num==array_size)
{
allocate((array_size)?array_size*2:16);
}
element[num++]=t;
}
else
{
assert(lock_size!=0);
if(num>=lock_size)
{
Dequeue();
element[num++]=t;
}
else
{
element[num++]=t;
}
}
}
template <class Type> Type Queue<Type>::Dequeue()
{
assert(num>0);
Type result=element[0];
for(int i=1;i<num;i++)
{
element[i-1]=element[i];
}
num--;
return result;
}
#endif