Upgraded to DirectX 9
This commit is contained in:
parent
fb64ecafe7
commit
a21139193e
@ -91,8 +91,8 @@ void CEffectInstance::OnUpdate()
|
|||||||
|
|
||||||
void CEffectInstance::OnRender()
|
void CEffectInstance::OnRender()
|
||||||
{
|
{
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_NONE);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_NONE);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_NONE);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_NONE);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||||
@ -107,13 +107,13 @@ void CEffectInstance::OnRender()
|
|||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_TEX1);
|
||||||
std::for_each(m_ParticleInstanceVector.begin(),m_ParticleInstanceVector.end(),std::void_mem_fun(&CEffectElementBaseInstance::Render));
|
std::for_each(m_ParticleInstanceVector.begin(),m_ParticleInstanceVector.end(),std::void_mem_fun(&CEffectElementBaseInstance::Render));
|
||||||
std::for_each(m_MeshInstanceVector.begin(),m_MeshInstanceVector.end(),std::void_mem_fun(&CEffectElementBaseInstance::Render));
|
std::for_each(m_MeshInstanceVector.begin(),m_MeshInstanceVector.end(),std::void_mem_fun(&CEffectElementBaseInstance::Render));
|
||||||
|
|
||||||
/////
|
/////
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MINFILTER);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MINFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MAGFILTER);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MAGFILTER);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
|
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
|
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <d3dx8.h>
|
#include <directxsdk/d3dx9.h>
|
||||||
|
|
||||||
#include "../eterlib/GrpScreen.h"
|
#include "../eterlib/GrpScreen.h"
|
||||||
#include "../eterlib/Resource.h"
|
#include "../eterlib/Resource.h"
|
||||||
|
@ -168,7 +168,7 @@ void CEffectMeshInstance::OnRender()
|
|||||||
|
|
||||||
Color.a = fAlpha * rFrameData.fVisibility;
|
Color.a = fAlpha * rFrameData.fVisibility;
|
||||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, DWORD(Color));
|
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, DWORD(Color));
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLELIST,
|
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||||
rFrameData.dwIndexCount/3,
|
rFrameData.dwIndexCount/3,
|
||||||
&rFrameData.PDTVertexVector[0],
|
&rFrameData.PDTVertexVector[0],
|
||||||
|
@ -145,7 +145,7 @@ float CLightData::GetDuration()
|
|||||||
{
|
{
|
||||||
return m_fDuration;
|
return m_fDuration;
|
||||||
}
|
}
|
||||||
void CLightData::InitializeLight(D3DLIGHT8& light)
|
void CLightData::InitializeLight(D3DLIGHT9& light)
|
||||||
{
|
{
|
||||||
light.Type = D3DLIGHT_POINT;
|
light.Type = D3DLIGHT_POINT;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <d3dx8.h>
|
#include <directxsdk/d3dx9.h>
|
||||||
|
|
||||||
#include "../eterLib/TextFileLoader.h"
|
#include "../eterLib/TextFileLoader.h"
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ class CLightData : public CEffectElementBase
|
|||||||
{
|
{
|
||||||
return m_iLoopCount;
|
return m_iLoopCount;
|
||||||
}
|
}
|
||||||
void InitializeLight(D3DLIGHT8& light);
|
void InitializeLight(D3DLIGHT9& light);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OnClear();
|
void OnClear();
|
||||||
|
@ -29,7 +29,7 @@ void CLightInstance::OnSetDataPointer(CEffectElementBase * pElement)
|
|||||||
|
|
||||||
m_iLoopCount = m_pData->GetLoopCount();
|
m_iLoopCount = m_pData->GetLoopCount();
|
||||||
|
|
||||||
D3DLIGHT8 Light;
|
D3DLIGHT9 Light;
|
||||||
m_pData->InitializeLight(Light);
|
m_pData->InitializeLight(Light);
|
||||||
CLightManager::Instance().RegisterLight(LIGHT_TYPE_DYNAMIC, &m_LightID, Light);
|
CLightManager::Instance().RegisterLight(LIGHT_TYPE_DYNAMIC, &m_LightID, Light);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ bool CGrannyMaterial::IsEqual(granny_material* pgrnMaterial) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 CGrannyMaterial::GetD3DTexture(int iStage) const
|
LPDIRECT3DTEXTURE9 CGrannyMaterial::GetD3DTexture(int iStage) const
|
||||||
{
|
{
|
||||||
const CGraphicImage::TRef & ratImage = m_roImage[iStage];
|
const CGraphicImage::TRef & ratImage = m_roImage[iStage];
|
||||||
|
|
||||||
@ -333,8 +333,8 @@ void CGrannyMaterial::__ApplySpecularRenderState()
|
|||||||
|
|
||||||
STATEMANAGER.SetTransform(D3DTS_TEXTURE1, &ms_matSpecular);
|
STATEMANAGER.SetTransform(D3DTS_TEXTURE1, &ms_matSpecular);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGrannyMaterial::__RestoreSpecularRenderState()
|
void CGrannyMaterial::__RestoreSpecularRenderState()
|
||||||
@ -346,8 +346,8 @@ void CGrannyMaterial::__RestoreSpecularRenderState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS);
|
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSU);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_ADDRESSU);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSV);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_ADDRESSV);
|
||||||
|
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXCOORDINDEX);
|
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXCOORDINDEX);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <granny.h>
|
#include <granny/granny.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <d3d8.h>
|
#include <d3d9.h>
|
||||||
|
|
||||||
#include "../eterlib/ReferenceObject.h"
|
#include "../eterlib/ReferenceObject.h"
|
||||||
#include "../eterlib/Ref.h"
|
#include "../eterlib/Ref.h"
|
||||||
@ -58,7 +58,7 @@ class CGrannyMaterial : public CReferenceObject
|
|||||||
const CGraphicTexture * GetDiffuseTexture() const;
|
const CGraphicTexture * GetDiffuseTexture() const;
|
||||||
const CGraphicTexture * GetOpacityTexture() const;
|
const CGraphicTexture * GetOpacityTexture() const;
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 GetD3DTexture(int iStage) const;
|
LPDIRECT3DTEXTURE9 GetD3DTexture(int iStage) const;
|
||||||
|
|
||||||
bool IsTwoSided() const { return m_bTwoSideRender; }
|
bool IsTwoSided() const { return m_bTwoSideRender; }
|
||||||
|
|
||||||
|
@ -72,12 +72,12 @@ granny_model* CGrannyModel::GetGrannyModelPointer()
|
|||||||
return m_pgrnModel;
|
return m_pgrnModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPDIRECT3DINDEXBUFFER8 CGrannyModel::GetD3DIndexBuffer() const
|
LPDIRECT3DINDEXBUFFER9 CGrannyModel::GetD3DIndexBuffer() const
|
||||||
{
|
{
|
||||||
return m_idxBuf.GetD3DIndexBuffer();
|
return m_idxBuf.GetD3DIndexBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
LPDIRECT3DVERTEXBUFFER8 CGrannyModel::GetPNTD3DVertexBuffer() const
|
LPDIRECT3DVERTEXBUFFER9 CGrannyModel::GetPNTD3DVertexBuffer() const
|
||||||
{
|
{
|
||||||
return m_pntVtxBuf.GetD3DVertexBuffer();
|
return m_pntVtxBuf.GetD3DVertexBuffer();
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ class CGrannyModel : public CReferenceObject
|
|||||||
granny_model * GetGrannyModelPointer();
|
granny_model * GetGrannyModelPointer();
|
||||||
const CGrannyMesh* GetMeshPointer(int iMesh) const;
|
const CGrannyMesh* GetMeshPointer(int iMesh) const;
|
||||||
|
|
||||||
LPDIRECT3DVERTEXBUFFER8 GetPNTD3DVertexBuffer() const;
|
LPDIRECT3DVERTEXBUFFER9 GetPNTD3DVertexBuffer() const;
|
||||||
LPDIRECT3DINDEXBUFFER8 GetD3DIndexBuffer() const;
|
LPDIRECT3DINDEXBUFFER9 GetD3DIndexBuffer() const;
|
||||||
|
|
||||||
const CGrannyModel::TMeshNode* GetMeshNodeList(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType) const;
|
const CGrannyModel::TMeshNode* GetMeshNodeList(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType) const;
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ class CGrannyModelInstance : public CGraphicCollisionObject
|
|||||||
bool __IsDeformableVertexBuffer();
|
bool __IsDeformableVertexBuffer();
|
||||||
void __SetSharedDeformableVertexBuffer(CGraphicVertexBuffer* pkSharedDeformableVertexBuffer);
|
void __SetSharedDeformableVertexBuffer(CGraphicVertexBuffer* pkSharedDeformableVertexBuffer);
|
||||||
|
|
||||||
IDirect3DVertexBuffer8* __GetDeformableD3DVertexBufferPtr();
|
IDirect3DVertexBuffer9* __GetDeformableD3DVertexBufferPtr();
|
||||||
CGraphicVertexBuffer& __GetDeformableVertexBufferRef();
|
CGraphicVertexBuffer& __GetDeformableVertexBufferRef();
|
||||||
|
|
||||||
granny_world_pose* __GetWorldPosePtr() const;
|
granny_world_pose* __GetWorldPosePtr() const;
|
||||||
|
@ -208,7 +208,7 @@ bool CGrannyModelInstance::__IsDeformableVertexBuffer()
|
|||||||
return m_kLocalDeformableVertexBuffer.IsEmpty();
|
return m_kLocalDeformableVertexBuffer.IsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
IDirect3DVertexBuffer8* CGrannyModelInstance::__GetDeformableD3DVertexBufferPtr()
|
IDirect3DVertexBuffer9* CGrannyModelInstance::__GetDeformableD3DVertexBufferPtr()
|
||||||
{
|
{
|
||||||
return __GetDeformableVertexBufferRef().GetD3DVertexBuffer();
|
return __GetDeformableVertexBufferRef().GetD3DVertexBuffer();
|
||||||
}
|
}
|
||||||
|
@ -58,13 +58,9 @@ void CGrannyModelInstance::RenderWithOneTexture()
|
|||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(ms_pntVS);
|
LPDIRECT3DVERTEXBUFFER9 lpd3dDeformPNTVtxBuf = __GetDeformableD3DVertexBufferPtr();
|
||||||
|
LPDIRECT3DVERTEXBUFFER9 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
||||||
// WORK
|
STATEMANAGER.SetFVF(ms_pntVS);
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dDeformPNTVtxBuf = __GetDeformableD3DVertexBufferPtr();
|
|
||||||
// END_OF_WORK
|
|
||||||
|
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
|
||||||
|
|
||||||
if (lpd3dDeformPNTVtxBuf)
|
if (lpd3dDeformPNTVtxBuf)
|
||||||
{
|
{
|
||||||
@ -83,12 +79,9 @@ void CGrannyModelInstance::BlendRenderWithOneTexture()
|
|||||||
if (IsEmpty())
|
if (IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// WORK
|
LPDIRECT3DVERTEXBUFFER9 lpd3dDeformPNTVtxBuf = __GetDeformableD3DVertexBufferPtr();
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dDeformPNTVtxBuf = __GetDeformableD3DVertexBufferPtr();
|
LPDIRECT3DVERTEXBUFFER9 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
||||||
// END_OF_WORK
|
STATEMANAGER.SetFVF(ms_pntVS);
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(ms_pntVS);
|
|
||||||
|
|
||||||
if (lpd3dDeformPNTVtxBuf)
|
if (lpd3dDeformPNTVtxBuf)
|
||||||
{
|
{
|
||||||
@ -110,12 +103,9 @@ void CGrannyModelInstance::RenderWithTwoTexture()
|
|||||||
if (IsEmpty())
|
if (IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(ms_pntVS);
|
LPDIRECT3DVERTEXBUFFER9 lpd3dDeformPNTVtxBuf = __GetDeformableD3DVertexBufferPtr();
|
||||||
|
LPDIRECT3DVERTEXBUFFER9 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
||||||
// WORK
|
STATEMANAGER.SetFVF(ms_pntVS);
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dDeformPNTVtxBuf = __GetDeformableD3DVertexBufferPtr();
|
|
||||||
// END_OF_WORK
|
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
|
||||||
|
|
||||||
if (lpd3dDeformPNTVtxBuf)
|
if (lpd3dDeformPNTVtxBuf)
|
||||||
{
|
{
|
||||||
@ -134,12 +124,9 @@ void CGrannyModelInstance::BlendRenderWithTwoTexture()
|
|||||||
if (IsEmpty())
|
if (IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// WORK
|
LPDIRECT3DVERTEXBUFFER9 lpd3dDeformPNTVtxBuf = __GetDeformableD3DVertexBufferPtr();
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dDeformPNTVtxBuf = __GetDeformableD3DVertexBufferPtr();
|
LPDIRECT3DVERTEXBUFFER9 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
||||||
// END_OF_WORK
|
STATEMANAGER.SetFVF(ms_pntVS);
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(ms_pntVS);
|
|
||||||
|
|
||||||
if (lpd3dDeformPNTVtxBuf)
|
if (lpd3dDeformPNTVtxBuf)
|
||||||
{
|
{
|
||||||
@ -159,14 +146,12 @@ void CGrannyModelInstance::RenderWithoutTexture()
|
|||||||
if (IsEmpty())
|
if (IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(ms_pntVS);
|
STATEMANAGER.SetFVF(ms_pntVS);
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, NULL);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
|
|
||||||
// WORK
|
LPDIRECT3DVERTEXBUFFER9 lpd3dDeformPNTVtxBuf = __GetDeformableD3DVertexBufferPtr();
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dDeformPNTVtxBuf = __GetDeformableD3DVertexBufferPtr();
|
LPDIRECT3DVERTEXBUFFER9 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
||||||
// END_OF_WORK
|
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
|
||||||
|
|
||||||
if (lpd3dDeformPNTVtxBuf)
|
if (lpd3dDeformPNTVtxBuf)
|
||||||
{
|
{
|
||||||
@ -195,7 +180,7 @@ void CGrannyModelInstance::RenderMeshNodeListWithOneTexture(CGrannyMesh::EType e
|
|||||||
{
|
{
|
||||||
assert(m_pModel != NULL);
|
assert(m_pModel != NULL);
|
||||||
|
|
||||||
LPDIRECT3DINDEXBUFFER8 lpd3dIdxBuf = m_pModel->GetD3DIndexBuffer();
|
LPDIRECT3DINDEXBUFFER9 lpd3dIdxBuf = m_pModel->GetD3DIndexBuffer();
|
||||||
assert(lpd3dIdxBuf != NULL);
|
assert(lpd3dIdxBuf != NULL);
|
||||||
|
|
||||||
const CGrannyModel::TMeshNode * pMeshNode = m_pModel->GetMeshNodeList(eMeshType, eMtrlType);
|
const CGrannyModel::TMeshNode * pMeshNode = m_pModel->GetMeshNodeList(eMeshType, eMtrlType);
|
||||||
@ -217,7 +202,7 @@ void CGrannyModelInstance::RenderMeshNodeListWithOneTexture(CGrannyMesh::EType e
|
|||||||
|
|
||||||
CGrannyMaterial& rkMtrl=m_kMtrlPal.GetMaterialRef(pTriGroupNode->mtrlIndex);
|
CGrannyMaterial& rkMtrl=m_kMtrlPal.GetMaterialRef(pTriGroupNode->mtrlIndex);
|
||||||
rkMtrl.ApplyRenderState();
|
rkMtrl.ApplyRenderState();
|
||||||
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, vtxCount, pTriGroupNode->idxPos, pTriGroupNode->triCount);
|
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, vtxCount, pTriGroupNode->idxPos, pTriGroupNode->triCount, vtxMeshBasePos);
|
||||||
rkMtrl.RestoreRenderState();
|
rkMtrl.RestoreRenderState();
|
||||||
|
|
||||||
pTriGroupNode = pTriGroupNode->pNextTriGroupNode;
|
pTriGroupNode = pTriGroupNode->pNextTriGroupNode;
|
||||||
@ -233,7 +218,7 @@ void CGrannyModelInstance::RenderMeshNodeListWithTwoTexture(CGrannyMesh::EType e
|
|||||||
{
|
{
|
||||||
assert(m_pModel != NULL);
|
assert(m_pModel != NULL);
|
||||||
|
|
||||||
LPDIRECT3DINDEXBUFFER8 lpd3dIdxBuf = m_pModel->GetD3DIndexBuffer();
|
LPDIRECT3DINDEXBUFFER9 lpd3dIdxBuf = m_pModel->GetD3DIndexBuffer();
|
||||||
assert(lpd3dIdxBuf != NULL);
|
assert(lpd3dIdxBuf != NULL);
|
||||||
|
|
||||||
const CGrannyModel::TMeshNode * pMeshNode = m_pModel->GetMeshNodeList(eMeshType, eMtrlType);
|
const CGrannyModel::TMeshNode * pMeshNode = m_pModel->GetMeshNodeList(eMeshType, eMtrlType);
|
||||||
@ -256,7 +241,7 @@ void CGrannyModelInstance::RenderMeshNodeListWithTwoTexture(CGrannyMesh::EType e
|
|||||||
const CGrannyMaterial& rkMtrl=m_kMtrlPal.GetMaterialRef(pTriGroupNode->mtrlIndex);
|
const CGrannyMaterial& rkMtrl=m_kMtrlPal.GetMaterialRef(pTriGroupNode->mtrlIndex);
|
||||||
STATEMANAGER.SetTexture(0, rkMtrl.GetD3DTexture(0));
|
STATEMANAGER.SetTexture(0, rkMtrl.GetD3DTexture(0));
|
||||||
STATEMANAGER.SetTexture(1, rkMtrl.GetD3DTexture(1));
|
STATEMANAGER.SetTexture(1, rkMtrl.GetD3DTexture(1));
|
||||||
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, vtxCount, pTriGroupNode->idxPos, pTriGroupNode->triCount);
|
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, vtxCount, pTriGroupNode->idxPos, pTriGroupNode->triCount, vtxMeshBasePos);
|
||||||
pTriGroupNode = pTriGroupNode->pNextTriGroupNode;
|
pTriGroupNode = pTriGroupNode->pNextTriGroupNode;
|
||||||
}
|
}
|
||||||
/////
|
/////
|
||||||
@ -270,7 +255,7 @@ void CGrannyModelInstance::RenderMeshNodeListWithoutTexture(CGrannyMesh::EType e
|
|||||||
{
|
{
|
||||||
assert(m_pModel != NULL);
|
assert(m_pModel != NULL);
|
||||||
|
|
||||||
LPDIRECT3DINDEXBUFFER8 lpd3dIdxBuf = m_pModel->GetD3DIndexBuffer();
|
LPDIRECT3DINDEXBUFFER9 lpd3dIdxBuf = m_pModel->GetD3DIndexBuffer();
|
||||||
assert(lpd3dIdxBuf != NULL);
|
assert(lpd3dIdxBuf != NULL);
|
||||||
|
|
||||||
const CGrannyModel::TMeshNode * pMeshNode = m_pModel->GetMeshNodeList(eMeshType, eMtrlType);
|
const CGrannyModel::TMeshNode * pMeshNode = m_pModel->GetMeshNodeList(eMeshType, eMtrlType);
|
||||||
@ -290,7 +275,7 @@ void CGrannyModelInstance::RenderMeshNodeListWithoutTexture(CGrannyMesh::EType e
|
|||||||
while (pTriGroupNode)
|
while (pTriGroupNode)
|
||||||
{
|
{
|
||||||
ms_faceCount += pTriGroupNode->triCount;
|
ms_faceCount += pTriGroupNode->triCount;
|
||||||
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, vtxCount, pTriGroupNode->idxPos, pTriGroupNode->triCount);
|
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, vtxCount, pTriGroupNode->idxPos, pTriGroupNode->triCount, vtxMeshBasePos);
|
||||||
pTriGroupNode = pTriGroupNode->pNextTriGroupNode;
|
pTriGroupNode = pTriGroupNode->pNextTriGroupNode;
|
||||||
}
|
}
|
||||||
/////
|
/////
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#pragma warning(disable:4786) // character 255 넘어가는거 끄기
|
#pragma warning(disable:4786) // character 255 넘어가는거 끄기
|
||||||
|
|
||||||
//#include <crtdbg.h>
|
//#include <crtdbg.h>
|
||||||
#include <granny.h>
|
#include <granny/granny.h>
|
||||||
|
|
||||||
#include "../eterBase/Utils.h"
|
#include "../eterBase/Utils.h"
|
||||||
#include "../eterBase/Debug.h"
|
#include "../eterBase/Debug.h"
|
||||||
|
@ -93,7 +93,7 @@ void CBlockTexture::Render(int ix, int iy)
|
|||||||
|
|
||||||
STATEMANAGER.SetTexture(0, m_lpd3dTexture);
|
STATEMANAGER.SetTexture(0, m_lpd3dTexture);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_TEX1|D3DFVF_DIFFUSE);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE);
|
||||||
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
|
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ void CBlockTexture::InvalidateRect(const RECT & c_rsrcRect)
|
|||||||
|
|
||||||
bool CBlockTexture::Create(CGraphicDib * pDIB, const RECT & c_rRect, DWORD dwWidth, DWORD dwHeight)
|
bool CBlockTexture::Create(CGraphicDib * pDIB, const RECT & c_rRect, DWORD dwWidth, DWORD dwHeight)
|
||||||
{
|
{
|
||||||
if (FAILED(ms_lpd3dDevice->CreateTexture(dwWidth, dwHeight, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_lpd3dTexture)))
|
if (FAILED(ms_lpd3dDevice->CreateTexture(dwWidth, dwHeight, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_lpd3dTexture, NULL)))
|
||||||
{
|
{
|
||||||
Tracef("Failed to create block texture %u, %u\n", dwWidth, dwHeight);
|
Tracef("Failed to create block texture %u, %u\n", dwWidth, dwHeight);
|
||||||
return false;
|
return false;
|
||||||
|
@ -22,5 +22,5 @@ class CBlockTexture : public CGraphicBase
|
|||||||
BOOL m_bClipEnable;
|
BOOL m_bClipEnable;
|
||||||
DWORD m_dwWidth;
|
DWORD m_dwWidth;
|
||||||
DWORD m_dwHeight;
|
DWORD m_dwHeight;
|
||||||
LPDIRECT3DTEXTURE8 m_lpd3dTexture;
|
LPDIRECT3DTEXTURE9 m_lpd3dTexture;
|
||||||
};
|
};
|
||||||
|
@ -279,7 +279,7 @@ void CCamera::SetViewMatrix()
|
|||||||
|
|
||||||
D3DXMatrixLookAtRH(&m_matView, &m_v3Eye, &m_v3Target, &m_v3Up);
|
D3DXMatrixLookAtRH(&m_matView, &m_v3Eye, &m_v3Target, &m_v3Up);
|
||||||
|
|
||||||
float fDeterminantD3DMatView = D3DXMatrixfDeterminant(&m_matView);
|
float fDeterminantD3DMatView = D3DXMatrixDeterminant(&m_matView);
|
||||||
D3DXMatrixInverse(&m_matInverseView, &fDeterminantD3DMatView, &m_matView);
|
D3DXMatrixInverse(&m_matInverseView, &fDeterminantD3DMatView, &m_matView);
|
||||||
|
|
||||||
m_matBillboard = m_matInverseView;
|
m_matBillboard = m_matInverseView;
|
||||||
|
@ -225,7 +225,7 @@ void CDecal::Render()
|
|||||||
D3DXMatrixIdentity(&matWorld);
|
D3DXMatrixIdentity(&matWorld);
|
||||||
STATEMANAGER.SetTransform(D3DTS_WORLD, &matWorld);
|
STATEMANAGER.SetTransform(D3DTS_WORLD, &matWorld);
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
|
|
||||||
for (DWORD dwi = 0; dwi < m_TriangleFanStructVector.size(); ++dwi)
|
for (DWORD dwi = 0; dwi < m_TriangleFanStructVector.size(); ++dwi)
|
||||||
STATEMANAGER.DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN,
|
STATEMANAGER.DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN,
|
||||||
|
@ -27,11 +27,11 @@ D3D_CDisplayModeAutoDetector CGraphicBase::ms_kD3DDetector;
|
|||||||
HWND CGraphicBase::ms_hWnd;
|
HWND CGraphicBase::ms_hWnd;
|
||||||
HDC CGraphicBase::ms_hDC;
|
HDC CGraphicBase::ms_hDC;
|
||||||
|
|
||||||
LPDIRECT3D8 CGraphicBase::ms_lpd3d = NULL;
|
LPDIRECT3D9 CGraphicBase::ms_lpd3d = NULL;
|
||||||
LPDIRECT3DDEVICE8 CGraphicBase::ms_lpd3dDevice = NULL;
|
LPDIRECT3DDEVICE9 CGraphicBase::ms_lpd3dDevice = NULL;
|
||||||
ID3DXMatrixStack * CGraphicBase::ms_lpd3dMatStack = NULL;
|
ID3DXMatrixStack * CGraphicBase::ms_lpd3dMatStack = NULL;
|
||||||
D3DPRESENT_PARAMETERS CGraphicBase::ms_d3dPresentParameter;
|
D3DPRESENT_PARAMETERS CGraphicBase::ms_d3dPresentParameter;
|
||||||
D3DVIEWPORT8 CGraphicBase::ms_Viewport;
|
D3DVIEWPORT9 CGraphicBase::ms_Viewport;
|
||||||
|
|
||||||
HRESULT CGraphicBase::ms_hLastResult = NULL;
|
HRESULT CGraphicBase::ms_hLastResult = NULL;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ int CGraphicBase::ms_iHeight;
|
|||||||
|
|
||||||
DWORD CGraphicBase::ms_faceCount = 0;
|
DWORD CGraphicBase::ms_faceCount = 0;
|
||||||
|
|
||||||
D3DCAPS8 CGraphicBase::ms_d3dCaps;
|
D3DCAPS9 CGraphicBase::ms_d3dCaps;
|
||||||
|
|
||||||
DWORD CGraphicBase::ms_dwD3DBehavior = 0;
|
DWORD CGraphicBase::ms_dwD3DBehavior = 0;
|
||||||
|
|
||||||
@ -96,9 +96,9 @@ std::vector<TIndex> CGraphicBase::ms_fillCubeIdxVector;
|
|||||||
LPD3DXMESH CGraphicBase::ms_lpSphereMesh = NULL;
|
LPD3DXMESH CGraphicBase::ms_lpSphereMesh = NULL;
|
||||||
LPD3DXMESH CGraphicBase::ms_lpCylinderMesh = NULL;
|
LPD3DXMESH CGraphicBase::ms_lpCylinderMesh = NULL;
|
||||||
|
|
||||||
LPDIRECT3DVERTEXBUFFER8 CGraphicBase::ms_alpd3dPDTVB[PDT_VERTEXBUFFER_NUM];
|
LPDIRECT3DVERTEXBUFFER9 CGraphicBase::ms_alpd3dPDTVB[PDT_VERTEXBUFFER_NUM];
|
||||||
|
|
||||||
LPDIRECT3DINDEXBUFFER8 CGraphicBase::ms_alpd3dDefIB[DEFAULT_IB_NUM];
|
LPDIRECT3DINDEXBUFFER9 CGraphicBase::ms_alpd3dDefIB[DEFAULT_IB_NUM];
|
||||||
|
|
||||||
bool CGraphicBase::IsLowTextureMemory()
|
bool CGraphicBase::IsLowTextureMemory()
|
||||||
{
|
{
|
||||||
@ -158,7 +158,7 @@ bool CGraphicBase::SetPDTStream(SPDTVertexRaw* pSrcVertices, UINT uVtxCount)
|
|||||||
if (s_dwVBPos>=PDT_VERTEXBUFFER_NUM)
|
if (s_dwVBPos>=PDT_VERTEXBUFFER_NUM)
|
||||||
s_dwVBPos=0;
|
s_dwVBPos=0;
|
||||||
|
|
||||||
IDirect3DVertexBuffer8* plpd3dFillRectVB=ms_alpd3dPDTVB[s_dwVBPos];
|
IDirect3DVertexBuffer9* plpd3dFillRectVB = ms_alpd3dPDTVB[s_dwVBPos];
|
||||||
++s_dwVBPos;
|
++s_dwVBPos;
|
||||||
|
|
||||||
assert(PDT_VERTEX_NUM>=uVtxCount);
|
assert(PDT_VERTEX_NUM>=uVtxCount);
|
||||||
@ -166,9 +166,7 @@ bool CGraphicBase::SetPDTStream(SPDTVertexRaw* pSrcVertices, UINT uVtxCount)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
TPDTVertex* pDstVertices;
|
TPDTVertex* pDstVertices;
|
||||||
if (FAILED(
|
if (FAILED(plpd3dFillRectVB->Lock(0, sizeof(TPDTVertex) * uVtxCount, (void**)&pDstVertices, D3DLOCK_DISCARD)))
|
||||||
plpd3dFillRectVB->Lock(0, sizeof(TPDTVertex)*uVtxCount, (BYTE**)&pDstVertices, D3DLOCK_DISCARD)
|
|
||||||
))
|
|
||||||
{
|
{
|
||||||
STATEMANAGER.SetStreamSource(0, NULL, 0);
|
STATEMANAGER.SetStreamSource(0, NULL, 0);
|
||||||
return false;
|
return false;
|
||||||
|
@ -247,13 +247,13 @@ class CGraphicBase
|
|||||||
|
|
||||||
static HWND ms_hWnd;
|
static HWND ms_hWnd;
|
||||||
static HDC ms_hDC;
|
static HDC ms_hDC;
|
||||||
static LPDIRECT3D8 ms_lpd3d;
|
static LPDIRECT3D9 ms_lpd3d;
|
||||||
static LPDIRECT3DDEVICE8 ms_lpd3dDevice;
|
static LPDIRECT3DDEVICE9 ms_lpd3dDevice;
|
||||||
static ID3DXMatrixStack* ms_lpd3dMatStack;
|
static ID3DXMatrixStack* ms_lpd3dMatStack;
|
||||||
static D3DVIEWPORT8 ms_Viewport;
|
static D3DVIEWPORT9 ms_Viewport;
|
||||||
|
|
||||||
static DWORD ms_faceCount;
|
static DWORD ms_faceCount;
|
||||||
static D3DCAPS8 ms_d3dCaps;
|
static D3DCAPS9 ms_d3dCaps;
|
||||||
static D3DPRESENT_PARAMETERS ms_d3dPresentParameter;
|
static D3DPRESENT_PARAMETERS ms_d3dPresentParameter;
|
||||||
|
|
||||||
static DWORD ms_dwD3DBehavior;
|
static DWORD ms_dwD3DBehavior;
|
||||||
@ -307,6 +307,6 @@ class CGraphicBase
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static LPDIRECT3DVERTEXBUFFER8 ms_alpd3dPDTVB[PDT_VERTEXBUFFER_NUM];
|
static LPDIRECT3DVERTEXBUFFER9 ms_alpd3dPDTVB[PDT_VERTEXBUFFER_NUM];
|
||||||
static LPDIRECT3DINDEXBUFFER8 ms_alpd3dDefIB[DEFAULT_IB_NUM];
|
static LPDIRECT3DINDEXBUFFER9 ms_alpd3dDefIB[DEFAULT_IB_NUM];
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,7 @@ const D3DFORMAT& D3D_CAdapterDisplayModeList::GetPixelFormatr(UINT iD3DFmt)
|
|||||||
return m_aeD3DFmt[iD3DFmt];
|
return m_aeD3DFmt[iD3DFmt];
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID D3D_CAdapterDisplayModeList::Build(IDirect3D8& rkD3D, D3DFORMAT eD3DFmtDefault, UINT iD3DAdapterInfo)
|
VOID D3D_CAdapterDisplayModeList::Build(IDirect3D9& rkD3D, D3DFORMAT eD3DFmtDefault, UINT iD3DAdapterInfo)
|
||||||
{
|
{
|
||||||
D3DDISPLAYMODE* akD3DDM=m_akD3DDM;
|
D3DDISPLAYMODE* akD3DDM=m_akD3DDM;
|
||||||
D3DFORMAT* aeD3DFmt=m_aeD3DFmt;
|
D3DFORMAT* aeD3DFmt=m_aeD3DFmt;
|
||||||
@ -77,11 +77,11 @@ VOID D3D_CAdapterDisplayModeList::Build(IDirect3D8& rkD3D, D3DFORMAT eD3DFmtDefa
|
|||||||
|
|
||||||
aeD3DFmt[uD3DFmtNum++]=eD3DFmtDefault;
|
aeD3DFmt[uD3DFmtNum++]=eD3DFmtDefault;
|
||||||
|
|
||||||
UINT uAdapterModeNum=rkD3D.GetAdapterModeCount(iD3DAdapterInfo);
|
UINT uAdapterModeNum = rkD3D.GetAdapterModeCount(iD3DAdapterInfo, eD3DFmtDefault);
|
||||||
for (UINT iD3DAdapterInfoMode=0; iD3DAdapterInfoMode<uAdapterModeNum; iD3DAdapterInfoMode++)
|
for (UINT iD3DAdapterInfoMode=0; iD3DAdapterInfoMode<uAdapterModeNum; iD3DAdapterInfoMode++)
|
||||||
{
|
{
|
||||||
D3DDISPLAYMODE kD3DDMCur;
|
D3DDISPLAYMODE kD3DDMCur;
|
||||||
rkD3D.EnumAdapterModes(iD3DAdapterInfo, iD3DAdapterInfoMode, &kD3DDMCur);
|
rkD3D.EnumAdapterModes(iD3DAdapterInfo, eD3DFmtDefault, iD3DAdapterInfoMode, &kD3DDMCur);
|
||||||
|
|
||||||
// IsFilterOutLowResolutionMode
|
// IsFilterOutLowResolutionMode
|
||||||
if( kD3DDMCur.Width < FILTEROUT_LOWRESOLUTION_WIDTH || kD3DDMCur.Height < FILTEROUT_LOWRESOLUTION_HEIGHT )
|
if( kD3DDMCur.Width < FILTEROUT_LOWRESOLUTION_WIDTH || kD3DDMCur.Height < FILTEROUT_LOWRESOLUTION_HEIGHT )
|
||||||
@ -178,7 +178,7 @@ D3D_SModeInfo* D3D_CDeviceInfo::GetD3DModeInfop(UINT iD3D_SModeInfo)
|
|||||||
return &m_akD3DModeInfo[iD3D_SModeInfo];
|
return &m_akD3DModeInfo[iD3D_SModeInfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL D3D_CDeviceInfo::FindDepthStencilFormat(IDirect3D8& rkD3D, UINT iD3DAdapterInfo, D3DDEVTYPE DeviceType, D3DFORMAT TargetFormat, D3DFORMAT* pDepthStencilFormat )
|
BOOL D3D_CDeviceInfo::FindDepthStencilFormat(IDirect3D9& rkD3D, UINT iD3DAdapterInfo, D3DDEVTYPE DeviceType, D3DFORMAT TargetFormat, D3DFORMAT* pDepthStencilFormat)
|
||||||
{
|
{
|
||||||
UINT m_dwMinDepthBits = 16;
|
UINT m_dwMinDepthBits = 16;
|
||||||
UINT m_dwMinStencilBits = 0;
|
UINT m_dwMinStencilBits = 0;
|
||||||
@ -270,8 +270,8 @@ BOOL D3D_CDeviceInfo::FindDepthStencilFormat(IDirect3D8& rkD3D, UINT iD3DAdapter
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL D3D_CDeviceInfo::Build(IDirect3D8& rkD3D, UINT iD3DAdapterInfo, UINT iDevType, D3D_CAdapterDisplayModeList& rkD3DADMList, BOOL (*pfnConfirmDevice)(D3DCAPS8& rkD3DCaps, UINT uBehavior, D3DFORMAT eD3DFmt))
|
BOOL D3D_CDeviceInfo::Build(IDirect3D9& rkD3D, UINT iD3DAdapterInfo, UINT iDevType, D3D_CAdapterDisplayModeList& rkD3DADMList, BOOL(*pfnConfirmDevice)(D3DCAPS9& rkD3DCaps, UINT uBehavior, D3DFORMAT eD3DFmt))
|
||||||
{
|
{
|
||||||
assert(pfnConfirmDevice!=NULL && "D3D_CDeviceInfo::Build");
|
assert(pfnConfirmDevice!=NULL && "D3D_CDeviceInfo::Build");
|
||||||
|
|
||||||
const D3DDEVTYPE c_eD3DDevType=msc_aeD3DDevType[iDevType];
|
const D3DDEVTYPE c_eD3DDevType=msc_aeD3DDevType[iDevType];
|
||||||
@ -315,15 +315,10 @@ BOOL D3D_CDeviceInfo::Build(IDirect3D8& rkD3D, UINT iD3DAdapterInfo, UINT iDevTy
|
|||||||
if (D3DDEVTYPE_HAL==m_eD3DDevType)
|
if (D3DDEVTYPE_HAL==m_eD3DDevType)
|
||||||
{
|
{
|
||||||
isHALExists=TRUE;
|
isHALExists=TRUE;
|
||||||
|
isHALWindowedCompatible=TRUE;
|
||||||
if (m_kD3DCaps.Caps2 & D3DCAPS2_CANRENDERWINDOWED)
|
|
||||||
{
|
|
||||||
isHALWindowedCompatible=TRUE;
|
|
||||||
|
|
||||||
if (iFmt==0)
|
if (iFmt==0)
|
||||||
isHALDesktopCompatible=TRUE;
|
isHALDesktopCompatible=TRUE;
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirm the device/format for HW vertex processing
|
// Confirm the device/format for HW vertex processing
|
||||||
@ -407,7 +402,7 @@ BOOL D3D_CDeviceInfo::Build(IDirect3D8& rkD3D, UINT iD3DAdapterInfo, UINT iDevTy
|
|||||||
|
|
||||||
// Check if the device is compatible with the desktop display mode
|
// Check if the device is compatible with the desktop display mode
|
||||||
// (which was added initially as formats[0])
|
// (which was added initially as formats[0])
|
||||||
if (aisFormatConfirmed[0] && (m_kD3DCaps.Caps2 & D3DCAPS2_CANRENDERWINDOWED) )
|
if (aisFormatConfirmed[0])
|
||||||
{
|
{
|
||||||
m_canDoWindowed=TRUE;
|
m_canDoWindowed=TRUE;
|
||||||
m_isWindowed=TRUE;
|
m_isWindowed=TRUE;
|
||||||
@ -523,14 +518,15 @@ BOOL D3D_CAdapterInfo::Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL D3D_CAdapterInfo::Build(IDirect3D8& rkD3D, UINT iD3DAdapterInfo, PFNCONFIRMDEVICE pfnConfirmDevice)
|
BOOL D3D_CAdapterInfo::Build(IDirect3D9& rkD3D, UINT iD3DAdapterInfo, PFNCONFIRMDEVICE pfnConfirmDevice)
|
||||||
{
|
{
|
||||||
D3DDISPLAYMODE& rkD3DDMDesktop=m_kD3DDMDesktop;
|
D3DDISPLAYMODE& rkD3DDMDesktop=m_kD3DDMDesktop;
|
||||||
if (FAILED(rkD3D.GetAdapterDisplayMode(iD3DAdapterInfo, &rkD3DDMDesktop)))
|
if (FAILED(rkD3D.GetAdapterDisplayMode(iD3DAdapterInfo, &rkD3DDMDesktop)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
rkD3D.GetAdapterIdentifier(iD3DAdapterInfo, D3DENUM_NO_WHQL_LEVEL, &m_kD3DAdapterIdentifier);
|
//rkD3D.GetAdapterIdentifier(iD3DAdapterInfo, D3DENUM_WHQL_LEVEL, &m_kD3DAdapterIdentifier);
|
||||||
|
rkD3D.GetAdapterIdentifier(iD3DAdapterInfo, 0, &m_kD3DAdapterIdentifier);
|
||||||
|
|
||||||
m_iCurD3DDevInfo=0;
|
m_iCurD3DDevInfo=0;
|
||||||
m_uD3DDevInfoNum=0;
|
m_uD3DDevInfoNum=0;
|
||||||
|
|
||||||
@ -613,7 +609,7 @@ BOOL D3D_CDisplayModeAutoDetector::Find(UINT uScrWidth, UINT uScrHeight, UINT uS
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL D3D_CDisplayModeAutoDetector::Build(IDirect3D8& rkD3D, PFNCONFIRMDEVICE pfnConfirmDevice)
|
BOOL D3D_CDisplayModeAutoDetector::Build(IDirect3D9& rkD3D, PFNCONFIRMDEVICE pfnConfirmDevice)
|
||||||
{
|
{
|
||||||
m_uD3DAdapterInfoCount=0;
|
m_uD3DAdapterInfoCount=0;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <d3d8.h>
|
#include <d3d9.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
typedef BOOL (*PFNCONFIRMDEVICE) (D3DCAPS8& rkD3DCaps, UINT uBehavior, D3DFORMAT eD3DFmt);
|
typedef BOOL(*PFNCONFIRMDEVICE) (D3DCAPS9& rkD3DCaps, UINT uBehavior, D3DFORMAT eD3DFmt);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ class D3D_CAdapterDisplayModeList
|
|||||||
public:
|
public:
|
||||||
D3D_CAdapterDisplayModeList() {}
|
D3D_CAdapterDisplayModeList() {}
|
||||||
~D3D_CAdapterDisplayModeList() {}
|
~D3D_CAdapterDisplayModeList() {}
|
||||||
VOID Build(IDirect3D8& rkD3D, D3DFORMAT eD3DFmtDefault, UINT iAdapter);
|
VOID Build(IDirect3D9& rkD3D, D3DFORMAT eD3DFmtDefault, UINT iAdapter);
|
||||||
|
|
||||||
UINT GetDisplayModeNum();
|
UINT GetDisplayModeNum();
|
||||||
UINT GetPixelFormatNum();
|
UINT GetPixelFormatNum();
|
||||||
@ -61,14 +61,14 @@ class D3D_CDeviceInfo
|
|||||||
public:
|
public:
|
||||||
D3D_CDeviceInfo() {}
|
D3D_CDeviceInfo() {}
|
||||||
~D3D_CDeviceInfo() {}
|
~D3D_CDeviceInfo() {}
|
||||||
BOOL Build(IDirect3D8& rkD3D, UINT iAdapter, UINT iDevType, D3D_CAdapterDisplayModeList& rkD3DADMList, PFNCONFIRMDEVICE pfnConfirmDevice);
|
BOOL Build(IDirect3D9& rkD3D, UINT iAdapter, UINT iDevType, D3D_CAdapterDisplayModeList& rkD3DADMList, PFNCONFIRMDEVICE pfnConfirmDevice);
|
||||||
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo);
|
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo);
|
||||||
|
|
||||||
UINT GetD3DModeInfoNum();
|
UINT GetD3DModeInfoNum();
|
||||||
|
|
||||||
VOID GetString(std::string* pstEnumList);
|
VOID GetString(std::string* pstEnumList);
|
||||||
|
|
||||||
BOOL FindDepthStencilFormat(IDirect3D8& rkD3D, UINT iAdapter, D3DDEVTYPE DeviceType, D3DFORMAT TargetFormat, D3DFORMAT* pDepthStencilFormat);
|
BOOL FindDepthStencilFormat(IDirect3D9& rkD3D, UINT iAdapter, D3DDEVTYPE DeviceType, D3DFORMAT TargetFormat, D3DFORMAT* pDepthStencilFormat);
|
||||||
|
|
||||||
D3D_SModeInfo& GetD3DModeInfor(UINT iD3DModeInfo);
|
D3D_SModeInfo& GetD3DModeInfor(UINT iD3DModeInfo);
|
||||||
D3D_SModeInfo* GetD3DModeInfop(UINT iD3DModeInfo);
|
D3D_SModeInfo* GetD3DModeInfop(UINT iD3DModeInfo);
|
||||||
@ -84,7 +84,7 @@ class D3D_CDeviceInfo
|
|||||||
const TCHAR* m_szDevDesc;
|
const TCHAR* m_szDevDesc;
|
||||||
|
|
||||||
D3DDEVTYPE m_eD3DDevType;
|
D3DDEVTYPE m_eD3DDevType;
|
||||||
D3DCAPS8 m_kD3DCaps;
|
D3DCAPS9 m_kD3DCaps;
|
||||||
BOOL m_canDoWindowed;
|
BOOL m_canDoWindowed;
|
||||||
|
|
||||||
UINT m_iCurD3DModeInfo;
|
UINT m_iCurD3DModeInfo;
|
||||||
@ -110,10 +110,10 @@ class D3D_CAdapterInfo
|
|||||||
~D3D_CAdapterInfo() {}
|
~D3D_CAdapterInfo() {}
|
||||||
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo, UINT* piD3DDevInfo);
|
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo, UINT* piD3DDevInfo);
|
||||||
|
|
||||||
BOOL Build(IDirect3D8& rkD3D, UINT iAdapter, PFNCONFIRMDEVICE pfnConfirmDevice);
|
BOOL Build(IDirect3D9& rkD3D, UINT iAdapter, PFNCONFIRMDEVICE pfnConfirmDevice);
|
||||||
VOID GetString(std::string* pstEnumList);
|
VOID GetString(std::string* pstEnumList);
|
||||||
|
|
||||||
D3DADAPTER_IDENTIFIER8& GetIdentifier()
|
D3DADAPTER_IDENTIFIER9& GetIdentifier()
|
||||||
{
|
{
|
||||||
return m_kD3DAdapterIdentifier;
|
return m_kD3DAdapterIdentifier;
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ class D3D_CAdapterInfo
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
D3DADAPTER_IDENTIFIER8 m_kD3DAdapterIdentifier;
|
D3DADAPTER_IDENTIFIER9 m_kD3DAdapterIdentifier;
|
||||||
D3DDISPLAYMODE m_kD3DDMDesktop;
|
D3DDISPLAYMODE m_kD3DDMDesktop;
|
||||||
|
|
||||||
UINT m_iCurD3DDevInfo;
|
UINT m_iCurD3DDevInfo;
|
||||||
@ -148,7 +148,7 @@ class D3D_CDisplayModeAutoDetector
|
|||||||
~D3D_CDisplayModeAutoDetector();
|
~D3D_CDisplayModeAutoDetector();
|
||||||
|
|
||||||
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo, UINT* piD3DDevInfo, UINT* piD3DAdapterInfo);
|
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo, UINT* piD3DDevInfo, UINT* piD3DAdapterInfo);
|
||||||
BOOL Build(IDirect3D8& rkD3D, PFNCONFIRMDEVICE pfnConfirmDevice);
|
BOOL Build(IDirect3D9& rkD3D, PFNCONFIRMDEVICE pfnConfirmDevice);
|
||||||
|
|
||||||
D3D_CAdapterInfo* GetD3DAdapterInfop(UINT iD3DAdapterInfo);
|
D3D_CAdapterInfo* GetD3DAdapterInfop(UINT iD3DAdapterInfo);
|
||||||
D3D_SModeInfo* GetD3DModeInfop(UINT iD3DAdapterInfo, UINT iD3DDevInfo, UINT iD3DModeInfo);
|
D3D_SModeInfo* GetD3DModeInfop(UINT iD3DAdapterInfo, UINT iD3DDevInfo, UINT iD3DModeInfo);
|
||||||
|
@ -76,11 +76,11 @@ void CGraphicDevice::EnableWebBrowserMode(const RECT& c_rcWebPage)
|
|||||||
g_rcBrowser=c_rcWebPage;
|
g_rcBrowser=c_rcWebPage;
|
||||||
|
|
||||||
//rkD3DPP.Windowed=TRUE;
|
//rkD3DPP.Windowed=TRUE;
|
||||||
rkD3DPP.SwapEffect=D3DSWAPEFFECT_COPY;
|
rkD3DPP.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||||
rkD3DPP.BackBufferCount = 1;
|
rkD3DPP.BackBufferCount = 0;
|
||||||
rkD3DPP.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
rkD3DPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||||
|
|
||||||
IDirect3DDevice8& rkD3DDev=*ms_lpd3dDevice;
|
IDirect3DDevice9& rkD3DDev = *ms_lpd3dDevice;
|
||||||
HRESULT hr=rkD3DDev.Reset(&rkD3DPP);
|
HRESULT hr=rkD3DDev.Reset(&rkD3DPP);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return;
|
return;
|
||||||
@ -99,7 +99,7 @@ void CGraphicDevice::DisableWebBrowserMode()
|
|||||||
|
|
||||||
rkD3DPP=g_kD3DPP;
|
rkD3DPP=g_kD3DPP;
|
||||||
|
|
||||||
IDirect3DDevice8& rkD3DDev=*ms_lpd3dDevice;
|
IDirect3DDevice9& rkD3DDev=*ms_lpd3dDevice;
|
||||||
HRESULT hr=rkD3DDev.Reset(&rkD3DPP);
|
HRESULT hr=rkD3DDev.Reset(&rkD3DPP);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return;
|
return;
|
||||||
@ -120,7 +120,7 @@ bool CGraphicDevice::ResizeBackBuffer(UINT uWidth, UINT uHeight)
|
|||||||
rkD3DPP.BackBufferWidth=uWidth;
|
rkD3DPP.BackBufferWidth=uWidth;
|
||||||
rkD3DPP.BackBufferHeight=uHeight;
|
rkD3DPP.BackBufferHeight=uHeight;
|
||||||
|
|
||||||
IDirect3DDevice8& rkD3DDev=*ms_lpd3dDevice;
|
IDirect3DDevice9& rkD3DDev=*ms_lpd3dDevice;
|
||||||
|
|
||||||
HRESULT hr=rkD3DDev.Reset(&rkD3DPP);
|
HRESULT hr=rkD3DDev.Reset(&rkD3DPP);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
@ -138,91 +138,13 @@ bool CGraphicDevice::ResizeBackBuffer(UINT uWidth, UINT uHeight)
|
|||||||
DWORD CGraphicDevice::CreatePNTStreamVertexShader()
|
DWORD CGraphicDevice::CreatePNTStreamVertexShader()
|
||||||
{
|
{
|
||||||
assert(ms_lpd3dDevice != NULL);
|
assert(ms_lpd3dDevice != NULL);
|
||||||
|
return D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1;
|
||||||
DWORD declVector[] =
|
|
||||||
{
|
|
||||||
D3DVSD_STREAM(0),
|
|
||||||
D3DVSD_REG(0, D3DVSDT_FLOAT3),
|
|
||||||
D3DVSD_REG(3, D3DVSDT_FLOAT3),
|
|
||||||
D3DVSD_REG(7, D3DVSDT_FLOAT2),
|
|
||||||
D3DVSD_END()
|
|
||||||
};
|
|
||||||
|
|
||||||
DWORD ret;
|
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateVertexShader(&declVector[0], NULL, &ret, 0)))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD CGraphicDevice::CreatePNT2StreamVertexShader()
|
DWORD CGraphicDevice::CreatePNT2StreamVertexShader()
|
||||||
{
|
{
|
||||||
assert(ms_lpd3dDevice != NULL);
|
assert(ms_lpd3dDevice != NULL);
|
||||||
|
return D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 | D3DFVF_TEX2;
|
||||||
DWORD declVector[] =
|
|
||||||
{
|
|
||||||
D3DVSD_STREAM(0),
|
|
||||||
D3DVSD_REG(0, D3DVSDT_FLOAT3),
|
|
||||||
D3DVSD_REG(3, D3DVSDT_FLOAT3),
|
|
||||||
D3DVSD_REG(7, D3DVSDT_FLOAT2),
|
|
||||||
D3DVSD_REG(D3DVSDE_TEXCOORD1, D3DVSDT_FLOAT2),
|
|
||||||
// D3DVSD_STREAM(1),
|
|
||||||
D3DVSD_END()
|
|
||||||
};
|
|
||||||
|
|
||||||
DWORD ret;
|
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateVertexShader(&declVector[0], NULL, &ret, 0)))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD CGraphicDevice::CreatePTStreamVertexShader()
|
|
||||||
{
|
|
||||||
assert(ms_lpd3dDevice != NULL);
|
|
||||||
|
|
||||||
DWORD declVector[] =
|
|
||||||
{
|
|
||||||
D3DVSD_STREAM(0),
|
|
||||||
D3DVSD_REG(0, D3DVSDT_FLOAT3),
|
|
||||||
D3DVSD_STREAM(1),
|
|
||||||
D3DVSD_REG(7, D3DVSDT_FLOAT2),
|
|
||||||
D3DVSD_END()
|
|
||||||
};
|
|
||||||
|
|
||||||
DWORD ret;
|
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateVertexShader(&declVector[0], NULL, &ret, 0)))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD CGraphicDevice::CreateDoublePNTStreamVertexShader()
|
|
||||||
{
|
|
||||||
assert(ms_lpd3dDevice != NULL);
|
|
||||||
|
|
||||||
DWORD declVector[] =
|
|
||||||
{
|
|
||||||
D3DVSD_STREAM(0),
|
|
||||||
D3DVSD_REG(0, D3DVSDT_FLOAT3),
|
|
||||||
D3DVSD_REG(3, D3DVSDT_FLOAT3),
|
|
||||||
D3DVSD_REG(7, D3DVSDT_FLOAT2),
|
|
||||||
D3DVSD_STREAM(1),
|
|
||||||
D3DVSD_REG(D3DVSDE_POSITION2, D3DVSDT_FLOAT3),
|
|
||||||
D3DVSD_REG(D3DVSDE_NORMAL2, D3DVSDT_FLOAT3),
|
|
||||||
D3DVSD_REG(D3DVSDE_TEXCOORD1, D3DVSDT_FLOAT2),
|
|
||||||
D3DVSD_END()
|
|
||||||
};
|
|
||||||
|
|
||||||
DWORD ret;
|
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateVertexShader(&declVector[0], NULL, &ret, 0)))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGraphicDevice::EDeviceState CGraphicDevice::GetDeviceState()
|
CGraphicDevice::EDeviceState CGraphicDevice::GetDeviceState()
|
||||||
@ -256,10 +178,10 @@ bool CGraphicDevice::Reset()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LPDIRECT3DSURFACE8 s_lpStencil;
|
static LPDIRECT3DSURFACE9 s_lpStencil;
|
||||||
static DWORD s_MaxTextureWidth, s_MaxTextureHeight;
|
static DWORD s_MaxTextureWidth, s_MaxTextureHeight;
|
||||||
|
|
||||||
BOOL EL3D_ConfirmDevice(D3DCAPS8& rkD3DCaps, UINT uBehavior, D3DFORMAT /*eD3DFmt*/)
|
BOOL EL3D_ConfirmDevice(D3DCAPS9& rkD3DCaps, UINT uBehavior, D3DFORMAT /*eD3DFmt*/)
|
||||||
{
|
{
|
||||||
// PUREDEVICE´Â GetTransform / GetViewport µîÀÌ µÇÁö ¾Ê´Â´Ù.
|
// PUREDEVICE´Â GetTransform / GetViewport µîÀÌ µÇÁö ¾Ê´Â´Ù.
|
||||||
if (uBehavior & D3DCREATE_PUREDEVICE)
|
if (uBehavior & D3DCREATE_PUREDEVICE)
|
||||||
@ -307,7 +229,7 @@ DWORD GetMaxTextureHeight()
|
|||||||
|
|
||||||
bool CGraphicDevice::__IsInDriverBlackList(D3D_CAdapterInfo& rkD3DAdapterInfo)
|
bool CGraphicDevice::__IsInDriverBlackList(D3D_CAdapterInfo& rkD3DAdapterInfo)
|
||||||
{
|
{
|
||||||
D3DADAPTER_IDENTIFIER8& rkD3DAdapterIdentifier=rkD3DAdapterInfo.GetIdentifier();
|
D3DADAPTER_IDENTIFIER9& rkD3DAdapterIdentifier = rkD3DAdapterInfo.GetIdentifier();
|
||||||
|
|
||||||
char szSrcDriver[256];
|
char szSrcDriver[256];
|
||||||
strncpy(szSrcDriver, rkD3DAdapterIdentifier.Driver, sizeof(szSrcDriver)-1);
|
strncpy(szSrcDriver, rkD3DAdapterIdentifier.Driver, sizeof(szSrcDriver)-1);
|
||||||
@ -356,7 +278,7 @@ int CGraphicDevice::Create(HWND hWnd, int iHres, int iVres, bool Windowed, int /
|
|||||||
|
|
||||||
ms_hWnd = hWnd;
|
ms_hWnd = hWnd;
|
||||||
ms_hDC = GetDC(hWnd);
|
ms_hDC = GetDC(hWnd);
|
||||||
ms_lpd3d = Direct3DCreate8(D3D_SDK_VERSION);
|
ms_lpd3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||||
|
|
||||||
if (!ms_lpd3d)
|
if (!ms_lpd3d)
|
||||||
return CREATE_NO_DIRECTX;
|
return CREATE_NO_DIRECTX;
|
||||||
@ -393,7 +315,7 @@ int CGraphicDevice::Create(HWND hWnd, int iHres, int iVres, bool Windowed, int /
|
|||||||
return CREATE_DETECT;
|
return CREATE_DETECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3DADAPTER_IDENTIFIER8& rkD3DAdapterId=pkD3DAdapterInfo->GetIdentifier();
|
D3DADAPTER_IDENTIFIER9& rkD3DAdapterId = pkD3DAdapterInfo->GetIdentifier();
|
||||||
if (Windowed &&
|
if (Windowed &&
|
||||||
strnicmp(rkD3DAdapterId.Driver, "3dfx", 4)==0 &&
|
strnicmp(rkD3DAdapterId.Driver, "3dfx", 4)==0 &&
|
||||||
22 == pkD3DAdapterInfo->GetDesktopD3DDisplayModer().Format)
|
22 == pkD3DAdapterInfo->GetDesktopD3DDisplayModer().Format)
|
||||||
@ -526,11 +448,11 @@ RETRY:
|
|||||||
ms_lpd3dDevice->GetViewport(&ms_Viewport);
|
ms_lpd3dDevice->GetViewport(&ms_Viewport);
|
||||||
|
|
||||||
m_pStateManager = new CStateManager(ms_lpd3dDevice);
|
m_pStateManager = new CStateManager(ms_lpd3dDevice);
|
||||||
|
m_pStateManager->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
|
||||||
|
|
||||||
D3DXCreateMatrixStack(0, &ms_lpd3dMatStack);
|
D3DXCreateMatrixStack(0, &ms_lpd3dMatStack);
|
||||||
ms_lpd3dMatStack->LoadIdentity();
|
ms_lpd3dMatStack->LoadIdentity();
|
||||||
|
|
||||||
ms_ptVS = CreatePTStreamVertexShader();
|
|
||||||
ms_pntVS = CreatePNTStreamVertexShader();
|
ms_pntVS = CreatePNTStreamVertexShader();
|
||||||
ms_pnt2VS = CreatePNT2StreamVertexShader();
|
ms_pnt2VS = CreatePNT2StreamVertexShader();
|
||||||
|
|
||||||
@ -580,7 +502,7 @@ RETRY:
|
|||||||
else
|
else
|
||||||
GRAPHICS_CAPS_CAN_NOT_TEXTURE_ADDRESS_BORDER=true;
|
GRAPHICS_CAPS_CAN_NOT_TEXTURE_ADDRESS_BORDER=true;
|
||||||
|
|
||||||
//D3DADAPTER_IDENTIFIER8& rkD3DAdapterId=pkD3DAdapterInfo->GetIdentifier();
|
//D3DADAPTER_IDENTIFIER9& rkD3DAdapterId=pkD3DAdapterInfo->GetIdentifier();
|
||||||
if (strnicmp(rkD3DAdapterId.Driver, "SIS", 3) == 0)
|
if (strnicmp(rkD3DAdapterId.Driver, "SIS", 3) == 0)
|
||||||
{
|
{
|
||||||
GRAPHICS_CAPS_CAN_NOT_DRAW_LINE = true;
|
GRAPHICS_CAPS_CAN_NOT_DRAW_LINE = true;
|
||||||
@ -622,11 +544,12 @@ bool CGraphicDevice::__CreatePDTVertexBufferList()
|
|||||||
{
|
{
|
||||||
if (FAILED(
|
if (FAILED(
|
||||||
ms_lpd3dDevice->CreateVertexBuffer(
|
ms_lpd3dDevice->CreateVertexBuffer(
|
||||||
sizeof(TPDTVertex)*PDT_VERTEX_NUM,
|
sizeof(TPDTVertex) * PDT_VERTEX_NUM,
|
||||||
D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,
|
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
|
||||||
D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1,
|
D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1,
|
||||||
D3DPOOL_SYSTEMMEM,
|
D3DPOOL_SYSTEMMEM,
|
||||||
&ms_alpd3dPDTVB[i])
|
&ms_alpd3dPDTVB[i],
|
||||||
|
NULL)
|
||||||
))
|
))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -655,17 +578,17 @@ bool CGraphicDevice::__CreateDefaultIndexBuffer(UINT eDefIB, UINT uIdxCount, con
|
|||||||
|
|
||||||
if (FAILED(
|
if (FAILED(
|
||||||
ms_lpd3dDevice->CreateIndexBuffer(
|
ms_lpd3dDevice->CreateIndexBuffer(
|
||||||
sizeof(WORD)*uIdxCount,
|
sizeof(WORD) * uIdxCount,
|
||||||
D3DUSAGE_WRITEONLY,
|
D3DUSAGE_WRITEONLY,
|
||||||
D3DFMT_INDEX16,
|
D3DFMT_INDEX16,
|
||||||
D3DPOOL_MANAGED,
|
D3DPOOL_MANAGED,
|
||||||
&ms_alpd3dDefIB[eDefIB])
|
&ms_alpd3dDefIB[eDefIB],
|
||||||
|
NULL)
|
||||||
)) return false;
|
)) return false;
|
||||||
|
|
||||||
WORD* dstIndices;
|
WORD* dstIndices;
|
||||||
if (FAILED(
|
if (FAILED(ms_alpd3dDefIB[eDefIB]->Lock(0, 0, (VOID**)&dstIndices, 0)))
|
||||||
ms_alpd3dDefIB[eDefIB]->Lock(0, 0, (BYTE**)&dstIndices, 0)
|
return false;
|
||||||
)) return false;
|
|
||||||
|
|
||||||
memcpy(dstIndices, c_awIndices, sizeof(WORD)*uIdxCount);
|
memcpy(dstIndices, c_awIndices, sizeof(WORD)*uIdxCount);
|
||||||
|
|
||||||
@ -729,23 +652,11 @@ void CGraphicDevice::Destroy()
|
|||||||
ms_hDC = NULL;
|
ms_hDC = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms_ptVS)
|
|
||||||
{
|
|
||||||
ms_lpd3dDevice->DeleteVertexShader(ms_ptVS);
|
|
||||||
ms_ptVS = 0;;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ms_pntVS)
|
if (ms_pntVS)
|
||||||
{
|
|
||||||
ms_lpd3dDevice->DeleteVertexShader(ms_pntVS);
|
|
||||||
ms_pntVS = 0;
|
ms_pntVS = 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (ms_pnt2VS)
|
if (ms_pnt2VS)
|
||||||
{
|
|
||||||
ms_lpd3dDevice->DeleteVertexShader(ms_pnt2VS);
|
|
||||||
ms_pnt2VS = 0;
|
ms_pnt2VS = 0;
|
||||||
}
|
|
||||||
|
|
||||||
safe_release(ms_lpSphereMesh);
|
safe_release(ms_lpSphereMesh);
|
||||||
safe_release(ms_lpCylinderMesh);
|
safe_release(ms_lpCylinderMesh);
|
||||||
|
@ -123,7 +123,7 @@ void CGraphicExpandedImageInstance::OnRender()
|
|||||||
|
|
||||||
STATEMANAGER.SetTexture(0, pTexture->GetD3DTexture());
|
STATEMANAGER.SetTexture(0, pTexture->GetD3DTexture());
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
|
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
|
||||||
}
|
}
|
||||||
//STATEMANAGER.DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, c_FillRectIndices, D3DFMT_INDEX16, vertices, sizeof(TPDTVertex));
|
//STATEMANAGER.DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, c_FillRectIndices, D3DFMT_INDEX16, vertices, sizeof(TPDTVertex));
|
||||||
|
@ -90,7 +90,7 @@ void CGraphicImageInstance::OnRender()
|
|||||||
|
|
||||||
STATEMANAGER.SetTexture(0, pTexture->GetD3DTexture());
|
STATEMANAGER.SetTexture(0, pTexture->GetD3DTexture());
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
|
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
|
||||||
}
|
}
|
||||||
//OLD: STATEMANAGER.DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, c_FillRectIndices, D3DFMT_INDEX16, vertices, sizeof(TPDTVertex));
|
//OLD: STATEMANAGER.DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, c_FillRectIndices, D3DFMT_INDEX16, vertices, sizeof(TPDTVertex));
|
||||||
|
@ -45,7 +45,7 @@ bool CGraphicImageTexture::CreateDeviceObjects()
|
|||||||
if (m_stFileName.empty())
|
if (m_stFileName.empty())
|
||||||
{
|
{
|
||||||
// ÆùÆ® ÅؽºÃÄ
|
// ÆùÆ® ÅؽºÃÄ
|
||||||
if (FAILED(ms_lpd3dDevice->CreateTexture(m_width, m_height, 1, 0, m_d3dFmt, D3DPOOL_MANAGED, &m_lpd3dTexture)))
|
if (FAILED(ms_lpd3dDevice->CreateTexture(m_width, m_height, 1, 0, m_d3dFmt, D3DPOOL_MANAGED, &m_lpd3dTexture, NULL)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -96,7 +96,7 @@ bool CGraphicImageTexture::CreateDDSTexture(CDXTCImage & image, const BYTE * /*c
|
|||||||
int mipmapCount = image.m_dwMipMapCount == 0 ? 1 : image.m_dwMipMapCount;
|
int mipmapCount = image.m_dwMipMapCount == 0 ? 1 : image.m_dwMipMapCount;
|
||||||
|
|
||||||
D3DFORMAT format;
|
D3DFORMAT format;
|
||||||
LPDIRECT3DTEXTURE8 lpd3dTexture;
|
LPDIRECT3DTEXTURE9 lpd3dTexture;
|
||||||
D3DPOOL pool = ms_bSupportDXT ? D3DPOOL_MANAGED : D3DPOOL_SCRATCH;;
|
D3DPOOL pool = ms_bSupportDXT ? D3DPOOL_MANAGED : D3DPOOL_SCRATCH;;
|
||||||
|
|
||||||
if(image.m_CompFormat == PF_DXT5)
|
if(image.m_CompFormat == PF_DXT5)
|
||||||
@ -173,13 +173,13 @@ bool CGraphicImageTexture::CreateDDSTexture(CDXTCImage & image, const BYTE * /*c
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDirect3DTexture8* pkTexSrc=lpd3dTexture;
|
IDirect3DTexture9* pkTexSrc = lpd3dTexture;
|
||||||
IDirect3DTexture8* pkTexDst=m_lpd3dTexture;
|
IDirect3DTexture9* pkTexDst = m_lpd3dTexture;
|
||||||
|
|
||||||
for(int i=0; i<mipmapCount; ++i) {
|
for(int i=0; i<mipmapCount; ++i) {
|
||||||
|
|
||||||
IDirect3DSurface8* ppsSrc = NULL;
|
IDirect3DSurface9* ppsSrc = NULL;
|
||||||
IDirect3DSurface8* ppsDst = NULL;
|
IDirect3DSurface9* ppsDst = NULL;
|
||||||
|
|
||||||
if (SUCCEEDED(pkTexSrc->GetSurfaceLevel(i, &ppsSrc)))
|
if (SUCCEEDED(pkTexSrc->GetSurfaceLevel(i, &ppsSrc)))
|
||||||
{
|
{
|
||||||
@ -216,22 +216,12 @@ bool CGraphicImageTexture::CreateFromMemoryFile(UINT bufSize, const void * c_pvB
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
D3DXIMAGE_INFO imageInfo;
|
D3DXIMAGE_INFO imageInfo;
|
||||||
if (FAILED(D3DXCreateTextureFromFileInMemoryEx(
|
if (FAILED(D3DXGetImageInfoFromFileInMemory(c_pvBuf, bufSize, &imageInfo)))
|
||||||
ms_lpd3dDevice,
|
{
|
||||||
c_pvBuf,
|
TraceError("CreateFromMemoryFile: Cannot GetImageInfo from texture");
|
||||||
bufSize,
|
return false;
|
||||||
D3DX_DEFAULT,
|
}
|
||||||
D3DX_DEFAULT,
|
if (FAILED(D3DXCreateTextureFromFileInMemoryEx(ms_lpd3dDevice, c_pvBuf, bufSize, imageInfo.Width, imageInfo.Height, D3DX_DEFAULT, 0, d3dFmt, D3DPOOL_MANAGED, dwFilter, dwFilter, 0xffff00ff, NULL, NULL, &m_lpd3dTexture)))
|
||||||
D3DX_DEFAULT,
|
|
||||||
0,
|
|
||||||
d3dFmt,
|
|
||||||
D3DPOOL_MANAGED,
|
|
||||||
dwFilter,
|
|
||||||
dwFilter,
|
|
||||||
0xffff00ff,
|
|
||||||
&imageInfo,
|
|
||||||
NULL,
|
|
||||||
&m_lpd3dTexture)))
|
|
||||||
{
|
{
|
||||||
TraceError("CreateFromMemoryFile: Cannot create texture");
|
TraceError("CreateFromMemoryFile: Cannot create texture");
|
||||||
return false;
|
return false;
|
||||||
@ -261,8 +251,8 @@ bool CGraphicImageTexture::CreateFromMemoryFile(UINT bufSize, const void * c_pvB
|
|||||||
if (IsLowTextureMemory())
|
if (IsLowTextureMemory())
|
||||||
if (uTexBias || format!=imageInfo.Format)
|
if (uTexBias || format!=imageInfo.Format)
|
||||||
{
|
{
|
||||||
IDirect3DTexture8* pkTexSrc=m_lpd3dTexture;
|
IDirect3DTexture9* pkTexSrc=m_lpd3dTexture;
|
||||||
IDirect3DTexture8* pkTexDst;
|
IDirect3DTexture9* pkTexDst;
|
||||||
|
|
||||||
|
|
||||||
if (SUCCEEDED(D3DXCreateTexture(
|
if (SUCCEEDED(D3DXCreateTexture(
|
||||||
@ -279,8 +269,8 @@ bool CGraphicImageTexture::CreateFromMemoryFile(UINT bufSize, const void * c_pvB
|
|||||||
|
|
||||||
for(int i=0; i<imageInfo.MipLevels; ++i) {
|
for(int i=0; i<imageInfo.MipLevels; ++i) {
|
||||||
|
|
||||||
IDirect3DSurface8* ppsSrc = NULL;
|
IDirect3DSurface9* ppsSrc = NULL;
|
||||||
IDirect3DSurface8* ppsDst = NULL;
|
IDirect3DSurface9* ppsDst = NULL;
|
||||||
|
|
||||||
if (SUCCEEDED(pkTexSrc->GetSurfaceLevel(i, &ppsSrc)))
|
if (SUCCEEDED(pkTexSrc->GetSurfaceLevel(i, &ppsSrc)))
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "GrpIndexBuffer.h"
|
#include "GrpIndexBuffer.h"
|
||||||
#include "StateManager.h"
|
#include "StateManager.h"
|
||||||
|
|
||||||
LPDIRECT3DINDEXBUFFER8 CGraphicIndexBuffer::GetD3DIndexBuffer() const
|
LPDIRECT3DINDEXBUFFER9 CGraphicIndexBuffer::GetD3DIndexBuffer() const
|
||||||
{
|
{
|
||||||
assert(m_lpd3dIdxBuf!=NULL);
|
assert(m_lpd3dIdxBuf!=NULL);
|
||||||
return m_lpd3dIdxBuf;
|
return m_lpd3dIdxBuf;
|
||||||
@ -20,7 +20,7 @@ bool CGraphicIndexBuffer::Lock(void** pretIndices) const
|
|||||||
{
|
{
|
||||||
assert(m_lpd3dIdxBuf!=NULL);
|
assert(m_lpd3dIdxBuf!=NULL);
|
||||||
|
|
||||||
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, (BYTE**)pretIndices, 0)))
|
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, pretIndices, 0)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -37,7 +37,7 @@ bool CGraphicIndexBuffer::Lock(void** pretIndices)
|
|||||||
{
|
{
|
||||||
assert(m_lpd3dIdxBuf!=NULL);
|
assert(m_lpd3dIdxBuf!=NULL);
|
||||||
|
|
||||||
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, (BYTE**)pretIndices, 0)))
|
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, pretIndices, 0)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -55,7 +55,7 @@ bool CGraphicIndexBuffer::Copy(int bufSize, const void* srcIndices)
|
|||||||
assert(m_lpd3dIdxBuf!=NULL);
|
assert(m_lpd3dIdxBuf!=NULL);
|
||||||
|
|
||||||
BYTE* dstIndices;
|
BYTE* dstIndices;
|
||||||
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, &dstIndices, 0)))
|
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, (void**)&dstIndices, 0)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
memcpy(dstIndices, srcIndices, bufSize);
|
memcpy(dstIndices, srcIndices, bufSize);
|
||||||
@ -73,7 +73,7 @@ bool CGraphicIndexBuffer::Create(int faceCount, TFace* faces)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
WORD* dstIndices;
|
WORD* dstIndices;
|
||||||
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, (BYTE**)&dstIndices, 0)))
|
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, (void**)&dstIndices, 0)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i<faceCount; ++i, dstIndices+=3)
|
for (int i = 0; i<faceCount; ++i, dstIndices+=3)
|
||||||
@ -90,13 +90,7 @@ bool CGraphicIndexBuffer::Create(int faceCount, TFace* faces)
|
|||||||
|
|
||||||
bool CGraphicIndexBuffer::CreateDeviceObjects()
|
bool CGraphicIndexBuffer::CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
if (FAILED(ms_lpd3dDevice->CreateIndexBuffer(
|
if (FAILED(ms_lpd3dDevice->CreateIndexBuffer(m_dwBufferSize, D3DUSAGE_WRITEONLY, m_d3dFmt, D3DPOOL_MANAGED, &m_lpd3dIdxBuf, NULL)))
|
||||||
m_dwBufferSize,
|
|
||||||
D3DUSAGE_WRITEONLY,
|
|
||||||
m_d3dFmt,
|
|
||||||
D3DPOOL_MANAGED,
|
|
||||||
&m_lpd3dIdxBuf)
|
|
||||||
))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -25,7 +25,7 @@ class CGraphicIndexBuffer : public CGraphicBase
|
|||||||
|
|
||||||
void SetIndices(int startIndex=0) const;
|
void SetIndices(int startIndex=0) const;
|
||||||
|
|
||||||
LPDIRECT3DINDEXBUFFER8 GetD3DIndexBuffer() const;
|
LPDIRECT3DINDEXBUFFER9 GetD3DIndexBuffer() const;
|
||||||
|
|
||||||
int GetIndexCount() const {return m_iidxCount;}
|
int GetIndexCount() const {return m_iidxCount;}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class CGraphicIndexBuffer : public CGraphicBase
|
|||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LPDIRECT3DINDEXBUFFER8 m_lpd3dIdxBuf;
|
LPDIRECT3DINDEXBUFFER9 m_lpd3dIdxBuf;
|
||||||
DWORD m_dwBufferSize;
|
DWORD m_dwBufferSize;
|
||||||
D3DFORMAT m_d3dFmt;
|
D3DFORMAT m_d3dFmt;
|
||||||
int m_iidxCount;
|
int m_iidxCount;
|
||||||
|
@ -32,7 +32,7 @@ void CLightManager::Initialize()
|
|||||||
m_LightPool.FreeAll();
|
m_LightPool.FreeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLightManager::RegisterLight(ELightType /*LightType*/, TLightID * poutLightID, D3DLIGHT8 & LightData)
|
void CLightManager::RegisterLight(ELightType /*LightType*/, TLightID * poutLightID, D3DLIGHT9& LightData)
|
||||||
{
|
{
|
||||||
CLight * pLight = m_LightPool.Alloc();
|
CLight * pLight = m_LightPool.Alloc();
|
||||||
TLightID ID = NewLightID();
|
TLightID ID = NewLightID();
|
||||||
@ -212,7 +212,7 @@ void CLight::SetDeviceLight(BOOL bActive)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLight::SetParameter(TLightID id, const D3DLIGHT8 & c_rLight)
|
void CLight::SetParameter(TLightID id, const D3DLIGHT9 & c_rLight)
|
||||||
{
|
{
|
||||||
m_LightID = id;
|
m_LightID = id;
|
||||||
m_d3dLight = c_rLight;
|
m_d3dLight = c_rLight;
|
||||||
|
@ -39,7 +39,7 @@ class CLight : public CGraphicBase, public CLightBase
|
|||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
void SetParameter(TLightID id, const D3DLIGHT8 & c_rLight);
|
void SetParameter(TLightID id, const D3DLIGHT9 & c_rLight);
|
||||||
|
|
||||||
void SetDistance(float fDistance);
|
void SetDistance(float fDistance);
|
||||||
float GetDistance() const { return m_fDistance; }
|
float GetDistance() const { return m_fDistance; }
|
||||||
@ -63,7 +63,7 @@ class CLight : public CGraphicBase, public CLightBase
|
|||||||
private:
|
private:
|
||||||
TLightID m_LightID; // Light ID. equal to D3D light index
|
TLightID m_LightID; // Light ID. equal to D3D light index
|
||||||
|
|
||||||
D3DLIGHT8 m_d3dLight;
|
D3DLIGHT9 m_d3dLight;
|
||||||
BOOL m_isEdited;
|
BOOL m_isEdited;
|
||||||
float m_fDistance;
|
float m_fDistance;
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class CLightManager : public CGraphicBase, public CLightBase, public CSingleton<
|
|||||||
void RestoreLight();
|
void RestoreLight();
|
||||||
|
|
||||||
/////
|
/////
|
||||||
void RegisterLight(ELightType LightType, TLightID * poutLightID, D3DLIGHT8 & LightData);
|
void RegisterLight(ELightType LightType, TLightID * poutLightID, D3DLIGHT9 & LightData);
|
||||||
CLight * GetLight(TLightID LightID);
|
CLight * GetLight(TLightID LightID);
|
||||||
void DeleteLight(TLightID LightID);
|
void DeleteLight(TLightID LightID);
|
||||||
/////
|
/////
|
||||||
|
@ -108,7 +108,7 @@ void CGraphicMarkInstance::OnRender()
|
|||||||
|
|
||||||
STATEMANAGER.SetTexture(0, pTexture->GetD3DTexture());
|
STATEMANAGER.SetTexture(0, pTexture->GetD3DTexture());
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
|
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
|
||||||
//OLD: STATEMANAGER.DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, c_FillRectIndices, D3DFMT_INDEX16, vertices, sizeof(TPDTVertex));
|
//OLD: STATEMANAGER.DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, c_FillRectIndices, D3DFMT_INDEX16, vertices, sizeof(TPDTVertex));
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,7 @@ void CPixelShader::Initialize()
|
|||||||
void CPixelShader::Destroy()
|
void CPixelShader::Destroy()
|
||||||
{
|
{
|
||||||
if (m_handle)
|
if (m_handle)
|
||||||
{
|
|
||||||
if (ms_lpd3dDevice)
|
|
||||||
ms_lpd3dDevice->DeletePixelShader(m_handle);
|
|
||||||
m_handle=0;
|
m_handle=0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPixelShader::CreateFromDiskFile(const char* c_szFileName)
|
bool CPixelShader::CreateFromDiskFile(const char* c_szFileName)
|
||||||
@ -34,16 +30,11 @@ bool CPixelShader::CreateFromDiskFile(const char* c_szFileName)
|
|||||||
|
|
||||||
LPD3DXBUFFER lpd3dxShaderBuffer;
|
LPD3DXBUFFER lpd3dxShaderBuffer;
|
||||||
LPD3DXBUFFER lpd3dxErrorBuffer;
|
LPD3DXBUFFER lpd3dxErrorBuffer;
|
||||||
|
|
||||||
if (FAILED(
|
if (FAILED(D3DXAssembleShaderFromFileA(c_szFileName, 0, NULL, 0, &lpd3dxShaderBuffer, &lpd3dxErrorBuffer)))
|
||||||
D3DXAssembleShaderFromFile(c_szFileName, 0, NULL, &lpd3dxShaderBuffer, &lpd3dxErrorBuffer)
|
|
||||||
))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CDirect3DXBuffer shaderBuffer(lpd3dxShaderBuffer);
|
if (FAILED(ms_lpd3dDevice->CreatePixelShader((const DWORD*)lpd3dxShaderBuffer->GetBufferPointer(), &m_handle)))
|
||||||
CDirect3DXBuffer errorBuffer(lpd3dxErrorBuffer);
|
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreatePixelShader((DWORD*)shaderBuffer.GetPointer(), &m_handle)))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -17,5 +17,5 @@ class CPixelShader : public CGraphicBase
|
|||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DWORD m_handle;
|
LPDIRECT3DPIXELSHADER9 m_handle;
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ void CScreen::RenderLine3d(float sx, float sy, float sz, float ex, float ey, flo
|
|||||||
{
|
{
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, NULL);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawPrimitive(D3DPT_LINELIST, 0, 1);
|
STATEMANAGER.DrawPrimitive(D3DPT_LINELIST, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ void CScreen::RenderBox3d(float sx, float sy, float sz, float ex, float ey, floa
|
|||||||
{
|
{
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, NULL);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawPrimitive(D3DPT_LINELIST, 0, 4);
|
STATEMANAGER.DrawPrimitive(D3DPT_LINELIST, 0, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ void CScreen::RenderBar3d(float sx, float sy, float sz, float ex, float ey, floa
|
|||||||
{
|
{
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, NULL);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ void CScreen::RenderBar3d(const D3DXVECTOR3 * c_pv3Positions)
|
|||||||
{
|
{
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, NULL);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ void CScreen::RenderGradationBar3d(float sx, float sy, float sz, float ex, float
|
|||||||
{
|
{
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, NULL);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ void CScreen::RenderLineCube(float sx, float sy, float sz, float ex, float ey, f
|
|||||||
{
|
{
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, NULL);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.SetTransform(D3DTS_WORLD, ms_lpd3dMatStack->GetTop());
|
STATEMANAGER.SetTransform(D3DTS_WORLD, ms_lpd3dMatStack->GetTop());
|
||||||
SetDefaultIndexBuffer(DEFAULT_IB_LINE_CUBE);
|
SetDefaultIndexBuffer(DEFAULT_IB_LINE_CUBE);
|
||||||
|
|
||||||
@ -174,13 +174,13 @@ void CScreen::RenderCube(float sx, float sy, float sz, float ex, float ey, float
|
|||||||
{ sx, ey, ez, ms_diffuseColor, 0.0f, 0.0f },
|
{ sx, ey, ez, ms_diffuseColor, 0.0f, 0.0f },
|
||||||
{ ex, ey, ez, ms_diffuseColor, 0.0f, 0.0f },
|
{ ex, ey, ez, ms_diffuseColor, 0.0f, 0.0f },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (SetPDTStream(vertices, 8))
|
if (SetPDTStream(vertices, 8))
|
||||||
{
|
{
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, NULL);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.SetTransform(D3DTS_WORLD, ms_lpd3dMatStack->GetTop());
|
STATEMANAGER.SetTransform(D3DTS_WORLD, ms_lpd3dMatStack->GetTop());
|
||||||
|
|
||||||
SetDefaultIndexBuffer(DEFAULT_IB_FILL_CUBE);
|
SetDefaultIndexBuffer(DEFAULT_IB_FILL_CUBE);
|
||||||
@ -220,7 +220,7 @@ void CScreen::RenderCube(float sx, float sy, float sz, float ex, float ey, float
|
|||||||
{
|
{
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, NULL);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.SetTransform(D3DTS_WORLD, ms_lpd3dMatStack->GetTop());
|
STATEMANAGER.SetTransform(D3DTS_WORLD, ms_lpd3dMatStack->GetTop());
|
||||||
|
|
||||||
SetDefaultIndexBuffer(DEFAULT_IB_FILL_CUBE);
|
SetDefaultIndexBuffer(DEFAULT_IB_FILL_CUBE);
|
||||||
@ -315,7 +315,7 @@ public:
|
|||||||
|
|
||||||
CD3DXMeshRenderingOption(D3DFILLMODE d3dFillMode, const D3DXMATRIX & c_rmatWorld)
|
CD3DXMeshRenderingOption(D3DFILLMODE d3dFillMode, const D3DXMATRIX & c_rmatWorld)
|
||||||
{
|
{
|
||||||
ms_lpd3dDevice->GetVertexShader(&m_dwVS);
|
ms_lpd3dDevice->GetFVF(&m_dwVS);
|
||||||
|
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||||
@ -329,7 +329,7 @@ public:
|
|||||||
|
|
||||||
virtual ~CD3DXMeshRenderingOption()
|
virtual ~CD3DXMeshRenderingOption()
|
||||||
{
|
{
|
||||||
ms_lpd3dDevice->SetVertexShader(m_dwVS);
|
ms_lpd3dDevice->SetFVF(m_dwVS);
|
||||||
|
|
||||||
STATEMANAGER.RestoreTransform(D3DTS_WORLD);
|
STATEMANAGER.RestoreTransform(D3DTS_WORLD);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
|
||||||
@ -356,11 +356,11 @@ void CScreen::RenderD3DXMesh(LPD3DXMESH lpMesh, const D3DXMATRIX * c_pmatWorld,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CD3DXMeshRenderingOption SetRenderingOption(d3dFillMode, matWorld);
|
CD3DXMeshRenderingOption SetRenderingOption(d3dFillMode, matWorld);
|
||||||
LPDIRECT3DINDEXBUFFER8 lpIndexBuffer;
|
LPDIRECT3DINDEXBUFFER9 lpIndexBuffer;
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpVertexBuffer;
|
LPDIRECT3DVERTEXBUFFER9 lpVertexBuffer;
|
||||||
lpMesh->GetIndexBuffer(&lpIndexBuffer);
|
lpMesh->GetIndexBuffer(&lpIndexBuffer);
|
||||||
lpMesh->GetVertexBuffer(&lpVertexBuffer);
|
lpMesh->GetVertexBuffer(&lpVertexBuffer);
|
||||||
STATEMANAGER.SetVertexShader(lpMesh->GetFVF());
|
STATEMANAGER.SetFVF(lpMesh->GetFVF());
|
||||||
STATEMANAGER.SetIndices(lpIndexBuffer, 0);
|
STATEMANAGER.SetIndices(lpIndexBuffer, 0);
|
||||||
STATEMANAGER.SetStreamSource(0, lpVertexBuffer, 24);
|
STATEMANAGER.SetStreamSource(0, lpVertexBuffer, 24);
|
||||||
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, lpMesh->GetNumVertices(), 0, lpMesh->GetNumFaces());
|
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, lpMesh->GetNumVertices(), 0, lpMesh->GetNumFaces());
|
||||||
@ -401,7 +401,7 @@ void CScreen::RenderTextureBox(float sx, float sy, float ex, float ey, float z,
|
|||||||
#ifdef WORLD_EDITOR
|
#ifdef WORLD_EDITOR
|
||||||
STATEMANAGER.SetTransform(D3DTS_WORLD, ms_lpd3dMatStack->GetTop());
|
STATEMANAGER.SetTransform(D3DTS_WORLD, ms_lpd3dMatStack->GetTop());
|
||||||
#endif
|
#endif
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
|
|
||||||
// 2004.11.18.myevan.DrawIndexPrimitiveUP -> DynamicVertexBuffer
|
// 2004.11.18.myevan.DrawIndexPrimitiveUP -> DynamicVertexBuffer
|
||||||
SetDefaultIndexBuffer(DEFAULT_IB_FILL_RECT);
|
SetDefaultIndexBuffer(DEFAULT_IB_FILL_RECT);
|
||||||
@ -431,8 +431,8 @@ void CScreen::RenderBillboard(D3DXVECTOR3 * Position, D3DXCOLOR & Color)
|
|||||||
vertices[3].position = TPosition(Position[3].x, Position[3].y, Position[3].z);
|
vertices[3].position = TPosition(Position[3].x, Position[3].y, Position[3].z);
|
||||||
vertices[3].diffuse = Color;
|
vertices[3].diffuse = Color;
|
||||||
vertices[3].texCoord = TTextureCoordinate(1, 1);
|
vertices[3].texCoord = TTextureCoordinate(1, 1);
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
|
|
||||||
// 2004.11.18.myevan.DrawIndexPrimitiveUP -> DynamicVertexBuffer
|
// 2004.11.18.myevan.DrawIndexPrimitiveUP -> DynamicVertexBuffer
|
||||||
SetDefaultIndexBuffer(DEFAULT_IB_FILL_RECT);
|
SetDefaultIndexBuffer(DEFAULT_IB_FILL_RECT);
|
||||||
@ -631,7 +631,7 @@ BOOL CScreen::IsLostDevice()
|
|||||||
if (!ms_lpd3dDevice)
|
if (!ms_lpd3dDevice)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
IDirect3DDevice8 & rkD3DDev = *ms_lpd3dDevice;
|
IDirect3DDevice9 & rkD3DDev = *ms_lpd3dDevice;
|
||||||
HRESULT hrTestCooperativeLevel = rkD3DDev.TestCooperativeLevel();
|
HRESULT hrTestCooperativeLevel = rkD3DDev.TestCooperativeLevel();
|
||||||
if (FAILED(hrTestCooperativeLevel))
|
if (FAILED(hrTestCooperativeLevel))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -645,8 +645,8 @@ BOOL CScreen::RestoreDevice()
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
UINT iD3DAdapterInfo = ms_iD3DAdapterInfo;
|
UINT iD3DAdapterInfo = ms_iD3DAdapterInfo;
|
||||||
IDirect3D8 & rkD3D = *ms_lpd3d;
|
IDirect3D9& rkD3D = *ms_lpd3d;
|
||||||
IDirect3DDevice8 & rkD3DDev = *ms_lpd3dDevice;
|
IDirect3DDevice9& rkD3DDev = *ms_lpd3dDevice;
|
||||||
D3DPRESENT_PARAMETERS & rkD3DPP = ms_d3dPresentParameter;
|
D3DPRESENT_PARAMETERS & rkD3DPP = ms_d3dPresentParameter;
|
||||||
D3D_CDisplayModeAutoDetector & rkD3DDetector = ms_kD3DDetector;
|
D3D_CDisplayModeAutoDetector & rkD3DDetector = ms_kD3DDetector;
|
||||||
|
|
||||||
@ -848,11 +848,12 @@ void CScreen::BuildViewFrustum()
|
|||||||
{
|
{
|
||||||
const D3DXVECTOR3& c_rv3Eye=CCameraManager::Instance().GetCurrentCamera()->GetEye();
|
const D3DXVECTOR3& c_rv3Eye=CCameraManager::Instance().GetCurrentCamera()->GetEye();
|
||||||
const D3DXVECTOR3& c_rv3View=CCameraManager::Instance().GetCurrentCamera()->GetView();
|
const D3DXVECTOR3& c_rv3View=CCameraManager::Instance().GetCurrentCamera()->GetView();
|
||||||
ms_frustum.BuildViewFrustum2(
|
D3DXMATRIX mat = ms_matView * ms_matProj;
|
||||||
ms_matView*ms_matProj,
|
ms_frustum.BuildViewFrustum2(
|
||||||
ms_fNearY,
|
mat,
|
||||||
ms_fFarY,
|
ms_fNearY,
|
||||||
ms_fFieldOfView,
|
ms_fFarY,
|
||||||
ms_fAspect,
|
ms_fFieldOfView,
|
||||||
c_rv3Eye, c_rv3View);
|
ms_fAspect,
|
||||||
|
c_rv3Eye, c_rv3View);
|
||||||
}
|
}
|
@ -35,13 +35,13 @@ bool CGraphicShadowTexture::Create(int width, int height)
|
|||||||
m_width = width;
|
m_width = width;
|
||||||
m_height = height;
|
m_height = height;
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateTexture(m_width, m_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_lpd3dShadowTexture)))
|
if (FAILED(ms_lpd3dDevice->CreateTexture(m_width, m_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_lpd3dShadowTexture, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (FAILED(m_lpd3dShadowTexture->GetSurfaceLevel(0, &m_lpd3dShadowSurface)))
|
if (FAILED(m_lpd3dShadowTexture->GetSurfaceLevel(0, &m_lpd3dShadowSurface)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_width, m_height, D3DFMT_D16, D3DMULTISAMPLE_NONE, &m_lpd3dDepthSurface)))
|
if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_width, m_height, D3DFMT_R32F, D3DMULTISAMPLE_NONE, 0, false, &m_lpd3dDepthSurface, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -57,7 +57,7 @@ const D3DXMATRIX& CGraphicShadowTexture::GetLightVPMatrixReference() const
|
|||||||
return m_d3dLightVPMatrix;
|
return m_d3dLightVPMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 CGraphicShadowTexture::GetD3DTexture() const
|
LPDIRECT3DTEXTURE9 CGraphicShadowTexture::GetD3DTexture() const
|
||||||
{
|
{
|
||||||
return m_lpd3dShadowTexture;
|
return m_lpd3dShadowTexture;
|
||||||
}
|
}
|
||||||
@ -66,13 +66,14 @@ void CGraphicShadowTexture::Begin()
|
|||||||
{
|
{
|
||||||
D3DXMatrixMultiply(&m_d3dLightVPMatrix, &ms_matView, &ms_matProj);
|
D3DXMatrixMultiply(&m_d3dLightVPMatrix, &ms_matView, &ms_matProj);
|
||||||
|
|
||||||
ms_lpd3dDevice->GetRenderTarget(&m_lpd3dOldBackBufferSurface);
|
ms_lpd3dDevice->GetRenderTarget(0, &m_lpd3dOldBackBufferSurface);
|
||||||
ms_lpd3dDevice->GetDepthStencilSurface(&m_lpd3dOldDepthBufferSurface);
|
ms_lpd3dDevice->GetDepthStencilSurface(&m_lpd3dOldDepthBufferSurface);
|
||||||
ms_lpd3dDevice->GetViewport(&m_d3dOldViewport);
|
ms_lpd3dDevice->GetViewport(&m_d3dOldViewport);
|
||||||
|
|
||||||
ms_lpd3dDevice->SetRenderTarget(m_lpd3dShadowSurface, m_lpd3dDepthSurface);
|
ms_lpd3dDevice->GetRenderTarget(0, &m_lpd3dShadowSurface);
|
||||||
|
ms_lpd3dDevice->GetDepthStencilSurface(&m_lpd3dDepthSurface);
|
||||||
|
|
||||||
D3DVIEWPORT8 d3dViewport;
|
D3DVIEWPORT9 d3dViewport;
|
||||||
d3dViewport.MinZ = 0.0f;
|
d3dViewport.MinZ = 0.0f;
|
||||||
d3dViewport.MaxZ = 1.0f;
|
d3dViewport.MaxZ = 1.0f;
|
||||||
d3dViewport.X = 0;
|
d3dViewport.X = 0;
|
||||||
@ -83,7 +84,7 @@ void CGraphicShadowTexture::Begin()
|
|||||||
ms_lpd3dDevice->SetViewport(&d3dViewport);
|
ms_lpd3dDevice->SetViewport(&d3dViewport);
|
||||||
ms_lpd3dDevice->BeginScene();
|
ms_lpd3dDevice->BeginScene();
|
||||||
|
|
||||||
ms_lpd3dDevice->Clear(0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0L);
|
ms_lpd3dDevice->Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
|
||||||
|
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
|
STATEMANAGER.SaveRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
|
||||||
@ -91,7 +92,7 @@ void CGraphicShadowTexture::Begin()
|
|||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, true);
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, true);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_TEXTUREFACTOR, 0xbb000000);
|
STATEMANAGER.SaveRenderState(D3DRS_TEXTUREFACTOR, 0xbb000000);
|
||||||
|
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, m_lpd3dShadowTexture);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
@ -99,13 +100,13 @@ void CGraphicShadowTexture::Begin()
|
|||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||||
|
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_POINT);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_POINT);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
|
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, nullptr);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
STATEMANAGER.SaveTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
STATEMANAGER.SaveTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SaveTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||||
@ -113,11 +114,11 @@ void CGraphicShadowTexture::Begin()
|
|||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
|
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_MINFILTER, D3DTEXF_POINT);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_POINT);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_MIPFILTER, D3DTEXF_POINT);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphicShadowTexture::End()
|
void CGraphicShadowTexture::End()
|
||||||
@ -127,7 +128,8 @@ void CGraphicShadowTexture::End()
|
|||||||
|
|
||||||
ms_lpd3dDevice->EndScene();
|
ms_lpd3dDevice->EndScene();
|
||||||
|
|
||||||
ms_lpd3dDevice->SetRenderTarget(m_lpd3dOldBackBufferSurface, m_lpd3dOldDepthBufferSurface);
|
ms_lpd3dDevice->SetRenderTarget(0, m_lpd3dOldBackBufferSurface);
|
||||||
|
ms_lpd3dDevice->SetDepthStencilSurface(m_lpd3dOldDepthBufferSurface);
|
||||||
ms_lpd3dDevice->SetViewport(&m_d3dOldViewport);
|
ms_lpd3dDevice->SetViewport(&m_d3dOldViewport);
|
||||||
|
|
||||||
m_lpd3dOldBackBufferSurface->Release();
|
m_lpd3dOldBackBufferSurface->Release();
|
||||||
@ -149,11 +151,11 @@ void CGraphicShadowTexture::End()
|
|||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG2);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG2);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAOP);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAOP);
|
||||||
|
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MINFILTER);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MINFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MAGFILTER);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MAGFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MIPFILTER);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MIPFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ADDRESSU);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_ADDRESSU);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ADDRESSV);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_ADDRESSV);
|
||||||
|
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_COLORARG1);
|
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_COLORARG1);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_COLORARG2);
|
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_COLORARG2);
|
||||||
@ -162,11 +164,11 @@ void CGraphicShadowTexture::End()
|
|||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ALPHAARG2);
|
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ALPHAARG2);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ALPHAOP);
|
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ALPHAOP);
|
||||||
|
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_MINFILTER);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_MINFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_MAGFILTER);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_MAGFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_MIPFILTER);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_MIPFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSU);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_ADDRESSU);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSV);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_ADDRESSV);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphicShadowTexture::Initialize()
|
void CGraphicShadowTexture::Initialize()
|
||||||
|
@ -17,19 +17,19 @@ class CGraphicShadowTexture : public CGraphicTexture
|
|||||||
void Set(int stage = 0) const;
|
void Set(int stage = 0) const;
|
||||||
|
|
||||||
const D3DXMATRIX& GetLightVPMatrixReference() const;
|
const D3DXMATRIX& GetLightVPMatrixReference() const;
|
||||||
LPDIRECT3DTEXTURE8 GetD3DTexture() const;
|
LPDIRECT3DTEXTURE9 GetD3DTexture() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
D3DXMATRIX m_d3dLightVPMatrix;
|
D3DXMATRIX m_d3dLightVPMatrix;
|
||||||
D3DVIEWPORT8 m_d3dOldViewport;
|
D3DVIEWPORT9 m_d3dOldViewport;
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 m_lpd3dShadowTexture;
|
|
||||||
LPDIRECT3DSURFACE8 m_lpd3dShadowSurface;
|
|
||||||
LPDIRECT3DSURFACE8 m_lpd3dDepthSurface;
|
|
||||||
|
|
||||||
LPDIRECT3DSURFACE8 m_lpd3dOldBackBufferSurface;
|
LPDIRECT3DTEXTURE9 m_lpd3dShadowTexture;
|
||||||
LPDIRECT3DSURFACE8 m_lpd3dOldDepthBufferSurface;
|
LPDIRECT3DSURFACE9 m_lpd3dShadowSurface;
|
||||||
|
LPDIRECT3DSURFACE9 m_lpd3dDepthSurface;
|
||||||
|
|
||||||
|
LPDIRECT3DSURFACE9 m_lpd3dOldBackBufferSurface;
|
||||||
|
LPDIRECT3DSURFACE9 m_lpd3dOldDepthBufferSurface;
|
||||||
};
|
};
|
||||||
|
@ -539,7 +539,7 @@ void CGraphicTextInstance::Render(RECT * pClipRect)
|
|||||||
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
|
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
|
||||||
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);
|
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
|
@ -34,7 +34,7 @@ void CGraphicTexture::SetTextureStage(int stage) const
|
|||||||
STATEMANAGER.SetTexture(stage, m_lpd3dTexture);
|
STATEMANAGER.SetTexture(stage, m_lpd3dTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 CGraphicTexture::GetD3DTexture() const
|
LPDIRECT3DTEXTURE9 CGraphicTexture::GetD3DTexture() const
|
||||||
{
|
{
|
||||||
return m_lpd3dTexture;
|
return m_lpd3dTexture;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ class CGraphicTexture : public CGraphicBase
|
|||||||
int GetHeight() const;
|
int GetHeight() const;
|
||||||
|
|
||||||
void SetTextureStage(int stage) const;
|
void SetTextureStage(int stage) const;
|
||||||
LPDIRECT3DTEXTURE8 GetD3DTexture() const;
|
LPDIRECT3DTEXTURE9 GetD3DTexture() const;
|
||||||
|
|
||||||
void DestroyDeviceObjects();
|
void DestroyDeviceObjects();
|
||||||
|
|
||||||
@ -28,5 +28,5 @@ class CGraphicTexture : public CGraphicBase
|
|||||||
int m_width;
|
int m_width;
|
||||||
int m_height;
|
int m_height;
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 m_lpd3dTexture;
|
LPDIRECT3DTEXTURE9 m_lpd3dTexture;
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@ bool CGraphicVertexBuffer::LockRange(unsigned count, void** pretVertices) const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
DWORD dwLockSize=GetVertexStride() * count;
|
DWORD dwLockSize=GetVertexStride() * count;
|
||||||
if (FAILED(m_lpd3dVB->Lock(0, dwLockSize, (BYTE **) pretVertices, m_dwLockFlag)))
|
if (FAILED(m_lpd3dVB->Lock(0, dwLockSize, pretVertices, m_dwLockFlag)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -43,7 +43,7 @@ bool CGraphicVertexBuffer::Lock(void ** pretVertices) const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
DWORD dwLockSize=GetVertexStride()*GetVertexCount();
|
DWORD dwLockSize=GetVertexStride()*GetVertexCount();
|
||||||
if (FAILED(m_lpd3dVB->Lock(0, dwLockSize, (BYTE **) pretVertices, m_dwLockFlag)))
|
if (FAILED(m_lpd3dVB->Lock(0, dwLockSize, pretVertices, m_dwLockFlag)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -72,7 +72,7 @@ bool CGraphicVertexBuffer::LockDynamic(void** pretVertices)
|
|||||||
if (!m_lpd3dVB)
|
if (!m_lpd3dVB)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (FAILED(m_lpd3dVB->Lock(0, 0, (BYTE**)pretVertices, 0)))
|
if (FAILED(m_lpd3dVB->Lock(0, 0, pretVertices, 0)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -83,7 +83,7 @@ bool CGraphicVertexBuffer::Lock(void ** pretVertices)
|
|||||||
if (!m_lpd3dVB)
|
if (!m_lpd3dVB)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (FAILED(m_lpd3dVB->Lock(0, 0, (BYTE**)pretVertices, m_dwLockFlag)))
|
if (FAILED(m_lpd3dVB->Lock(0, 0, pretVertices, m_dwLockFlag)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -117,14 +117,7 @@ bool CGraphicVertexBuffer::CreateDeviceObjects()
|
|||||||
assert(ms_lpd3dDevice != NULL);
|
assert(ms_lpd3dDevice != NULL);
|
||||||
assert(m_lpd3dVB == NULL);
|
assert(m_lpd3dVB == NULL);
|
||||||
|
|
||||||
if (FAILED(
|
if (FAILED(ms_lpd3dDevice->CreateVertexBuffer(m_dwBufferSize, m_dwUsage, m_dwFVF, m_d3dPool, &m_lpd3dVB, NULL)))
|
||||||
ms_lpd3dDevice->CreateVertexBuffer(
|
|
||||||
m_dwBufferSize,
|
|
||||||
m_dwUsage,
|
|
||||||
m_dwFVF,
|
|
||||||
m_d3dPool,
|
|
||||||
&m_lpd3dVB)
|
|
||||||
))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -30,7 +30,7 @@ class CGraphicVertexBuffer : public CGraphicBase
|
|||||||
int GetVertexStride() const;
|
int GetVertexStride() const;
|
||||||
DWORD GetFlexibleVertexFormat() const;
|
DWORD GetFlexibleVertexFormat() const;
|
||||||
|
|
||||||
inline LPDIRECT3DVERTEXBUFFER8 GetD3DVertexBuffer() const { return m_lpd3dVB; }
|
inline LPDIRECT3DVERTEXBUFFER9 GetD3DVertexBuffer() const { return m_lpd3dVB; }
|
||||||
inline DWORD GetBufferSize() const { return m_dwBufferSize; }
|
inline DWORD GetBufferSize() const { return m_dwBufferSize; }
|
||||||
|
|
||||||
bool IsEmpty() const;
|
bool IsEmpty() const;
|
||||||
@ -39,7 +39,7 @@ class CGraphicVertexBuffer : public CGraphicBase
|
|||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LPDIRECT3DVERTEXBUFFER8 m_lpd3dVB;
|
LPDIRECT3DVERTEXBUFFER9 m_lpd3dVB;
|
||||||
|
|
||||||
DWORD m_dwBufferSize;
|
DWORD m_dwBufferSize;
|
||||||
DWORD m_dwFVF;
|
DWORD m_dwFVF;
|
||||||
|
@ -22,9 +22,7 @@ void CVertexShader::Destroy()
|
|||||||
{
|
{
|
||||||
if (m_handle)
|
if (m_handle)
|
||||||
{
|
{
|
||||||
if (ms_lpd3dDevice)
|
m_handle->Release();
|
||||||
ms_lpd3dDevice->DeleteVertexShader(m_handle);
|
|
||||||
|
|
||||||
m_handle = 0;
|
m_handle = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,17 +33,10 @@ bool CVertexShader::CreateFromDiskFile(const char* c_szFileName, const DWORD* c_
|
|||||||
|
|
||||||
LPD3DXBUFFER lpd3dxShaderBuffer;
|
LPD3DXBUFFER lpd3dxShaderBuffer;
|
||||||
LPD3DXBUFFER lpd3dxErrorBuffer;
|
LPD3DXBUFFER lpd3dxErrorBuffer;
|
||||||
|
if (FAILED(D3DXAssembleShaderFromFile(c_szFileName, 0, NULL, 0, &lpd3dxShaderBuffer, &lpd3dxErrorBuffer)))
|
||||||
if (FAILED(
|
return false;
|
||||||
D3DXAssembleShaderFromFile(c_szFileName, 0, NULL, &lpd3dxShaderBuffer, &lpd3dxErrorBuffer)
|
|
||||||
)) return false;
|
|
||||||
|
|
||||||
CDirect3DXBuffer shaderBuffer(lpd3dxShaderBuffer);
|
if (FAILED(ms_lpd3dDevice->CreateVertexShader((const DWORD*)lpd3dxShaderBuffer->GetBufferPointer(), &m_handle)))
|
||||||
CDirect3DXBuffer errorBuffer(lpd3dxErrorBuffer);
|
|
||||||
|
|
||||||
if (FAILED(
|
|
||||||
ms_lpd3dDevice->CreateVertexShader(c_pdwVertexDecl, (DWORD*)shaderBuffer.GetPointer(), &m_handle, 0 )
|
|
||||||
))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -17,5 +17,5 @@ class CVertexShader : public CGraphicBase
|
|||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DWORD m_handle;
|
LPDIRECT3DVERTEXSHADER9 m_handle;
|
||||||
};
|
};
|
||||||
|
@ -259,7 +259,7 @@ void CLensFlare::DrawBeforeFlare()
|
|||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertices, sizeof(SVertex));
|
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertices, sizeof(SVertex));
|
||||||
|
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_LIGHTING);
|
STATEMANAGER.RestoreRenderState(D3DRS_LIGHTING);
|
||||||
@ -540,7 +540,7 @@ void CFlare::Draw(float fBrightScale, int nWidth, int nHeight, int nX, int nY)
|
|||||||
float fDY = float(nY) - float(nHeight) / 2.0f;
|
float fDY = float(nY) - float(nHeight) / 2.0f;
|
||||||
|
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <d3dx8.h>
|
#include <directxsdk/d3dx9.h>
|
||||||
|
|
||||||
class CRay
|
class CRay
|
||||||
{
|
{
|
||||||
|
@ -820,7 +820,7 @@ void CSkyBox::Render()
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
|
|
||||||
STATEMANAGER.SetTransform(D3DTS_WORLD, &m_matWorld);
|
STATEMANAGER.SetTransform(D3DTS_WORLD, &m_matWorld);
|
||||||
|
|
||||||
@ -828,8 +828,8 @@ void CSkyBox::Render()
|
|||||||
if( m_ucRenderMode == CSkyObject::SKY_RENDER_MODE_TEXTURE )
|
if( m_ucRenderMode == CSkyObject::SKY_RENDER_MODE_TEXTURE )
|
||||||
{
|
{
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 6; ++i)
|
for (unsigned int i = 0; i < 6; ++i)
|
||||||
{
|
{
|
||||||
@ -844,8 +844,8 @@ void CSkyBox::Render()
|
|||||||
|
|
||||||
//STATEMANAGER.SetTexture( 0, NULL );
|
//STATEMANAGER.SetTexture( 0, NULL );
|
||||||
|
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ADDRESSU);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_ADDRESSU);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ADDRESSV);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_ADDRESSV);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -10,20 +10,20 @@ struct SLightData
|
|||||||
{
|
{
|
||||||
LIGHT_NUM = 8,
|
LIGHT_NUM = 8,
|
||||||
};
|
};
|
||||||
D3DLIGHT8 m_akD3DLight[LIGHT_NUM];
|
D3DLIGHT9 m_akD3DLight[LIGHT_NUM];
|
||||||
} m_kLightData;
|
} m_kLightData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CStateManager::SetLight(DWORD index, CONST D3DLIGHT8* pLight)
|
void CStateManager::SetLight(DWORD index, CONST D3DLIGHT9* pLight)
|
||||||
{
|
{
|
||||||
assert(index<SLightData::LIGHT_NUM);
|
assert(index < SLightData::LIGHT_NUM);
|
||||||
m_kLightData.m_akD3DLight[index]=*pLight;
|
m_kLightData.m_akD3DLight[index] = *pLight;
|
||||||
|
|
||||||
m_lpD3DDev->SetLight(index, pLight);
|
m_lpD3DDev->SetLight(index, pLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::GetLight(DWORD index, D3DLIGHT8* pLight)
|
void CStateManager::GetLight(DWORD index, D3DLIGHT9* pLight)
|
||||||
{
|
{
|
||||||
assert(index<8);
|
assert(index<8);
|
||||||
*pLight=m_kLightData.m_akD3DLight[index];
|
*pLight=m_kLightData.m_akD3DLight[index];
|
||||||
@ -54,7 +54,7 @@ void CStateManager::EndScene()
|
|||||||
m_bScene=false;
|
m_bScene=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStateManager::CStateManager(LPDIRECT3DDEVICE8 lpDevice) : m_lpD3DDev(NULL)
|
CStateManager::CStateManager(LPDIRECT3DDEVICE9 lpDevice) : m_lpD3DDev(NULL)
|
||||||
{
|
{
|
||||||
m_bScene = false;
|
m_bScene = false;
|
||||||
m_dwBestMinFilter = D3DTEXF_LINEAR;
|
m_dwBestMinFilter = D3DTEXF_LINEAR;
|
||||||
@ -71,7 +71,7 @@ CStateManager::~CStateManager()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SetDevice(LPDIRECT3DDEVICE8 lpDevice)
|
void CStateManager::SetDevice(LPDIRECT3DDEVICE9 lpDevice)
|
||||||
{
|
{
|
||||||
StateManager_Assert(lpDevice);
|
StateManager_Assert(lpDevice);
|
||||||
lpDevice->AddRef();
|
lpDevice->AddRef();
|
||||||
@ -84,7 +84,7 @@ void CStateManager::SetDevice(LPDIRECT3DDEVICE8 lpDevice)
|
|||||||
|
|
||||||
m_lpD3DDev = lpDevice;
|
m_lpD3DDev = lpDevice;
|
||||||
|
|
||||||
D3DCAPS8 d3dCaps;
|
D3DCAPS9 d3dCaps;
|
||||||
m_lpD3DDev->GetDeviceCaps(&d3dCaps);
|
m_lpD3DDev->GetDeviceCaps(&d3dCaps);
|
||||||
|
|
||||||
if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC)
|
if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC)
|
||||||
@ -101,16 +101,16 @@ void CStateManager::SetDevice(LPDIRECT3DDEVICE8 lpDevice)
|
|||||||
dwMax = dwMax < 4 ? dwMax : 4;
|
dwMax = dwMax < 4 ? dwMax : 4;
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax);
|
m_lpD3DDev->SetSamplerState(i, D3DSAMP_MAXANISOTROPY, dwMax);
|
||||||
|
|
||||||
SetDefaultState();
|
SetDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SetBestFiltering(DWORD dwStage)
|
void CStateManager::SetBestFiltering(DWORD dwStage)
|
||||||
{
|
{
|
||||||
SetTextureStageState(dwStage, D3DTSS_MINFILTER, m_dwBestMinFilter);
|
SetSamplerState(dwStage, D3DSAMP_MINFILTER, m_dwBestMinFilter);
|
||||||
SetTextureStageState(dwStage, D3DTSS_MAGFILTER, m_dwBestMagFilter);
|
SetSamplerState(dwStage, D3DSAMP_MAGFILTER, m_dwBestMagFilter);
|
||||||
SetTextureStageState(dwStage, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
SetSamplerState(dwStage, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::Restore()
|
void CStateManager::Restore()
|
||||||
@ -126,6 +126,10 @@ void CStateManager::Restore()
|
|||||||
for (j = 0; j < STATEMANAGER_MAX_TEXTURESTATES; ++j)
|
for (j = 0; j < STATEMANAGER_MAX_TEXTURESTATES; ++j)
|
||||||
SetTextureStageState(i, D3DTEXTURESTAGESTATETYPE(j), m_CurrentState.m_TextureStates[i][j]);
|
SetTextureStageState(i, D3DTEXTURESTAGESTATETYPE(j), m_CurrentState.m_TextureStates[i][j]);
|
||||||
|
|
||||||
|
for (i = 0; i < STATEMANAGER_MAX_STAGES; ++i)
|
||||||
|
for (j = 0; j < STATEMANAGER_MAX_SAMPLERSTATES; ++j)
|
||||||
|
SetSamplerState(i, D3DSAMPLERSTATETYPE(j), m_CurrentState.m_SamplerStates[i][j]);
|
||||||
|
|
||||||
for (i = 0; i < STATEMANAGER_MAX_STAGES; ++i)
|
for (i = 0; i < STATEMANAGER_MAX_STAGES; ++i)
|
||||||
SetTexture(i, m_CurrentState.m_Textures[i]);
|
SetTexture(i, m_CurrentState.m_Textures[i]);
|
||||||
|
|
||||||
@ -148,8 +152,8 @@ void CStateManager::SetDefaultState()
|
|||||||
SetTransform(D3DTS_VIEW, &Identity);
|
SetTransform(D3DTS_VIEW, &Identity);
|
||||||
SetTransform(D3DTS_PROJECTION, &Identity);
|
SetTransform(D3DTS_PROJECTION, &Identity);
|
||||||
|
|
||||||
D3DMATERIAL8 DefaultMat;
|
D3DMATERIAL9 DefaultMat;
|
||||||
ZeroMemory(&DefaultMat, sizeof(D3DMATERIAL8));
|
ZeroMemory(&DefaultMat, sizeof(D3DMATERIAL9));
|
||||||
|
|
||||||
DefaultMat.Diffuse.r = 1.0f;
|
DefaultMat.Diffuse.r = 1.0f;
|
||||||
DefaultMat.Diffuse.g = 1.0f;
|
DefaultMat.Diffuse.g = 1.0f;
|
||||||
@ -176,24 +180,20 @@ void CStateManager::SetDefaultState()
|
|||||||
SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
|
SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||||
SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
|
SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||||
|
|
||||||
SetRenderState(D3DRS_LINEPATTERN, 0xFFFFFFFF);
|
|
||||||
SetRenderState(D3DRS_LASTPIXEL, FALSE);
|
SetRenderState(D3DRS_LASTPIXEL, FALSE);
|
||||||
SetRenderState(D3DRS_ALPHAREF, 1);
|
SetRenderState(D3DRS_ALPHAREF, 1);
|
||||||
SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
|
SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
|
||||||
SetRenderState(D3DRS_ZVISIBLE, FALSE);
|
|
||||||
SetRenderState(D3DRS_FOGSTART, 0);
|
SetRenderState(D3DRS_FOGSTART, 0);
|
||||||
SetRenderState(D3DRS_FOGEND, 0);
|
SetRenderState(D3DRS_FOGEND, 0);
|
||||||
SetRenderState(D3DRS_FOGDENSITY, 0);
|
SetRenderState(D3DRS_FOGDENSITY, 0);
|
||||||
SetRenderState(D3DRS_EDGEANTIALIAS, FALSE);
|
|
||||||
SetRenderState(D3DRS_ZBIAS, 0);
|
|
||||||
SetRenderState(D3DRS_STENCILWRITEMASK, 0xFFFFFFFF);
|
SetRenderState(D3DRS_STENCILWRITEMASK, 0xFFFFFFFF);
|
||||||
SetRenderState(D3DRS_AMBIENT, 0x00000000);
|
SetRenderState(D3DRS_AMBIENT, 0x00000000);
|
||||||
SetRenderState(D3DRS_LOCALVIEWER, FALSE);
|
SetRenderState(D3DRS_LOCALVIEWER, FALSE);
|
||||||
SetRenderState(D3DRS_NORMALIZENORMALS, FALSE);
|
SetRenderState(D3DRS_NORMALIZENORMALS, FALSE);
|
||||||
SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
|
SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
|
||||||
SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
|
SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
|
||||||
SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
|
m_lpD3DDev->SetSoftwareVertexProcessing(false);
|
||||||
SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);
|
SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
|
||||||
SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
|
SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
|
||||||
SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
|
SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
|
||||||
SetRenderState(D3DRS_COLORWRITEENABLE, 0xFFFFFFFF);
|
SetRenderState(D3DRS_COLORWRITEENABLE, 0xFFFFFFFF);
|
||||||
@ -293,75 +293,18 @@ void CStateManager::SetDefaultState()
|
|||||||
SetTextureStageState(6, D3DTSS_TEXCOORDINDEX, 6);
|
SetTextureStageState(6, D3DTSS_TEXCOORDINDEX, 6);
|
||||||
SetTextureStageState(7, D3DTSS_TEXCOORDINDEX, 7);
|
SetTextureStageState(7, D3DTSS_TEXCOORDINDEX, 7);
|
||||||
|
|
||||||
SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
for (DWORD i = 0; i < 8; ++i)
|
||||||
SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
{
|
||||||
SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
SetSamplerState(i, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||||
|
SetSamplerState(i, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||||
SetTextureStageState(1, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
SetSamplerState(i, D3DSAMP_MIPFILTER, D3DTEXF_ANISOTROPIC);
|
||||||
SetTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
|
||||||
SetTextureStageState(1, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
|
||||||
|
SetTextureStageState(i, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
||||||
SetTextureStageState(2, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
SetTexture(i, NULL);
|
||||||
SetTextureStageState(2, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
}
|
||||||
SetTextureStageState(2, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
|
||||||
|
|
||||||
SetTextureStageState(3, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
|
||||||
SetTextureStageState(3, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
|
||||||
SetTextureStageState(3, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
|
||||||
|
|
||||||
SetTextureStageState(4, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
|
||||||
SetTextureStageState(4, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
|
||||||
SetTextureStageState(4, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
|
||||||
|
|
||||||
SetTextureStageState(5, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
|
||||||
SetTextureStageState(5, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
|
||||||
SetTextureStageState(5, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
|
||||||
|
|
||||||
SetTextureStageState(6, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
|
||||||
SetTextureStageState(6, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
|
||||||
SetTextureStageState(6, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
|
||||||
|
|
||||||
SetTextureStageState(7, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
|
||||||
SetTextureStageState(7, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
|
||||||
SetTextureStageState(7, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
|
||||||
|
|
||||||
SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(2, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(2, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(3, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(3, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(4, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(4, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(5, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(5, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(6, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(6, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(7, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
|
||||||
SetTextureStageState(7, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
|
||||||
|
|
||||||
SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
|
||||||
SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
|
||||||
SetTextureStageState(2, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
|
||||||
SetTextureStageState(3, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
|
||||||
SetTextureStageState(4, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
|
||||||
SetTextureStageState(5, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
|
||||||
SetTextureStageState(6, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
|
||||||
SetTextureStageState(7, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
|
||||||
|
|
||||||
SetTexture(0, NULL);
|
|
||||||
SetTexture(1, NULL);
|
|
||||||
SetTexture(2, NULL);
|
|
||||||
SetTexture(3, NULL);
|
|
||||||
SetTexture(4, NULL);
|
|
||||||
SetTexture(5, NULL);
|
|
||||||
SetTexture(6, NULL);
|
|
||||||
SetTexture(7, NULL);
|
|
||||||
|
|
||||||
SetPixelShader(0);
|
SetPixelShader(0);
|
||||||
SetVertexShader(D3DFVF_XYZ);
|
SetFVF(D3DFVF_XYZ);
|
||||||
|
|
||||||
D3DXVECTOR4 av4Null[STATEMANAGER_MAX_VCONSTANTS];
|
D3DXVECTOR4 av4Null[STATEMANAGER_MAX_VCONSTANTS];
|
||||||
memset(av4Null, 0, sizeof(av4Null));
|
memset(av4Null, 0, sizeof(av4Null));
|
||||||
@ -381,6 +324,10 @@ void CStateManager::SetDefaultState()
|
|||||||
for (j = 0; j < STATEMANAGER_MAX_STAGES; ++j)
|
for (j = 0; j < STATEMANAGER_MAX_STAGES; ++j)
|
||||||
for (i = 0; i < STATEMANAGER_MAX_TEXTURESTATES; ++i)
|
for (i = 0; i < STATEMANAGER_MAX_TEXTURESTATES; ++i)
|
||||||
m_bTextureStageStateSavingFlag[j][i] = FALSE;
|
m_bTextureStageStateSavingFlag[j][i] = FALSE;
|
||||||
|
|
||||||
|
for (j = 0; j < STATEMANAGER_MAX_STAGES; ++j)
|
||||||
|
for (i = 0; i < STATEMANAGER_MAX_SAMPLERSTATES; ++i)
|
||||||
|
m_bSamplerStateSavingFlag[j][i] = FALSE;
|
||||||
#endif _DEBUG
|
#endif _DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +337,7 @@ void CStateManager::SaveMaterial()
|
|||||||
m_CopyState.m_D3DMaterial = m_CurrentState.m_D3DMaterial;
|
m_CopyState.m_D3DMaterial = m_CurrentState.m_D3DMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SaveMaterial(const D3DMATERIAL8 * pMaterial)
|
void CStateManager::SaveMaterial(const D3DMATERIAL9* pMaterial)
|
||||||
{
|
{
|
||||||
// Check that we have set this up before, if not, the default is this.
|
// Check that we have set this up before, if not, the default is this.
|
||||||
m_CopyState.m_D3DMaterial = m_CurrentState.m_D3DMaterial;
|
m_CopyState.m_D3DMaterial = m_CurrentState.m_D3DMaterial;
|
||||||
@ -402,13 +349,13 @@ void CStateManager::RestoreMaterial()
|
|||||||
SetMaterial(&m_CopyState.m_D3DMaterial);
|
SetMaterial(&m_CopyState.m_D3DMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SetMaterial(const D3DMATERIAL8 * pMaterial)
|
void CStateManager::SetMaterial(const D3DMATERIAL9* pMaterial)
|
||||||
{
|
{
|
||||||
m_lpD3DDev->SetMaterial(pMaterial);
|
m_lpD3DDev->SetMaterial(pMaterial);
|
||||||
m_CurrentState.m_D3DMaterial = *pMaterial;
|
m_CurrentState.m_D3DMaterial = *pMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::GetMaterial(D3DMATERIAL8 * pMaterial)
|
void CStateManager::GetMaterial(D3DMATERIAL9* pMaterial)
|
||||||
{
|
{
|
||||||
// Set the renderstate and remember it.
|
// Set the renderstate and remember it.
|
||||||
*pMaterial = m_CurrentState.m_D3DMaterial;
|
*pMaterial = m_CurrentState.m_D3DMaterial;
|
||||||
@ -465,7 +412,7 @@ void CStateManager::GetRenderState(D3DRENDERSTATETYPE Type, DWORD * pdwValue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Textures
|
// Textures
|
||||||
void CStateManager::SaveTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE8 pTexture)
|
void CStateManager::SaveTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE9 pTexture)
|
||||||
{
|
{
|
||||||
// Check that we have set this up before, if not, the default is this.
|
// Check that we have set this up before, if not, the default is this.
|
||||||
m_CopyState.m_Textures[dwStage] = m_CurrentState.m_Textures[dwStage];
|
m_CopyState.m_Textures[dwStage] = m_CurrentState.m_Textures[dwStage];
|
||||||
@ -477,7 +424,7 @@ void CStateManager::RestoreTexture(DWORD dwStage)
|
|||||||
SetTexture(dwStage, m_CopyState.m_Textures[dwStage]);
|
SetTexture(dwStage, m_CopyState.m_Textures[dwStage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE8 pTexture)
|
void CStateManager::SetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE9 pTexture)
|
||||||
{
|
{
|
||||||
if (pTexture == m_CurrentState.m_Textures[dwStage])
|
if (pTexture == m_CurrentState.m_Textures[dwStage])
|
||||||
return;
|
return;
|
||||||
@ -486,13 +433,13 @@ void CStateManager::SetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE8 pTexture)
|
|||||||
m_CurrentState.m_Textures[dwStage] = pTexture;
|
m_CurrentState.m_Textures[dwStage] = pTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::GetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE8 * ppTexture)
|
void CStateManager::GetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE9* ppTexture)
|
||||||
{
|
{
|
||||||
*ppTexture = m_CurrentState.m_Textures[dwStage];
|
*ppTexture = m_CurrentState.m_Textures[dwStage];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texture stage states
|
// Texture stage states
|
||||||
void CStateManager::SaveTextureStageState(DWORD dwStage,D3DTEXTURESTAGESTATETYPE Type, DWORD dwValue)
|
void CStateManager::SaveTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type, DWORD dwValue)
|
||||||
{
|
{
|
||||||
// Check that we have set this up before, if not, the default is this.
|
// Check that we have set this up before, if not, the default is this.
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@ -534,8 +481,52 @@ void CStateManager::GetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE
|
|||||||
*pdwValue = m_CurrentState.m_TextureStates[dwStage][Type];
|
*pdwValue = m_CurrentState.m_TextureStates[dwStage][Type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DirectX 9 upgrade
|
||||||
|
void CStateManager::SaveSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE Type, DWORD dwValue)
|
||||||
|
{
|
||||||
|
// Check that we have set this up before, if not, the default is this.
|
||||||
|
#ifdef _DEBUG
|
||||||
|
if (m_bSamplerStateSavingFlag[dwStage][Type])
|
||||||
|
{
|
||||||
|
Tracef(" CStateManager::SaveSamplerState - This sampler state is already saved [%d, %d]\n", dwStage, Type);
|
||||||
|
StateManager_Assert(!" This sampler state is already saved!");
|
||||||
|
}
|
||||||
|
m_bSamplerStateSavingFlag[dwStage][Type] = TRUE;
|
||||||
|
#endif _DEBUG
|
||||||
|
m_CopyState.m_SamplerStates[dwStage][Type] = m_CurrentState.m_SamplerStates[dwStage][Type];
|
||||||
|
SetSamplerState(dwStage, Type, dwValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::RestoreSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE Type)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
if (!m_bSamplerStateSavingFlag[dwStage][Type])
|
||||||
|
{
|
||||||
|
Tracef(" CStateManager::RestoreSamplerState - This sampler state was not saved [%d, %d]\n", dwStage, Type);
|
||||||
|
StateManager_Assert(!" This sampler state was not saved!");
|
||||||
|
}
|
||||||
|
m_bSamplerStateSavingFlag[dwStage][Type] = FALSE;
|
||||||
|
#endif _DEBUG
|
||||||
|
SetSamplerState(dwStage, Type, m_CopyState.m_SamplerStates[dwStage][Type]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::SetSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE Type, DWORD dwValue)
|
||||||
|
{
|
||||||
|
if (m_CurrentState.m_SamplerStates[dwStage][Type] == dwValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_lpD3DDev->SetSamplerState(dwStage, Type, dwValue);
|
||||||
|
|
||||||
|
m_CurrentState.m_SamplerStates[dwStage][Type] = dwValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::GetSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE Type, DWORD* pdwValue)
|
||||||
|
{
|
||||||
|
*pdwValue = m_CurrentState.m_SamplerStates[dwStage][Type];
|
||||||
|
}
|
||||||
|
|
||||||
// Vertex Shader
|
// Vertex Shader
|
||||||
void CStateManager::SaveVertexShader(DWORD dwShader)
|
void CStateManager::SaveVertexShader(LPDIRECT3DVERTEXSHADER9 dwShader)
|
||||||
{
|
{
|
||||||
m_CopyState.m_dwVertexShader = m_CurrentState.m_dwVertexShader;
|
m_CopyState.m_dwVertexShader = m_CurrentState.m_dwVertexShader;
|
||||||
SetVertexShader(dwShader);
|
SetVertexShader(dwShader);
|
||||||
@ -546,22 +537,49 @@ void CStateManager::RestoreVertexShader()
|
|||||||
SetVertexShader(m_CopyState.m_dwVertexShader);
|
SetVertexShader(m_CopyState.m_dwVertexShader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SetVertexShader(DWORD dwShader)
|
void CStateManager::SetVertexShader(LPDIRECT3DVERTEXSHADER9 dwShader)
|
||||||
{
|
{
|
||||||
if (m_CurrentState.m_dwVertexShader == dwShader)
|
if (m_CurrentState.m_dwVertexShader != dwShader)
|
||||||
return;
|
{
|
||||||
|
m_CurrentState.m_dwVertexShader = dwShader;
|
||||||
m_lpD3DDev->SetVertexShader(dwShader);
|
m_lpD3DDev->SetVertexShader(dwShader);
|
||||||
m_CurrentState.m_dwVertexShader = dwShader;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::GetVertexShader(DWORD * pdwShader)
|
void CStateManager::GetVertexShader(LPDIRECT3DVERTEXSHADER9* pdwShader)
|
||||||
{
|
{
|
||||||
*pdwShader = m_CurrentState.m_dwVertexShader;
|
*pdwShader = m_CurrentState.m_dwVertexShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Vertex Declaration
|
||||||
|
void CStateManager::SaveVertexDeclaration(LPDIRECT3DVERTEXDECLARATION9 dwShader)
|
||||||
|
{
|
||||||
|
m_CopyState.m_dwVertexDeclaration = m_CurrentState.m_dwVertexDeclaration;
|
||||||
|
SetVertexDeclaration(dwShader);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::RestoreVertexDeclaration()
|
||||||
|
{
|
||||||
|
SetVertexDeclaration(m_CopyState.m_dwVertexDeclaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::SetVertexDeclaration(LPDIRECT3DVERTEXDECLARATION9 dwShader)
|
||||||
|
{
|
||||||
|
if (m_CurrentState.m_dwVertexDeclaration == dwShader)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_lpD3DDev->SetVertexDeclaration(dwShader);
|
||||||
|
m_CurrentState.m_dwVertexDeclaration = dwShader;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::GetVertexDeclaration(LPDIRECT3DVERTEXDECLARATION9* pdwShader)
|
||||||
|
{
|
||||||
|
*pdwShader = m_CurrentState.m_dwVertexDeclaration;
|
||||||
|
}
|
||||||
|
|
||||||
// Pixel Shader
|
// Pixel Shader
|
||||||
void CStateManager::SavePixelShader(DWORD dwShader)
|
void CStateManager::SavePixelShader(LPDIRECT3DPIXELSHADER9 dwShader)
|
||||||
{
|
{
|
||||||
m_CopyState.m_dwPixelShader = m_CurrentState.m_dwPixelShader;
|
m_CopyState.m_dwPixelShader = m_CurrentState.m_dwPixelShader;
|
||||||
SetPixelShader(dwShader);
|
SetPixelShader(dwShader);
|
||||||
@ -572,20 +590,46 @@ void CStateManager::RestorePixelShader()
|
|||||||
SetPixelShader(m_CopyState.m_dwPixelShader);
|
SetPixelShader(m_CopyState.m_dwPixelShader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SetPixelShader(DWORD dwShader)
|
void CStateManager::SetPixelShader(LPDIRECT3DPIXELSHADER9 dwShader)
|
||||||
{
|
{
|
||||||
if (m_CurrentState.m_dwPixelShader == dwShader)
|
if (m_CurrentState.m_dwPixelShader != dwShader) {
|
||||||
return;
|
m_CurrentState.m_dwPixelShader = dwShader;
|
||||||
|
m_lpD3DDev->SetPixelShader(dwShader);
|
||||||
m_lpD3DDev->SetPixelShader(dwShader);
|
}
|
||||||
m_CurrentState.m_dwPixelShader = dwShader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::GetPixelShader(DWORD * pdwShader)
|
void CStateManager::GetPixelShader(LPDIRECT3DPIXELSHADER9* pdwShader)
|
||||||
{
|
{
|
||||||
*pdwShader = m_CurrentState.m_dwPixelShader;
|
*pdwShader = m_CurrentState.m_dwPixelShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FVF
|
||||||
|
void CStateManager::SaveFVF(DWORD dwFVF)
|
||||||
|
{
|
||||||
|
m_CopyState.m_dwFVF = m_CurrentState.m_dwFVF;
|
||||||
|
SetFVF(dwFVF);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::RestoreFVF()
|
||||||
|
{
|
||||||
|
SetFVF(m_CopyState.m_dwFVF);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::SetFVF(DWORD dwFVF)
|
||||||
|
{
|
||||||
|
if (m_CurrentState.m_dwFVF != dwFVF)
|
||||||
|
{
|
||||||
|
m_lpD3DDev->SetFVF(dwFVF);
|
||||||
|
m_CurrentState.m_dwFVF = dwFVF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::GetFVF(DWORD* dwFVF)
|
||||||
|
{
|
||||||
|
*dwFVF = m_CurrentState.m_dwFVF;
|
||||||
|
}
|
||||||
|
|
||||||
// *** These states are cached, but not protected from multiple sends of the same value.
|
// *** These states are cached, but not protected from multiple sends of the same value.
|
||||||
// Transform
|
// Transform
|
||||||
void CStateManager::SaveTransform(D3DTRANSFORMSTATETYPE Type, const D3DMATRIX* pMatrix)
|
void CStateManager::SaveTransform(D3DTRANSFORMSTATETYPE Type, const D3DMATRIX* pMatrix)
|
||||||
@ -640,9 +684,7 @@ void CStateManager::GetTransform(D3DTRANSFORMSTATETYPE Type, D3DMATRIX * pMatrix
|
|||||||
// SetVertexShaderConstant
|
// SetVertexShaderConstant
|
||||||
void CStateManager::SaveVertexShaderConstant(DWORD dwRegister,CONST void* pConstantData,DWORD dwConstantCount)
|
void CStateManager::SaveVertexShaderConstant(DWORD dwRegister,CONST void* pConstantData,DWORD dwConstantCount)
|
||||||
{
|
{
|
||||||
DWORD i;
|
for (DWORD i = 0; i < dwConstantCount; i++)
|
||||||
|
|
||||||
for (i = 0; i < dwConstantCount; i++)
|
|
||||||
{
|
{
|
||||||
StateManager_Assert((dwRegister + i) < STATEMANAGER_MAX_VCONSTANTS);
|
StateManager_Assert((dwRegister + i) < STATEMANAGER_MAX_VCONSTANTS);
|
||||||
m_CopyState.m_VertexShaderConstants[dwRegister + i] = m_CurrentState.m_VertexShaderConstants[dwRegister + i];
|
m_CopyState.m_VertexShaderConstants[dwRegister + i] = m_CurrentState.m_VertexShaderConstants[dwRegister + i];
|
||||||
@ -651,14 +693,14 @@ void CStateManager::SaveVertexShaderConstant(DWORD dwRegister,CONST void* pConst
|
|||||||
SetVertexShaderConstant(dwRegister, pConstantData, dwConstantCount);
|
SetVertexShaderConstant(dwRegister, pConstantData, dwConstantCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::RestoreVertexShaderConstant(DWORD dwRegister, DWORD dwConstantCount)
|
void CStateManager::RestoreVertexShaderConstant(UINT dwRegister, UINT dwConstantCount)
|
||||||
{
|
{
|
||||||
SetVertexShaderConstant(dwRegister, &m_CopyState.m_VertexShaderConstants[dwRegister], dwConstantCount);
|
SetVertexShaderConstant(dwRegister, &m_CopyState.m_VertexShaderConstants[dwRegister], dwConstantCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SetVertexShaderConstant(DWORD dwRegister,CONST void* pConstantData,DWORD dwConstantCount)
|
void CStateManager::SetVertexShaderConstant(DWORD dwRegister,CONST void* pConstantData,DWORD dwConstantCount)
|
||||||
{
|
{
|
||||||
m_lpD3DDev->SetVertexShaderConstant(dwRegister, pConstantData, dwConstantCount);
|
m_lpD3DDev->SetVertexShaderConstantF(dwRegister, (const float*)pConstantData, dwConstantCount);
|
||||||
|
|
||||||
// Set the renderstate and remember it.
|
// Set the renderstate and remember it.
|
||||||
for (DWORD i = 0; i < dwConstantCount; i++)
|
for (DWORD i = 0; i < dwConstantCount; i++)
|
||||||
@ -671,9 +713,7 @@ void CStateManager::SetVertexShaderConstant(DWORD dwRegister,CONST void* pConsta
|
|||||||
// SetPixelShaderConstant
|
// SetPixelShaderConstant
|
||||||
void CStateManager::SavePixelShaderConstant(DWORD dwRegister,CONST void* pConstantData,DWORD dwConstantCount)
|
void CStateManager::SavePixelShaderConstant(DWORD dwRegister,CONST void* pConstantData,DWORD dwConstantCount)
|
||||||
{
|
{
|
||||||
DWORD i;
|
for (DWORD i = 0; i < dwConstantCount; i++)
|
||||||
|
|
||||||
for (i = 0; i < dwConstantCount; i++)
|
|
||||||
{
|
{
|
||||||
StateManager_Assert((dwRegister + i) < STATEMANAGER_MAX_VCONSTANTS);
|
StateManager_Assert((dwRegister + i) < STATEMANAGER_MAX_VCONSTANTS);
|
||||||
m_CopyState.m_PixelShaderConstants[dwRegister + i] = *(((D3DXVECTOR4*)pConstantData) + i);
|
m_CopyState.m_PixelShaderConstants[dwRegister + i] = *(((D3DXVECTOR4*)pConstantData) + i);
|
||||||
@ -682,14 +722,9 @@ void CStateManager::SavePixelShaderConstant(DWORD dwRegister,CONST void* pConsta
|
|||||||
SetPixelShaderConstant(dwRegister, pConstantData, dwConstantCount);
|
SetPixelShaderConstant(dwRegister, pConstantData, dwConstantCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::RestorePixelShaderConstant(DWORD dwRegister, DWORD dwConstantCount)
|
|
||||||
{
|
|
||||||
SetPixelShaderConstant(dwRegister, &m_CopyState.m_PixelShaderConstants[dwRegister], dwConstantCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CStateManager::SetPixelShaderConstant(DWORD dwRegister,CONST void* pConstantData,DWORD dwConstantCount)
|
void CStateManager::SetPixelShaderConstant(DWORD dwRegister,CONST void* pConstantData,DWORD dwConstantCount)
|
||||||
{
|
{
|
||||||
m_lpD3DDev->SetPixelShaderConstant(dwRegister, pConstantData, dwConstantCount);
|
m_lpD3DDev->SetPixelShaderConstantF(dwRegister, (const float*)pConstantData, dwConstantCount);
|
||||||
|
|
||||||
// Set the renderstate and remember it.
|
// Set the renderstate and remember it.
|
||||||
for (DWORD i = 0; i < dwConstantCount; i++)
|
for (DWORD i = 0; i < dwConstantCount; i++)
|
||||||
@ -699,7 +734,12 @@ void CStateManager::SetPixelShaderConstant(DWORD dwRegister,CONST void* pConstan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SaveStreamSource(UINT StreamNumber, LPDIRECT3DVERTEXBUFFER8 pStreamData,UINT Stride)
|
void CStateManager::RestorePixelShaderConstant(UINT dwRegister, UINT dwConstantCount)
|
||||||
|
{
|
||||||
|
SetPixelShaderConstant(dwRegister, &m_CopyState.m_PixelShaderConstants[dwRegister], dwConstantCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::SaveStreamSource(UINT StreamNumber, LPDIRECT3DVERTEXBUFFER9 pStreamData, UINT Stride)
|
||||||
{
|
{
|
||||||
// Check that we have set this up before, if not, the default is this.
|
// Check that we have set this up before, if not, the default is this.
|
||||||
m_CopyState.m_StreamData[StreamNumber] = m_CurrentState.m_StreamData[StreamNumber];
|
m_CopyState.m_StreamData[StreamNumber] = m_CurrentState.m_StreamData[StreamNumber];
|
||||||
@ -713,17 +753,17 @@ void CStateManager::RestoreStreamSource(UINT StreamNumber)
|
|||||||
m_CopyState.m_StreamData[StreamNumber].m_Stride);
|
m_CopyState.m_StreamData[StreamNumber].m_Stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SetStreamSource(UINT StreamNumber, LPDIRECT3DVERTEXBUFFER8 pStreamData, UINT Stride)
|
void CStateManager::SetStreamSource(UINT StreamNumber, LPDIRECT3DVERTEXBUFFER9 pStreamData, UINT Stride)
|
||||||
{
|
{
|
||||||
CStreamData kStreamData(pStreamData, Stride);
|
CStreamData kStreamData(pStreamData, Stride);
|
||||||
if (m_CurrentState.m_StreamData[StreamNumber] == kStreamData)
|
if (m_CurrentState.m_StreamData[StreamNumber] == kStreamData)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_lpD3DDev->SetStreamSource(StreamNumber, pStreamData, Stride);
|
m_lpD3DDev->SetStreamSource(StreamNumber, pStreamData, 0, Stride);
|
||||||
m_CurrentState.m_StreamData[StreamNumber] = kStreamData;
|
m_CurrentState.m_StreamData[StreamNumber] = kStreamData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SaveIndices(LPDIRECT3DINDEXBUFFER8 pIndexData, UINT BaseVertexIndex)
|
void CStateManager::SaveIndices(LPDIRECT3DINDEXBUFFER9 pIndexData, UINT BaseVertexIndex)
|
||||||
{
|
{
|
||||||
m_CopyState.m_IndexData = m_CurrentState.m_IndexData;
|
m_CopyState.m_IndexData = m_CurrentState.m_IndexData;
|
||||||
SetIndices(pIndexData, BaseVertexIndex);
|
SetIndices(pIndexData, BaseVertexIndex);
|
||||||
@ -734,14 +774,14 @@ void CStateManager::RestoreIndices()
|
|||||||
SetIndices(m_CopyState.m_IndexData.m_lpIndexData, m_CopyState.m_IndexData.m_BaseVertexIndex);
|
SetIndices(m_CopyState.m_IndexData.m_lpIndexData, m_CopyState.m_IndexData.m_BaseVertexIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::SetIndices(LPDIRECT3DINDEXBUFFER8 pIndexData, UINT BaseVertexIndex)
|
void CStateManager::SetIndices(LPDIRECT3DINDEXBUFFER9 pIndexData, UINT BaseVertexIndex)
|
||||||
{
|
{
|
||||||
CIndexData kIndexData(pIndexData, BaseVertexIndex);
|
CIndexData kIndexData(pIndexData, BaseVertexIndex);
|
||||||
|
|
||||||
if (m_CurrentState.m_IndexData == kIndexData)
|
if (m_CurrentState.m_IndexData == kIndexData)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_lpD3DDev->SetIndices(pIndexData, BaseVertexIndex);
|
m_lpD3DDev->SetIndices(pIndexData);
|
||||||
m_CurrentState.m_IndexData = kIndexData;
|
m_CurrentState.m_IndexData = kIndexData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,9 +796,9 @@ HRESULT CStateManager::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT Prim
|
|||||||
return (m_lpD3DDev->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride));
|
return (m_lpD3DDev->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride));
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CStateManager::DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT minIndex, UINT NumVertices, UINT startIndex, UINT primCount)
|
HRESULT CStateManager::DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT minIndex, UINT NumVertices, UINT startIndex, UINT primCount, INT baseVertexIndex)
|
||||||
{
|
{
|
||||||
return (m_lpD3DDev->DrawIndexedPrimitive(PrimitiveType, minIndex, NumVertices, startIndex, primCount));
|
return (m_lpD3DDev->DrawIndexedPrimitive(PrimitiveType, baseVertexIndex, minIndex, NumVertices, startIndex, primCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CStateManager::DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices, UINT PrimitiveCount, CONST void * pIndexData, D3DFORMAT IndexDataFormat, CONST void * pVertexStreamZeroData, UINT VertexStreamZeroStride)
|
HRESULT CStateManager::DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices, UINT PrimitiveCount, CONST void * pIndexData, D3DFORMAT IndexDataFormat, CONST void * pVertexStreamZeroData, UINT VertexStreamZeroStride)
|
||||||
|
@ -38,11 +38,10 @@
|
|||||||
|
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef __CSTATEMANAGER_H
|
#pragma once
|
||||||
#define __CSTATEMANAGER_H
|
|
||||||
|
|
||||||
#include <d3d8.h>
|
#include <d3d9.h>
|
||||||
#include <d3dx8.h>
|
#include <directxsdk/d3dx9.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -58,6 +57,7 @@
|
|||||||
|
|
||||||
static const DWORD STATEMANAGER_MAX_RENDERSTATES = 256;
|
static const DWORD STATEMANAGER_MAX_RENDERSTATES = 256;
|
||||||
static const DWORD STATEMANAGER_MAX_TEXTURESTATES = 128;
|
static const DWORD STATEMANAGER_MAX_TEXTURESTATES = 128;
|
||||||
|
static const DWORD STATEMANAGER_MAX_SAMPLERSTATES = 128;
|
||||||
static const DWORD STATEMANAGER_MAX_STAGES = 8;
|
static const DWORD STATEMANAGER_MAX_STAGES = 8;
|
||||||
static const DWORD STATEMANAGER_MAX_VCONSTANTS = 96;
|
static const DWORD STATEMANAGER_MAX_VCONSTANTS = 96;
|
||||||
static const DWORD STATEMANAGER_MAX_PCONSTANTS = 8;
|
static const DWORD STATEMANAGER_MAX_PCONSTANTS = 8;
|
||||||
@ -67,7 +67,7 @@ static const DWORD STATEMANAGER_MAX_STREAMS = 16;
|
|||||||
class CStreamData
|
class CStreamData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CStreamData(LPDIRECT3DVERTEXBUFFER8 pStreamData = NULL, UINT Stride = 0) : m_lpStreamData(pStreamData), m_Stride(Stride)
|
CStreamData(LPDIRECT3DVERTEXBUFFER9 pStreamData = NULL, UINT Stride = 0) : m_lpStreamData(pStreamData), m_Stride(Stride)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,15 +75,14 @@ class CStreamData
|
|||||||
{
|
{
|
||||||
return ((m_lpStreamData == rhs.m_lpStreamData) && (m_Stride == rhs.m_Stride));
|
return ((m_lpStreamData == rhs.m_lpStreamData) && (m_Stride == rhs.m_Stride));
|
||||||
}
|
}
|
||||||
|
LPDIRECT3DVERTEXBUFFER9 m_lpStreamData;
|
||||||
LPDIRECT3DVERTEXBUFFER8 m_lpStreamData;
|
|
||||||
UINT m_Stride;
|
UINT m_Stride;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIndexData
|
class CIndexData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CIndexData(LPDIRECT3DINDEXBUFFER8 pIndexData = NULL, UINT BaseVertexIndex = 0)
|
CIndexData(LPDIRECT3DINDEXBUFFER9 pIndexData = NULL, UINT BaseVertexIndex = 0)
|
||||||
: m_lpIndexData(pIndexData),
|
: m_lpIndexData(pIndexData),
|
||||||
m_BaseVertexIndex(BaseVertexIndex)
|
m_BaseVertexIndex(BaseVertexIndex)
|
||||||
{
|
{
|
||||||
@ -94,7 +93,7 @@ class CIndexData
|
|||||||
return ((m_lpIndexData == rhs.m_lpIndexData) && (m_BaseVertexIndex == rhs.m_BaseVertexIndex));
|
return ((m_lpIndexData == rhs.m_lpIndexData) && (m_BaseVertexIndex == rhs.m_BaseVertexIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
LPDIRECT3DINDEXBUFFER8 m_lpIndexData;
|
LPDIRECT3DINDEXBUFFER9 m_lpIndexData;
|
||||||
UINT m_BaseVertexIndex;
|
UINT m_BaseVertexIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -170,10 +169,14 @@ class CStateManagerState
|
|||||||
for (i = 0; i < STATEMANAGER_MAX_RENDERSTATES; i++)
|
for (i = 0; i < STATEMANAGER_MAX_RENDERSTATES; i++)
|
||||||
m_RenderStates[i] = 0x7FFFFFFF;
|
m_RenderStates[i] = 0x7FFFFFFF;
|
||||||
|
|
||||||
for (i = 0; i < STATEMANAGER_MAX_STAGES; i++)
|
for (i = 0; i < STATEMANAGER_MAX_STAGES; ++i)
|
||||||
for (y = 0; y < STATEMANAGER_MAX_TEXTURESTATES; y++)
|
for (y = 0; y < STATEMANAGER_MAX_TEXTURESTATES; ++y)
|
||||||
m_TextureStates[i][y] = 0x7FFFFFFF;
|
m_TextureStates[i][y] = 0x7FFFFFFF;
|
||||||
|
|
||||||
|
for (i = 0; i < STATEMANAGER_MAX_STAGES; ++i)
|
||||||
|
for (y = 0; y < STATEMANAGER_MAX_SAMPLERSTATES; ++y)
|
||||||
|
m_SamplerStates[i][y] = 0x7FFFFFFF;
|
||||||
|
|
||||||
for (i = 0; i < STATEMANAGER_MAX_STREAMS; i++)
|
for (i = 0; i < STATEMANAGER_MAX_STREAMS; i++)
|
||||||
m_StreamData[i] = CStreamData();
|
m_StreamData[i] = CStreamData();
|
||||||
|
|
||||||
@ -182,7 +185,7 @@ class CStateManagerState
|
|||||||
for (i = 0; i < STATEMANAGER_MAX_STAGES; i++)
|
for (i = 0; i < STATEMANAGER_MAX_STAGES; i++)
|
||||||
m_Textures[i] = NULL;
|
m_Textures[i] = NULL;
|
||||||
|
|
||||||
// Matrices and constants are not cached, just restored. It's silly to check all the
|
// Matrices and constants are not cached, just restored. It's silly to check all the
|
||||||
// data elements (by which time the driver could have been sent them).
|
// data elements (by which time the driver could have been sent them).
|
||||||
for (i = 0; i < STATEMANAGER_MAX_TRANSFORMSTATES; i++)
|
for (i = 0; i < STATEMANAGER_MAX_TRANSFORMSTATES; i++)
|
||||||
D3DXMatrixIdentity(&m_Matrices[i]);
|
D3DXMatrixIdentity(&m_Matrices[i]);
|
||||||
@ -193,8 +196,9 @@ class CStateManagerState
|
|||||||
for (i = 0; i < STATEMANAGER_MAX_PCONSTANTS; i++)
|
for (i = 0; i < STATEMANAGER_MAX_PCONSTANTS; i++)
|
||||||
m_PixelShaderConstants[i] = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 0.0f);
|
m_PixelShaderConstants[i] = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
m_dwPixelShader = 0;
|
m_dwFVF = D3DFVF_XYZ;
|
||||||
m_dwVertexShader = D3DFVF_XYZ;
|
m_dwVertexShader = NULL;
|
||||||
|
m_dwPixelShader = NULL;
|
||||||
|
|
||||||
ZeroMemory(&m_Matrices, sizeof(D3DXMATRIX) * STATEMANAGER_MAX_TRANSFORMSTATES);
|
ZeroMemory(&m_Matrices, sizeof(D3DXMATRIX) * STATEMANAGER_MAX_TRANSFORMSTATES);
|
||||||
}
|
}
|
||||||
@ -205,6 +209,9 @@ class CStateManagerState
|
|||||||
// Texture stage states
|
// Texture stage states
|
||||||
DWORD m_TextureStates[STATEMANAGER_MAX_STAGES][STATEMANAGER_MAX_TEXTURESTATES];
|
DWORD m_TextureStates[STATEMANAGER_MAX_STAGES][STATEMANAGER_MAX_TEXTURESTATES];
|
||||||
|
|
||||||
|
// Texture sampler states
|
||||||
|
DWORD m_SamplerStates[STATEMANAGER_MAX_STAGES][STATEMANAGER_MAX_SAMPLERSTATES];
|
||||||
|
|
||||||
// Vertex shader constants
|
// Vertex shader constants
|
||||||
D3DXVECTOR4 m_VertexShaderConstants[STATEMANAGER_MAX_VCONSTANTS];
|
D3DXVECTOR4 m_VertexShaderConstants[STATEMANAGER_MAX_VCONSTANTS];
|
||||||
|
|
||||||
@ -212,15 +219,18 @@ class CStateManagerState
|
|||||||
D3DXVECTOR4 m_PixelShaderConstants[STATEMANAGER_MAX_PCONSTANTS];
|
D3DXVECTOR4 m_PixelShaderConstants[STATEMANAGER_MAX_PCONSTANTS];
|
||||||
|
|
||||||
// Textures
|
// Textures
|
||||||
LPDIRECT3DBASETEXTURE8 m_Textures[STATEMANAGER_MAX_STAGES];
|
LPDIRECT3DBASETEXTURE9 m_Textures[STATEMANAGER_MAX_STAGES];
|
||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
DWORD m_dwPixelShader;
|
LPDIRECT3DVERTEXSHADER9 m_dwVertexShader;
|
||||||
DWORD m_dwVertexShader;
|
LPDIRECT3DVERTEXDECLARATION9 m_dwVertexDeclaration;
|
||||||
|
LPDIRECT3DPIXELSHADER9 m_dwPixelShader;
|
||||||
|
|
||||||
|
DWORD m_dwFVF;
|
||||||
|
|
||||||
D3DXMATRIX m_Matrices[STATEMANAGER_MAX_TRANSFORMSTATES];
|
D3DXMATRIX m_Matrices[STATEMANAGER_MAX_TRANSFORMSTATES];
|
||||||
|
|
||||||
D3DMATERIAL8 m_D3DMaterial;
|
D3DMATERIAL9 m_D3DMaterial;
|
||||||
|
|
||||||
CStreamData m_StreamData[STATEMANAGER_MAX_STREAMS];
|
CStreamData m_StreamData[STATEMANAGER_MAX_STREAMS];
|
||||||
CIndexData m_IndexData;
|
CIndexData m_IndexData;
|
||||||
@ -229,7 +239,7 @@ class CStateManagerState
|
|||||||
class CStateManager : public CSingleton<CStateManager>
|
class CStateManager : public CSingleton<CStateManager>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CStateManager(LPDIRECT3DDEVICE8 lpDevice);
|
CStateManager(LPDIRECT3DDEVICE9 lpDevice);
|
||||||
virtual ~CStateManager();
|
virtual ~CStateManager();
|
||||||
|
|
||||||
void SetDefaultState();
|
void SetDefaultState();
|
||||||
@ -237,47 +247,60 @@ class CStateManager : public CSingleton<CStateManager>
|
|||||||
|
|
||||||
bool BeginScene();
|
bool BeginScene();
|
||||||
void EndScene();
|
void EndScene();
|
||||||
|
|
||||||
// Material
|
// Material
|
||||||
void SaveMaterial();
|
void SaveMaterial();
|
||||||
void SaveMaterial(const D3DMATERIAL8 * pMaterial);
|
void SaveMaterial(const D3DMATERIAL9* pMaterial);
|
||||||
void RestoreMaterial();
|
void RestoreMaterial();
|
||||||
void SetMaterial(const D3DMATERIAL8 * pMaterial);
|
void SetMaterial(const D3DMATERIAL9* pMaterial);
|
||||||
void GetMaterial(D3DMATERIAL8 * pMaterial);
|
void GetMaterial(D3DMATERIAL9* pMaterial);
|
||||||
|
|
||||||
void SetLight(DWORD index, CONST D3DLIGHT8* pLight);
|
void SetLight(DWORD index, CONST D3DLIGHT9* pLight);
|
||||||
void GetLight(DWORD index, D3DLIGHT8* pLight);
|
void GetLight(DWORD index, D3DLIGHT9* pLight);
|
||||||
|
|
||||||
// Renderstates
|
// Renderstates
|
||||||
void SaveRenderState(D3DRENDERSTATETYPE Type, DWORD dwValue);
|
void SaveRenderState(D3DRENDERSTATETYPE Type, DWORD dwValue);
|
||||||
void RestoreRenderState(D3DRENDERSTATETYPE Type);
|
void RestoreRenderState(D3DRENDERSTATETYPE Type);
|
||||||
void SetRenderState(D3DRENDERSTATETYPE Type, DWORD Value);
|
void SetRenderState(D3DRENDERSTATETYPE Type, DWORD Value);
|
||||||
void GetRenderState(D3DRENDERSTATETYPE Type, DWORD * pdwValue);
|
void GetRenderState(D3DRENDERSTATETYPE Type, DWORD* pdwValue);
|
||||||
|
|
||||||
// Textures
|
// Textures
|
||||||
void SaveTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE8 pTexture);
|
void SaveTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE9 pTexture);
|
||||||
void RestoreTexture(DWORD dwStage);
|
void RestoreTexture(DWORD dwStage);
|
||||||
void SetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE8 pTexture);
|
void SetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE9 pTexture);
|
||||||
void GetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE8 * ppTexture);
|
void GetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE9* ppTexture);
|
||||||
|
|
||||||
// Texture stage states
|
// Texture stage states
|
||||||
void SaveTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type, DWORD dwValue);
|
void SaveTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type, DWORD dwValue);
|
||||||
void RestoreTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type);
|
void RestoreTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type);
|
||||||
void SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type, DWORD dwValue);
|
void SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type, DWORD dwValue);
|
||||||
void GetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type, DWORD * pdwValue);
|
void GetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pdwValue);
|
||||||
|
void SaveSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE Type, DWORD dwValue);
|
||||||
|
void RestoreSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE Type);
|
||||||
|
void SetSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE Type, DWORD dwValue);
|
||||||
|
void GetSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE Type, DWORD* pdwValue);
|
||||||
void SetBestFiltering(DWORD dwStage); // if possible set anisotropy filtering, or use trilinear
|
void SetBestFiltering(DWORD dwStage); // if possible set anisotropy filtering, or use trilinear
|
||||||
|
|
||||||
// Vertex Shader
|
// Vertex Shader
|
||||||
void SaveVertexShader(DWORD dwShader);
|
void SaveVertexShader(LPDIRECT3DVERTEXSHADER9 dwShader);
|
||||||
void RestoreVertexShader();
|
void RestoreVertexShader();
|
||||||
void SetVertexShader(DWORD dwShader);
|
void SetVertexShader(LPDIRECT3DVERTEXSHADER9 dwShader);
|
||||||
void GetVertexShader(DWORD * pdwShader);
|
void GetVertexShader(LPDIRECT3DVERTEXSHADER9* pdwShader);
|
||||||
|
void SaveVertexDeclaration(LPDIRECT3DVERTEXDECLARATION9 dwShader);
|
||||||
|
void RestoreVertexDeclaration();
|
||||||
|
void SetVertexDeclaration(LPDIRECT3DVERTEXDECLARATION9 dwShader);
|
||||||
|
void GetVertexDeclaration(LPDIRECT3DVERTEXDECLARATION9* pdwShader);
|
||||||
|
|
||||||
// Pixel Shader
|
// Pixel Shader
|
||||||
void SavePixelShader(DWORD dwShader);
|
void SavePixelShader(LPDIRECT3DPIXELSHADER9 lpShader);
|
||||||
void RestorePixelShader();
|
void RestorePixelShader();
|
||||||
void SetPixelShader(DWORD dwShader);
|
void SetPixelShader(LPDIRECT3DPIXELSHADER9 lpShader);
|
||||||
void GetPixelShader(DWORD * pdwShader);
|
void GetPixelShader(LPDIRECT3DPIXELSHADER9* lppShader);
|
||||||
|
|
||||||
|
void SaveFVF(DWORD dwFVF);
|
||||||
|
void RestoreFVF();
|
||||||
|
void SetFVF(DWORD dwFVF);
|
||||||
|
void GetFVF(DWORD* dwFVF);
|
||||||
|
|
||||||
// *** These states are cached, but not protected from multiple sends of the same value.
|
// *** These states are cached, but not protected from multiple sends of the same value.
|
||||||
// Transform
|
// Transform
|
||||||
@ -286,36 +309,36 @@ class CStateManager : public CSingleton<CStateManager>
|
|||||||
|
|
||||||
// Don't cache-check the transform. To much to do
|
// Don't cache-check the transform. To much to do
|
||||||
void SetTransform(D3DTRANSFORMSTATETYPE Type, const D3DMATRIX* pMatrix);
|
void SetTransform(D3DTRANSFORMSTATETYPE Type, const D3DMATRIX* pMatrix);
|
||||||
void GetTransform(D3DTRANSFORMSTATETYPE Type, D3DMATRIX * pMatrix);
|
void GetTransform(D3DTRANSFORMSTATETYPE Type, D3DMATRIX* pMatrix);
|
||||||
|
|
||||||
// SetVertexShaderConstant
|
// SetVertexShaderConstant
|
||||||
void SaveVertexShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
void SaveVertexShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
||||||
void RestoreVertexShaderConstant(DWORD dwRegister, DWORD dwConstantCount);
|
void RestoreVertexShaderConstant(UINT uiRegister, UINT uiConstantCount);
|
||||||
void SetVertexShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
void SetVertexShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
||||||
|
|
||||||
// SetPixelShaderConstant
|
// SetPixelShaderConstant
|
||||||
void SavePixelShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
void SavePixelShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
||||||
void RestorePixelShaderConstant(DWORD dwRegister, DWORD dwConstantCount);
|
void RestorePixelShaderConstant(UINT uiRegister, UINT uiConstantCount);
|
||||||
void SetPixelShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
void SetPixelShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
||||||
|
|
||||||
void SaveStreamSource(UINT StreamNumber, LPDIRECT3DVERTEXBUFFER8 pStreamData, UINT Stride);
|
void SaveStreamSource(UINT StreamNumber, LPDIRECT3DVERTEXBUFFER9 pStreamData, UINT Stride);
|
||||||
void RestoreStreamSource(UINT StreamNumber);
|
void RestoreStreamSource(UINT StreamNumber);
|
||||||
void SetStreamSource(UINT StreamNumber, LPDIRECT3DVERTEXBUFFER8 pStreamData, UINT Stride);
|
void SetStreamSource(UINT StreamNumber, LPDIRECT3DVERTEXBUFFER9 pStreamData, UINT Stride);
|
||||||
|
|
||||||
void SaveIndices(LPDIRECT3DINDEXBUFFER8 pIndexData, UINT BaseVertexIndex);
|
void SaveIndices(LPDIRECT3DINDEXBUFFER9 pIndexData, UINT BaseVertexIndex);
|
||||||
void RestoreIndices();
|
void RestoreIndices();
|
||||||
void SetIndices(LPDIRECT3DINDEXBUFFER8 pIndexData,UINT BaseVertexIndex);
|
void SetIndices(LPDIRECT3DINDEXBUFFER9 pIndexData, UINT BaseVertexIndex);
|
||||||
|
|
||||||
HRESULT DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
|
HRESULT DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
|
||||||
HRESULT DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, const void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
|
HRESULT DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, const void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
|
||||||
HRESULT DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT minIndex, UINT NumVertices, UINT startIndex, UINT primCount);
|
HRESULT DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT minIndex, UINT NumVertices, UINT startIndex, UINT primCount, INT baseVertexIndex = 0);
|
||||||
HRESULT DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices, UINT PrimitiveCount, CONST void * pIndexData, D3DFORMAT IndexDataFormat, CONST void * pVertexStreamZeroData, UINT VertexStreamZeroStride);
|
HRESULT DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
|
||||||
|
|
||||||
// Codes For Debug
|
// Codes For Debug
|
||||||
DWORD GetRenderState(D3DRENDERSTATETYPE Type);
|
DWORD GetRenderState(D3DRENDERSTATETYPE Type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetDevice(LPDIRECT3DDEVICE8 lpDevice);
|
void SetDevice(LPDIRECT3DDEVICE9 lpDevice);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CStateManagerState m_ChipState;
|
CStateManagerState m_ChipState;
|
||||||
@ -326,16 +349,15 @@ class CStateManager : public CSingleton<CStateManager>
|
|||||||
bool m_bScene;
|
bool m_bScene;
|
||||||
DWORD m_dwBestMinFilter;
|
DWORD m_dwBestMinFilter;
|
||||||
DWORD m_dwBestMagFilter;
|
DWORD m_dwBestMagFilter;
|
||||||
LPDIRECT3DDEVICE8 m_lpD3DDev;
|
LPDIRECT3DDEVICE9 m_lpD3DDev;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// Saving Flag
|
// Saving Flag
|
||||||
BOOL m_bRenderStateSavingFlag[STATEMANAGER_MAX_RENDERSTATES];
|
BOOL m_bRenderStateSavingFlag[STATEMANAGER_MAX_RENDERSTATES];
|
||||||
BOOL m_bTextureStageStateSavingFlag[STATEMANAGER_MAX_STAGES][STATEMANAGER_MAX_TEXTURESTATES];
|
BOOL m_bTextureStageStateSavingFlag[STATEMANAGER_MAX_STAGES][STATEMANAGER_MAX_TEXTURESTATES];
|
||||||
|
BOOL m_bSamplerStateSavingFlag[STATEMANAGER_MAX_STAGES][STATEMANAGER_MAX_SAMPLERSTATES];
|
||||||
BOOL m_bTransformSavingFlag[STATEMANAGER_MAX_TRANSFORMSTATES];
|
BOOL m_bTransformSavingFlag[STATEMANAGER_MAX_TRANSFORMSTATES];
|
||||||
#endif _DEBUG
|
#endif _DEBUG
|
||||||
};
|
};
|
||||||
|
|
||||||
#define STATEMANAGER (CStateManager::Instance())
|
#define STATEMANAGER (CStateManager::Instance())
|
||||||
|
|
||||||
#endif __CSTATEMANAGER_H
|
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#pragma warning(disable:4201 4512 4238 4239)
|
#pragma warning(disable:4201 4512 4238 4239)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <d3d8.h>
|
#include <d3d9.h>
|
||||||
#include <d3dx8.h>
|
#include <directxsdk/d3dx9.h>
|
||||||
|
|
||||||
#define DIRECTINPUT_VERSION 0x0800
|
#define DIRECTINPUT_VERSION 0x0800
|
||||||
|
|
||||||
@ -38,8 +38,7 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
#pragma comment(lib, "winmm.lib")
|
#pragma comment(lib, "winmm.lib")
|
||||||
#pragma comment(lib, "d3d8.lib")
|
#pragma comment(lib, "d3d9.lib")
|
||||||
#pragma comment(lib, "d3dx8.lib")
|
|
||||||
|
|
||||||
#include "../eterBase/StdAfx.h"
|
#include "../eterBase/StdAfx.h"
|
||||||
#include "../eterBase/Debug.h"
|
#include "../eterBase/Debug.h"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <d3dx8.h>
|
#include <directxsdk/d3dx9.h>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class CTransitor
|
class CTransitor
|
||||||
|
@ -9,7 +9,7 @@ void CPythonGraphic::Destroy()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
LPDIRECT3D8 CPythonGraphic::GetD3D()
|
LPDIRECT3D9 CPythonGraphic::GetD3D()
|
||||||
{
|
{
|
||||||
return ms_lpd3d;
|
return ms_lpd3d;
|
||||||
}
|
}
|
||||||
@ -25,9 +25,9 @@ void CPythonGraphic::SetInterfaceRenderState()
|
|||||||
STATEMANAGER.SetTransform(D3DTS_VIEW, &ms_matIdentity);
|
STATEMANAGER.SetTransform(D3DTS_VIEW, &ms_matIdentity);
|
||||||
STATEMANAGER.SetTransform(D3DTS_WORLD, &ms_matIdentity);
|
STATEMANAGER.SetTransform(D3DTS_WORLD, &ms_matIdentity);
|
||||||
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_NONE);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_NONE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_NONE);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_NONE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_NONE);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
|
||||||
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||||
@ -41,9 +41,9 @@ void CPythonGraphic::SetInterfaceRenderState()
|
|||||||
|
|
||||||
void CPythonGraphic::SetGameRenderState()
|
void CPythonGraphic::SetGameRenderState()
|
||||||
{
|
{
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
|
||||||
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||||
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);
|
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);
|
||||||
@ -57,13 +57,13 @@ void CPythonGraphic::SetCursorPosition(int x, int y)
|
|||||||
void CPythonGraphic::SetOmniLight()
|
void CPythonGraphic::SetOmniLight()
|
||||||
{
|
{
|
||||||
// Set up a material
|
// Set up a material
|
||||||
D3DMATERIAL8 Material;
|
D3DMATERIAL9 Material;
|
||||||
Material.Ambient = D3DXCOLOR(0.3f, 0.3f, 0.3f, 1.0f);
|
Material.Ambient = D3DXCOLOR(0.3f, 0.3f, 0.3f, 1.0f);
|
||||||
Material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
|
Material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
Material.Emissive = D3DXCOLOR(0.1f, 0.1f, 0.1f, 1.0f);
|
Material.Emissive = D3DXCOLOR(0.1f, 0.1f, 0.1f, 1.0f);
|
||||||
STATEMANAGER.SetMaterial(&Material);
|
STATEMANAGER.SetMaterial(&Material);
|
||||||
|
|
||||||
D3DLIGHT8 Light;
|
D3DLIGHT9 Light;
|
||||||
Light.Type = D3DLIGHT_SPOT;
|
Light.Type = D3DLIGHT_SPOT;
|
||||||
Light.Position = D3DXVECTOR3(50.0f, 150.0f, 350.0f);
|
Light.Position = D3DXVECTOR3(50.0f, 150.0f, 350.0f);
|
||||||
Light.Direction = D3DXVECTOR3(-0.15f, -0.3f, -0.9f);
|
Light.Direction = D3DXVECTOR3(-0.15f, -0.3f, -0.9f);
|
||||||
@ -98,7 +98,7 @@ void CPythonGraphic::SetViewport(float fx, float fy, float fWidth, float fHeight
|
|||||||
{
|
{
|
||||||
ms_lpd3dDevice->GetViewport(&m_backupViewport);
|
ms_lpd3dDevice->GetViewport(&m_backupViewport);
|
||||||
|
|
||||||
D3DVIEWPORT8 ViewPort;
|
D3DVIEWPORT9 ViewPort;
|
||||||
ViewPort.X = fx;
|
ViewPort.X = fx;
|
||||||
ViewPort.Y = fy;
|
ViewPort.Y = fy;
|
||||||
ViewPort.Width = fWidth;
|
ViewPort.Width = fWidth;
|
||||||
@ -123,7 +123,7 @@ void CPythonGraphic::RestoreViewport()
|
|||||||
|
|
||||||
void CPythonGraphic::SetGamma(float fGammaFactor)
|
void CPythonGraphic::SetGamma(float fGammaFactor)
|
||||||
{
|
{
|
||||||
D3DCAPS8 d3dCaps;
|
D3DCAPS9 d3dCaps;
|
||||||
D3DGAMMARAMP NewRamp;
|
D3DGAMMARAMP NewRamp;
|
||||||
int ui, val;
|
int ui, val;
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ void CPythonGraphic::SetGamma(float fGammaFactor)
|
|||||||
NewRamp.blue[i] = (WORD) (val | (32768 * ui));
|
NewRamp.blue[i] = (WORD) (val | (32768 * ui));
|
||||||
}
|
}
|
||||||
|
|
||||||
ms_lpd3dDevice->SetGammaRamp(D3DSGR_NO_CALIBRATION, &NewRamp);
|
ms_lpd3dDevice->SetGammaRamp(0, D3DSGR_NO_CALIBRATION, &NewRamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenScreenShotTag(const char* src, DWORD crc32, char* leaf, size_t leafLen)
|
void GenScreenShotTag(const char* src, DWORD crc32, char* leaf, size_t leafLen)
|
||||||
@ -172,10 +172,10 @@ bool CPythonGraphic::SaveJPEG(const char * pszFileName, LPBYTE pbyBuffer, UINT u
|
|||||||
bool CPythonGraphic::SaveScreenShot(const char * c_pszFileName)
|
bool CPythonGraphic::SaveScreenShot(const char * c_pszFileName)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
LPDIRECT3DSURFACE8 lpSurface;
|
LPDIRECT3DSURFACE9 lpSurface;
|
||||||
D3DSURFACE_DESC stSurfaceDesc;
|
D3DSURFACE_DESC stSurfaceDesc;
|
||||||
|
|
||||||
if (FAILED(hr = ms_lpd3dDevice->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &lpSurface)))
|
if (FAILED(hr = ms_lpd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &lpSurface)))
|
||||||
{
|
{
|
||||||
TraceError("Failed to get back buffer (0x%08x)", hr);
|
TraceError("Failed to get back buffer (0x%08x)", hr);
|
||||||
return false;
|
return false;
|
||||||
@ -481,7 +481,7 @@ void CPythonGraphic::RenderAlphaImage(CGraphicImageInstance* pImageInstance, flo
|
|||||||
vertices[3].diffuse = DiffuseColor2;
|
vertices[3].diffuse = DiffuseColor2;
|
||||||
vertices[3].texCoord = TTextureCoordinate(eu, ev);
|
vertices[3].texCoord = TTextureCoordinate(eu, ev);
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(ms_pntVS);
|
STATEMANAGER.SetFVF(ms_pntVS);
|
||||||
// 2004.11.18.myevan.DrawIndexPrimitiveUP -> DynamicVertexBuffer
|
// 2004.11.18.myevan.DrawIndexPrimitiveUP -> DynamicVertexBuffer
|
||||||
CGraphicBase::SetDefaultIndexBuffer(DEFAULT_IB_FILL_RECT);
|
CGraphicBase::SetDefaultIndexBuffer(DEFAULT_IB_FILL_RECT);
|
||||||
if (CGraphicBase::SetPDTStream(vertices, 4))
|
if (CGraphicBase::SetPDTStream(vertices, 4))
|
||||||
@ -563,7 +563,7 @@ void CPythonGraphic::RenderCoolTimeBox(float fxCenter, float fyCenter, float fRa
|
|||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTexture(0, NULL);
|
STATEMANAGER.SetTexture(0, NULL);
|
||||||
STATEMANAGER.SetTexture(1, NULL);
|
STATEMANAGER.SetTexture(1, NULL);
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLEFAN, 0, iTriCount);
|
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLEFAN, 0, iTriCount);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLOROP);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLOROP);
|
||||||
@ -613,7 +613,7 @@ CPythonGraphic::CPythonGraphic()
|
|||||||
m_lightColor = GetColor(1.0f, 1.0f, 1.0f);
|
m_lightColor = GetColor(1.0f, 1.0f, 1.0f);
|
||||||
m_darkColor = GetColor(0.0f, 0.0f, 0.0f);
|
m_darkColor = GetColor(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
memset(&m_backupViewport, 0, sizeof(D3DVIEWPORT8));
|
memset(&m_backupViewport, 0, sizeof(D3DVIEWPORT9));
|
||||||
|
|
||||||
m_fOrthoDepth = 1000.0f;
|
m_fOrthoDepth = 1000.0f;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class CPythonGraphic : public CScreen, public CSingleton<CPythonGraphic>
|
|||||||
void PushState();
|
void PushState();
|
||||||
void PopState();
|
void PopState();
|
||||||
|
|
||||||
LPDIRECT3D8 GetD3D();
|
LPDIRECT3D9 GetD3D();
|
||||||
|
|
||||||
float GetOrthoDepth();
|
float GetOrthoDepth();
|
||||||
void SetInterfaceRenderState();
|
void SetInterfaceRenderState();
|
||||||
@ -62,7 +62,7 @@ class CPythonGraphic : public CScreen, public CSingleton<CPythonGraphic>
|
|||||||
|
|
||||||
CCullingManager m_CullingManager;
|
CCullingManager m_CullingManager;
|
||||||
|
|
||||||
D3DVIEWPORT8 m_backupViewport;
|
D3DVIEWPORT9 m_backupViewport;
|
||||||
|
|
||||||
float m_fOrthoDepth;
|
float m_fOrthoDepth;
|
||||||
};
|
};
|
@ -2,7 +2,7 @@
|
|||||||
#include "ActorInstance.h"
|
#include "ActorInstance.h"
|
||||||
#include "AreaTerrain.h"
|
#include "AreaTerrain.h"
|
||||||
#include "RaceData.h"
|
#include "RaceData.h"
|
||||||
#include "../SpeedTreeLib/SpeedTreeForestDirectX8.h"
|
#include "../SpeedTreeLib/CSpeedTreeDirectX.h"
|
||||||
#include "../SpeedTreeLib/SpeedTreeWrapper.h"
|
#include "../SpeedTreeLib/SpeedTreeWrapper.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -801,8 +801,8 @@ void CActorInstance::__CreateTree(const char * c_szFileName)
|
|||||||
{
|
{
|
||||||
__DestroyTree();
|
__DestroyTree();
|
||||||
|
|
||||||
CSpeedTreeForestDirectX8& rkForest=CSpeedTreeForestDirectX8::Instance();
|
CSpeedTreeForest& rkForest = CSpeedTreeForest::Instance();
|
||||||
m_pkTree=rkForest.CreateInstance(m_x, m_y, m_z, GetCaseCRC32(c_szFileName, strlen(c_szFileName)), c_szFileName);
|
m_pkTree = rkForest.CreateInstance(m_x, m_y, m_z, GetCaseCRC32(c_szFileName, strlen(c_szFileName)), c_szFileName);
|
||||||
m_pkTree->SetPosition(m_x, m_y, m_z);
|
m_pkTree->SetPosition(m_x, m_y, m_z);
|
||||||
m_pkTree->UpdateBoundingSphere();
|
m_pkTree->UpdateBoundingSphere();
|
||||||
m_pkTree->UpdateCollisionData();
|
m_pkTree->UpdateCollisionData();
|
||||||
@ -813,7 +813,7 @@ void CActorInstance::__DestroyTree()
|
|||||||
if (!m_pkTree)
|
if (!m_pkTree)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CSpeedTreeForestDirectX8::Instance().DeleteInstance(m_pkTree);
|
CSpeedTreeForest::Instance().DeleteInstance(m_pkTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CActorInstance::__SetTreePosition(float fx, float fy, float fz)
|
void CActorInstance::__SetTreePosition(float fx, float fy, float fz)
|
||||||
|
@ -32,7 +32,7 @@ void CActorInstance::SetMaterialAlpha(DWORD dwAlpha)
|
|||||||
|
|
||||||
void CActorInstance::OnRender()
|
void CActorInstance::OnRender()
|
||||||
{
|
{
|
||||||
D3DMATERIAL8 kMtrl;
|
D3DMATERIAL9 kMtrl;
|
||||||
STATEMANAGER.GetMaterial(&kMtrl);
|
STATEMANAGER.GetMaterial(&kMtrl);
|
||||||
|
|
||||||
kMtrl.Diffuse=D3DXCOLOR(m_dwMtrlColor);
|
kMtrl.Diffuse=D3DXCOLOR(m_dwMtrlColor);
|
||||||
@ -127,7 +127,7 @@ void CActorInstance::OnRender()
|
|||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLOROP);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLOROP);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAOP);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAOP);
|
||||||
STATEMANAGER.RestoreVertexShader();
|
STATEMANAGER.RestoreFVF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "../eterLib/ResourceManager.h"
|
#include "../eterLib/ResourceManager.h"
|
||||||
#include "../eterLib/StateManager.h"
|
#include "../eterLib/StateManager.h"
|
||||||
#include "../effectLib/EffectManager.h"
|
#include "../effectLib/EffectManager.h"
|
||||||
#include "../SpeedTreeLib/SpeedTreeForestDirectX8.h"
|
#include "../SpeedTreeLib/CSpeedTreeDirectX.h"
|
||||||
#include "../eterBase/Timer.h"
|
#include "../eterBase/Timer.h"
|
||||||
|
|
||||||
#include "Area.h"
|
#include "Area.h"
|
||||||
@ -585,7 +585,7 @@ void CArea::__SetObjectInstance_SetTree(TObjectInstance * pObjectInstance, const
|
|||||||
|
|
||||||
void CArea::TObjectInstance::SetTree(float x, float y, float z, DWORD dwTreeCRC, const char* c_szTreeName)
|
void CArea::TObjectInstance::SetTree(float x, float y, float z, DWORD dwTreeCRC, const char* c_szTreeName)
|
||||||
{
|
{
|
||||||
CSpeedTreeForestDirectX8& rkForest=CSpeedTreeForestDirectX8::Instance();
|
CSpeedTreeForest& rkForest = CSpeedTreeForest::Instance();
|
||||||
pTree=rkForest.CreateInstance(x, y, z, dwTreeCRC, c_szTreeName);
|
pTree=rkForest.CreateInstance(x, y, z, dwTreeCRC, c_szTreeName);
|
||||||
dwType = prt::PROPERTY_TYPE_TREE;
|
dwType = prt::PROPERTY_TYPE_TREE;
|
||||||
}
|
}
|
||||||
@ -1245,7 +1245,7 @@ void CArea::__Clear_DestroyObjectInstance(TObjectInstance * pObjectInstance)
|
|||||||
if (pObjectInstance->pTree)
|
if (pObjectInstance->pTree)
|
||||||
{
|
{
|
||||||
pObjectInstance->pTree->Clear();
|
pObjectInstance->pTree->Clear();
|
||||||
CSpeedTreeForestDirectX8::Instance().DeleteInstance(pObjectInstance->pTree);
|
CSpeedTreeForest::Instance().DeleteInstance(pObjectInstance->pTree);
|
||||||
pObjectInstance->pTree = NULL;
|
pObjectInstance->pTree = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,7 +757,7 @@ void CTerrain::RAW_GenerateSplat(bool bBGLoading)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 CTerrain::AddTexture32(BYTE byImageNum, BYTE * pbyImage, long lTextureWidth, long lTextureHeight)
|
LPDIRECT3DTEXTURE9 CTerrain::AddTexture32(BYTE byImageNum, BYTE* pbyImage, long lTextureWidth, long lTextureHeight)
|
||||||
{
|
{
|
||||||
assert(NULL==m_lpAlphaTexture[byImageNum]);
|
assert(NULL==m_lpAlphaTexture[byImageNum]);
|
||||||
|
|
||||||
@ -777,13 +777,11 @@ LPDIRECT3DTEXTURE8 CTerrain::AddTexture32(BYTE byImageNum, BYTE * pbyImage, long
|
|||||||
|
|
||||||
bool bResizedAndSuccess = false;
|
bool bResizedAndSuccess = false;
|
||||||
|
|
||||||
IDirect3DTexture8* pkTex=NULL;
|
IDirect3DTexture9* pkTex = NULL;
|
||||||
|
|
||||||
UINT uiNewWidth = 256;
|
UINT uiNewWidth = 256;
|
||||||
UINT uiNewHeight = 256;
|
UINT uiNewHeight = 256;
|
||||||
hr = ms_lpd3dDevice->CreateTexture(
|
hr = ms_lpd3dDevice->CreateTexture(uiNewWidth, uiNewHeight, 5, 0, format, D3DPOOL_MANAGED, &pkTex, NULL);
|
||||||
uiNewWidth, uiNewHeight, 5, 0,
|
|
||||||
format, D3DPOOL_MANAGED, &pkTex);
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
TraceError("CTerrain::AddTexture32 - CreateTexture Error");
|
TraceError("CTerrain::AddTexture32 - CreateTexture Error");
|
||||||
@ -1153,7 +1151,7 @@ void CTerrain::AllocateMarkedSplats(BYTE * pbyAlphaMap)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
hr = ms_lpd3dDevice->CreateTexture(ATTRMAP_XSIZE, ATTRMAP_YSIZE, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_lpMarkedTexture);
|
hr = ms_lpd3dDevice->CreateTexture(ATTRMAP_XSIZE, ATTRMAP_YSIZE, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_lpMarkedTexture, NULL);
|
||||||
} while(FAILED(hr));
|
} while(FAILED(hr));
|
||||||
|
|
||||||
D3DLOCKED_RECT d3dlr;
|
D3DLOCKED_RECT d3dlr;
|
||||||
|
@ -78,7 +78,7 @@ class CTerrain : public CTerrainImpl, public CGraphicBase
|
|||||||
|
|
||||||
// MiniMap
|
// MiniMap
|
||||||
void LoadMiniMapTexture(const char * c_pszFileName);
|
void LoadMiniMapTexture(const char * c_pszFileName);
|
||||||
inline LPDIRECT3DTEXTURE8 GetMiniMapTexture() { return m_lpMiniMapTexture; }
|
inline LPDIRECT3DTEXTURE9 GetMiniMapTexture() { return m_lpMiniMapTexture; }
|
||||||
|
|
||||||
// Marked Area
|
// Marked Area
|
||||||
BOOL IsMarked() { return m_bMarked; }
|
BOOL IsMarked() { return m_bMarked; }
|
||||||
@ -107,7 +107,7 @@ class CTerrain : public CTerrainImpl, public CGraphicBase
|
|||||||
void RAW_DeallocateSplats(bool bBGLoading = false);
|
void RAW_DeallocateSplats(bool bBGLoading = false);
|
||||||
virtual void RAW_CountTiles();
|
virtual void RAW_CountTiles();
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 AddTexture32(BYTE byImageNum, BYTE * pbyImage, long lTextureWidth, long lTextureHeight);
|
LPDIRECT3DTEXTURE9 AddTexture32(BYTE byImageNum, BYTE * pbyImage, long lTextureWidth, long lTextureHeight);
|
||||||
void PutImage32(BYTE * pbySrc, BYTE * pbyDst, long src_pitch, long dst_pitch, long lTextureWidth, long lTextureHeight, bool bResize = false);
|
void PutImage32(BYTE * pbySrc, BYTE * pbyDst, long src_pitch, long dst_pitch, long lTextureWidth, long lTextureHeight, bool bResize = false);
|
||||||
void PutImage16(BYTE * pbySrc, BYTE * pbyDst, long src_pitch, long dst_pitch, long lTextureWidth, long lTextureHeight, bool bResize = false);
|
void PutImage16(BYTE * pbySrc, BYTE * pbyDst, long src_pitch, long dst_pitch, long lTextureWidth, long lTextureHeight, bool bResize = false);
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ class CTerrain : public CTerrainImpl, public CGraphicBase
|
|||||||
|
|
||||||
//MiniMap
|
//MiniMap
|
||||||
CGraphicImageInstance m_MiniMapGraphicImageInstance;
|
CGraphicImageInstance m_MiniMapGraphicImageInstance;
|
||||||
LPDIRECT3DTEXTURE8 m_lpMiniMapTexture;
|
LPDIRECT3DTEXTURE9 m_lpMiniMapTexture;
|
||||||
|
|
||||||
|
|
||||||
// Owner COutdoorMap poineter
|
// Owner COutdoorMap poineter
|
||||||
@ -142,7 +142,7 @@ class CTerrain : public CTerrainImpl, public CGraphicBase
|
|||||||
|
|
||||||
BOOL m_bMarked;
|
BOOL m_bMarked;
|
||||||
TTerrainSplatPatch m_MarkedSplatPatch;
|
TTerrainSplatPatch m_MarkedSplatPatch;
|
||||||
LPDIRECT3DTEXTURE8 m_lpMarkedTexture;
|
LPDIRECT3DTEXTURE9 m_lpMarkedTexture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CTerrainPatch * GetTerrainPatchPtr(BYTE byPatchNumX, BYTE byPatchNumY);
|
CTerrainPatch * GetTerrainPatchPtr(BYTE byPatchNumX, BYTE byPatchNumY);
|
||||||
|
@ -14,8 +14,8 @@ class CDungeonModelInstance : public CGrannyModelInstance
|
|||||||
if (IsEmpty())
|
if (IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(ms_pnt2VS);
|
STATEMANAGER.SetFVF(ms_pnt2VS);
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
LPDIRECT3DVERTEXBUFFER9 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
||||||
if (lpd3dRigidPNTVtxBuf)
|
if (lpd3dRigidPNTVtxBuf)
|
||||||
{
|
{
|
||||||
STATEMANAGER.SetStreamSource(0, lpd3dRigidPNTVtxBuf, sizeof(TPNT2Vertex));
|
STATEMANAGER.SetStreamSource(0, lpd3dRigidPNTVtxBuf, sizeof(TPNT2Vertex));
|
||||||
@ -36,8 +36,8 @@ class CDungeonModelInstance : public CGrannyModelInstance
|
|||||||
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
|
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);
|
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(ms_pnt2VS);
|
STATEMANAGER.SetFVF(ms_pnt2VS);
|
||||||
LPDIRECT3DVERTEXBUFFER8 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
LPDIRECT3DVERTEXBUFFER9 lpd3dRigidPNTVtxBuf = m_pModel->GetPNTD3DVertexBuffer();
|
||||||
if (lpd3dRigidPNTVtxBuf)
|
if (lpd3dRigidPNTVtxBuf)
|
||||||
{
|
{
|
||||||
STATEMANAGER.SetStreamSource(0, lpd3dRigidPNTVtxBuf, sizeof(TPNT2Vertex));
|
STATEMANAGER.SetStreamSource(0, lpd3dRigidPNTVtxBuf, sizeof(TPNT2Vertex));
|
||||||
|
@ -130,7 +130,7 @@ void CFlyTrace::Render()
|
|||||||
D3DXMatrixIdentity(&matWorld);
|
D3DXMatrixIdentity(&matWorld);
|
||||||
|
|
||||||
STATEMANAGER.SaveTransform(D3DTS_WORLD, &matWorld);
|
STATEMANAGER.SaveTransform(D3DTS_WORLD, &matWorld);
|
||||||
STATEMANAGER.SaveVertexShader(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
STATEMANAGER.SaveFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||||
|
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
@ -278,7 +278,7 @@ void CFlyTrace::Render()
|
|||||||
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
|
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
|
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
|
||||||
STATEMANAGER.RestoreVertexShader();
|
STATEMANAGER.RestoreFVF();
|
||||||
STATEMANAGER.RestoreTransform(D3DTS_WORLD);
|
STATEMANAGER.RestoreTransform(D3DTS_WORLD);
|
||||||
//STATEMANAGER.RestoreRenderState(D3DRS_ZWRITEENABLE);
|
//STATEMANAGER.RestoreRenderState(D3DRS_ZWRITEENABLE);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ZFUNC);
|
STATEMANAGER.RestoreRenderState(D3DRS_ZFUNC);
|
||||||
|
@ -23,7 +23,7 @@ class CFlyTrace : public CScreen
|
|||||||
typedef std::deque<TTimePosition> TTimePositionDeque;
|
typedef std::deque<TTimePosition> TTimePositionDeque;
|
||||||
|
|
||||||
//CGraphicImageInstance m_ImageInstance;
|
//CGraphicImageInstance m_ImageInstance;
|
||||||
//LPDIRECT3DTEXTURE8 m_lpTexture;
|
//LPDIRECT3DTEXTURE9 m_lpTexture;
|
||||||
|
|
||||||
bool m_bRectShape;
|
bool m_bRectShape;
|
||||||
DWORD m_dwColor;
|
DWORD m_dwColor;
|
||||||
|
@ -24,7 +24,7 @@ class CMapBase : public CScreen
|
|||||||
virtual float GetHeight(float fx, float fy) = 0;
|
virtual float GetHeight(float fx, float fy) = 0;
|
||||||
virtual void OnBeginEnvironment() = 0; // 렌더링 할 때 불려지며 여기서 Environment에 관련 있는 것들을 셋팅 한다.
|
virtual void OnBeginEnvironment() = 0; // 렌더링 할 때 불려지며 여기서 Environment에 관련 있는 것들을 셋팅 한다.
|
||||||
|
|
||||||
virtual void ApplyLight(DWORD dwVersion, const D3DLIGHT8& c_rkLight) = 0;
|
virtual void ApplyLight(DWORD dwVersion, const D3DLIGHT9& c_rkLight) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnRender() = 0;
|
virtual void OnRender() = 0;
|
||||||
|
@ -259,7 +259,7 @@ void CMapManager::BeginEnvironment()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CSpeedTreeForestDirectX8& rkForest=CSpeedTreeForestDirectX8::Instance();
|
CSpeedTreeForest& rkForest = CSpeedTreeForest::Instance();
|
||||||
rkForest.SetFog(
|
rkForest.SetFog(
|
||||||
mc_pcurEnvironmentData->GetFogNearDistance(),
|
mc_pcurEnvironmentData->GetFogNearDistance(),
|
||||||
mc_pcurEnvironmentData->GetFogFarDistance()
|
mc_pcurEnvironmentData->GetFogFarDistance()
|
||||||
|
@ -106,8 +106,8 @@ class CMapManager : public CScreen, public IPhysicsWorld
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Map
|
// Map
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
CMapOutdoor * m_pkMap;
|
CMapOutdoor * m_pkMap;
|
||||||
CSpeedTreeForestDirectX8 m_Forest;
|
CSpeedTreeDirectX m_Forest;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 2004.10.14.myevan.TEMP_CAreaLoaderThread
|
// 2004.10.14.myevan.TEMP_CAreaLoaderThread
|
||||||
|
@ -190,7 +190,7 @@ bool CMapOutdoor::Initialize()
|
|||||||
m_bEnableTerrainOnlyForHeight = FALSE;
|
m_bEnableTerrainOnlyForHeight = FALSE;
|
||||||
m_bEnablePortal = FALSE;
|
m_bEnablePortal = FALSE;
|
||||||
|
|
||||||
m_wShadowMapSize = 512;
|
m_wShadowMapSize = 2048;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ bool CMapOutdoor::Destroy()
|
|||||||
m_kPool_kMonsterAreaInfo.Destroy();
|
m_kPool_kMonsterAreaInfo.Destroy();
|
||||||
m_AlphaFogImageInstance.Destroy();
|
m_AlphaFogImageInstance.Destroy();
|
||||||
|
|
||||||
CSpeedTreeForestDirectX8::Instance().Clear();
|
CSpeedTreeForest::Instance().Clear();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -248,13 +248,13 @@ void CMapOutdoor::OnBeginEnvironment()
|
|||||||
if (!mc_pEnvironmentData)
|
if (!mc_pEnvironmentData)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CSpeedTreeForestDirectX8& rkForest=CSpeedTreeForestDirectX8::Instance();
|
CSpeedTreeForest& rkForest = CSpeedTreeForest::Instance();
|
||||||
rkForest.SetFog(
|
rkForest.SetFog(
|
||||||
mc_pEnvironmentData->GetFogNearDistance(),
|
mc_pEnvironmentData->GetFogNearDistance(),
|
||||||
mc_pEnvironmentData->GetFogFarDistance()
|
mc_pEnvironmentData->GetFogFarDistance()
|
||||||
);
|
);
|
||||||
|
|
||||||
const D3DLIGHT8& c_rkLight = mc_pEnvironmentData->DirLights[ENV_DIRLIGHT_CHARACTER];
|
const D3DLIGHT9& c_rkLight = mc_pEnvironmentData->DirLights[ENV_DIRLIGHT_CHARACTER];
|
||||||
rkForest.SetLight(
|
rkForest.SetLight(
|
||||||
(const float *)&c_rkLight.Direction,
|
(const float *)&c_rkLight.Direction,
|
||||||
(const float *)&c_rkLight.Ambient,
|
(const float *)&c_rkLight.Ambient,
|
||||||
@ -1068,8 +1068,8 @@ void CMapOutdoor::SaveAlphaFogOperation()
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
|
|
||||||
STATEMANAGER.SetTransform(D3DTS_TEXTURE1, &m_matAlphaFogTexture);
|
STATEMANAGER.SetTransform(D3DTS_TEXTURE1, &m_matAlphaFogTexture);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
@ -1350,7 +1350,7 @@ void CMapOutdoor::XMasTree_Destroy()
|
|||||||
{
|
{
|
||||||
if (m_kXMas.m_pkTree)
|
if (m_kXMas.m_pkTree)
|
||||||
{
|
{
|
||||||
CSpeedTreeForestDirectX8& rkForest=CSpeedTreeForestDirectX8::Instance();
|
CSpeedTreeForest& rkForest = CSpeedTreeForest::Instance();
|
||||||
m_kXMas.m_pkTree->Clear();
|
m_kXMas.m_pkTree->Clear();
|
||||||
rkForest.DeleteInstance(m_kXMas.m_pkTree);
|
rkForest.DeleteInstance(m_kXMas.m_pkTree);
|
||||||
m_kXMas.m_pkTree=NULL;
|
m_kXMas.m_pkTree=NULL;
|
||||||
@ -1368,7 +1368,7 @@ void CMapOutdoor::__XMasTree_Create(float x, float y, float z, const char* c_szT
|
|||||||
assert(NULL==m_kXMas.m_pkTree);
|
assert(NULL==m_kXMas.m_pkTree);
|
||||||
assert(-1==m_kXMas.m_iEffectID);
|
assert(-1==m_kXMas.m_iEffectID);
|
||||||
|
|
||||||
CSpeedTreeForestDirectX8& rkForest=CSpeedTreeForestDirectX8::Instance();
|
CSpeedTreeForest& rkForest = CSpeedTreeForest::Instance();
|
||||||
DWORD dwCRC32 = GetCaseCRC32(c_szTreeName, strlen(c_szTreeName));
|
DWORD dwCRC32 = GetCaseCRC32(c_szTreeName, strlen(c_szTreeName));
|
||||||
m_kXMas.m_pkTree=rkForest.CreateInstance(x, y, z, dwCRC32, c_szTreeName);
|
m_kXMas.m_pkTree=rkForest.CreateInstance(x, y, z, dwCRC32, c_szTreeName);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "../PRTerrainLib/TerrainType.h"
|
#include "../PRTerrainLib/TerrainType.h"
|
||||||
#include "../PRTerrainLib/TextureSet.h"
|
#include "../PRTerrainLib/TextureSet.h"
|
||||||
|
|
||||||
#include "../SpeedTreeLib/SpeedTreeForestDirectX8.h"
|
#include "../SpeedTreeLib/CSpeedTreeDirectX.h"
|
||||||
|
|
||||||
#include "MapBase.h"
|
#include "MapBase.h"
|
||||||
#include "Area.h"
|
#include "Area.h"
|
||||||
@ -100,7 +100,7 @@ class CMapOutdoor : public CMapBase
|
|||||||
|
|
||||||
bool LoadSetting(const char * c_szFileName);
|
bool LoadSetting(const char * c_szFileName);
|
||||||
|
|
||||||
void ApplyLight(DWORD dwVersion, const D3DLIGHT8& c_rkLight);
|
void ApplyLight(DWORD dwVersion, const D3DLIGHT9& c_rkLight);
|
||||||
void SetEnvironmentScreenFilter();
|
void SetEnvironmentScreenFilter();
|
||||||
void SetEnvironmentSkyBox();
|
void SetEnvironmentSkyBox();
|
||||||
void SetEnvironmentLensFlare();
|
void SetEnvironmentLensFlare();
|
||||||
@ -431,16 +431,16 @@ class CMapOutdoor : public CMapBase
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Character Shadow
|
// Character Shadow
|
||||||
LPDIRECT3DTEXTURE8 m_lpCharacterShadowMapTexture;
|
LPDIRECT3DTEXTURE9 m_lpCharacterShadowMapTexture;
|
||||||
LPDIRECT3DSURFACE8 m_lpCharacterShadowMapRenderTargetSurface;
|
LPDIRECT3DSURFACE9 m_lpCharacterShadowMapRenderTargetSurface;
|
||||||
LPDIRECT3DSURFACE8 m_lpCharacterShadowMapDepthSurface;
|
LPDIRECT3DSURFACE9 m_lpCharacterShadowMapDepthSurface;
|
||||||
D3DVIEWPORT8 m_ShadowMapViewport;
|
D3DVIEWPORT9 m_ShadowMapViewport;
|
||||||
WORD m_wShadowMapSize;
|
WORD m_wShadowMapSize;
|
||||||
|
|
||||||
// Backup Device Context
|
// Backup Device Context
|
||||||
LPDIRECT3DSURFACE8 m_lpBackupRenderTargetSurface;
|
LPDIRECT3DSURFACE9 m_lpBackupRenderTargetSurface;
|
||||||
LPDIRECT3DSURFACE8 m_lpBackupDepthSurface;
|
LPDIRECT3DSURFACE9 m_lpBackupDepthSurface;
|
||||||
D3DVIEWPORT8 m_BackupViewport;
|
D3DVIEWPORT9 m_BackupViewport;
|
||||||
|
|
||||||
// Character Shadow
|
// Character Shadow
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -593,8 +593,8 @@ class CMapOutdoor : public CMapBase
|
|||||||
NONE_VB_NUM = 8,
|
NONE_VB_NUM = 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
IDirect3DVertexBuffer8* m_pkVBSplat[SPLAT_VB_NUM];
|
IDirect3DVertexBuffer9* m_pkVBSplat[SPLAT_VB_NUM];
|
||||||
IDirect3DVertexBuffer8* m_pkVBNone[NONE_VB_NUM];
|
IDirect3DVertexBuffer9* m_pkVBNone[NONE_VB_NUM];
|
||||||
DWORD m_dwSplatPos;
|
DWORD m_dwSplatPos;
|
||||||
DWORD m_dwNonePos;
|
DWORD m_dwNonePos;
|
||||||
DWORD m_dwLightVersion;
|
DWORD m_dwLightVersion;
|
||||||
@ -604,8 +604,8 @@ class CMapOutdoor : public CMapBase
|
|||||||
D3DXMATRIX m_m4Proj;
|
D3DXMATRIX m_m4Proj;
|
||||||
D3DXMATRIX m_m4Frustum;
|
D3DXMATRIX m_m4Frustum;
|
||||||
D3DXMATRIX m_m4DynamicShadow;
|
D3DXMATRIX m_m4DynamicShadow;
|
||||||
D3DLIGHT8 m_kLight;
|
D3DLIGHT9 m_kLight;
|
||||||
D3DMATERIAL8 m_kMtrl;
|
D3DMATERIAL9 m_kMtrl;
|
||||||
D3DXVECTOR3 m_v3Player;
|
D3DXVECTOR3 m_v3Player;
|
||||||
DWORD m_dwFogColor;
|
DWORD m_dwFogColor;
|
||||||
float m_fScreenHalfWidth;
|
float m_fScreenHalfWidth;
|
||||||
|
@ -36,7 +36,7 @@ void CMapOutdoor::CreateCharacterShadowTexture()
|
|||||||
m_ShadowMapViewport.MinZ = 0.0f;
|
m_ShadowMapViewport.MinZ = 0.0f;
|
||||||
m_ShadowMapViewport.MaxZ = 1.0f;
|
m_ShadowMapViewport.MaxZ = 1.0f;
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateTexture(m_wShadowMapSize, m_wShadowMapSize, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &m_lpCharacterShadowMapTexture)))
|
if (FAILED(ms_lpd3dDevice->CreateTexture(m_wShadowMapSize, m_wShadowMapSize, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &m_lpCharacterShadowMapTexture, NULL)))
|
||||||
{
|
{
|
||||||
TraceError("CMapOutdoor Unable to create Character Shadow render target texture\n");
|
TraceError("CMapOutdoor Unable to create Character Shadow render target texture\n");
|
||||||
return;
|
return;
|
||||||
@ -48,7 +48,13 @@ void CMapOutdoor::CreateCharacterShadowTexture()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_wShadowMapSize, m_wShadowMapSize, D3DFMT_D16, D3DMULTISAMPLE_NONE, &m_lpCharacterShadowMapDepthSurface)))
|
IDirect3DSurface9* pBackBufferSurface;
|
||||||
|
ms_lpd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBufferSurface);
|
||||||
|
D3DSURFACE_DESC kDesc;
|
||||||
|
pBackBufferSurface->GetDesc(&kDesc);
|
||||||
|
pBackBufferSurface->Release();
|
||||||
|
|
||||||
|
if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_wShadowMapSize, m_wShadowMapSize, D3DFMT_D16, kDesc.MultiSampleType, kDesc.MultiSampleQuality, FALSE, &m_lpCharacterShadowMapDepthSurface, NULL)))
|
||||||
{
|
{
|
||||||
TraceError("CMapOutdoor Unable to create Character Shadow depth Surface\n");
|
TraceError("CMapOutdoor Unable to create Character Shadow depth Surface\n");
|
||||||
return;
|
return;
|
||||||
@ -107,7 +113,7 @@ bool CMapOutdoor::BeginRenderCharacterShadowToTexture()
|
|||||||
bool bSuccess = true;
|
bool bSuccess = true;
|
||||||
|
|
||||||
// Backup Device Context
|
// Backup Device Context
|
||||||
if (FAILED(ms_lpd3dDevice->GetRenderTarget(&m_lpBackupRenderTargetSurface)))
|
if (FAILED(ms_lpd3dDevice->GetRenderTarget(0, &m_lpBackupRenderTargetSurface)))
|
||||||
{
|
{
|
||||||
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Save Window Render Target\n");
|
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Save Window Render Target\n");
|
||||||
bSuccess = false;
|
bSuccess = false;
|
||||||
@ -119,11 +125,17 @@ bool CMapOutdoor::BeginRenderCharacterShadowToTexture()
|
|||||||
bSuccess = false;
|
bSuccess = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->SetRenderTarget(m_lpCharacterShadowMapRenderTargetSurface, m_lpCharacterShadowMapDepthSurface)))
|
if (FAILED(ms_lpd3dDevice->SetRenderTarget(0, m_lpCharacterShadowMapRenderTargetSurface)))
|
||||||
{
|
{
|
||||||
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Set Shadow Map Render Target\n");
|
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Set Shadow Map Render Target\n");
|
||||||
bSuccess = false;
|
bSuccess = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FAILED(ms_lpd3dDevice->SetDepthStencilSurface(m_lpCharacterShadowMapDepthSurface)))
|
||||||
|
{
|
||||||
|
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Set Shadow Map Depth Surface\n");
|
||||||
|
bSuccess = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0xFF, 0xFF, 0xFF), 1.0f, 0)))
|
if (FAILED(ms_lpd3dDevice->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0xFF, 0xFF, 0xFF), 1.0f, 0)))
|
||||||
{
|
{
|
||||||
@ -150,7 +162,8 @@ void CMapOutdoor::EndRenderCharacterShadowToTexture()
|
|||||||
{
|
{
|
||||||
ms_lpd3dDevice->SetViewport(&m_BackupViewport);
|
ms_lpd3dDevice->SetViewport(&m_BackupViewport);
|
||||||
|
|
||||||
ms_lpd3dDevice->SetRenderTarget(m_lpBackupRenderTargetSurface, m_lpBackupDepthSurface);
|
ms_lpd3dDevice->SetRenderTarget(0, m_lpBackupRenderTargetSurface);
|
||||||
|
ms_lpd3dDevice->SetDepthStencilSurface(m_lpBackupDepthSurface);
|
||||||
|
|
||||||
SAFE_RELEASE(m_lpBackupRenderTargetSurface);
|
SAFE_RELEASE(m_lpBackupRenderTargetSurface);
|
||||||
SAFE_RELEASE(m_lpBackupDepthSurface);
|
SAFE_RELEASE(m_lpBackupDepthSurface);
|
||||||
|
@ -37,7 +37,7 @@ bool CMapOutdoor::Load(float x, float y, float z)
|
|||||||
m_lOldReadX = -1;
|
m_lOldReadX = -1;
|
||||||
|
|
||||||
// TODO: SetRenderingDevice에서 Environment로 부터 라이트 속성을 넘겨줘야 스태틱 라이트가 제대로 작동한다.
|
// TODO: SetRenderingDevice에서 Environment로 부터 라이트 속성을 넘겨줘야 스태틱 라이트가 제대로 작동한다.
|
||||||
CSpeedTreeForestDirectX8::Instance().SetRenderingDevice(ms_lpd3dDevice);
|
CSpeedTreeDirectX::Instance().SetRenderingDevice();
|
||||||
|
|
||||||
Update(x, y, z);
|
Update(x, y, z);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ void CMapOutdoor::__RenderTerrain_AppendPatch(const D3DXVECTOR3& c_rv3Center, fl
|
|||||||
m_PatchVector.push_back(std::make_pair(fDistance, lPatchNum));
|
m_PatchVector.push_back(std::make_pair(fDistance, lPatchNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapOutdoor::ApplyLight(DWORD dwVersion, const D3DLIGHT8& c_rkLight)
|
void CMapOutdoor::ApplyLight(DWORD dwVersion, const D3DLIGHT9& c_rkLight)
|
||||||
{
|
{
|
||||||
m_kSTPD.m_dwLightVersion=dwVersion;
|
m_kSTPD.m_dwLightVersion=dwVersion;
|
||||||
STATEMANAGER.SetLight(0, &c_rkLight);
|
STATEMANAGER.SetLight(0, &c_rkLight);
|
||||||
@ -236,7 +236,7 @@ void CMapOutdoor::RenderCloud()
|
|||||||
void CMapOutdoor::RenderTree()
|
void CMapOutdoor::RenderTree()
|
||||||
{
|
{
|
||||||
if (IsVisiblePart(PART_TREE))
|
if (IsVisiblePart(PART_TREE))
|
||||||
CSpeedTreeForestDirectX8::Instance().Render();
|
CSpeedTreeForest::Instance().Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapOutdoor::SetInverseViewAndDynamicShaodwMatrices()
|
void CMapOutdoor::SetInverseViewAndDynamicShaodwMatrices()
|
||||||
@ -422,17 +422,17 @@ void CMapOutdoor::RenderArea(bool bRenderAmbience)
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_BORDER);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_BORDER);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_BORDERCOLOR, 0xFFFFFFFF);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_BORDERCOLOR, 0xFFFFFFFF);
|
||||||
|
|
||||||
std::for_each(m_ShadowReceiverVector.begin(), m_ShadowReceiverVector.end(), FAreaRenderShadow());
|
std::for_each(m_ShadowReceiverVector.begin(), m_ShadowReceiverVector.end(), FAreaRenderShadow());
|
||||||
|
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXCOORDINDEX);
|
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXCOORDINDEX);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS);
|
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSU);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_ADDRESSU);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSV);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_ADDRESSV);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_BORDERCOLOR);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_BORDERCOLOR);
|
||||||
|
|
||||||
STATEMANAGER.RestoreTransform(D3DTS_TEXTURE1);
|
STATEMANAGER.RestoreTransform(D3DTS_TEXTURE1);
|
||||||
|
|
||||||
@ -630,8 +630,8 @@ void CMapOutdoor::RenderPCBlocker()
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
|
|
||||||
STATEMANAGER.SaveTransform(D3DTS_TEXTURE1, &m_matBuildingTransparent);
|
STATEMANAGER.SaveTransform(D3DTS_TEXTURE1, &m_matBuildingTransparent);
|
||||||
STATEMANAGER.SetTexture(1, m_BuildingTransparentImageInstance.GetTexturePointer()->GetD3DTexture());
|
STATEMANAGER.SetTexture(1, m_BuildingTransparentImageInstance.GetTexturePointer()->GetD3DTexture());
|
||||||
@ -647,8 +647,8 @@ void CMapOutdoor::RenderPCBlocker()
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSU);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_ADDRESSU);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSV);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_ADDRESSV);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -858,11 +858,11 @@ void CMapOutdoor::RenderMarkedArea()
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
|
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_MINFILTER, D3DTEXF_POINT);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_POINT);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_MIPFILTER, D3DTEXF_POINT);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
|
|
||||||
STATEMANAGER.SetTexture(0, m_attrImageInstance.GetTexturePointer()->GetD3DTexture());
|
STATEMANAGER.SetTexture(0, m_attrImageInstance.GetTexturePointer()->GetD3DTexture());
|
||||||
|
|
||||||
@ -872,11 +872,11 @@ void CMapOutdoor::RenderMarkedArea()
|
|||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXCOORDINDEX);
|
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXCOORDINDEX);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS);
|
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_MINFILTER);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_MINFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_MAGFILTER);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_MAGFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_MIPFILTER);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_MIPFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSU);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_ADDRESSU);
|
||||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSV);
|
STATEMANAGER.RestoreSamplerState(1, D3DSAMP_ADDRESSV);
|
||||||
|
|
||||||
STATEMANAGER.RestoreTransform(D3DTS_TEXTURE0);
|
STATEMANAGER.RestoreTransform(D3DTS_TEXTURE0);
|
||||||
STATEMANAGER.RestoreTransform(D3DTS_TEXTURE1);
|
STATEMANAGER.RestoreTransform(D3DTS_TEXTURE1);
|
||||||
@ -949,7 +949,7 @@ void CMapOutdoor::DrawPatchAttr(long patchnum)
|
|||||||
TTerrainSplatPatch & rAttrSplatPatch = pTerrain->GetMarkedSplatPatch();
|
TTerrainSplatPatch & rAttrSplatPatch = pTerrain->GetMarkedSplatPatch();
|
||||||
STATEMANAGER.SetTexture(1, rAttrSplatPatch.Splats[0].pd3dTexture);
|
STATEMANAGER.SetTexture(1, rAttrSplatPatch.Splats[0].pd3dTexture);
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL);
|
||||||
STATEMANAGER.SetStreamSource(0, pTerrainPatchProxy->HardwareTransformPatch_GetVertexBufferPtr()->GetD3DVertexBuffer(), m_iPatchTerrainVertexSize);
|
STATEMANAGER.SetStreamSource(0, pTerrainPatchProxy->HardwareTransformPatch_GetVertexBufferPtr()->GetD3DVertexBuffer(), m_iPatchTerrainVertexSize);
|
||||||
|
|
||||||
#ifdef WORLD_EDITOR
|
#ifdef WORLD_EDITOR
|
||||||
|
@ -41,39 +41,38 @@ void CMapOutdoor::__RenderTerrain_RenderHardwareTransformPatch()
|
|||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
|
||||||
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
|
|
||||||
#ifdef WORLD_EDITOR
|
#ifdef WORLD_EDITOR
|
||||||
if (GetAsyncKeyState(VK_CAPITAL))
|
if (GetAsyncKeyState(VK_CAPITAL))
|
||||||
{
|
{
|
||||||
CSpeedTreeWrapper::ms_bSelfShadowOn = false;
|
CSpeedTreeWrapper::ms_bSelfShadowOn = false;
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_GAUSSIANCUBIC);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_GAUSSIANQUAD);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_GAUSSIANCUBIC);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_GAUSSIANQUAD);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_GAUSSIANCUBIC);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_GAUSSIANQUAD);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_MINFILTER, D3DTEXF_GAUSSIANCUBIC);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_GAUSSIANQUAD);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_GAUSSIANCUBIC);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_GAUSSIANQUAD);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_MIPFILTER, D3DTEXF_GAUSSIANCUBIC);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_GAUSSIANQUAD);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CSpeedTreeWrapper::ms_bSelfShadowOn = true;
|
CSpeedTreeWrapper::ms_bSelfShadowOn = true;
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
CSpeedTreeWrapper::ms_bSelfShadowOn = true;
|
|
||||||
STATEMANAGER.SetBestFiltering(0);
|
STATEMANAGER.SetBestFiltering(0);
|
||||||
STATEMANAGER.SetBestFiltering(1);
|
STATEMANAGER.SetBestFiltering(1);
|
||||||
#endif
|
#endif
|
||||||
@ -88,7 +87,7 @@ void CMapOutdoor::__RenderTerrain_RenderHardwareTransformPatch()
|
|||||||
// Render State & TextureStageState
|
// Render State & TextureStageState
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_NORMAL);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL);
|
||||||
|
|
||||||
m_iRenderedSplatNumSqSum = 0;
|
m_iRenderedSplatNumSqSum = 0;
|
||||||
m_iRenderedPatchNum = 0;
|
m_iRenderedPatchNum = 0;
|
||||||
@ -624,8 +623,8 @@ void CMapOutdoor::__HardwareTransformPatch_RenderPatchSplat(long patchnum, WORD
|
|||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
|
|
||||||
if (m_bDrawChrShadow)
|
if (m_bDrawChrShadow)
|
||||||
{
|
{
|
||||||
@ -636,8 +635,8 @@ void CMapOutdoor::__HardwareTransformPatch_RenderPatchSplat(long patchnum, WORD
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -661,8 +660,8 @@ void CMapOutdoor::__HardwareTransformPatch_RenderPatchSplat(long patchnum, WORD
|
|||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
|
||||||
|
|
||||||
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||||
|
@ -43,7 +43,7 @@ void CMapOutdoor::__RenderTerrain_RenderSoftwareTransformPatch()
|
|||||||
|
|
||||||
SelectIndexBuffer(0, &wPrimitiveCount, &ePrimitiveType);
|
SelectIndexBuffer(0, &wPrimitiveCount, &ePrimitiveType);
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_SPECULAR|D3DFVF_TEX2);
|
STATEMANAGER.SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2);
|
||||||
|
|
||||||
std::vector<std::pair<float, long> >::iterator it = m_PatchVector.begin();
|
std::vector<std::pair<float, long> >::iterator it = m_PatchVector.begin();
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ void CMapOutdoor::__RenderTerrain_RenderSoftwareTransformPatch()
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZRHW);
|
STATEMANAGER.SetFVF(D3DFVF_XYZRHW);
|
||||||
|
|
||||||
if (IsFastTNL())
|
if (IsFastTNL())
|
||||||
{
|
{
|
||||||
@ -315,16 +315,15 @@ void CMapOutdoor::__SoftwareTransformPatch_RenderPatchNone(SoftwareTransformPatc
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IDirect3DVertexBuffer8* pkVB=m_kSTPD.m_pkVBNone[m_kSTPD.m_dwNonePos++];
|
IDirect3DVertexBuffer9* pkVB = m_kSTPD.m_pkVBNone[m_kSTPD.m_dwNonePos++];
|
||||||
m_kSTPD.m_dwNonePos%=SoftwareTransformPatch_SData::NONE_VB_NUM;
|
m_kSTPD.m_dwNonePos%=SoftwareTransformPatch_SData::NONE_VB_NUM;
|
||||||
if (!pkVB)
|
if (!pkVB)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DWORD dwVBSize=sizeof(SoftwareTransformPatch_STVertex)*CTerrainPatch::TERRAIN_VERTEX_COUNT;
|
DWORD dwVBSize=sizeof(SoftwareTransformPatch_STVertex)*CTerrainPatch::TERRAIN_VERTEX_COUNT;
|
||||||
SoftwareTransformPatch_STVertex* akDstVertex;
|
SoftwareTransformPatch_STVertex* akDstVertex;
|
||||||
if (FAILED(
|
if (FAILED(pkVB->Lock(0, dwVBSize, (VOID**)&akDstVertex, D3DLOCK_DISCARD)))
|
||||||
pkVB->Lock(0, dwVBSize, (BYTE**)&akDstVertex, D3DLOCK_DISCARD)
|
return;
|
||||||
)) return;
|
|
||||||
|
|
||||||
memcpy(akDstVertex, akTransVertex, dwVBSize);
|
memcpy(akDstVertex, akTransVertex, dwVBSize);
|
||||||
|
|
||||||
@ -345,8 +344,8 @@ void CMapOutdoor::__SoftwareTransformPatch_ApplyStaticShadowRenderState()
|
|||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,8 +358,8 @@ void CMapOutdoor::__SoftwareTransformPatch_ApplyDynamicShadowRenderState()
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapOutdoor::__SoftwareTransformPatch_ApplyFogShadowRenderState()
|
void CMapOutdoor::__SoftwareTransformPatch_ApplyFogShadowRenderState()
|
||||||
@ -377,9 +376,9 @@ void CMapOutdoor::__SoftwareTransformPatch_RestoreStaticShadowRenderState()
|
|||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
|
||||||
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||||
STATEMANAGER.SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
STATEMANAGER.SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||||
}
|
}
|
||||||
@ -394,8 +393,8 @@ void CMapOutdoor::__SoftwareTransformPatch_RestoreDynamicShadowRenderState()
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -421,8 +420,6 @@ void CMapOutdoor::__SoftwareTransformPatch_ApplyRenderState()
|
|||||||
if (!IsTLVertexClipping())
|
if (!IsTLVertexClipping())
|
||||||
isSoftwareVertexClipping=TRUE;
|
isSoftwareVertexClipping=TRUE;
|
||||||
|
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, isSoftwareVertexClipping);
|
|
||||||
|
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, TRUE);
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, TRUE);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHAREF, 0x00000000);
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHAREF, 0x00000000);
|
||||||
@ -437,8 +434,8 @@ void CMapOutdoor::__SoftwareTransformPatch_ApplyRenderState()
|
|||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
|
||||||
STATEMANAGER.SetBestFiltering(0);
|
STATEMANAGER.SetBestFiltering(0);
|
||||||
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||||
@ -447,8 +444,8 @@ void CMapOutdoor::__SoftwareTransformPatch_ApplyRenderState()
|
|||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SetBestFiltering(1);
|
STATEMANAGER.SetBestFiltering(1);
|
||||||
|
|
||||||
CSpeedTreeWrapper::ms_bSelfShadowOn = true;
|
CSpeedTreeWrapper::ms_bSelfShadowOn = true;
|
||||||
@ -491,8 +488,6 @@ void CMapOutdoor::__SoftwareTransformPatch_RestoreRenderState(DWORD dwFogEnable)
|
|||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHATESTENABLE);
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHATESTENABLE);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHAREF);
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHAREF);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHAFUNC);
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHAFUNC);
|
||||||
|
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_SOFTWAREVERTEXPROCESSING);
|
|
||||||
|
|
||||||
// Render State & TextureStageState
|
// Render State & TextureStageState
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -677,16 +672,15 @@ bool CMapOutdoor::__SoftwareTransformPatch_SetTransform(SoftwareTransformPatch_S
|
|||||||
|
|
||||||
bool CMapOutdoor::__SoftwareTransformPatch_SetSplatStream(SoftwareTransformPatch_STLVertex* akSrcVertex)
|
bool CMapOutdoor::__SoftwareTransformPatch_SetSplatStream(SoftwareTransformPatch_STLVertex* akSrcVertex)
|
||||||
{
|
{
|
||||||
IDirect3DVertexBuffer8* pkVB=m_kSTPD.m_pkVBSplat[m_kSTPD.m_dwSplatPos++];
|
IDirect3DVertexBuffer9* pkVB = m_kSTPD.m_pkVBSplat[m_kSTPD.m_dwSplatPos++];
|
||||||
m_kSTPD.m_dwSplatPos%=SoftwareTransformPatch_SData::SPLAT_VB_NUM;
|
m_kSTPD.m_dwSplatPos%=SoftwareTransformPatch_SData::SPLAT_VB_NUM;
|
||||||
if (!pkVB)
|
if (!pkVB)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DWORD dwVBSize=sizeof(SoftwareTransformPatch_SSplatVertex)*CTerrainPatch::TERRAIN_VERTEX_COUNT;
|
DWORD dwVBSize=sizeof(SoftwareTransformPatch_SSplatVertex)*CTerrainPatch::TERRAIN_VERTEX_COUNT;
|
||||||
SoftwareTransformPatch_SSplatVertex* akDstVertex;
|
SoftwareTransformPatch_SSplatVertex* akDstVertex;
|
||||||
if (FAILED(
|
if (FAILED(pkVB->Lock(0, dwVBSize, (VOID**)&akDstVertex, 0)))
|
||||||
pkVB->Lock(0, dwVBSize, (BYTE**)&akDstVertex, 0)//D3DLOCK_DISCARD)
|
return false;
|
||||||
)) return false;
|
|
||||||
|
|
||||||
for (UINT uIndex=0; uIndex!=CTerrainPatch::TERRAIN_VERTEX_COUNT; ++uIndex)
|
for (UINT uIndex=0; uIndex!=CTerrainPatch::TERRAIN_VERTEX_COUNT; ++uIndex)
|
||||||
*(akDstVertex+uIndex)=*((SoftwareTransformPatch_SSplatVertex*)(akSrcVertex+uIndex));
|
*(akDstVertex+uIndex)=*((SoftwareTransformPatch_SSplatVertex*)(akSrcVertex+uIndex));
|
||||||
@ -699,16 +693,15 @@ bool CMapOutdoor::__SoftwareTransformPatch_SetSplatStream(SoftwareTransformPatch
|
|||||||
|
|
||||||
bool CMapOutdoor::__SoftwareTransformPatch_SetShadowStream(SoftwareTransformPatch_STLVertex* akSrcVertex)
|
bool CMapOutdoor::__SoftwareTransformPatch_SetShadowStream(SoftwareTransformPatch_STLVertex* akSrcVertex)
|
||||||
{
|
{
|
||||||
IDirect3DVertexBuffer8* pkVB=m_kSTPD.m_pkVBSplat[m_kSTPD.m_dwSplatPos++];
|
IDirect3DVertexBuffer9* pkVB = m_kSTPD.m_pkVBSplat[m_kSTPD.m_dwSplatPos++];
|
||||||
m_kSTPD.m_dwSplatPos%=SoftwareTransformPatch_SData::SPLAT_VB_NUM;
|
m_kSTPD.m_dwSplatPos%=SoftwareTransformPatch_SData::SPLAT_VB_NUM;
|
||||||
if (!pkVB)
|
if (!pkVB)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DWORD dwVBSize=sizeof(SoftwareTransformPatch_SSplatVertex)*CTerrainPatch::TERRAIN_VERTEX_COUNT;
|
DWORD dwVBSize=sizeof(SoftwareTransformPatch_SSplatVertex)*CTerrainPatch::TERRAIN_VERTEX_COUNT;
|
||||||
SoftwareTransformPatch_SSplatVertex* akDstVertex;
|
SoftwareTransformPatch_SSplatVertex* akDstVertex;
|
||||||
if (FAILED(
|
if (FAILED(pkVB->Lock(0, dwVBSize, (VOID**)&akDstVertex, 0)))
|
||||||
pkVB->Lock(0, dwVBSize, (BYTE**)&akDstVertex, 0)//D3DLOCK_DISCARD)
|
return false;
|
||||||
)) return false;
|
|
||||||
|
|
||||||
SoftwareTransformPatch_STLVertex* pkSrcVertex;
|
SoftwareTransformPatch_STLVertex* pkSrcVertex;
|
||||||
SoftwareTransformPatch_SSplatVertex* pkDstVertex;
|
SoftwareTransformPatch_SSplatVertex* pkDstVertex;
|
||||||
@ -725,7 +718,7 @@ bool CMapOutdoor::__SoftwareTransformPatch_SetShadowStream(SoftwareTransformPatc
|
|||||||
pkVB->Unlock();
|
pkVB->Unlock();
|
||||||
|
|
||||||
|
|
||||||
ms_lpd3dDevice->SetStreamSource(0, pkVB, sizeof(SoftwareTransformPatch_SSplatVertex));
|
ms_lpd3dDevice->SetStreamSource(0, pkVB, 0, sizeof(SoftwareTransformPatch_SSplatVertex));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -753,13 +746,15 @@ bool CMapOutdoor::__SoftwareTransformPatch_Create()
|
|||||||
assert(NULL==m_kSTPD.m_pkVBSplat[uIndex]);
|
assert(NULL==m_kSTPD.m_pkVBSplat[uIndex]);
|
||||||
if (FAILED(
|
if (FAILED(
|
||||||
ms_lpd3dDevice->CreateVertexBuffer(
|
ms_lpd3dDevice->CreateVertexBuffer(
|
||||||
sizeof(SoftwareTransformPatch_SSplatVertex)*CTerrainPatch::TERRAIN_VERTEX_COUNT,
|
sizeof(SoftwareTransformPatch_SSplatVertex) * CTerrainPatch::TERRAIN_VERTEX_COUNT,
|
||||||
D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,
|
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
|
||||||
D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_SPECULAR|D3DFVF_TEX2,
|
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2,
|
||||||
D3DPOOL_SYSTEMMEM,
|
D3DPOOL_SYSTEMMEM,
|
||||||
&m_kSTPD.m_pkVBSplat[uIndex]
|
&m_kSTPD.m_pkVBSplat[uIndex],
|
||||||
|
NULL
|
||||||
)
|
)
|
||||||
)) return false;
|
))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,13 +764,15 @@ bool CMapOutdoor::__SoftwareTransformPatch_Create()
|
|||||||
assert(NULL==m_kSTPD.m_pkVBNone[uIndex]);
|
assert(NULL==m_kSTPD.m_pkVBNone[uIndex]);
|
||||||
if (FAILED(
|
if (FAILED(
|
||||||
ms_lpd3dDevice->CreateVertexBuffer(
|
ms_lpd3dDevice->CreateVertexBuffer(
|
||||||
sizeof(SoftwareTransformPatch_STVertex)*CTerrainPatch::TERRAIN_VERTEX_COUNT,
|
sizeof(SoftwareTransformPatch_STVertex) * CTerrainPatch::TERRAIN_VERTEX_COUNT,
|
||||||
D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,
|
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
|
||||||
D3DFVF_XYZRHW,
|
D3DFVF_XYZRHW,
|
||||||
D3DPOOL_SYSTEMMEM,
|
D3DPOOL_SYSTEMMEM,
|
||||||
&m_kSTPD.m_pkVBNone[uIndex]
|
&m_kSTPD.m_pkVBNone[uIndex],
|
||||||
|
NULL
|
||||||
)
|
)
|
||||||
)) return false;
|
))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -112,7 +112,7 @@ bool CMapOutdoor::Update(float fX, float fY, float fZ)
|
|||||||
#ifdef __PERFORMANCE_CHECKER__
|
#ifdef __PERFORMANCE_CHECKER__
|
||||||
DWORD t3=ELTimer_GetMSec();
|
DWORD t3=ELTimer_GetMSec();
|
||||||
#endif
|
#endif
|
||||||
CSpeedTreeForestDirectX8::Instance().UpdateSystem(CTimer::Instance().GetCurrentSecond());
|
CSpeedTreeForest::Instance().UpdateSystem(CTimer::Instance().GetCurrentSecond());
|
||||||
#ifdef __PERFORMANCE_CHECKER__
|
#ifdef __PERFORMANCE_CHECKER__
|
||||||
DWORD t4=ELTimer_GetMSec();
|
DWORD t4=ELTimer_GetMSec();
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,15 +46,15 @@ void CMapOutdoor::RenderWater()
|
|||||||
D3DXMatrixMultiply(&matTexTransformWater, &m_matViewInverse, &matTexTransformWater);
|
D3DXMatrixMultiply(&matTexTransformWater, &m_matViewInverse, &matTexTransformWater);
|
||||||
|
|
||||||
STATEMANAGER.SaveTransform(D3DTS_TEXTURE0, &matTexTransformWater);
|
STATEMANAGER.SaveTransform(D3DTS_TEXTURE0, &matTexTransformWater);
|
||||||
STATEMANAGER.SaveVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE);
|
STATEMANAGER.SaveFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE);
|
||||||
|
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
|
||||||
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||||
@ -121,13 +121,13 @@ void CMapOutdoor::RenderWater()
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// RenderState
|
// RenderState
|
||||||
STATEMANAGER.RestoreVertexShader();
|
STATEMANAGER.RestoreFVF();
|
||||||
STATEMANAGER.RestoreTransform(D3DTS_TEXTURE0);
|
STATEMANAGER.RestoreTransform(D3DTS_TEXTURE0);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MINFILTER);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MINFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MAGFILTER);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MAGFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MIPFILTER);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_MIPFILTER);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ADDRESSU);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_ADDRESSU);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ADDRESSV);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_ADDRESSV);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_TEXCOORDINDEX);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_TEXCOORDINDEX);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS);
|
||||||
|
|
||||||
|
@ -127,10 +127,10 @@ typedef struct SEnvironmentData
|
|||||||
{
|
{
|
||||||
// Light
|
// Light
|
||||||
BOOL bDirLightsEnable[ENV_DIRLIGHT_NUM];
|
BOOL bDirLightsEnable[ENV_DIRLIGHT_NUM];
|
||||||
D3DLIGHT8 DirLights[ENV_DIRLIGHT_NUM];
|
D3DLIGHT9 DirLights[ENV_DIRLIGHT_NUM];
|
||||||
|
|
||||||
// Material
|
// Material
|
||||||
D3DMATERIAL8 Material;
|
D3DMATERIAL9 Material;
|
||||||
|
|
||||||
// Fog
|
// Fog
|
||||||
BOOL bFogEnable;
|
BOOL bFogEnable;
|
||||||
|
@ -90,10 +90,11 @@ void CSnowEnvironment::__BeginBlur()
|
|||||||
if (!m_bBlurEnable)
|
if (!m_bBlurEnable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ms_lpd3dDevice->GetRenderTarget(&m_lpOldSurface);
|
ms_lpd3dDevice->GetRenderTarget(0, &m_lpOldSurface);
|
||||||
ms_lpd3dDevice->GetDepthStencilSurface(&m_lpOldDepthStencilSurface);
|
ms_lpd3dDevice->GetDepthStencilSurface(&m_lpOldDepthStencilSurface);
|
||||||
ms_lpd3dDevice->SetRenderTarget(m_lpSnowRenderTargetSurface, m_lpSnowDepthSurface);
|
ms_lpd3dDevice->SetRenderTarget(0, m_lpSnowRenderTargetSurface);
|
||||||
ms_lpd3dDevice->Clear(0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0L);
|
ms_lpd3dDevice->SetDepthStencilSurface(m_lpSnowDepthSurface);
|
||||||
|
ms_lpd3dDevice->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0L);
|
||||||
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||||
@ -145,7 +146,8 @@ void CSnowEnvironment::__ApplyBlur()
|
|||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
{
|
{
|
||||||
ms_lpd3dDevice->SetRenderTarget(m_lpOldSurface, m_lpOldDepthStencilSurface);
|
ms_lpd3dDevice->SetRenderTarget(0, m_lpOldSurface);
|
||||||
|
ms_lpd3dDevice->SetDepthStencilSurface(m_lpOldDepthStencilSurface);
|
||||||
|
|
||||||
STATEMANAGER.SetTexture(0,m_lpSnowTexture);
|
STATEMANAGER.SetTexture(0,m_lpSnowTexture);
|
||||||
STATEMANAGER.SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE);
|
STATEMANAGER.SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
@ -162,7 +164,7 @@ void CSnowEnvironment::__ApplyBlur()
|
|||||||
BlurVertex(D3DXVECTOR3(0.0f,sy,0.0f),1.0f ,0xFFFFFF, 0,1) ,
|
BlurVertex(D3DXVECTOR3(0.0f,sy,0.0f),1.0f ,0xFFFFFF, 0,1) ,
|
||||||
BlurVertex(D3DXVECTOR3(sx,sy,0.0f),1.0f ,0xFFFFFF, 1,1) };
|
BlurVertex(D3DXVECTOR3(sx,sy,0.0f),1.0f ,0xFFFFFF, 1,1) };
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShader( D3DFVF_XYZRHW | D3DFVF_DIFFUSE|D3DFVF_TEX1 );
|
STATEMANAGER.SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,V,sizeof(BlurVertex));
|
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,V,sizeof(BlurVertex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,7 +189,7 @@ void CSnowEnvironment::Render()
|
|||||||
const D3DXVECTOR3 & c_rv3Cross = pCamera->GetCross();
|
const D3DXVECTOR3 & c_rv3Cross = pCamera->GetCross();
|
||||||
|
|
||||||
SParticleVertex * pv3Verticies;
|
SParticleVertex * pv3Verticies;
|
||||||
if (SUCCEEDED(m_pVB->Lock(0, sizeof(SParticleVertex)*dwParticleCount*4, (BYTE **) &pv3Verticies, D3DLOCK_DISCARD)))
|
if (SUCCEEDED(m_pVB->Lock(0, sizeof(SParticleVertex) * dwParticleCount * 4, (void**)&pv3Verticies, D3DLOCK_DISCARD)))
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
std::vector<CSnowParticle*>::iterator itor = m_kVct_pkParticleSnow.begin();
|
std::vector<CSnowParticle*>::iterator itor = m_kVct_pkParticleSnow.begin();
|
||||||
@ -219,7 +221,7 @@ void CSnowEnvironment::Render()
|
|||||||
m_pImageInstance->GetGraphicImagePointer()->GetTextureReference().SetTextureStage(0);
|
m_pImageInstance->GetGraphicImagePointer()->GetTextureReference().SetTextureStage(0);
|
||||||
STATEMANAGER.SetIndices(m_pIB, 0);
|
STATEMANAGER.SetIndices(m_pIB, 0);
|
||||||
STATEMANAGER.SetStreamSource(0, m_pVB, sizeof(SParticleVertex));
|
STATEMANAGER.SetStreamSource(0, m_pVB, sizeof(SParticleVertex));
|
||||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1);
|
STATEMANAGER.SetFVF(D3DFVF_XYZ | D3DFVF_TEX1);
|
||||||
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, dwParticleCount*4, 0, dwParticleCount*2);
|
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, dwParticleCount*4, 0, dwParticleCount*2);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ZWRITEENABLE);
|
STATEMANAGER.RestoreRenderState(D3DRS_ZWRITEENABLE);
|
||||||
@ -233,18 +235,18 @@ bool CSnowEnvironment::__CreateBlurTexture()
|
|||||||
if (!m_bBlurEnable)
|
if (!m_bBlurEnable)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateTexture(m_wBlurTextureSize, m_wBlurTextureSize, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_lpSnowTexture)))
|
if (FAILED(ms_lpd3dDevice->CreateTexture(m_wBlurTextureSize, m_wBlurTextureSize, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_lpSnowTexture, NULL)))
|
||||||
return false;
|
return false;
|
||||||
if (FAILED(m_lpSnowTexture->GetSurfaceLevel(0, &m_lpSnowRenderTargetSurface)))
|
if (FAILED(m_lpSnowTexture->GetSurfaceLevel(0, &m_lpSnowRenderTargetSurface)))
|
||||||
return false;
|
return false;
|
||||||
if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_wBlurTextureSize, m_wBlurTextureSize, D3DFMT_D16, D3DMULTISAMPLE_NONE, &m_lpSnowDepthSurface)))
|
if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_wBlurTextureSize, m_wBlurTextureSize, D3DFMT_D16, D3DMULTISAMPLE_NONE, 0, FALSE, &m_lpSnowDepthSurface, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateTexture(m_wBlurTextureSize, m_wBlurTextureSize, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_lpAccumTexture)))
|
if (FAILED(ms_lpd3dDevice->CreateTexture(m_wBlurTextureSize, m_wBlurTextureSize, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_lpAccumTexture, NULL)))
|
||||||
return false;
|
return false;
|
||||||
if (FAILED(m_lpAccumTexture->GetSurfaceLevel(0, &m_lpAccumRenderTargetSurface)))
|
if (FAILED(m_lpAccumTexture->GetSurfaceLevel(0, &m_lpAccumRenderTargetSurface)))
|
||||||
return false;
|
return false;
|
||||||
if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_wBlurTextureSize, m_wBlurTextureSize, D3DFMT_D16, D3DMULTISAMPLE_NONE, &m_lpAccumDepthSurface)))
|
if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_wBlurTextureSize, m_wBlurTextureSize, D3DFMT_D16, D3DMULTISAMPLE_NONE, 0, FALSE, &m_lpAccumDepthSurface, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -252,22 +254,14 @@ bool CSnowEnvironment::__CreateBlurTexture()
|
|||||||
|
|
||||||
bool CSnowEnvironment::__CreateGeometry()
|
bool CSnowEnvironment::__CreateGeometry()
|
||||||
{
|
{
|
||||||
if (FAILED(ms_lpd3dDevice->CreateVertexBuffer(sizeof(SParticleVertex)*m_dwParticleMaxNum*4,
|
if (FAILED(ms_lpd3dDevice->CreateVertexBuffer(sizeof(SParticleVertex) * m_dwParticleMaxNum * 4, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_XYZ | D3DFVF_TEX1, D3DPOOL_SYSTEMMEM, &m_pVB, NULL)))
|
||||||
D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,
|
|
||||||
D3DFVF_XYZ | D3DFVF_TEX1,
|
|
||||||
D3DPOOL_SYSTEMMEM,
|
|
||||||
&m_pVB)))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (FAILED(ms_lpd3dDevice->CreateIndexBuffer(sizeof(WORD)*m_dwParticleMaxNum*6,
|
if (FAILED(ms_lpd3dDevice->CreateIndexBuffer(sizeof(WORD) * m_dwParticleMaxNum * 6, D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_pIB, NULL)))
|
||||||
D3DUSAGE_WRITEONLY,
|
|
||||||
D3DFMT_INDEX16,
|
|
||||||
D3DPOOL_MANAGED,
|
|
||||||
&m_pIB)))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
WORD* dstIndices;
|
WORD* dstIndices;
|
||||||
if (FAILED(m_pIB->Lock(0, sizeof(WORD)*m_dwParticleMaxNum*6, (BYTE**)&dstIndices, 0)))
|
if (FAILED(m_pIB->Lock(0, sizeof(WORD) * m_dwParticleMaxNum * 6, (VOID**)&dstIndices, 0)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const WORD c_awFillRectIndices[6] = { 0, 2, 1, 2, 3, 1, };
|
const WORD c_awFillRectIndices[6] = { 0, 2, 1, 2, 3, 1, };
|
||||||
@ -275,7 +269,7 @@ bool CSnowEnvironment::__CreateGeometry()
|
|||||||
{
|
{
|
||||||
for (int j = 0; j < 6; ++j)
|
for (int j = 0; j < 6; ++j)
|
||||||
{
|
{
|
||||||
dstIndices[i*6 + j] = i*4 + c_awFillRectIndices[j];
|
dstIndices[i * 6 + j] = i * 4 + c_awFillRectIndices[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,19 +28,19 @@ class CSnowEnvironment : public CScreen
|
|||||||
void __ApplyBlur();
|
void __ApplyBlur();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LPDIRECT3DSURFACE8 m_lpOldSurface;
|
LPDIRECT3DSURFACE9 m_lpOldSurface;
|
||||||
LPDIRECT3DSURFACE8 m_lpOldDepthStencilSurface;
|
LPDIRECT3DSURFACE9 m_lpOldDepthStencilSurface;
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 m_lpSnowTexture;
|
LPDIRECT3DTEXTURE9 m_lpSnowTexture;
|
||||||
LPDIRECT3DSURFACE8 m_lpSnowRenderTargetSurface;
|
LPDIRECT3DSURFACE9 m_lpSnowRenderTargetSurface;
|
||||||
LPDIRECT3DSURFACE8 m_lpSnowDepthSurface;
|
LPDIRECT3DSURFACE9 m_lpSnowDepthSurface;
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 m_lpAccumTexture;
|
LPDIRECT3DTEXTURE9 m_lpAccumTexture;
|
||||||
LPDIRECT3DSURFACE8 m_lpAccumRenderTargetSurface;
|
LPDIRECT3DSURFACE9 m_lpAccumRenderTargetSurface;
|
||||||
LPDIRECT3DSURFACE8 m_lpAccumDepthSurface;
|
LPDIRECT3DSURFACE9 m_lpAccumDepthSurface;
|
||||||
|
|
||||||
LPDIRECT3DVERTEXBUFFER8 m_pVB;
|
LPDIRECT3DVERTEXBUFFER9 m_pVB;
|
||||||
LPDIRECT3DINDEXBUFFER8 m_pIB;
|
LPDIRECT3DINDEXBUFFER9 m_pIB;
|
||||||
|
|
||||||
D3DXVECTOR3 m_v3Center;
|
D3DXVECTOR3 m_v3Center;
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ void CTerrainDecal::Render()
|
|||||||
|
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
|
STATEMANAGER.SaveTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
STATEMANAGER.SaveSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||||
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
@ -110,8 +110,8 @@ void CTerrainDecal::Render()
|
|||||||
|
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_TEXCOORDINDEX);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_TEXCOORDINDEX);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS);
|
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ADDRESSU);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_ADDRESSU);
|
||||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ADDRESSV);
|
STATEMANAGER.RestoreSamplerState(0, D3DSAMP_ADDRESSV);
|
||||||
|
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ void CTerrainPatch::__BuildHardwareTerrainVertexBuffer(HardwareTransformPatch_SS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTerrainPatch::SoftwareTransformPatch_UpdateTerrainLighting(DWORD dwVersion, const D3DLIGHT8& c_rkLight, const D3DMATERIAL8& c_rkMtrl)
|
void CTerrainPatch::SoftwareTransformPatch_UpdateTerrainLighting(DWORD dwVersion, const D3DLIGHT9& c_rkLight, const D3DMATERIAL9& c_rkMtrl)
|
||||||
{
|
{
|
||||||
if (m_dwVersion==dwVersion)
|
if (m_dwVersion==dwVersion)
|
||||||
return;
|
return;
|
||||||
@ -200,7 +200,7 @@ bool CTerrainPatchProxy::IsIn(const D3DXVECTOR3& c_rv3Target, float fRadius)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTerrainPatchProxy::SoftwareTransformPatch_UpdateTerrainLighting(DWORD dwVersion, const D3DLIGHT8& c_rkLight, const D3DMATERIAL8& c_rkMtrl)
|
void CTerrainPatchProxy::SoftwareTransformPatch_UpdateTerrainLighting(DWORD dwVersion, const D3DLIGHT9& c_rkLight, const D3DMATERIAL9& c_rkMtrl)
|
||||||
{
|
{
|
||||||
if (m_pTerrainPatch)
|
if (m_pTerrainPatch)
|
||||||
m_pTerrainPatch->SoftwareTransformPatch_UpdateTerrainLighting(dwVersion, c_rkLight, c_rkMtrl);
|
m_pTerrainPatch->SoftwareTransformPatch_UpdateTerrainLighting(dwVersion, c_rkLight, c_rkMtrl);
|
||||||
|
@ -95,8 +95,8 @@ public:
|
|||||||
|
|
||||||
UINT GetWaterFaceCount();
|
UINT GetWaterFaceCount();
|
||||||
|
|
||||||
void SoftwareTransformPatch_UpdateTerrainLighting(DWORD dwVersion, const D3DLIGHT8& c_rkLight, const D3DMATERIAL8& c_rkMtrl);
|
void SoftwareTransformPatch_UpdateTerrainLighting(DWORD dwVersion, const D3DLIGHT9& c_rkLight, const D3DMATERIAL9& c_rkMtrl);
|
||||||
|
|
||||||
void BuildTerrainVertexBuffer(HardwareTransformPatch_SSourceVertex* akSrcVertex);
|
void BuildTerrainVertexBuffer(HardwareTransformPatch_SSourceVertex* akSrcVertex);
|
||||||
void BuildWaterVertexBuffer(SWaterVertex* akSrcVertex, UINT uWaterVertexCount);
|
void BuildWaterVertexBuffer(SWaterVertex* akSrcVertex, UINT uWaterVertexCount);
|
||||||
|
|
||||||
@ -194,8 +194,8 @@ public:
|
|||||||
SoftwareTransformPatch_SSourceVertex* SoftwareTransformPatch_GetTerrainVertexDataPtr();
|
SoftwareTransformPatch_SSourceVertex* SoftwareTransformPatch_GetTerrainVertexDataPtr();
|
||||||
CGraphicVertexBuffer* HardwareTransformPatch_GetVertexBufferPtr();
|
CGraphicVertexBuffer* HardwareTransformPatch_GetVertexBufferPtr();
|
||||||
|
|
||||||
void SoftwareTransformPatch_UpdateTerrainLighting(DWORD dwVersion, const D3DLIGHT8& c_rkLight, const D3DMATERIAL8& c_rkMtrl);
|
void SoftwareTransformPatch_UpdateTerrainLighting(DWORD dwVersion, const D3DLIGHT9& c_rkLight, const D3DMATERIAL9& c_rkMtrl);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_bUsed;
|
bool m_bUsed;
|
||||||
short m_sPatchNum; // Patch Number
|
short m_sPatchNum; // Patch Number
|
||||||
|
@ -290,14 +290,14 @@ void CWeaponTrace::Render()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 lpTexture=NULL;
|
LPDIRECT3DTEXTURE9 lpTexture=NULL;
|
||||||
|
|
||||||
// Have to optimize
|
// Have to optimize
|
||||||
D3DXMATRIX matWorld;
|
D3DXMATRIX matWorld;
|
||||||
D3DXMatrixIdentity(&matWorld);
|
D3DXMatrixIdentity(&matWorld);
|
||||||
|
|
||||||
STATEMANAGER.SaveTransform(D3DTS_WORLD, &matWorld);
|
STATEMANAGER.SaveTransform(D3DTS_WORLD, &matWorld);
|
||||||
STATEMANAGER.SaveVertexShader(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
STATEMANAGER.SaveFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||||
|
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
@ -346,7 +346,7 @@ void CWeaponTrace::Render()
|
|||||||
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
|
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
|
||||||
|
|
||||||
STATEMANAGER.RestoreTransform(D3DTS_WORLD);
|
STATEMANAGER.RestoreTransform(D3DTS_WORLD);
|
||||||
STATEMANAGER.RestoreVertexShader();
|
STATEMANAGER.RestoreFVF();
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
|
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef __MILESLIB_CSOUNDDATA_H__
|
#ifndef __MILESLIB_CSOUNDDATA_H__
|
||||||
#define __MILESLIB_CSOUNDDATA_H__
|
#define __MILESLIB_CSOUNDDATA_H__
|
||||||
|
|
||||||
#include <mss.h>
|
#include <miles/MSS.H>
|
||||||
#include "../eterBase/MappedFile.h"
|
#include "../eterBase/MappedFile.h"
|
||||||
|
|
||||||
class CSoundData
|
class CSoundData
|
||||||
|
@ -91,7 +91,7 @@ class CTerrainImpl
|
|||||||
bool LoadWaterMap(const char * c_szWaterMapName);
|
bool LoadWaterMap(const char * c_szWaterMapName);
|
||||||
bool LoadWaterMapFile(const char * c_szWaterMapName);
|
bool LoadWaterMapFile(const char * c_szWaterMapName);
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 GetShadowTexture() { return m_lpShadowTexture; }
|
LPDIRECT3DTEXTURE9 GetShadowTexture() { return m_lpShadowTexture; }
|
||||||
|
|
||||||
DWORD GetShadowMapColor(float fx, float fy);
|
DWORD GetShadowMapColor(float fx, float fy);
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ class CTerrainImpl
|
|||||||
__forceinline WORD GetHeightMapValue(short sx, short sy);
|
__forceinline WORD GetHeightMapValue(short sx, short sy);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LPDIRECT3DTEXTURE8 m_lpAlphaTexture[MAXTERRAINTEXTURES];
|
LPDIRECT3DTEXTURE9 m_lpAlphaTexture[MAXTERRAINTEXTURES];
|
||||||
WORD m_awRawHeightMap[HEIGHTMAP_RAW_YSIZE*HEIGHTMAP_RAW_XSIZE];
|
WORD m_awRawHeightMap[HEIGHTMAP_RAW_YSIZE*HEIGHTMAP_RAW_XSIZE];
|
||||||
|
|
||||||
BYTE m_abyTileMap[TILEMAP_RAW_YSIZE*TILEMAP_RAW_XSIZE];
|
BYTE m_abyTileMap[TILEMAP_RAW_YSIZE*TILEMAP_RAW_XSIZE];
|
||||||
@ -139,7 +139,7 @@ class CTerrainImpl
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Shadow Map
|
// Shadow Map
|
||||||
LPDIRECT3DTEXTURE8 m_lpShadowTexture;
|
LPDIRECT3DTEXTURE9 m_lpShadowTexture;
|
||||||
WORD m_awShadowMap[SHADOWMAP_YSIZE*SHADOWMAP_XSIZE]; // 16bit R5 G6 B5
|
WORD m_awShadowMap[SHADOWMAP_YSIZE*SHADOWMAP_XSIZE]; // 16bit R5 G6 B5
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -13,7 +13,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
long Active;
|
long Active;
|
||||||
long NeedsUpdate;
|
long NeedsUpdate;
|
||||||
LPDIRECT3DTEXTURE8 pd3dTexture;
|
LPDIRECT3DTEXTURE9 pd3dTexture;
|
||||||
} TTerainSplat;
|
} TTerainSplat;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -21,7 +21,7 @@ typedef struct STerrainTexture
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string stFilename;
|
std::string stFilename;
|
||||||
LPDIRECT3DTEXTURE8 pd3dTexture;
|
LPDIRECT3DTEXTURE9 pd3dTexture;
|
||||||
CGraphicImageInstance ImageInstance;
|
CGraphicImageInstance ImageInstance;
|
||||||
float UScale;
|
float UScale;
|
||||||
float VScale;
|
float VScale;
|
||||||
|
246
src/SpeedTreeLib/CSpeedTreeDirectX.cpp
Normal file
246
src/SpeedTreeLib/CSpeedTreeDirectX.cpp
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
#include "StdAfx.h"
|
||||||
|
#include "CSpeedTreeDirectX.h"
|
||||||
|
#include <d3d9.h>
|
||||||
|
#include <d3d9types.h>
|
||||||
|
#include <directxsdk/d3dx9.h>
|
||||||
|
#include "VertexShaders.h"
|
||||||
|
#include "../eterBase/Timer.h"
|
||||||
|
#include "../eterLib/StateManager.h"
|
||||||
|
#include "../eterLib/Camera.h"
|
||||||
|
|
||||||
|
CSpeedTreeDirectX::CSpeedTreeDirectX() : m_dwBranchVertexShader(NULL), m_dwLeafVertexShader(NULL) {}
|
||||||
|
|
||||||
|
CSpeedTreeDirectX::~CSpeedTreeDirectX()
|
||||||
|
{
|
||||||
|
SAFE_RELEASE(m_dwBranchVertexShader);
|
||||||
|
SAFE_RELEASE(m_dwLeafVertexShader);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSpeedTreeDirectX::UploadWindMatrix(unsigned int uiLocation, const float* pMatrix) const
|
||||||
|
{
|
||||||
|
STATEMANAGER.SetVertexShaderConstant(uiLocation, pMatrix, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSpeedTreeDirectX::UpdateCompundMatrix(const D3DXVECTOR3& c_rEyeVec, const D3DXMATRIX& c_rmatView, const D3DXMATRIX& c_rmatProj)
|
||||||
|
{
|
||||||
|
D3DXMATRIX matBlend;
|
||||||
|
D3DXMatrixIdentity(&matBlend);
|
||||||
|
|
||||||
|
D3DXMATRIX matBlendShader;
|
||||||
|
D3DXMatrixMultiply(&matBlendShader, &c_rmatView, &c_rmatProj);
|
||||||
|
|
||||||
|
float afDirection[3];
|
||||||
|
afDirection[0] = matBlendShader.m[0][2];
|
||||||
|
afDirection[1] = matBlendShader.m[1][2];
|
||||||
|
afDirection[2] = matBlendShader.m[2][2];
|
||||||
|
CSpeedTreeRT::SetCamera(c_rEyeVec, afDirection);
|
||||||
|
|
||||||
|
D3DXMatrixTranspose(&matBlendShader, &matBlendShader);
|
||||||
|
STATEMANAGER.SetVertexShaderConstant(c_nVertexShader_CompoundMatrix, (const float*)&matBlendShader, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSpeedTreeDirectX::SetRenderingDevice()
|
||||||
|
{
|
||||||
|
if (!InitVertexShaders())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const float c_afLightPosition[4] = { -0.707f, -0.300f, 0.707f, 0.0f };
|
||||||
|
const float c_afLightAmbient[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||||
|
const float c_afLightDiffuse[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
|
const float c_afLightSpecular[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
|
float afLight1[] =
|
||||||
|
{
|
||||||
|
c_afLightPosition[0], c_afLightPosition[1], c_afLightPosition[2],
|
||||||
|
c_afLightDiffuse[0], c_afLightDiffuse[1], c_afLightDiffuse[2],
|
||||||
|
c_afLightAmbient[0], c_afLightAmbient[1], c_afLightAmbient[2],
|
||||||
|
c_afLightSpecular[0], c_afLightSpecular[1], c_afLightSpecular[2],
|
||||||
|
c_afLightPosition[3],
|
||||||
|
1.0f, 0.0f, 0.0f
|
||||||
|
};
|
||||||
|
|
||||||
|
CSpeedTreeRT::SetLightAttributes(0, afLight1);
|
||||||
|
CSpeedTreeRT::SetLightState(0, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSpeedTreeDirectX::Render(unsigned long ulRenderBitVector)
|
||||||
|
{
|
||||||
|
if (m_pMainTreeMap.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(ulRenderBitVector & Forest_RenderToShadow) && !(ulRenderBitVector & Forest_RenderToMiniMap))
|
||||||
|
UpdateCompundMatrix(CCameraManager::Instance().GetCurrentCamera()->GetEye(), ms_matView, ms_matProj);
|
||||||
|
|
||||||
|
DWORD dwLightState = STATEMANAGER.GetRenderState(D3DRS_LIGHTING);
|
||||||
|
DWORD dwColorVertexState = STATEMANAGER.GetRenderState(D3DRS_COLORVERTEX);
|
||||||
|
DWORD dwFogVertexMode = STATEMANAGER.GetRenderState(D3DRS_FOGVERTEXMODE);
|
||||||
|
|
||||||
|
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||||
|
STATEMANAGER.SetRenderState(D3DRS_COLORVERTEX, TRUE);
|
||||||
|
|
||||||
|
UINT uiCount;
|
||||||
|
TTreeMap::const_iterator itor = m_pMainTreeMap.begin();
|
||||||
|
|
||||||
|
while (itor != m_pMainTreeMap.end())
|
||||||
|
{
|
||||||
|
CSpeedTreeWrapper* pMainTree = (itor++)->second;
|
||||||
|
CSpeedTreeWrapper** ppInstances = pMainTree->GetInstances(uiCount);
|
||||||
|
|
||||||
|
for (UINT i = 0; i < uiCount; ++i)
|
||||||
|
{
|
||||||
|
ppInstances[i]->Advance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATEMANAGER.SetVertexShaderConstant(c_nVertexShader_Light, m_afLighting, 3);
|
||||||
|
STATEMANAGER.SetVertexShaderConstant(c_nVertexShader_Fog, m_afFog, 1);
|
||||||
|
|
||||||
|
if (ulRenderBitVector & Forest_RenderToShadow)
|
||||||
|
{
|
||||||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
|
||||||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
|
||||||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||||
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||||
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||||
|
STATEMANAGER.SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_ANISOTROPIC);
|
||||||
|
|
||||||
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||||
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
|
||||||
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||||
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
|
||||||
|
STATEMANAGER.SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, TRUE);
|
||||||
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
|
||||||
|
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_CW);
|
||||||
|
|
||||||
|
if (STATEMANAGER.GetRenderState(D3DRS_FOGENABLE)){}
|
||||||
|
|
||||||
|
STATEMANAGER.SetFVF(D3DFVF_SPEEDTREE_BRANCH_VERTEX);
|
||||||
|
STATEMANAGER.SetVertexShader(m_dwBranchVertexShader);
|
||||||
|
|
||||||
|
if (ulRenderBitVector & Forest_RenderBranches)
|
||||||
|
{
|
||||||
|
itor = m_pMainTreeMap.begin();
|
||||||
|
|
||||||
|
while (itor != m_pMainTreeMap.end())
|
||||||
|
{
|
||||||
|
CSpeedTreeWrapper* pMainTree = (itor++)->second;
|
||||||
|
CSpeedTreeWrapper** ppInstances = pMainTree->GetInstances(uiCount);
|
||||||
|
|
||||||
|
pMainTree->SetupBranchForTreeType();
|
||||||
|
|
||||||
|
for (UINT i = 0; i < uiCount; ++i)
|
||||||
|
if (ppInstances[i]->isShow())
|
||||||
|
ppInstances[i]->RenderBranches();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATEMANAGER.SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||||
|
|
||||||
|
if (ulRenderBitVector & Forest_RenderFronds)
|
||||||
|
{
|
||||||
|
itor = m_pMainTreeMap.begin();
|
||||||
|
|
||||||
|
while (itor != m_pMainTreeMap.end())
|
||||||
|
{
|
||||||
|
CSpeedTreeWrapper* pMainTree = (itor++)->second;
|
||||||
|
CSpeedTreeWrapper** ppInstances = pMainTree->GetInstances(uiCount);
|
||||||
|
|
||||||
|
pMainTree->SetupFrondForTreeType();
|
||||||
|
|
||||||
|
for (UINT i = 0; i < uiCount; ++i)
|
||||||
|
if (ppInstances[i]->isShow())
|
||||||
|
ppInstances[i]->RenderFronds();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ulRenderBitVector & Forest_RenderLeaves)
|
||||||
|
{
|
||||||
|
STATEMANAGER.SetFVF(D3DFVF_SPEEDTREE_LEAF_VERTEX);
|
||||||
|
STATEMANAGER.SetVertexShader(m_dwLeafVertexShader);
|
||||||
|
|
||||||
|
if (STATEMANAGER.GetRenderState(D3DRS_FOGENABLE)){}
|
||||||
|
if (ulRenderBitVector & Forest_RenderToShadow || ulRenderBitVector & Forest_RenderToMiniMap)
|
||||||
|
{
|
||||||
|
STATEMANAGER.SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_NOTEQUAL);
|
||||||
|
STATEMANAGER.SaveRenderState(D3DRS_ALPHAREF, 0x00000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
itor = m_pMainTreeMap.begin();
|
||||||
|
|
||||||
|
while (itor != m_pMainTreeMap.end())
|
||||||
|
{
|
||||||
|
CSpeedTreeWrapper* pMainTree = (itor++)->second;
|
||||||
|
CSpeedTreeWrapper** ppInstances = pMainTree->GetInstances(uiCount);
|
||||||
|
|
||||||
|
pMainTree->SetupLeafForTreeType();
|
||||||
|
|
||||||
|
for (UINT i = 0; i < uiCount; ++i)
|
||||||
|
if (ppInstances[i]->isShow())
|
||||||
|
ppInstances[i]->RenderLeaves();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ulRenderBitVector & Forest_RenderToShadow || ulRenderBitVector & Forest_RenderToMiniMap)
|
||||||
|
{
|
||||||
|
STATEMANAGER.SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
|
||||||
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHAREF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ulRenderBitVector & Forest_RenderBillboards)
|
||||||
|
{
|
||||||
|
STATEMANAGER.SetVertexShader(NULL);
|
||||||
|
STATEMANAGER.SetFVF(D3DFVF_SPEEDTREE_BILLBOARD_VERTEX);
|
||||||
|
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||||
|
STATEMANAGER.SetRenderState(D3DRS_COLORVERTEX, FALSE);
|
||||||
|
|
||||||
|
itor = m_pMainTreeMap.begin();
|
||||||
|
|
||||||
|
while (itor != m_pMainTreeMap.end())
|
||||||
|
{
|
||||||
|
CSpeedTreeWrapper* pMainTree = (itor++)->second;
|
||||||
|
CSpeedTreeWrapper** ppInstances = pMainTree->GetInstances(uiCount);
|
||||||
|
|
||||||
|
pMainTree->SetupBranchForTreeType();
|
||||||
|
|
||||||
|
for (UINT i = 0; i < uiCount; ++i)
|
||||||
|
if (ppInstances[i]->isShow())
|
||||||
|
ppInstances[i]->RenderBillboards();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, dwLightState);
|
||||||
|
STATEMANAGER.SetRenderState(D3DRS_COLORVERTEX, dwColorVertexState);
|
||||||
|
STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, dwFogVertexMode);
|
||||||
|
|
||||||
|
if (!(ulRenderBitVector & Forest_RenderToShadow))
|
||||||
|
{
|
||||||
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||||
|
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHATESTENABLE);
|
||||||
|
STATEMANAGER.RestoreRenderState(D3DRS_ALPHAFUNC);
|
||||||
|
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSpeedTreeDirectX::InitVertexShaders(void)
|
||||||
|
{
|
||||||
|
m_dwBranchVertexShader = LoadBranchShader(ms_lpd3dDevice);
|
||||||
|
m_dwLeafVertexShader = LoadLeafShader(ms_lpd3dDevice);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
23
src/SpeedTreeLib/CSpeedTreeDirectX.h
Normal file
23
src/SpeedTreeLib/CSpeedTreeDirectX.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <map>
|
||||||
|
#include "SpeedTreeForest.h"
|
||||||
|
#include "SpeedTreeMaterial.h"
|
||||||
|
|
||||||
|
class CSpeedTreeDirectX : public CSpeedTreeForest, public CGraphicBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSpeedTreeDirectX();
|
||||||
|
~CSpeedTreeDirectX();
|
||||||
|
|
||||||
|
void UploadWindMatrix(unsigned int uiLocation, const float* pMatrix) const;
|
||||||
|
bool SetRenderingDevice();
|
||||||
|
void Render(unsigned long ulRenderBitVector = Forest_RenderAll);
|
||||||
|
void UpdateCompundMatrix(const D3DXVECTOR3& c_rEyeVec, const D3DXMATRIX& c_rmatView, const D3DXMATRIX& c_rmatProj);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool InitVertexShaders();
|
||||||
|
|
||||||
|
private:
|
||||||
|
LPDIRECT3DVERTEXSHADER9 m_dwBranchVertexShader;
|
||||||
|
LPDIRECT3DVERTEXSHADER9 m_dwLeafVertexShader;
|
||||||
|
};
|
@ -1,769 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT Class
|
|
||||||
//
|
|
||||||
// (c) 2003 IDV, Inc.
|
|
||||||
//
|
|
||||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
|
||||||
//
|
|
||||||
// This software is supplied under the terms of a license agreement or
|
|
||||||
// nondisclosure agreement with Interactive Data Visualization and may
|
|
||||||
// not be copied or disclosed except in accordance with the terms of
|
|
||||||
// that agreement.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2001-2003 IDV, Inc.
|
|
||||||
// All Rights Reserved.
|
|
||||||
//
|
|
||||||
// IDV, Inc.
|
|
||||||
// 1233 Washington St. Suite 610
|
|
||||||
// Columbia, SC 29201
|
|
||||||
// Voice: (803) 799-1699
|
|
||||||
// Fax: (803) 931-0320
|
|
||||||
// Web: http://www.idvinc.com
|
|
||||||
|
|
||||||
|
|
||||||
#include "StdAfx.h"
|
|
||||||
#include "BoundaryShapeManager.h"
|
|
||||||
|
|
||||||
#ifdef USE_SPEEDGRASS
|
|
||||||
|
|
||||||
inline float VecInterpolate(float fStart, float fEnd, float fPercent)
|
|
||||||
{
|
|
||||||
return fStart + (fEnd - fStart) * fPercent;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VectorSinD(x) sinf((x) / 57.29578f)
|
|
||||||
#define VectorCosD(x) cosf((x) / 57.29578f)
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
// macros
|
|
||||||
#ifndef max
|
|
||||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
#ifndef min
|
|
||||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// static variables
|
|
||||||
float CSpeedGrassRT::m_fLodFarDistance = 100.0f;
|
|
||||||
float CSpeedGrassRT::m_fLodTransitionLength = 37.5f;
|
|
||||||
float CSpeedGrassRT::m_afUnitBillboard[12] = { 0.0f };
|
|
||||||
float CSpeedGrassRT::m_afWindDir[4] = { 1.0f, 0.3f, 0.0f, 0.0f };
|
|
||||||
|
|
||||||
// camera
|
|
||||||
float CSpeedGrassRT::m_afCameraOut[3] = { 0.0f, 1.0f, 0.0f };
|
|
||||||
float CSpeedGrassRT::m_afCameraUp[3] = { 0.0f, 0.0f, 1.0f };
|
|
||||||
float CSpeedGrassRT::m_afCameraRight[3] = { 1.0f, 0.0f, 0.0f };
|
|
||||||
float CSpeedGrassRT::m_afCameraPos[3] = { 0.0f, 0.0f, 0.0f };
|
|
||||||
float CSpeedGrassRT::m_fFieldOfView = D3DXToRadian(40.0f);
|
|
||||||
float CSpeedGrassRT::m_fAspectRatio = 4.0f / 3.0f;
|
|
||||||
|
|
||||||
// culling
|
|
||||||
float CSpeedGrassRT::m_afFrustumBox[6] = { 0.0f };
|
|
||||||
float CSpeedGrassRT::m_afFrustumMin[2] = { FLT_MAX, FLT_MAX };
|
|
||||||
float CSpeedGrassRT::m_afFrustumMax[2] = { -FLT_MAX, -FLT_MAX };
|
|
||||||
float CSpeedGrassRT::m_afFrustumPlanes[5][4] = { 0.0f };
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::SBlade::SBlade
|
|
||||||
|
|
||||||
CSpeedGrassRT::SBlade::SBlade( ) :
|
|
||||||
m_fSize(1.0f),
|
|
||||||
m_fNoise(0.0f),
|
|
||||||
m_fThrow(0.0f),
|
|
||||||
m_ucWhichTexture(0)
|
|
||||||
{
|
|
||||||
m_afBottomColor[0] = m_afBottomColor[1] = m_afBottomColor[2] = 1.0f;
|
|
||||||
m_afTopColor[0] = m_afTopColor[1] = m_afTopColor[2] = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::SRegion::SRegion
|
|
||||||
|
|
||||||
CSpeedGrassRT::SRegion::SRegion( ) :
|
|
||||||
m_bCulled(false),
|
|
||||||
m_fCullingRadius(1.0f)
|
|
||||||
{
|
|
||||||
m_afCenter[0] = m_afCenter[1] = m_afCenter[2] = 0.5f;
|
|
||||||
m_afMin[0] = m_afMin[1] = m_afMin[2] = 0.0f;
|
|
||||||
m_afMax[0] = m_afMax[1] = m_afMax[2] = 1.0f;
|
|
||||||
m_VertexBuffer.Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::CSpeedGrassRT
|
|
||||||
|
|
||||||
CSpeedGrassRT::CSpeedGrassRT( ) :
|
|
||||||
m_nNumRegions(0),
|
|
||||||
m_nNumRegionCols(0),
|
|
||||||
m_nNumRegionRows(0),
|
|
||||||
m_pRegions(NULL),
|
|
||||||
m_bAllRegionsCulled(false)
|
|
||||||
{
|
|
||||||
m_afBoundingBox[0] = m_afBoundingBox[1] = m_afBoundingBox[2] = 0.0f;
|
|
||||||
m_afBoundingBox[3] = m_afBoundingBox[4] = m_afBoundingBox[5] = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::~CSpeedGrassRT
|
|
||||||
|
|
||||||
CSpeedGrassRT::~CSpeedGrassRT( )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::DeleteRegions
|
|
||||||
|
|
||||||
void CSpeedGrassRT::DeleteRegions(void)
|
|
||||||
{
|
|
||||||
delete[] m_pRegions;
|
|
||||||
m_pRegions = NULL;
|
|
||||||
m_nNumRegions = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::GetRegions
|
|
||||||
|
|
||||||
const CSpeedGrassRT::SRegion* CSpeedGrassRT::GetRegions(unsigned int& uiNumRegions)
|
|
||||||
{
|
|
||||||
uiNumRegions = m_nNumRegions;
|
|
||||||
|
|
||||||
return m_pRegions;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::ParseBsfFile
|
|
||||||
|
|
||||||
bool CSpeedGrassRT::ParseBsfFile(const char* pFilename, unsigned int nNumBlades, unsigned int uiRows, unsigned int uiCols, float fCollisionDistance)
|
|
||||||
{
|
|
||||||
bool bSuccess = false;
|
|
||||||
|
|
||||||
// copy region settings
|
|
||||||
m_nNumRegionCols = int(uiCols);
|
|
||||||
m_nNumRegionRows = int(uiRows);
|
|
||||||
|
|
||||||
// initialize bounding box
|
|
||||||
m_afBoundingBox[0] = m_afBoundingBox[1] = m_afBoundingBox[2] = FLT_MAX;
|
|
||||||
m_afBoundingBox[3] = m_afBoundingBox[4] = m_afBoundingBox[5] = -FLT_MAX;
|
|
||||||
|
|
||||||
CBoundaryShapeManager cManager;
|
|
||||||
vector<SBlade> vSceneBlades;
|
|
||||||
|
|
||||||
if (cManager.LoadBsfFile(pFilename))
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < nNumBlades; ++i)
|
|
||||||
{
|
|
||||||
SBlade sBlade;
|
|
||||||
|
|
||||||
// try to place a blade
|
|
||||||
if (cManager.RandomPoint(sBlade.m_afPos[0], sBlade.m_afPos[1]))
|
|
||||||
{
|
|
||||||
sBlade.m_afPos[2] = Height(sBlade.m_afPos[0], sBlade.m_afPos[1], sBlade.m_afNormal);
|
|
||||||
|
|
||||||
// CVec3 cNormal(sBlade.m_afNormal[0], sBlade.m_afNormal[1], sBlade.m_afNormal[2]);
|
|
||||||
// cNormal.Normalize( );
|
|
||||||
// cNormal[2] = -cNormal[2];
|
|
||||||
// memcpy(sBlade.m_afNormal, cNormal, 3 * sizeof(float));
|
|
||||||
D3DXVECTOR3 v3Normal(sBlade.m_afNormal[0], sBlade.m_afNormal[1], sBlade.m_afNormal[2]);
|
|
||||||
D3DXVec3Normalize(&v3Normal, &v3Normal);
|
|
||||||
v3Normal.z = -v3Normal.z;
|
|
||||||
sBlade.m_afNormal[0] = v3Normal.x;
|
|
||||||
sBlade.m_afNormal[1] = v3Normal.y;
|
|
||||||
sBlade.m_afNormal[2] = v3Normal.z;
|
|
||||||
|
|
||||||
// check against overall scene bounding box
|
|
||||||
for (int nAxis = 0; nAxis < 3; ++nAxis)
|
|
||||||
{
|
|
||||||
m_afBoundingBox[nAxis] = min(m_afBoundingBox[nAxis], sBlade.m_afPos[nAxis]);
|
|
||||||
m_afBoundingBox[nAxis + 3] = max(m_afBoundingBox[nAxis + 3], sBlade.m_afPos[nAxis]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set bottom and top color
|
|
||||||
float fHeightPercent = Color(sBlade.m_afPos[0], sBlade.m_afPos[1], sBlade.m_afNormal, sBlade.m_afTopColor, sBlade.m_afBottomColor);
|
|
||||||
sBlade.m_fSize = VecInterpolate(c_fMinBladeSize, c_fMaxBladeSize, fHeightPercent);
|
|
||||||
|
|
||||||
// assign which blade texture map
|
|
||||||
sBlade.m_ucWhichTexture = GetRandom(0, c_nNumBladeMaps - 1);
|
|
||||||
|
|
||||||
// compute wind effects
|
|
||||||
sBlade.m_fNoise = GetRandom(c_fMinBladeNoise, c_fMaxBladeNoise);
|
|
||||||
sBlade.m_fThrow = GetRandom(c_fMinBladeThrow, c_fMaxBladeThrow);
|
|
||||||
|
|
||||||
// store all blades together
|
|
||||||
vSceneBlades.push_back(sBlade);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bSuccess = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fprintf(stderr, "%s\n", cManager.GetCurrentError( ).c_str( ));
|
|
||||||
|
|
||||||
if (bSuccess)
|
|
||||||
CreateRegions(vSceneBlades, fCollisionDistance);
|
|
||||||
|
|
||||||
return bSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::CustomPlacement
|
|
||||||
//
|
|
||||||
// Use this function to perform custom grass blade placement. Feel free
|
|
||||||
// to add parameters as necessary but be sure to call CreateRegions( )
|
|
||||||
// at the end of the function to set up the SpeedGrass region system.
|
|
||||||
|
|
||||||
bool CSpeedGrassRT::CustomPlacement(unsigned int uiRows, unsigned int uiCols)
|
|
||||||
{
|
|
||||||
// copy region settings (do not remove)
|
|
||||||
m_nNumRegionCols = int(uiCols);
|
|
||||||
m_nNumRegionRows = int(uiRows);
|
|
||||||
|
|
||||||
// initialize bounding box (do not remove)
|
|
||||||
m_afBoundingBox[0] = m_afBoundingBox[1] = m_afBoundingBox[2] = FLT_MAX;
|
|
||||||
m_afBoundingBox[3] = m_afBoundingBox[4] = m_afBoundingBox[5] = -FLT_MAX;
|
|
||||||
|
|
||||||
// place one blade as an example
|
|
||||||
vector<SBlade> vSceneBlades;
|
|
||||||
|
|
||||||
SBlade sBlade;
|
|
||||||
|
|
||||||
sBlade.m_afPos[0] = 0.0f;
|
|
||||||
sBlade.m_afPos[1] = 0.0f;
|
|
||||||
sBlade.m_afPos[2] = 0.0f;
|
|
||||||
|
|
||||||
sBlade.m_afNormal[0] = 0.0f;
|
|
||||||
sBlade.m_afNormal[1] = 0.0f;
|
|
||||||
sBlade.m_afNormal[2] = 1.0f;
|
|
||||||
|
|
||||||
// check against overall scene bounding box (always do this)
|
|
||||||
for (int nAxis = 0; nAxis < 3; ++nAxis)
|
|
||||||
{
|
|
||||||
m_afBoundingBox[nAxis] = min(m_afBoundingBox[nAxis], sBlade.m_afPos[nAxis]);
|
|
||||||
m_afBoundingBox[nAxis + 3] = max(m_afBoundingBox[nAxis + 3], sBlade.m_afPos[nAxis]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set bottom and top color
|
|
||||||
memcpy(sBlade.m_afBottomColor, sBlade.m_afNormal, 12);
|
|
||||||
memcpy(sBlade.m_afTopColor, sBlade.m_afNormal, 12);
|
|
||||||
|
|
||||||
// assign which blade texture map
|
|
||||||
sBlade.m_ucWhichTexture = GetRandom(0, c_nNumBladeMaps - 1);
|
|
||||||
|
|
||||||
// compute wind effects
|
|
||||||
sBlade.m_fNoise = GetRandom(c_fMinBladeNoise, c_fMaxBladeNoise);
|
|
||||||
sBlade.m_fThrow = GetRandom(c_fMinBladeThrow, c_fMaxBladeThrow);
|
|
||||||
|
|
||||||
// compute dimensions
|
|
||||||
sBlade.m_fSize = GetRandom(c_fMinBladeSize, c_fMaxBladeSize);
|
|
||||||
|
|
||||||
// store all blades together
|
|
||||||
vSceneBlades.push_back(sBlade);
|
|
||||||
|
|
||||||
// create regions based on blades (do not remove)
|
|
||||||
CreateRegions(vSceneBlades);
|
|
||||||
|
|
||||||
// true = success, false = error
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::GetLodParams
|
|
||||||
|
|
||||||
void CSpeedGrassRT::GetLodParams(float& fFarDistance, float& fTransitionLength)
|
|
||||||
{
|
|
||||||
fFarDistance = m_fLodFarDistance;
|
|
||||||
fTransitionLength = m_fLodTransitionLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::SetLodParams
|
|
||||||
|
|
||||||
void CSpeedGrassRT::SetLodParams(float fFarDistance, float fTransitionLength)
|
|
||||||
{
|
|
||||||
m_fLodFarDistance = fFarDistance;
|
|
||||||
m_fLodTransitionLength = fTransitionLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::Cull
|
|
||||||
//
|
|
||||||
// Using a two-dimensional projection, determine which regions
|
|
||||||
// intersect with the view frustum (+Z is assumed to be up)
|
|
||||||
|
|
||||||
void CSpeedGrassRT::Cull(void)
|
|
||||||
{
|
|
||||||
// convert raw frustum min and max values into min and max region cell indices
|
|
||||||
int anFrustumCellsMin[2], anFrustumCellsMax[2];
|
|
||||||
ConvertCoordsToCell(m_afFrustumMin, anFrustumCellsMin);
|
|
||||||
ConvertCoordsToCell(m_afFrustumMax, anFrustumCellsMax);
|
|
||||||
|
|
||||||
// set all regions to culled, modify later
|
|
||||||
for (int i = 0; i < m_nNumRegions; ++i)
|
|
||||||
m_pRegions[i].m_bCulled = true;
|
|
||||||
|
|
||||||
int nRegionsDrawn = 0;
|
|
||||||
|
|
||||||
// is the entire set of regions culled?
|
|
||||||
if ((anFrustumCellsMin[0] < 0 && anFrustumCellsMax[0] < 0) ||
|
|
||||||
(anFrustumCellsMin[0] >= m_nNumRegionCols && anFrustumCellsMax[0] >= m_nNumRegionCols) ||
|
|
||||||
(anFrustumCellsMin[1] < 0 && anFrustumCellsMax[1] < 0) ||
|
|
||||||
(anFrustumCellsMin[1] >= m_nNumRegionRows && anFrustumCellsMax[1] >= m_nNumRegionRows))
|
|
||||||
m_bAllRegionsCulled = true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// clip cell values
|
|
||||||
anFrustumCellsMin[0] = max(anFrustumCellsMin[0], 0);
|
|
||||||
anFrustumCellsMin[1] = max(anFrustumCellsMin[1], 0);
|
|
||||||
anFrustumCellsMax[0] = min(anFrustumCellsMax[0], m_nNumRegionCols - 1);
|
|
||||||
anFrustumCellsMax[1] = min(anFrustumCellsMax[1], m_nNumRegionRows - 1);
|
|
||||||
|
|
||||||
for (i = anFrustumCellsMin[0]; i <= anFrustumCellsMax[0]; ++i)
|
|
||||||
for (int j = anFrustumCellsMin[1]; j <= anFrustumCellsMax[1]; ++j)
|
|
||||||
{
|
|
||||||
SRegion* pRegion = m_pRegions + GetRegionIndex(j, i);
|
|
||||||
pRegion->m_bCulled = OutsideFrustum(pRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bAllRegionsCulled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::SetWindDirection
|
|
||||||
|
|
||||||
void CSpeedGrassRT::SetWindDirection(const float* pWindDir)
|
|
||||||
{
|
|
||||||
memcpy(m_afWindDir, pWindDir, 3 * sizeof(float));
|
|
||||||
m_afWindDir[3] = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::GetWindDirection
|
|
||||||
|
|
||||||
const float* CSpeedGrassRT::GetWindDirection(void)
|
|
||||||
{
|
|
||||||
return m_afWindDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::GetCameraPos
|
|
||||||
|
|
||||||
const float* CSpeedGrassRT::GetCameraPos(void)
|
|
||||||
{
|
|
||||||
return m_afCameraPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::SetCamera
|
|
||||||
|
|
||||||
void CSpeedGrassRT::SetCamera(const float* pPosition, const double* pModelviewMatrix)
|
|
||||||
{
|
|
||||||
memcpy(m_afCameraPos, pPosition, 3 * sizeof(float));
|
|
||||||
|
|
||||||
// "right" vector
|
|
||||||
m_afCameraRight[0] = pModelviewMatrix[0];
|
|
||||||
m_afCameraRight[1] = pModelviewMatrix[4];
|
|
||||||
m_afCameraRight[2] = pModelviewMatrix[8];
|
|
||||||
|
|
||||||
// "up" vector
|
|
||||||
m_afCameraUp[0] = pModelviewMatrix[1];
|
|
||||||
m_afCameraUp[1] = pModelviewMatrix[5];
|
|
||||||
m_afCameraUp[2] = pModelviewMatrix[9];
|
|
||||||
|
|
||||||
// "out of screen" vector
|
|
||||||
m_afCameraOut[0] = pModelviewMatrix[2];
|
|
||||||
m_afCameraOut[1] = pModelviewMatrix[6];
|
|
||||||
m_afCameraOut[2] = pModelviewMatrix[10];
|
|
||||||
|
|
||||||
// with direction changed, billboard turns
|
|
||||||
ComputeUnitBillboard( );
|
|
||||||
|
|
||||||
// compute new frustum box
|
|
||||||
ComputeFrustum( );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::SetPerspective
|
|
||||||
|
|
||||||
void CSpeedGrassRT::SetPerspective(float fAspectRatio, float fFieldOfView)
|
|
||||||
{
|
|
||||||
m_fAspectRatio = fAspectRatio;
|
|
||||||
m_fFieldOfView = D3DXToRadian(fAspectRatio * fFieldOfView);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::CreateRegions
|
|
||||||
|
|
||||||
void CSpeedGrassRT::CreateRegions(const vector<SBlade>& vSceneBlades, float fCollisionDistance)
|
|
||||||
{
|
|
||||||
// create regions based on overall extents
|
|
||||||
DeleteRegions( );
|
|
||||||
m_nNumRegions = int(m_nNumRegionRows * m_nNumRegionCols);
|
|
||||||
m_pRegions = new SRegion[m_nNumRegions];
|
|
||||||
|
|
||||||
// run through all regions, computing extents for each
|
|
||||||
float fCellWidth = (m_afBoundingBox[3] - m_afBoundingBox[0]) / m_nNumRegionCols;
|
|
||||||
float fCellHeight = (m_afBoundingBox[4] - m_afBoundingBox[1]) / m_nNumRegionRows;
|
|
||||||
|
|
||||||
float fY = m_afBoundingBox[1];
|
|
||||||
for (int nRow = 0; nRow < m_nNumRegionRows; ++nRow)
|
|
||||||
{
|
|
||||||
float fX = m_afBoundingBox[0];
|
|
||||||
for (int nCol = 0; nCol < m_nNumRegionCols; ++nCol)
|
|
||||||
{
|
|
||||||
SRegion* pRegion = m_pRegions + GetRegionIndex(nRow, nCol);
|
|
||||||
|
|
||||||
// compute extents
|
|
||||||
pRegion->m_afMin[0] = fX;
|
|
||||||
pRegion->m_afMax[0] = fX + fCellWidth;
|
|
||||||
pRegion->m_afMin[1] = fY;
|
|
||||||
pRegion->m_afMax[1] = fY + fCellHeight;
|
|
||||||
|
|
||||||
// compute center
|
|
||||||
pRegion->m_afCenter[0] = 0.5f * (pRegion->m_afMin[0] + pRegion->m_afMax[0]);
|
|
||||||
pRegion->m_afCenter[1] = 0.5f * (pRegion->m_afMin[1] + pRegion->m_afMax[1]);
|
|
||||||
|
|
||||||
// compute culling radius
|
|
||||||
pRegion->m_fCullingRadius = 1.1f * sqrt(
|
|
||||||
((pRegion->m_afMax[0] - pRegion->m_afCenter[0]) * (pRegion->m_afMax[0] - pRegion->m_afCenter[0])) +
|
|
||||||
((pRegion->m_afMax[1] - pRegion->m_afCenter[1]) * (pRegion->m_afMax[1] - pRegion->m_afCenter[1]))
|
|
||||||
);
|
|
||||||
|
|
||||||
fX += fCellWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
fY += fCellHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
// assign each blade of grass to its particular region
|
|
||||||
for (vector<SBlade>::const_iterator iBlade = vSceneBlades.begin( ); iBlade != vSceneBlades.end( ); ++iBlade)
|
|
||||||
{
|
|
||||||
// convert position to row/col index
|
|
||||||
float fPercentAlongX = (iBlade->m_afPos[0] - m_afBoundingBox[0]) / (m_afBoundingBox[3] - m_afBoundingBox[0]);
|
|
||||||
float fPercentAlongY = (iBlade->m_afPos[1] - m_afBoundingBox[1]) / (m_afBoundingBox[4] - m_afBoundingBox[1]);
|
|
||||||
|
|
||||||
// clip values
|
|
||||||
unsigned int uiCol = min(fPercentAlongX * m_nNumRegionCols, m_nNumRegionCols - 1);
|
|
||||||
unsigned int uiRow = min(fPercentAlongY * m_nNumRegionRows, m_nNumRegionRows - 1);
|
|
||||||
|
|
||||||
m_pRegions[GetRegionIndex(uiRow, uiCol)].m_vBlades.push_back(*iBlade);
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute z extents (now that the blades are in)
|
|
||||||
for (int i = 0; i < m_nNumRegions; ++i)
|
|
||||||
{
|
|
||||||
SRegion* pRegion = m_pRegions + i;
|
|
||||||
|
|
||||||
pRegion->m_afMin[2] = FLT_MAX;
|
|
||||||
pRegion->m_afMax[2] = -FLT_MAX;
|
|
||||||
for (vector<SBlade>::iterator iBlade = pRegion->m_vBlades.begin( ); iBlade != pRegion->m_vBlades.end( ); ++iBlade)
|
|
||||||
{
|
|
||||||
pRegion->m_afMin[2] = min(pRegion->m_afMin[2], iBlade->m_afPos[2]);
|
|
||||||
pRegion->m_afMax[2] = max(pRegion->m_afMax[2], iBlade->m_afPos[2] + iBlade->m_fSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
pRegion->m_afCenter[0] = 0.5f * (pRegion->m_afMin[0] + pRegion->m_afMax[0]);
|
|
||||||
pRegion->m_afCenter[1] = 0.5f * (pRegion->m_afMin[1] + pRegion->m_afMax[1]);
|
|
||||||
pRegion->m_afCenter[2] = 0.5f * (pRegion->m_afMin[2] + pRegion->m_afMax[2]);
|
|
||||||
|
|
||||||
// compute culling radius
|
|
||||||
pRegion->m_fCullingRadius = 1.1f * sqrt(
|
|
||||||
((pRegion->m_afMax[0] - pRegion->m_afCenter[0]) * (pRegion->m_afMax[0] - pRegion->m_afCenter[0])) +
|
|
||||||
((pRegion->m_afMax[1] - pRegion->m_afCenter[1]) * (pRegion->m_afMax[1] - pRegion->m_afCenter[1])) +
|
|
||||||
((pRegion->m_afMax[2] - pRegion->m_afCenter[2]) * (pRegion->m_afMax[2] - pRegion->m_afCenter[2]))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// collision detection
|
|
||||||
if (fCollisionDistance > 0.0f)
|
|
||||||
{
|
|
||||||
fCollisionDistance *= fCollisionDistance;
|
|
||||||
for (int nRow = 0; nRow < m_nNumRegionRows; ++nRow)
|
|
||||||
{
|
|
||||||
float fX = m_afBoundingBox[0];
|
|
||||||
for (int nCol = 0; nCol < m_nNumRegionCols; ++nCol)
|
|
||||||
{
|
|
||||||
SRegion* pRegion = m_pRegions + GetRegionIndex(nRow, nCol);
|
|
||||||
|
|
||||||
// check each blade against all other blades in the region
|
|
||||||
for (DWORD i = 0; i < pRegion->m_vBlades.size( ); ++i)
|
|
||||||
{
|
|
||||||
float fX = pRegion->m_vBlades[i].m_afPos[0];
|
|
||||||
float fY = pRegion->m_vBlades[i].m_afPos[1];
|
|
||||||
bool bCollision = false;
|
|
||||||
for (DWORD j = 0; j < pRegion->m_vBlades.size( ) && !bCollision; ++j)
|
|
||||||
{
|
|
||||||
if (i != j)
|
|
||||||
{
|
|
||||||
float fDistance = (fX - pRegion->m_vBlades[j].m_afPos[0]) * (fX - pRegion->m_vBlades[j].m_afPos[0]) + (fY - pRegion->m_vBlades[j].m_afPos[1]) * (fY - pRegion->m_vBlades[j].m_afPos[1]);
|
|
||||||
if (fDistance < fCollisionDistance)
|
|
||||||
bCollision = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete the blade if necessary and adjust the main loop counter to compensate
|
|
||||||
if (bCollision)
|
|
||||||
pRegion->m_vBlades.erase(pRegion->m_vBlades.begin( ) + i--);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::RotateAxisFromIdentity
|
|
||||||
|
|
||||||
__forceinline void CSpeedGrassRT::RotateAxisFromIdentity(D3DXMATRIX * pMat, const float & c_fAngle, const D3DXVECTOR3 & c_rv3Axis)
|
|
||||||
{
|
|
||||||
float s = VectorSinD(c_fAngle);
|
|
||||||
float c = VectorCosD(c_fAngle);
|
|
||||||
float t = 1.0 - c;
|
|
||||||
|
|
||||||
float x = c_rv3Axis.x;
|
|
||||||
float y = c_rv3Axis.y;
|
|
||||||
float z = c_rv3Axis.z;
|
|
||||||
|
|
||||||
pMat->_11 = t * x * x + c;
|
|
||||||
pMat->_12 = t * x * y + s * z;
|
|
||||||
pMat->_13 = t * x * z - s * y;
|
|
||||||
pMat->_21 = t * x * y - s * z;
|
|
||||||
pMat->_22 = t * y * y + c;
|
|
||||||
pMat->_23 = t * y * z + s * x;
|
|
||||||
pMat->_31 = t * x * z + s * y;
|
|
||||||
pMat->_32 = t * y * z - s * x;
|
|
||||||
pMat->_33 = t * z * z + c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::ComputeFrustum
|
|
||||||
|
|
||||||
void CSpeedGrassRT::ComputeFrustum(void)
|
|
||||||
{
|
|
||||||
// setup useful vectors
|
|
||||||
// CVec3 cCameraIn(-m_afCameraOut[0], -m_afCameraOut[1], -m_afCameraOut[2]);
|
|
||||||
// CVec3 cCameraUp(m_afCameraUp[0], m_afCameraUp[1], m_afCameraUp[2]);
|
|
||||||
// CVec3 cCameraRight(m_afCameraRight[0], m_afCameraRight[1], m_afCameraRight[2]);
|
|
||||||
// CVec3 cCameraPos(m_afCameraPos[0], m_afCameraPos[1], m_afCameraPos[2]);
|
|
||||||
// CVec3 cFarPoint = cCameraPos + cCameraIn * (m_fLodFarDistance + m_fLodTransitionLength);
|
|
||||||
D3DXVECTOR3 cCameraIn(-m_afCameraOut[0], -m_afCameraOut[1], -m_afCameraOut[2]);
|
|
||||||
D3DXVECTOR3 cCameraUp(m_afCameraUp[0], m_afCameraUp[1], m_afCameraUp[2]);
|
|
||||||
D3DXVECTOR3 cCameraRight(m_afCameraRight[0], m_afCameraRight[1], m_afCameraRight[2]);
|
|
||||||
D3DXVECTOR3 cCameraPos(m_afCameraPos[0], m_afCameraPos[1], m_afCameraPos[2]);
|
|
||||||
D3DXVECTOR3 cFarPoint = cCameraPos + cCameraIn * (m_fLodFarDistance + m_fLodTransitionLength);
|
|
||||||
|
|
||||||
// far plane
|
|
||||||
// memcpy(m_afFrustumPlanes[0], cCameraIn, 3 * sizeof(float));
|
|
||||||
// m_afFrustumPlanes[0][3] = -(cCameraIn ^ cFarPoint); // operator^ is dot product
|
|
||||||
m_afFrustumPlanes[0][0] = cCameraIn.x;
|
|
||||||
m_afFrustumPlanes[0][1] = cCameraIn.y;
|
|
||||||
m_afFrustumPlanes[0][2] = cCameraIn.z;
|
|
||||||
m_afFrustumPlanes[0][3] = -D3DXVec3Dot(&cCameraIn, &cFarPoint); // operator^ is dot product
|
|
||||||
|
|
||||||
// CRotTransform cRotate(true);
|
|
||||||
D3DXMATRIX cRotate;
|
|
||||||
D3DXMatrixIdentity(&cRotate);
|
|
||||||
D3DXVECTOR3 cNormal;
|
|
||||||
|
|
||||||
// upper plane
|
|
||||||
// cRotate.RotateAxisFromIdentity(VecRad2Deg(0.5f * m_fFieldOfView * m_fAspectRatio + c_fHalfPi) , cCameraRight);
|
|
||||||
// CVec3 cNormal = cCameraIn * cRotate;
|
|
||||||
// cNormal.Normalize( );
|
|
||||||
// memcpy(m_afFrustumPlanes[1], cNormal, 3 * sizeof(float));
|
|
||||||
// m_afFrustumPlanes[1][3] = -(cNormal ^ cCameraPos);
|
|
||||||
|
|
||||||
// left plane
|
|
||||||
// cRotate.RotateAxisFromIdentity(VecRad2Deg(0.5f * m_fFieldOfView + c_fHalfPi) , cCameraUp);
|
|
||||||
// cNormal = cCameraIn * cRotate;
|
|
||||||
// cNormal.Normalize( );
|
|
||||||
// memcpy(m_afFrustumPlanes[2], cNormal, 3 * sizeof(float));
|
|
||||||
// m_afFrustumPlanes[2][3] = -(cNormal ^ cCameraPos);
|
|
||||||
|
|
||||||
// lower plane
|
|
||||||
// cRotate.RotateAxisFromIdentity(-VecRad2Deg(0.5f * m_fFieldOfView * m_fAspectRatio + c_fHalfPi) , cCameraRight);
|
|
||||||
// cNormal = cCameraIn * cRotate;
|
|
||||||
// cNormal.Normalize( );
|
|
||||||
// memcpy(m_afFrustumPlanes[3], cNormal, 3 * sizeof(float));
|
|
||||||
// m_afFrustumPlanes[3][3] = -(cNormal ^ cCameraPos);
|
|
||||||
|
|
||||||
// right plane
|
|
||||||
// cRotate.RotateAxisFromIdentity(-VecRad2Deg(0.5f * m_fFieldOfView + c_fHalfPi) , cCameraUp);
|
|
||||||
// cNormal = cCameraIn * cRotate;
|
|
||||||
// cNormal.Normalize( );
|
|
||||||
// memcpy(m_afFrustumPlanes[4], cNormal, 3 * sizeof(float));
|
|
||||||
// m_afFrustumPlanes[4][3] = -(cNormal ^ cCameraPos);
|
|
||||||
|
|
||||||
RotateAxisFromIdentity(&cRotate, D3DXToDegree(0.5f * m_fFieldOfView * m_fAspectRatio + c_fHalfPi), cCameraRight);
|
|
||||||
D3DXVec3TransformCoord(&cNormal, &cCameraIn, &cRotate);
|
|
||||||
D3DXVec3Normalize(&cNormal, &cNormal);
|
|
||||||
m_afFrustumPlanes[1][0] = cNormal.x;
|
|
||||||
m_afFrustumPlanes[1][1] = cNormal.y;
|
|
||||||
m_afFrustumPlanes[1][2] = cNormal.z;
|
|
||||||
m_afFrustumPlanes[1][3] = -D3DXVec3Dot(&cNormal, &cCameraPos); // operator^ is dot product
|
|
||||||
|
|
||||||
RotateAxisFromIdentity(&cRotate, D3DXToDegree(0.5f * m_fFieldOfView + c_fHalfPi), cCameraUp);
|
|
||||||
D3DXVec3TransformCoord(&cNormal, &cCameraIn, &cRotate);
|
|
||||||
D3DXVec3Normalize(&cNormal, &cNormal);
|
|
||||||
m_afFrustumPlanes[2][0] = cNormal.x;
|
|
||||||
m_afFrustumPlanes[2][1] = cNormal.y;
|
|
||||||
m_afFrustumPlanes[2][2] = cNormal.z;
|
|
||||||
m_afFrustumPlanes[2][3] = -D3DXVec3Dot(&cNormal, &cCameraPos); // operator^ is dot product
|
|
||||||
|
|
||||||
RotateAxisFromIdentity(&cRotate, -D3DXToDegree(0.5f * m_fFieldOfView * m_fAspectRatio + c_fHalfPi), cCameraRight);
|
|
||||||
D3DXVec3TransformCoord(&cNormal, &cCameraIn, &cRotate);
|
|
||||||
D3DXVec3Normalize(&cNormal, &cNormal);
|
|
||||||
m_afFrustumPlanes[3][0] = cNormal.x;
|
|
||||||
m_afFrustumPlanes[3][1] = cNormal.y;
|
|
||||||
m_afFrustumPlanes[3][2] = cNormal.z;
|
|
||||||
m_afFrustumPlanes[3][3] = -D3DXVec3Dot(&cNormal, &cCameraPos); // operator^ is dot product
|
|
||||||
|
|
||||||
RotateAxisFromIdentity(&cRotate, -D3DXToDegree(0.5f * m_fFieldOfView + c_fHalfPi), cCameraUp);
|
|
||||||
D3DXVec3TransformCoord(&cNormal, &cCameraIn, &cRotate);
|
|
||||||
D3DXVec3Normalize(&cNormal, &cNormal);
|
|
||||||
m_afFrustumPlanes[4][0] = cNormal.x;
|
|
||||||
m_afFrustumPlanes[4][1] = cNormal.y;
|
|
||||||
m_afFrustumPlanes[4][2] = cNormal.z;
|
|
||||||
m_afFrustumPlanes[4][3] = -D3DXVec3Dot(&cNormal, &cCameraPos); // operator^ is dot product
|
|
||||||
|
|
||||||
// frustum points
|
|
||||||
float fFrustumHeight = (m_fLodFarDistance + m_fLodTransitionLength) * tanf(0.5f * m_fFieldOfView);
|
|
||||||
float fFrustumWidth = (m_fLodFarDistance + m_fLodTransitionLength) * tanf(0.5f * m_fFieldOfView * m_fAspectRatio);
|
|
||||||
|
|
||||||
// CVec3 acFrustum[5];
|
|
||||||
D3DXVECTOR3 acFrustum[5];
|
|
||||||
acFrustum[0] = cCameraPos;
|
|
||||||
acFrustum[1] = cFarPoint + cCameraRight * fFrustumWidth + cCameraUp * fFrustumHeight;
|
|
||||||
acFrustum[2] = cFarPoint - cCameraRight * fFrustumWidth + cCameraUp * fFrustumHeight;
|
|
||||||
acFrustum[3] = cFarPoint - cCameraRight * fFrustumWidth - cCameraUp * fFrustumHeight;
|
|
||||||
acFrustum[4] = cFarPoint + cCameraRight * fFrustumWidth - cCameraUp * fFrustumHeight;
|
|
||||||
|
|
||||||
// find min/max (x,y) coordinates
|
|
||||||
m_afFrustumMin[0] = m_afFrustumMin[1] = FLT_MAX;
|
|
||||||
m_afFrustumMax[0] = m_afFrustumMax[1] = -FLT_MAX;
|
|
||||||
for (int i = 0; i < 5; ++i)
|
|
||||||
{
|
|
||||||
m_afFrustumMin[0] = min(m_afFrustumMin[0], acFrustum[i][0]);
|
|
||||||
m_afFrustumMax[0] = max(m_afFrustumMax[0], acFrustum[i][0]);
|
|
||||||
m_afFrustumMin[1] = min(m_afFrustumMin[1], acFrustum[i][1]);
|
|
||||||
m_afFrustumMax[1] = max(m_afFrustumMax[1], acFrustum[i][1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::ComputeUnitBillboard
|
|
||||||
|
|
||||||
void CSpeedGrassRT::ComputeUnitBillboard(void)
|
|
||||||
{
|
|
||||||
// float fAzimuth = D3DXToDegree(atan2(-m_afCameraOut[1], -m_afCameraOut[0]));
|
|
||||||
float fAzimuth = atan2(-m_afCameraOut[1], -m_afCameraOut[0]);
|
|
||||||
|
|
||||||
// CRotTransform cTrans;
|
|
||||||
// cTrans.RotateZ(fAzimuth);
|
|
||||||
//
|
|
||||||
// static CVec3 afCorner1(0.0f, 0.5f, 1.0f);
|
|
||||||
// static CVec3 afCorner2(0.0f, -0.5f, 1.0f);
|
|
||||||
// static CVec3 afCorner3(0.0f, -0.5f, 0.0f);
|
|
||||||
// static CVec3 afCorner4(0.0f, 0.5f, 0.0f);
|
|
||||||
//
|
|
||||||
// CVec3 afNewCorner1 = afCorner1 * cTrans;
|
|
||||||
// CVec3 afNewCorner2 = afCorner2 * cTrans;
|
|
||||||
// CVec3 afNewCorner3 = afCorner3 * cTrans;
|
|
||||||
// CVec3 afNewCorner4 = afCorner4 * cTrans;
|
|
||||||
//
|
|
||||||
// memcpy(m_afUnitBillboard + 0, afNewCorner1.m_afData, 3 * sizeof(float));
|
|
||||||
// memcpy(m_afUnitBillboard + 3, afNewCorner2.m_afData, 3 * sizeof(float));
|
|
||||||
// memcpy(m_afUnitBillboard + 6, afNewCorner3.m_afData, 3 * sizeof(float));
|
|
||||||
// memcpy(m_afUnitBillboard + 9, afNewCorner4.m_afData, 3 * sizeof(float));
|
|
||||||
|
|
||||||
D3DXMATRIX cTrans;
|
|
||||||
D3DXMatrixRotationZ(&cTrans, fAzimuth);
|
|
||||||
|
|
||||||
static D3DXVECTOR3 afCorner1(0.0f, 0.5f, 1.0f);
|
|
||||||
static D3DXVECTOR3 afCorner2(0.0f, -0.5f, 1.0f);
|
|
||||||
static D3DXVECTOR3 afCorner3(0.0f, -0.5f, 0.0f);
|
|
||||||
static D3DXVECTOR3 afCorner4(0.0f, 0.5f, 0.0f);
|
|
||||||
|
|
||||||
D3DXVECTOR3 afNewCorner1;
|
|
||||||
D3DXVECTOR3 afNewCorner2;
|
|
||||||
D3DXVECTOR3 afNewCorner3;
|
|
||||||
D3DXVECTOR3 afNewCorner4;
|
|
||||||
|
|
||||||
D3DXVec3TransformCoord(&afNewCorner1, &afCorner1, &cTrans);
|
|
||||||
D3DXVec3TransformCoord(&afNewCorner2, &afCorner2, &cTrans);
|
|
||||||
D3DXVec3TransformCoord(&afNewCorner3, &afCorner3, &cTrans);
|
|
||||||
D3DXVec3TransformCoord(&afNewCorner4, &afCorner4, &cTrans);
|
|
||||||
|
|
||||||
m_afUnitBillboard[0] = afNewCorner1.x;
|
|
||||||
m_afUnitBillboard[1] = afNewCorner1.y;
|
|
||||||
m_afUnitBillboard[2] = afNewCorner1.z;
|
|
||||||
m_afUnitBillboard[3] = afNewCorner2.x;
|
|
||||||
m_afUnitBillboard[4] = afNewCorner2.y;
|
|
||||||
m_afUnitBillboard[5] = afNewCorner2.z;
|
|
||||||
m_afUnitBillboard[6] = afNewCorner3.x;
|
|
||||||
m_afUnitBillboard[7] = afNewCorner3.y;
|
|
||||||
m_afUnitBillboard[8] = afNewCorner3.z;
|
|
||||||
m_afUnitBillboard[9] = afNewCorner4.x;
|
|
||||||
m_afUnitBillboard[10] = afNewCorner4.y;
|
|
||||||
m_afUnitBillboard[11] = afNewCorner4.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::ConvertCoordsToCell
|
|
||||||
|
|
||||||
void CSpeedGrassRT::ConvertCoordsToCell(const float* pCoords, int* pGridCoords) const
|
|
||||||
{
|
|
||||||
float fPercentAlongX = (pCoords[0] - m_afBoundingBox[0]) / (m_afBoundingBox[3] - m_afBoundingBox[0]);
|
|
||||||
float fPercentAlongY = (pCoords[1] - m_afBoundingBox[1]) / (m_afBoundingBox[4] - m_afBoundingBox[1]);
|
|
||||||
|
|
||||||
if (fPercentAlongX < 0.0f)
|
|
||||||
pGridCoords[0] = -1;
|
|
||||||
else if (fPercentAlongX > 1.0f)
|
|
||||||
pGridCoords[0] = m_nNumRegionCols;
|
|
||||||
else
|
|
||||||
pGridCoords[0] = fPercentAlongX * m_nNumRegionCols;
|
|
||||||
|
|
||||||
if (fPercentAlongY < 0.0f)
|
|
||||||
pGridCoords[1] = -1;
|
|
||||||
else if (fPercentAlongY > 1.0f)
|
|
||||||
pGridCoords[1] = m_nNumRegionRows;
|
|
||||||
else
|
|
||||||
pGridCoords[1] = fPercentAlongY * m_nNumRegionRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT::OutsideFrustum
|
|
||||||
|
|
||||||
__forceinline bool CSpeedGrassRT::OutsideFrustum(CSpeedGrassRT::SRegion* pRegion)
|
|
||||||
{
|
|
||||||
bool bOutside = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < 5 && !bOutside; ++i)
|
|
||||||
if (m_afFrustumPlanes[i][0] * pRegion->m_afCenter[0] +
|
|
||||||
m_afFrustumPlanes[i][1] * pRegion->m_afCenter[1] +
|
|
||||||
m_afFrustumPlanes[i][2] * pRegion->m_afCenter[2] +
|
|
||||||
m_afFrustumPlanes[i][3] > pRegion->m_fCullingRadius)
|
|
||||||
bOutside = true;
|
|
||||||
|
|
||||||
return bOutside;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // USE_SPEEDGRASS
|
|
@ -1,180 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassRT Class
|
|
||||||
//
|
|
||||||
// (c) 2003 IDV, Inc.
|
|
||||||
//
|
|
||||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
|
||||||
//
|
|
||||||
// This software is supplied under the terms of a license agreement or
|
|
||||||
// nondisclosure agreement with Interactive Data Visualization and may
|
|
||||||
// not be copied or disclosed except in accordance with the terms of
|
|
||||||
// that agreement.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2001-2003 IDV, Inc.
|
|
||||||
// All Rights Reserved.
|
|
||||||
//
|
|
||||||
// IDV, Inc.
|
|
||||||
// 1233 Washington St. Suite 610
|
|
||||||
// Columbia, SC 29201
|
|
||||||
// Voice: (803) 799-1699
|
|
||||||
// Fax: (803) 931-0320
|
|
||||||
// Web: http://www.idvinc.com
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
//#include <vector>
|
|
||||||
//#include "Constants.h"
|
|
||||||
//#include "../Common Source/IdvVertexBuffer.h"
|
|
||||||
|
|
||||||
#ifdef USE_SPEEDGRASS
|
|
||||||
|
|
||||||
|
|
||||||
// forward reference
|
|
||||||
class CIdvTerrain;
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// class CSpeedGrassRT declaration
|
|
||||||
|
|
||||||
class CSpeedGrassRT
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CSpeedGrassRT( );
|
|
||||||
virtual ~CSpeedGrassRT( );
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// struct SBlade
|
|
||||||
|
|
||||||
struct SBlade
|
|
||||||
{
|
|
||||||
SBlade( );
|
|
||||||
|
|
||||||
// geometry
|
|
||||||
float m_afPos[3];
|
|
||||||
float m_afNormal[3];
|
|
||||||
float m_fSize;
|
|
||||||
unsigned char m_ucWhichTexture;
|
|
||||||
|
|
||||||
// wind
|
|
||||||
float m_fNoise;
|
|
||||||
float m_fThrow;
|
|
||||||
|
|
||||||
// color
|
|
||||||
float m_afBottomColor[3];
|
|
||||||
float m_afTopColor[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// struct SRegion
|
|
||||||
|
|
||||||
struct SRegion
|
|
||||||
{
|
|
||||||
SRegion( );
|
|
||||||
|
|
||||||
// dimensions
|
|
||||||
float m_afCenter[3];
|
|
||||||
float m_afMin[3];
|
|
||||||
float m_afMax[3];
|
|
||||||
|
|
||||||
// culling
|
|
||||||
bool m_bCulled;
|
|
||||||
float m_fCullingRadius;
|
|
||||||
|
|
||||||
// grass/brush blades
|
|
||||||
std::vector<SBlade> m_vBlades;
|
|
||||||
// CIdvVertexBuffer* m_pVertexBuffer;
|
|
||||||
CGraphicVertexBuffer m_VertexBuffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
void DeleteRegions(void);
|
|
||||||
const SRegion* GetRegions(unsigned int& uiNumRegions);
|
|
||||||
bool ParseBsfFile(const char* pFilename, unsigned int nNumBlades, unsigned int uiRows, unsigned int uiCols, float fCollisionDistance = 0.0f);
|
|
||||||
bool CustomPlacement(unsigned int uiRows, unsigned int uiCols);
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Utility
|
|
||||||
static void RotateAxisFromIdentity(D3DXMATRIX * pMat, const float & c_fAngle, const D3DXVECTOR3 & c_rv3Axis);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// Geometry
|
|
||||||
|
|
||||||
static const float* GetUnitBillboard(void) { return m_afUnitBillboard; }
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// LOD
|
|
||||||
|
|
||||||
static void GetLodParams(float& fFarDistance, float& fTransitionLength);
|
|
||||||
static void SetLodParams(float fFarDistance, float fTransitionLength);
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// Culling
|
|
||||||
|
|
||||||
bool AllRegionsAreCulled(void) const { return m_bAllRegionsCulled; }
|
|
||||||
void Cull(void);
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// Wind
|
|
||||||
|
|
||||||
static void SetWindDirection(const float* pWindDir);
|
|
||||||
static const float* GetWindDirection(void);
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// Camera
|
|
||||||
|
|
||||||
static const float* GetCameraPos(void);
|
|
||||||
static void SetCamera(const float* pPosition, const double* pModelviewMatrix);
|
|
||||||
static void SetPerspective(float fAspectRatio, float fFieldOfView);
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// Terrain hugging
|
|
||||||
|
|
||||||
virtual float Color(float fX, float fY, const float* pNormal, float* pTopColor, float* pBottomColor) const { return 0.0f; }
|
|
||||||
virtual float Height(float fX, float fY, float* pNormal) const { return 0.0f; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
void CreateRegions(const std::vector<SBlade>& vSceneBlades, float fCollisionDistance = 0.0f);
|
|
||||||
static void ComputeFrustum(void);
|
|
||||||
static void ComputeUnitBillboard(void);
|
|
||||||
void ConvertCoordsToCell(const float* pCoords, int* pGridCoords) const;
|
|
||||||
unsigned int GetRegionIndex(unsigned int uiRow, unsigned int uiCol) const { return uiRow * m_nNumRegionCols + uiCol; }
|
|
||||||
static bool OutsideFrustum(SRegion* pRegion);
|
|
||||||
|
|
||||||
// general
|
|
||||||
static float m_fLodFarDistance;
|
|
||||||
static float m_fLodTransitionLength;
|
|
||||||
static float m_afUnitBillboard[12];
|
|
||||||
static float m_afWindDir[4];
|
|
||||||
|
|
||||||
// regions
|
|
||||||
int m_nNumRegions;
|
|
||||||
int m_nNumRegionCols;
|
|
||||||
int m_nNumRegionRows;
|
|
||||||
SRegion* m_pRegions;
|
|
||||||
|
|
||||||
// camera
|
|
||||||
static float m_afCameraOut[3];
|
|
||||||
static float m_afCameraRight[3];
|
|
||||||
static float m_afCameraUp[3];
|
|
||||||
static float m_afCameraPos[3];
|
|
||||||
static float m_fFieldOfView;
|
|
||||||
static float m_fAspectRatio;
|
|
||||||
|
|
||||||
// culling
|
|
||||||
static float m_afFrustumBox[6];
|
|
||||||
static float m_afFrustumMin[2];
|
|
||||||
static float m_afFrustumMax[2];
|
|
||||||
static float m_afFrustumPlanes[5][4];
|
|
||||||
float m_afBoundingBox[6];
|
|
||||||
bool m_bAllRegionsCulled;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern float VecInterpolate(float fStart, float fEnd, float fPercent);
|
|
||||||
#endif // USE_SPEEDGRASS
|
|
@ -1,322 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassWrapper Class
|
|
||||||
//
|
|
||||||
// (c) 2003 IDV, Inc.
|
|
||||||
//
|
|
||||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
|
||||||
//
|
|
||||||
// This software is supplied under the terms of a license agreement or
|
|
||||||
// nondisclosure agreement with Interactive Data Visualization and may
|
|
||||||
// not be copied or disclosed except in accordance with the terms of
|
|
||||||
// that agreement.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2001-2003 IDV, Inc.
|
|
||||||
// All Rights Reserved.
|
|
||||||
//
|
|
||||||
// IDV, Inc.
|
|
||||||
// 1233 Washington St. Suite 610
|
|
||||||
// Columbia, SC 29201
|
|
||||||
// Voice: (803) 799-1699
|
|
||||||
// Fax: (803) 931-0320
|
|
||||||
// Web: http://www.idvinc.com
|
|
||||||
|
|
||||||
#include "StdAfx.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <vector>
|
|
||||||
//#include "../Common Source/extgl.h"
|
|
||||||
//#include "SpeedGrassWrapper.h"
|
|
||||||
//#include "Scene.h"
|
|
||||||
//#include "../Common Source/nv_dds.h"
|
|
||||||
//#include "../Common Source/Random.h"
|
|
||||||
//#include "TextureLayers.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#ifdef USE_SPEEDGRASS
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassWrapper::CSpeedGrassWrapper
|
|
||||||
|
|
||||||
CSpeedGrassWrapper::CSpeedGrassWrapper() : m_pMapOutdoor(NULL), m_lpD3DTexure8(NULL)//m_uiTexture(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassWrapper::~CSpeedGrassWrapper
|
|
||||||
|
|
||||||
CSpeedGrassWrapper::~CSpeedGrassWrapper( )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassWrapper::Draw
|
|
||||||
|
|
||||||
int CSpeedGrassWrapper::Draw(float fDensity)
|
|
||||||
{
|
|
||||||
int nTriangleCount = 0;
|
|
||||||
|
|
||||||
// // determine which regions are visible
|
|
||||||
// Cull( );
|
|
||||||
//
|
|
||||||
// // setup opengl state
|
|
||||||
// glPushAttrib(GL_ENABLE_BIT);
|
|
||||||
// glDisable(GL_CULL_FACE);
|
|
||||||
// glDisable(GL_BLEND);
|
|
||||||
//
|
|
||||||
// glEnable(GL_TEXTURE_2D);
|
|
||||||
// glBindTexture(GL_TEXTURE_2D, m_uiTexture);
|
|
||||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
|
||||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
|
||||||
//
|
|
||||||
// glEnable(GL_ALPHA_TEST);
|
|
||||||
// glAlphaFunc(GL_GREATER, 0.4f);
|
|
||||||
// glDisable(GL_LIGHTING);
|
|
||||||
//
|
|
||||||
// unsigned int uiCount = 0;
|
|
||||||
// unsigned int uiNumRegions = 0;
|
|
||||||
// const SRegion* pRegions = GetRegions(uiNumRegions);
|
|
||||||
//
|
|
||||||
// // setup for vertex buffer rendering (enable client buffers)
|
|
||||||
// CIdvVertexBuffer::Enable(true);
|
|
||||||
// if (uiNumRegions > 0)
|
|
||||||
// pRegions[0].m_pVertexBuffer->EnableClientStates( );
|
|
||||||
//
|
|
||||||
// // run through the regions and render those that aren't culled
|
|
||||||
// for (unsigned int i = 0; i < uiNumRegions; ++i)
|
|
||||||
// {
|
|
||||||
// if (!pRegions[i].m_bCulled)
|
|
||||||
// {
|
|
||||||
// pRegions[i].m_pVertexBuffer->Bind( );
|
|
||||||
// unsigned int uiNumBlades = int(fDensity * pRegions[i].m_vBlades.size( ));
|
|
||||||
// glDrawArrays(GL_QUADS, 0, uiNumBlades * 4);
|
|
||||||
// nTriangleCount += uiNumBlades * 2;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // disable client buffers
|
|
||||||
// if (uiNumRegions > 0)
|
|
||||||
// pRegions[0].m_pVertexBuffer->DisableClientStates( );
|
|
||||||
// CIdvVertexBuffer::Disable(true);
|
|
||||||
//
|
|
||||||
// // restore opengl state
|
|
||||||
// glPopAttrib( );
|
|
||||||
|
|
||||||
return nTriangleCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassWrapper::InitFromBsfFile
|
|
||||||
|
|
||||||
bool CSpeedGrassWrapper::InitFromBsfFile(const char* pFilename,
|
|
||||||
unsigned int nNumBlades,
|
|
||||||
unsigned int uiRows,
|
|
||||||
unsigned int uiCols,
|
|
||||||
float fCollisionDistance)
|
|
||||||
{
|
|
||||||
bool bSuccess = false;
|
|
||||||
|
|
||||||
if (pFilename)
|
|
||||||
{
|
|
||||||
// use SpeedGrass's built-in parse function
|
|
||||||
if (ParseBsfFile(pFilename, nNumBlades, uiRows, uiCols, fCollisionDistance))
|
|
||||||
bSuccess = true;
|
|
||||||
}
|
|
||||||
InitGraphics( );
|
|
||||||
|
|
||||||
return bSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassWrapper::Color
|
|
||||||
|
|
||||||
float CSpeedGrassWrapper::Color(float fX, float fY, const float* pNormal, float* pTopColor, float* pBottomColor) const
|
|
||||||
{
|
|
||||||
const float c_fColorAdjust = 0.3f; // controls how much the color of the top vertices of each grass blade can vary
|
|
||||||
const float c_fColorThrow = 1.0f; // controls how much the r, g, and b components can vary
|
|
||||||
const float c_fColorRandomness = 0.01f; // controls how much the r, g, and b components can vary
|
|
||||||
const float c_TopLight = 0.75f;
|
|
||||||
|
|
||||||
float afLowColor[4] = { 0.0f }, afHighColor[4] = { 0.0f };
|
|
||||||
if (m_pMapOutdoor->GetBrushColor(fX, fY, afLowColor, afHighColor))
|
|
||||||
{
|
|
||||||
pBottomColor[0] = afLowColor[2];
|
|
||||||
pBottomColor[1] = afLowColor[1];
|
|
||||||
pBottomColor[2] = afLowColor[0];
|
|
||||||
|
|
||||||
float fColorThrow = GetRandom(0.0f, c_fColorThrow);
|
|
||||||
pTopColor[0] = VecInterpolate(pBottomColor[0], afHighColor[2], fColorThrow) + GetRandom(-c_fColorRandomness, c_fColorRandomness);
|
|
||||||
pTopColor[1] = VecInterpolate(pBottomColor[1], afHighColor[1], fColorThrow) + GetRandom(-c_fColorRandomness, c_fColorRandomness);
|
|
||||||
pTopColor[2] = VecInterpolate(pBottomColor[2], afHighColor[0], fColorThrow) + GetRandom(-c_fColorRandomness, c_fColorRandomness);
|
|
||||||
|
|
||||||
float fLargest = pTopColor[0];
|
|
||||||
if (pTopColor[1] > fLargest)
|
|
||||||
fLargest = pTopColor[1];
|
|
||||||
if (pTopColor[2] > fLargest)
|
|
||||||
fLargest = pTopColor[2];
|
|
||||||
if (fLargest > 1.0f)
|
|
||||||
{
|
|
||||||
pTopColor[0] /= fLargest;
|
|
||||||
pTopColor[1] /= fLargest;
|
|
||||||
pTopColor[2] /= fLargest;
|
|
||||||
}
|
|
||||||
pTopColor[0] = max(0.0f, pTopColor[0]);
|
|
||||||
pTopColor[1] = max(0.0f, pTopColor[1]);
|
|
||||||
pTopColor[2] = max(0.0f, pTopColor[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return afLowColor[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassWrapper::Height
|
|
||||||
|
|
||||||
float CSpeedGrassWrapper::Height(float fX, float fY, float* pNormal) const
|
|
||||||
{
|
|
||||||
float fHeight = 0.0f;
|
|
||||||
float afPos[3] = { fX, fY, 0.0f };
|
|
||||||
fHeight = m_pMapOutdoor->GetHeight(afPos);
|
|
||||||
|
|
||||||
pNormal[0] = 0.0f;
|
|
||||||
pNormal[1] = 0.0f;
|
|
||||||
pNormal[2] = 1.0f;
|
|
||||||
|
|
||||||
return fHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassWrapper::InitGraphics
|
|
||||||
|
|
||||||
void CSpeedGrassWrapper::InitGraphics(void)
|
|
||||||
{
|
|
||||||
// load texture
|
|
||||||
// m_uiTexture = LoadDDS((c_strDataPath + string("brush_2.dds")).c_str( ));
|
|
||||||
CGraphicImage * pImage = (CGraphicImage *) CResourceManager::Instance().GetResourcePointer("D:/ymir work/special/brush_2.dds");
|
|
||||||
m_GrassImageInstance.SetImagePointer(pImage);
|
|
||||||
m_lpD3DTexure8 = m_GrassImageInstance.GetTexturePointer()->GetD3DTexture();
|
|
||||||
|
|
||||||
// prepare static vertex buffers
|
|
||||||
for (int i = 0; i < m_nNumRegions; ++i)
|
|
||||||
{
|
|
||||||
SRegion* pRegion = m_pRegions + i;
|
|
||||||
|
|
||||||
// pRegion->m_pVertexBuffer = new CIdvVertexBuffer;
|
|
||||||
|
|
||||||
// setup up temporary buffer to copy later
|
|
||||||
const int c_nNumCorners = 4;
|
|
||||||
unsigned int uiNumBlades = pRegion->m_vBlades.size( );
|
|
||||||
unsigned int uiBufferSize = uiNumBlades * c_nNumCorners * c_nGrassVertexTotalSize;
|
|
||||||
unsigned char* pBuffer = new unsigned char[uiBufferSize];
|
|
||||||
|
|
||||||
// setup initial pointers for individual attribute copying
|
|
||||||
float* pTexCoords0 = reinterpret_cast<float*>(pBuffer + 0);
|
|
||||||
float* pTexCoords1 = reinterpret_cast<float*>(pTexCoords0 + c_nGrassVertexTexture0Size * uiNumBlades * c_nNumCorners / sizeof(float));
|
|
||||||
unsigned char* pColors = (unsigned char*) pTexCoords1 + c_nGrassVertexTexture1Size * uiNumBlades * c_nNumCorners;
|
|
||||||
float* pPositions = reinterpret_cast<float*>(pColors + c_nGrassVertexColorSize * uiNumBlades * c_nNumCorners);
|
|
||||||
|
|
||||||
for (vector<SBlade>::const_iterator iBlade = pRegion->m_vBlades.begin( ); iBlade != pRegion->m_vBlades.end( ); ++iBlade)
|
|
||||||
{
|
|
||||||
float fS1 = float(iBlade->m_ucWhichTexture) / c_nNumBladeMaps;
|
|
||||||
float fS2 = float(iBlade->m_ucWhichTexture + 1) / c_nNumBladeMaps;
|
|
||||||
|
|
||||||
for (int nCorner = 0; nCorner < c_nNumCorners; ++nCorner)
|
|
||||||
{
|
|
||||||
// texcoord 0
|
|
||||||
switch (nCorner)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
pTexCoords0[0] = fS2;
|
|
||||||
pTexCoords0[1] = 1.0f;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
pTexCoords0[0] = fS1;
|
|
||||||
pTexCoords0[1] = 1.0f;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
pTexCoords0[0] = fS1;
|
|
||||||
pTexCoords0[1] = 0.0f;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
pTexCoords0[0] = fS2;
|
|
||||||
pTexCoords0[1] = 0.0f;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
pTexCoords0 += c_nGrassVertexTexture0Size / sizeof(float);
|
|
||||||
|
|
||||||
// texcoord 1
|
|
||||||
switch (nCorner)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
pTexCoords1[0] = c_nShaderGrassBillboard;
|
|
||||||
pTexCoords1[2] = iBlade->m_fThrow;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
pTexCoords1[0] = c_nShaderGrassBillboard + 1;
|
|
||||||
pTexCoords1[2] = iBlade->m_fThrow;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
pTexCoords1[0] = c_nShaderGrassBillboard + 2;
|
|
||||||
pTexCoords1[2] = 0.0f;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
pTexCoords1[0] = c_nShaderGrassBillboard + 3;
|
|
||||||
pTexCoords1[2] = 0.0f;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
// same for all corners
|
|
||||||
pTexCoords1[1] = iBlade->m_fSize;
|
|
||||||
pTexCoords1[3] = iBlade->m_fNoise;
|
|
||||||
pTexCoords1 += c_nGrassVertexTexture1Size / sizeof(float);
|
|
||||||
|
|
||||||
// color
|
|
||||||
unsigned long ulColor = 0;
|
|
||||||
if (nCorner == 0 || nCorner == 1)
|
|
||||||
ulColor = (int(iBlade->m_afTopColor[0] * 255.0f) << 0) +
|
|
||||||
(int(iBlade->m_afTopColor[1] * 255.0f) << 8) +
|
|
||||||
(int(iBlade->m_afTopColor[2] * 255.0f) << 16) +
|
|
||||||
0xff000000;
|
|
||||||
else
|
|
||||||
ulColor = (int(iBlade->m_afBottomColor[0] * 255.0f) << 0) +
|
|
||||||
(int(iBlade->m_afBottomColor[1] * 255.0f) << 8) +
|
|
||||||
(int(iBlade->m_afBottomColor[2] * 255.0f) << 16) +
|
|
||||||
0xff000000;
|
|
||||||
memcpy(pColors, &ulColor, c_nGrassVertexColorSize);
|
|
||||||
pColors += c_nGrassVertexColorSize;
|
|
||||||
|
|
||||||
// position
|
|
||||||
memcpy(pPositions, iBlade->m_afPos, c_nGrassVertexPositionSize);
|
|
||||||
pPositions += c_nGrassVertexPositionSize / sizeof(float);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// assert((unsigned char*) pTexCoords0 - pBuffer == c_nGrassVertexTexture0Size * uiNumBlades * c_nNumCorners);
|
|
||||||
// assert(pTexCoords1 - pTexCoords0 == (c_nGrassVertexTexture1Size * uiNumBlades * c_nNumCorners) / sizeof(float));
|
|
||||||
// assert(pColors - (unsigned char*) pTexCoords1 == c_nGrassVertexColorSize * uiNumBlades * c_nNumCorners);
|
|
||||||
// assert((unsigned char*) pPositions - pColors == c_nGrassVertexPositionSize * uiNumBlades * c_nNumCorners);
|
|
||||||
|
|
||||||
// pRegion->m_pVertexBuffer->SetBuffer(pBuffer, uiBufferSize, true);
|
|
||||||
// pRegion->m_pVertexBuffer->SetStride(CIdvVertexBuffer::VERTEX_TEXCOORD0, 2, GL_FLOAT, 0, 0);
|
|
||||||
// pRegion->m_pVertexBuffer->SetStride(CIdvVertexBuffer::VERTEX_TEXCOORD1, 4, GL_FLOAT, 0, (unsigned char*) pTexCoords0 - pBuffer);
|
|
||||||
// pRegion->m_pVertexBuffer->SetStride(CIdvVertexBuffer::VERTEX_COLOR, 4, GL_UNSIGNED_BYTE, 0, (unsigned char*) pTexCoords1 - pBuffer);
|
|
||||||
// pRegion->m_pVertexBuffer->SetStride(CIdvVertexBuffer::VERTEX_POSITION, 3, GL_FLOAT, 0, pColors - pBuffer);
|
|
||||||
|
|
||||||
DWORD dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1;
|
|
||||||
// pRegion->m_VertexBuffer.Create();
|
|
||||||
|
|
||||||
delete[] pBuffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // USE_SPEEDGRASS
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedGrassWrapper Class
|
|
||||||
//
|
|
||||||
// (c) 2003 IDV, Inc.
|
|
||||||
//
|
|
||||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
|
||||||
//
|
|
||||||
// This software is supplied under the terms of a license agreement or
|
|
||||||
// nondisclosure agreement with Interactive Data Visualization and may
|
|
||||||
// not be copied or disclosed except in accordance with the terms of
|
|
||||||
// that agreement.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2001-2003 IDV, Inc.
|
|
||||||
// All Rights Reserved.
|
|
||||||
//
|
|
||||||
// IDV, Inc.
|
|
||||||
// 1233 Washington St. Suite 610
|
|
||||||
// Columbia, SC 29201
|
|
||||||
// Voice: (803) 799-1699
|
|
||||||
// Fax: (803) 931-0320
|
|
||||||
// Web: http://www.idvinc.com
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
//#include "SpeedGrassRT.h"
|
|
||||||
#ifdef USE_SPEEDGRASS
|
|
||||||
//#include "../Common Source/IdvVertexBuffer.h"
|
|
||||||
//#include <vector>
|
|
||||||
|
|
||||||
// forward reference
|
|
||||||
//class CScene;
|
|
||||||
class CMapOutdoor;
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// class CSpeedGrassWrapper declaration
|
|
||||||
|
|
||||||
class CSpeedGrassWrapper : public CSpeedGrassRT
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CSpeedGrassWrapper( );
|
|
||||||
virtual ~CSpeedGrassWrapper( );
|
|
||||||
|
|
||||||
void SetMapOutdoor(CMapOutdoor* pMapOutdoor) { m_pMapOutdoor = pMapOutdoor; }
|
|
||||||
int Draw(float fDensity);
|
|
||||||
bool InitFromBsfFile(const char* pFilename,
|
|
||||||
unsigned int nNumBlades,
|
|
||||||
unsigned int uiRows,
|
|
||||||
unsigned int uiCols,
|
|
||||||
float fCollisionDistance);
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual float Color(float fX, float fY, const float* pNormal, float* pTopColor, float* pBottomColor) const;
|
|
||||||
virtual float Height(float fX, float fY, float* pNormal) const;
|
|
||||||
void InitGraphics(void);
|
|
||||||
|
|
||||||
CMapOutdoor * m_pMapOutdoor;
|
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE8 m_lpD3DTexure8;
|
|
||||||
|
|
||||||
CGraphicImageInstance m_GrassImageInstance;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // USE_SPEEDGRASS
|
|
@ -22,15 +22,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
const int c_nNumWindMatrices = 4;
|
const int c_nNumWindMatrices = 40;
|
||||||
const int c_nNumInstancesPerModel = 10;
|
const float c_fNearLodFactor = 1000000000.0f;
|
||||||
const float c_fForestSize = 200.0f;
|
const float c_fFarLodFactor = 50000000000.0f;
|
||||||
const float c_fSpacingTolerance = 30.0f;
|
|
||||||
const int c_nMaxPlacementIterations = 500;
|
|
||||||
const int c_nDefaultAlphaTestValue = 84;
|
|
||||||
const float c_fNearLodFactor = 2.0f;
|
|
||||||
const float c_fFarLodFactor = 9.0f;
|
|
||||||
const float c_fBenchmarkPeriod = 1.0f;
|
|
||||||
|
|
||||||
// vertex shader constant locations
|
// vertex shader constant locations
|
||||||
const int c_nVertexShader_LeafLightingAdjustment = 70;
|
const int c_nVertexShader_LeafLightingAdjustment = 70;
|
||||||
@ -42,14 +36,6 @@ const int c_nVertexShader_WindMatrices = 54;
|
|||||||
const int c_nVertexShader_LeafTables = 4;
|
const int c_nVertexShader_LeafTables = 4;
|
||||||
const int c_nVertexShader_Fog = 85;
|
const int c_nVertexShader_Fog = 85;
|
||||||
|
|
||||||
// lighting
|
|
||||||
const float c_afLightPosition[4] = { -0.707f, 0.0f, 0.707f, 0.0f };
|
|
||||||
const float c_afLightAmbient[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
|
||||||
const float c_afLightDiffuse[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
||||||
const float c_afLightSpecular[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
||||||
const float c_afLightGlobalAmbient[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
|
||||||
|
|
||||||
|
|
||||||
// setup lighting (enable ONE of the two below)
|
// setup lighting (enable ONE of the two below)
|
||||||
#define WRAPPER_USE_STATIC_LIGHTING
|
#define WRAPPER_USE_STATIC_LIGHTING
|
||||||
//#define WRAPPER_USE_DYNAMIC_LIGHTING
|
//#define WRAPPER_USE_DYNAMIC_LIGHTING
|
||||||
@ -91,8 +77,8 @@ const float c_afLightGlobalAmbient[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// loading from STF or clones/instances? (enable ONE of the two below)
|
// loading from STF or clones/instances? (enable ONE of the two below)
|
||||||
//#define WRAPPER_FOREST_FROM_STF
|
#define WRAPPER_FOREST_FROM_STF
|
||||||
#define WRAPPER_FOREST_FROM_INSTANCES
|
//#define WRAPPER_FOREST_FROM_INSTANCES
|
||||||
|
|
||||||
#if defined WRAPPER_FOREST_FROM_STF && defined WRAPPER_FOREST_FROM_INSTANCES
|
#if defined WRAPPER_FOREST_FROM_STF && defined WRAPPER_FOREST_FROM_INSTANCES
|
||||||
#error Please define exactly one loading mechanism
|
#error Please define exactly one loading mechanism
|
||||||
@ -103,18 +89,18 @@ const float c_afLightGlobalAmbient[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
|||||||
//#define WRAPPER_RENDER_HORIZONTAL_BILLBOARD
|
//#define WRAPPER_RENDER_HORIZONTAL_BILLBOARD
|
||||||
|
|
||||||
// render self-shadows
|
// render self-shadows
|
||||||
#define WRAPPER_RENDER_SELF_SHADOWS
|
//#define WRAPPER_RENDER_SELF_SHADOWS
|
||||||
|
|
||||||
// use fog
|
// use fog
|
||||||
#define WRAPPER_USE_FOG
|
#define WRAPPER_USE_FOG
|
||||||
|
|
||||||
// derived constants
|
// derived constants
|
||||||
#ifdef WRAPPER_USE_GPU_WIND
|
//#ifdef WRAPPER_USE_GPU_WIND
|
||||||
#define BRANCHES_USE_SHADERS
|
// #define BRANCHES_USE_SHADERS
|
||||||
#define FRONDS_USE_SHADERS
|
// #define FRONDS_USE_SHADERS
|
||||||
#define LEAVES_USE_SHADERS
|
// #define LEAVES_USE_SHADERS
|
||||||
#endif
|
//#endif
|
||||||
|
//
|
||||||
#ifdef WRAPPER_USE_GPU_LEAF_PLACEMENT
|
//#ifdef WRAPPER_USE_GPU_LEAF_PLACEMENT
|
||||||
#define LEAVES_USE_SHADERS
|
// #define LEAVES_USE_SHADERS
|
||||||
#endif
|
//#endif
|
||||||
|
@ -87,6 +87,7 @@ BOOL CSpeedTreeForest::GetMainTree(DWORD dwCRC, CSpeedTreeWrapper ** ppMainTree,
|
|||||||
if (!pTree->LoadTree(c_pszFileName, (const BYTE *) c_pvData, file.Size()))
|
if (!pTree->LoadTree(c_pszFileName, (const BYTE *) c_pvData, file.Size()))
|
||||||
{
|
{
|
||||||
delete pTree;
|
delete pTree;
|
||||||
|
pTree = nullptr;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,63 +231,12 @@ void CSpeedTreeForest::SetupWindMatrices(float fTimeInSecs)
|
|||||||
afMatrix[9] = -fSinX;
|
afMatrix[9] = -fSinX;
|
||||||
afMatrix[10] = fCosX * fCosY;
|
afMatrix[10] = fCosX * fCosY;
|
||||||
afMatrix[15] = 1.0f;
|
afMatrix[15] = 1.0f;
|
||||||
|
|
||||||
#ifdef WRAPPER_USE_CPU_WIND
|
|
||||||
CSpeedTreeRT::SetWindMatrix(j, afMatrix);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WRAPPER_USE_GPU_WIND
|
|
||||||
// graphics API specific
|
|
||||||
UploadWindMatrix(c_nVertexShader_WindMatrices + j * 4, afMatrix);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// track wind strength
|
// track wind strength
|
||||||
fOldStrength = m_fWindStrength;
|
fOldStrength = m_fWindStrength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedTreeForest::SetLodLimits
|
|
||||||
/*
|
|
||||||
void CSpeedTreeForest::SetLodLimits(void)
|
|
||||||
{
|
|
||||||
// find tallest tree
|
|
||||||
float fTallest = -1.0f;
|
|
||||||
|
|
||||||
TTreeMap::iterator itor = m_pMainTreeMap.begin();
|
|
||||||
UINT uiCount;
|
|
||||||
|
|
||||||
while (itor != m_pMainTreeMap.end())
|
|
||||||
{
|
|
||||||
CSpeedTreeWrapper * pMainTree = (itor++)->second;
|
|
||||||
CSpeedTreeWrapper ** ppInstances = pMainTree->GetInstances(uiCount);
|
|
||||||
|
|
||||||
float fHeight;
|
|
||||||
fHeight = pMainTree->GetBoundingBox()[5] - pMainTree->GetBoundingBox()[0];
|
|
||||||
fTallest = __max(fHeight, fTallest);
|
|
||||||
|
|
||||||
for (UINT i = 0; i < uiCount; ++i)
|
|
||||||
{
|
|
||||||
fHeight = ppInstances[i]->GetBoundingBox()[5] - ppInstances[i]->GetBoundingBox()[0];
|
|
||||||
fTallest = __max(fHeight, fTallest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
itor = m_pMainTreeMap.begin();
|
|
||||||
|
|
||||||
while (itor != m_pMainTreeMap.end())
|
|
||||||
{
|
|
||||||
CSpeedTreeWrapper * pMainTree = (itor++)->second;
|
|
||||||
CSpeedTreeWrapper ** ppInstances = pMainTree->GetInstances(uiCount);
|
|
||||||
|
|
||||||
pMainTree->GetSpeedTree()->SetLodLimits(fTallest * c_fNearLodFactor, fTallest * c_fFarLodFactor);
|
|
||||||
|
|
||||||
for (UINT i = 0; i < uiCount; ++i)
|
|
||||||
ppInstances[i]->GetSpeedTree()->SetLodLimits(fTallest * c_fNearLodFactor, fTallest * c_fFarLodFactor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
void CSpeedTreeForest::SetLight(const float * afDirection, const float * afAmbient, const float * afDiffuse)
|
void CSpeedTreeForest::SetLight(const float * afDirection, const float * afAmbient, const float * afDiffuse)
|
||||||
{
|
{
|
||||||
m_afLighting[0] = afDirection[0];
|
m_afLighting[0] = afDirection[0];
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// Include Files
|
// Include Files
|
||||||
#include <SpeedTreeRT.h>
|
#include <speedtree/SpeedTreeRT.h>
|
||||||
#include "SpeedTreeWrapper.h"
|
#include "SpeedTreeWrapper.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -52,7 +52,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// class CSpeedTreeForest declaration
|
// class CSpeedTreeForest declaration
|
||||||
|
|
||||||
class CSpeedTreeForest
|
class CSpeedTreeForest : public CSingleton<CSpeedTreeForest>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::map<DWORD, CSpeedTreeWrapper *> TTreeMap;
|
typedef std::map<DWORD, CSpeedTreeWrapper *> TTreeMap;
|
||||||
@ -71,8 +71,6 @@ class CSpeedTreeForest
|
|||||||
CSpeedTreeWrapper * CreateInstance(float x, float y, float z, DWORD dwTreeCRC, const char * c_pszTreeName);
|
CSpeedTreeWrapper * CreateInstance(float x, float y, float z, DWORD dwTreeCRC, const char * c_pszTreeName);
|
||||||
void DeleteInstance(CSpeedTreeWrapper * pTree);
|
void DeleteInstance(CSpeedTreeWrapper * pTree);
|
||||||
|
|
||||||
//void SetLodLimits(void);
|
|
||||||
|
|
||||||
void UpdateSystem(float fCurrentTime);
|
void UpdateSystem(float fCurrentTime);
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
@ -90,8 +88,10 @@ class CSpeedTreeForest
|
|||||||
|
|
||||||
// overridden by specific graphics API
|
// overridden by specific graphics API
|
||||||
virtual void UploadWindMatrix(unsigned int uiLocation, const float* pMatrix) const = 0;
|
virtual void UploadWindMatrix(unsigned int uiLocation, const float* pMatrix) const = 0;
|
||||||
virtual void Render(unsigned long ulRenderBitVector) = 0;
|
virtual void Render(unsigned long ulRenderBitVector = Forest_RenderAll) = 0;
|
||||||
|
virtual bool SetRenderingDevice() = 0;
|
||||||
|
virtual void UpdateCompundMatrix(const D3DXVECTOR3& c_rEyeVec, const D3DXMATRIX& c_rmatView, const D3DXMATRIX& c_rmatProj) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TTreeMap m_pMainTreeMap;
|
TTreeMap m_pMainTreeMap;
|
||||||
|
|
||||||
|
@ -1,344 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedTreeForestDirectX8 Class
|
|
||||||
//
|
|
||||||
// (c) 2003 IDV, Inc.
|
|
||||||
//
|
|
||||||
// This class is provided to illustrate one way to incorporate
|
|
||||||
// SpeedTreeRT into an OpenGL application. All of the SpeedTreeRT
|
|
||||||
// calls that must be made on a per tree basis are done by this class.
|
|
||||||
// Calls that apply to all trees (i.e. static SpeedTreeRT functions)
|
|
||||||
// are made in the functions in main.cpp.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
|
||||||
//
|
|
||||||
// This software is supplied under the terms of a license agreement or
|
|
||||||
// nondisclosure agreement with Interactive Data Visualization and may
|
|
||||||
// not be copied or disclosed except in accordance with the terms of
|
|
||||||
// that agreement.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2001-2003 IDV, Inc.
|
|
||||||
// All Rights Reserved.
|
|
||||||
//
|
|
||||||
// IDV, Inc.
|
|
||||||
// 1233 Washington St. Suite 610
|
|
||||||
// Columbia, SC 29201
|
|
||||||
// Voice: (803) 799-1699
|
|
||||||
// Fax: (803) 931-0320
|
|
||||||
// Web: http://www.idvinc.com
|
|
||||||
|
|
||||||
#include "StdAfx.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <d3d8.h>
|
|
||||||
#include <d3d8types.h>
|
|
||||||
#include <d3dx8.h>
|
|
||||||
|
|
||||||
#include "../eterBase/Timer.h"
|
|
||||||
#include "../eterlib/StateManager.h"
|
|
||||||
#include "../eterlib/Camera.h"
|
|
||||||
|
|
||||||
#include "SpeedTreeForestDirectX8.h"
|
|
||||||
#include "SpeedTreeConfig.h"
|
|
||||||
#include "VertexShaders.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedTreeForestDirectX8::CSpeedTreeForestDirectX8
|
|
||||||
|
|
||||||
CSpeedTreeForestDirectX8::CSpeedTreeForestDirectX8() : m_dwBranchVertexShader(0), m_dwLeafVertexShader(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedTreeForestDirectX8::~CSpeedTreeForestDirectX8
|
|
||||||
|
|
||||||
CSpeedTreeForestDirectX8::~CSpeedTreeForestDirectX8()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedTreeForestDirectX8::InitVertexShaders
|
|
||||||
bool CSpeedTreeForestDirectX8::InitVertexShaders(void)
|
|
||||||
{
|
|
||||||
NANOBEGIN
|
|
||||||
// load the vertex shaders
|
|
||||||
if (!m_dwBranchVertexShader)
|
|
||||||
m_dwBranchVertexShader = LoadBranchShader(m_pDx);
|
|
||||||
|
|
||||||
if (!m_dwLeafVertexShader)
|
|
||||||
m_dwLeafVertexShader = LoadLeafShader(m_pDx);
|
|
||||||
|
|
||||||
if (m_dwBranchVertexShader && m_dwLeafVertexShader)
|
|
||||||
{
|
|
||||||
CSpeedTreeWrapper::SetVertexShaders(m_dwBranchVertexShader, m_dwLeafVertexShader);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
NANOEND
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSpeedTreeForestDirectX8::SetRenderingDevice(LPDIRECT3DDEVICE8 lpDevice)
|
|
||||||
{
|
|
||||||
m_pDx = lpDevice;
|
|
||||||
|
|
||||||
if (!InitVertexShaders())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const float c_afLightPosition[4] = { -0.707f, -0.300f, 0.707f, 0.0f };
|
|
||||||
const float c_afLightAmbient[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
|
||||||
const float c_afLightDiffuse[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
||||||
const float c_afLightSpecular[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
||||||
|
|
||||||
float afLight1[] =
|
|
||||||
{
|
|
||||||
c_afLightPosition[0], c_afLightPosition[1], c_afLightPosition[2], // pos
|
|
||||||
c_afLightDiffuse[0], c_afLightDiffuse[1], c_afLightDiffuse[2], // diffuse
|
|
||||||
c_afLightAmbient[0], c_afLightAmbient[1], c_afLightAmbient[2], // ambient
|
|
||||||
c_afLightSpecular[0], c_afLightSpecular[1], c_afLightSpecular[2], // specular
|
|
||||||
c_afLightPosition[3], // directional flag
|
|
||||||
1.0f, 0.0f, 0.0f // attenuation (constant, linear, quadratic)
|
|
||||||
};
|
|
||||||
|
|
||||||
CSpeedTreeRT::SetNumWindMatrices(c_nNumWindMatrices);
|
|
||||||
|
|
||||||
CSpeedTreeRT::SetLightAttributes(0, afLight1);
|
|
||||||
CSpeedTreeRT::SetLightState(0, true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedTreeForestDirectX8::UploadWindMatrix
|
|
||||||
|
|
||||||
void CSpeedTreeForestDirectX8::UploadWindMatrix(UINT uiLocation, const float* pMatrix) const
|
|
||||||
{
|
|
||||||
STATEMANAGER.SetVertexShaderConstant(uiLocation, pMatrix, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSpeedTreeForestDirectX8::UpdateCompundMatrix(const D3DXVECTOR3 & c_rEyeVec, const D3DXMATRIX & c_rmatView, const D3DXMATRIX & c_rmatProj)
|
|
||||||
{
|
|
||||||
// setup composite matrix for shader
|
|
||||||
D3DXMATRIX matBlend;
|
|
||||||
D3DXMatrixIdentity(&matBlend);
|
|
||||||
|
|
||||||
D3DXMATRIX matBlendShader;
|
|
||||||
D3DXMatrixMultiply(&matBlendShader, &c_rmatView, &c_rmatProj);
|
|
||||||
|
|
||||||
float afDirection[3];
|
|
||||||
afDirection[0] = matBlendShader.m[0][2];
|
|
||||||
afDirection[1] = matBlendShader.m[1][2];
|
|
||||||
afDirection[2] = matBlendShader.m[2][2];
|
|
||||||
CSpeedTreeRT::SetCamera(c_rEyeVec, afDirection);
|
|
||||||
|
|
||||||
D3DXMatrixTranspose(&matBlendShader, &matBlendShader);
|
|
||||||
STATEMANAGER.SetVertexShaderConstant(c_nVertexShader_CompoundMatrix, &matBlendShader, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedTreeForestDirectX8::Render
|
|
||||||
|
|
||||||
void CSpeedTreeForestDirectX8::Render(unsigned long ulRenderBitVector)
|
|
||||||
{
|
|
||||||
UpdateSystem(CTimer::Instance().GetCurrentSecond());
|
|
||||||
|
|
||||||
if (m_pMainTreeMap.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!(ulRenderBitVector & Forest_RenderToShadow) && !(ulRenderBitVector & Forest_RenderToMiniMap))
|
|
||||||
UpdateCompundMatrix(CCameraManager::Instance().GetCurrentCamera()->GetEye(), ms_matView, ms_matProj);
|
|
||||||
|
|
||||||
DWORD dwLightState = STATEMANAGER.GetRenderState(D3DRS_LIGHTING);
|
|
||||||
DWORD dwColorVertexState = STATEMANAGER.GetRenderState(D3DRS_COLORVERTEX);
|
|
||||||
DWORD dwFogVertexMode = STATEMANAGER.GetRenderState(D3DRS_FOGVERTEXMODE);
|
|
||||||
|
|
||||||
#ifdef WRAPPER_USE_DYNAMIC_LIGHTING
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);
|
|
||||||
#else
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_COLORVERTEX, TRUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TTreeMap::iterator itor;
|
|
||||||
UINT uiCount;
|
|
||||||
|
|
||||||
itor = m_pMainTreeMap.begin();
|
|
||||||
|
|
||||||
while (itor != m_pMainTreeMap.end())
|
|
||||||
{
|
|
||||||
CSpeedTreeWrapper * pMainTree = (itor++)->second;
|
|
||||||
CSpeedTreeWrapper ** ppInstances = pMainTree->GetInstances(uiCount);
|
|
||||||
|
|
||||||
for (UINT i = 0; i < uiCount; ++i)
|
|
||||||
{
|
|
||||||
ppInstances[i]->Advance();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
STATEMANAGER.SetVertexShaderConstant(c_nVertexShader_Light, m_afLighting, 3);
|
|
||||||
STATEMANAGER.SetVertexShaderConstant(c_nVertexShader_Fog, m_afFog, 1);
|
|
||||||
|
|
||||||
if (ulRenderBitVector & Forest_RenderToShadow)
|
|
||||||
{
|
|
||||||
//STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
|
||||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
|
||||||
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, TRUE);
|
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
|
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_CW);
|
|
||||||
|
|
||||||
// set up fog if it is enabled
|
|
||||||
if (STATEMANAGER.GetRenderState(D3DRS_FOGENABLE))
|
|
||||||
{
|
|
||||||
#ifdef WRAPPER_USE_GPU_WIND
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_NONE); // GPU needs to work on all cards
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// choose fixed function pipeline or custom shader for fronds and branches
|
|
||||||
STATEMANAGER.SetVertexShader(m_dwBranchVertexShader);
|
|
||||||
|
|
||||||
// render branches
|
|
||||||
if (ulRenderBitVector & Forest_RenderBranches)
|
|
||||||
{
|
|
||||||
itor = m_pMainTreeMap.begin();
|
|
||||||
|
|
||||||
while (itor != m_pMainTreeMap.end())
|
|
||||||
{
|
|
||||||
CSpeedTreeWrapper * pMainTree = (itor++)->second;
|
|
||||||
CSpeedTreeWrapper ** ppInstances = pMainTree->GetInstances(uiCount);
|
|
||||||
|
|
||||||
pMainTree->SetupBranchForTreeType();
|
|
||||||
|
|
||||||
for (UINT i = 0; i < uiCount; ++i)
|
|
||||||
if (ppInstances[i]->isShow())
|
|
||||||
ppInstances[i]->RenderBranches();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set render states
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
|
||||||
|
|
||||||
// render fronds
|
|
||||||
if (ulRenderBitVector & Forest_RenderFronds)
|
|
||||||
{
|
|
||||||
itor = m_pMainTreeMap.begin();
|
|
||||||
|
|
||||||
while (itor != m_pMainTreeMap.end())
|
|
||||||
{
|
|
||||||
CSpeedTreeWrapper * pMainTree = (itor++)->second;
|
|
||||||
CSpeedTreeWrapper ** ppInstances = pMainTree->GetInstances(uiCount);
|
|
||||||
|
|
||||||
pMainTree->SetupFrondForTreeType();
|
|
||||||
|
|
||||||
for (UINT i = 0; i < uiCount; ++i)
|
|
||||||
if (ppInstances[i]->isShow())
|
|
||||||
ppInstances[i]->RenderFronds();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// render leaves
|
|
||||||
if (ulRenderBitVector & Forest_RenderLeaves)
|
|
||||||
{
|
|
||||||
STATEMANAGER.SetVertexShader(m_dwLeafVertexShader);
|
|
||||||
|
|
||||||
if (STATEMANAGER.GetRenderState(D3DRS_FOGENABLE))
|
|
||||||
{
|
|
||||||
#if defined WRAPPER_USE_GPU_WIND || defined WRAPPER_USE_GPU_LEAF_PLACEMENT
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_NONE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ulRenderBitVector & Forest_RenderToShadow || ulRenderBitVector & Forest_RenderToMiniMap)
|
|
||||||
{
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_NOTEQUAL);
|
|
||||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHAREF, 0x00000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
itor = m_pMainTreeMap.begin();
|
|
||||||
|
|
||||||
while (itor != m_pMainTreeMap.end())
|
|
||||||
{
|
|
||||||
CSpeedTreeWrapper * pMainTree = (itor++)->second;
|
|
||||||
CSpeedTreeWrapper ** ppInstances = pMainTree->GetInstances(uiCount);
|
|
||||||
|
|
||||||
pMainTree->SetupLeafForTreeType();
|
|
||||||
|
|
||||||
for (UINT i = 0; i < uiCount; ++i)
|
|
||||||
if (ppInstances[i]->isShow())
|
|
||||||
ppInstances[i]->RenderLeaves();
|
|
||||||
}
|
|
||||||
|
|
||||||
while (itor != m_pMainTreeMap.end())
|
|
||||||
(itor++)->second->EndLeafForTreeType();
|
|
||||||
|
|
||||||
if (ulRenderBitVector & Forest_RenderToShadow || ulRenderBitVector & Forest_RenderToMiniMap)
|
|
||||||
{
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
|
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHAREF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// render billboards
|
|
||||||
#ifndef WRAPPER_NO_BILLBOARD_MODE
|
|
||||||
if (ulRenderBitVector & Forest_RenderBillboards)
|
|
||||||
{
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_COLORVERTEX, FALSE);
|
|
||||||
|
|
||||||
itor = m_pMainTreeMap.begin();
|
|
||||||
|
|
||||||
while (itor != m_pMainTreeMap.end())
|
|
||||||
{
|
|
||||||
CSpeedTreeWrapper * pMainTree = (itor++)->second;
|
|
||||||
CSpeedTreeWrapper ** ppInstances = pMainTree->GetInstances(uiCount);
|
|
||||||
|
|
||||||
pMainTree->SetupBranchForTreeType();
|
|
||||||
|
|
||||||
for (UINT i = 0; i < uiCount; ++i)
|
|
||||||
if (ppInstances[i]->isShow())
|
|
||||||
ppInstances[i]->RenderBillboards();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, dwLightState);
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_COLORVERTEX, dwColorVertexState);
|
|
||||||
STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, dwFogVertexMode);
|
|
||||||
|
|
||||||
// 셀프섀도우로 쓰는 TextureStage 1의 COLOROP와 ALPHAOP를 꺼줘야 다음 렌더링 할 놈들이
|
|
||||||
// 제대로 나온다. (안그러면 검게 나올 가능성이..)
|
|
||||||
if (!(ulRenderBitVector & Forest_RenderToShadow))
|
|
||||||
{
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
|
||||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHATESTENABLE);
|
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHAFUNC);
|
|
||||||
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
|
|
||||||
}
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// CSpeedTreeForestOpenGL Class
|
|
||||||
//
|
|
||||||
// (c) 2003 IDV, Inc.
|
|
||||||
//
|
|
||||||
// This class is provided to illustrate one way to incorporate
|
|
||||||
// SpeedTreeRT into an OpenGL application. All of the SpeedTreeRT
|
|
||||||
// calls that must be made on a per tree basis are done by this class.
|
|
||||||
// Calls that apply to all trees (i.e. static SpeedTreeRT functions)
|
|
||||||
// are made in the functions in main.cpp.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
|
||||||
//
|
|
||||||
// This software is supplied under the terms of a license agreement or
|
|
||||||
// nondisclosure agreement with Interactive Data Visualization and may
|
|
||||||
// not be copied or disclosed except in accordance with the terms of
|
|
||||||
// that agreement.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2001-2003 IDV, Inc.
|
|
||||||
// All Rights Reserved.
|
|
||||||
//
|
|
||||||
// IDV, Inc.
|
|
||||||
// 1233 Washington St. Suite 610
|
|
||||||
// Columbia, SC 29201
|
|
||||||
// Voice: (803) 799-1699
|
|
||||||
// Fax: (803) 931-0320
|
|
||||||
// Web: http://www.idvinc.com
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// Include Files
|
|
||||||
|
|
||||||
//#include <map>
|
|
||||||
#define SPEEDTREE_DATA_FORMAT_DIRECTX
|
|
||||||
|
|
||||||
#include "SpeedTreeForest.h"
|
|
||||||
#include "SpeedTreeMaterial.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// class CSpeedTreeForestDirectX8 declaration
|
|
||||||
class CSpeedTreeForestDirectX8 : public CSpeedTreeForest, public CGraphicBase, public CSingleton<CSpeedTreeForestDirectX8>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CSpeedTreeForestDirectX8();
|
|
||||||
virtual ~CSpeedTreeForestDirectX8();
|
|
||||||
|
|
||||||
void UploadWindMatrix(unsigned int uiLocation, const float* pMatrix) const;
|
|
||||||
void UpdateCompundMatrix(const D3DXVECTOR3 & c_rEyeVec, const D3DXMATRIX & c_rmatView, const D3DXMATRIX & c_rmatProj);
|
|
||||||
|
|
||||||
void Render(unsigned long ulRenderBitVector = Forest_RenderAll);
|
|
||||||
bool SetRenderingDevice(LPDIRECT3DDEVICE8 pDevice);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool InitVertexShaders();
|
|
||||||
|
|
||||||
private:
|
|
||||||
LPDIRECT3DDEVICE8 m_pDx; // the rendering context
|
|
||||||
|
|
||||||
DWORD m_dwBranchVertexShader; // branch/frond vertex shaders
|
|
||||||
DWORD m_dwLeafVertexShader; // leaf vertex shader
|
|
||||||
};
|
|
@ -339,46 +339,7 @@
|
|||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="SpeedGrassRT.cpp">
|
<ClCompile Include="CSpeedTreeDirectX.cpp" />
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
|
||||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
|
||||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="SpeedGrassWrapper.cpp">
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
|
||||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
|
||||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="SpeedTreeForest.cpp">
|
<ClCompile Include="SpeedTreeForest.cpp">
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||||
@ -399,26 +360,6 @@
|
|||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="SpeedTreeForestDirectX8.cpp">
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
|
||||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
|
||||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="SpeedTreeWrapper.cpp">
|
<ClCompile Include="SpeedTreeWrapper.cpp">
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||||
@ -457,11 +398,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="BoundaryShapeManager.h" />
|
<ClInclude Include="BoundaryShapeManager.h" />
|
||||||
<ClInclude Include="Constants.h" />
|
<ClInclude Include="Constants.h" />
|
||||||
<ClInclude Include="SpeedGrassRT.h" />
|
<ClInclude Include="CSpeedTreeDirectX.h" />
|
||||||
<ClInclude Include="SpeedGrassWrapper.h" />
|
|
||||||
<ClInclude Include="SpeedTreeConfig.h" />
|
<ClInclude Include="SpeedTreeConfig.h" />
|
||||||
<ClInclude Include="SpeedTreeForest.h" />
|
<ClInclude Include="SpeedTreeForest.h" />
|
||||||
<ClInclude Include="SpeedTreeForestDirectX8.h" />
|
|
||||||
<ClInclude Include="SpeedTreeMaterial.h" />
|
<ClInclude Include="SpeedTreeMaterial.h" />
|
||||||
<ClInclude Include="SpeedTreeWrapper.h" />
|
<ClInclude Include="SpeedTreeWrapper.h" />
|
||||||
<ClInclude Include="StdAfx.h" />
|
<ClInclude Include="StdAfx.h" />
|
||||||
|
@ -14,24 +14,18 @@
|
|||||||
<ClCompile Include="BoundaryShapeManager.cpp">
|
<ClCompile Include="BoundaryShapeManager.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="SpeedGrassRT.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="SpeedGrassWrapper.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="SpeedTreeForest.cpp">
|
<ClCompile Include="SpeedTreeForest.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="SpeedTreeForestDirectX8.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="SpeedTreeWrapper.cpp">
|
<ClCompile Include="SpeedTreeWrapper.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="StdAfx.cpp">
|
<ClCompile Include="StdAfx.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="CSpeedTreeDirectX.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="BoundaryShapeManager.h">
|
<ClInclude Include="BoundaryShapeManager.h">
|
||||||
@ -40,21 +34,12 @@
|
|||||||
<ClInclude Include="Constants.h">
|
<ClInclude Include="Constants.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="SpeedGrassRT.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="SpeedGrassWrapper.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="SpeedTreeConfig.h">
|
<ClInclude Include="SpeedTreeConfig.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="SpeedTreeForest.h">
|
<ClInclude Include="SpeedTreeForest.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="SpeedTreeForestDirectX8.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="SpeedTreeMaterial.h">
|
<ClInclude Include="SpeedTreeMaterial.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -67,5 +52,8 @@
|
|||||||
<ClInclude Include="VertexShaders.h">
|
<ClInclude Include="VertexShaders.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="CSpeedTreeDirectX.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -30,14 +30,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// Include Files
|
// Include Files
|
||||||
|
|
||||||
#include <d3d8.h>
|
#include <d3d9.h>
|
||||||
#include <d3d8types.h>
|
#include <d3d9types.h>
|
||||||
#include <d3dx8.h>
|
#include <directxsdk/d3dx9.h>
|
||||||
|
#include "../eterLib/StateManager.h"
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// class CSpeedTreeMaterial declaration/definiton
|
// class CSpeedTreeMaterial declaration/definiton
|
||||||
|
|
||||||
class CSpeedTreeMaterial
|
class CSpeedTreeMaterial
|
||||||
@ -45,10 +46,10 @@ class CSpeedTreeMaterial
|
|||||||
public:
|
public:
|
||||||
CSpeedTreeMaterial()
|
CSpeedTreeMaterial()
|
||||||
{
|
{
|
||||||
m_cMaterial.Ambient.r = m_cMaterial.Diffuse.r = m_cMaterial.Specular.r = m_cMaterial.Emissive.r = 1.0f;
|
m_cMaterial.Ambient.r = m_cMaterial.Diffuse.r = m_cMaterial.Specular.r = m_cMaterial.Emissive.r = 3.0f;
|
||||||
m_cMaterial.Ambient.g = m_cMaterial.Diffuse.g = m_cMaterial.Specular.g = m_cMaterial.Emissive.g = 1.0f;
|
m_cMaterial.Ambient.g = m_cMaterial.Diffuse.g = m_cMaterial.Specular.g = m_cMaterial.Emissive.g = 3.0f;
|
||||||
m_cMaterial.Ambient.b = m_cMaterial.Diffuse.b = m_cMaterial.Specular.b = m_cMaterial.Emissive.b = 1.0f;
|
m_cMaterial.Ambient.b = m_cMaterial.Diffuse.b = m_cMaterial.Specular.b = m_cMaterial.Emissive.b = 3.0f;
|
||||||
m_cMaterial.Ambient.a = m_cMaterial.Diffuse.a = m_cMaterial.Specular.a = m_cMaterial.Emissive.a = 1.0f;
|
m_cMaterial.Ambient.a = m_cMaterial.Diffuse.a = m_cMaterial.Specular.a = m_cMaterial.Emissive.a = 3.0f;
|
||||||
m_cMaterial.Power = 5.0f;
|
m_cMaterial.Power = 5.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,12 +69,11 @@ class CSpeedTreeMaterial
|
|||||||
|
|
||||||
m_cMaterial.Power = pMaterialArray[12];
|
m_cMaterial.Power = pMaterialArray[12];
|
||||||
}
|
}
|
||||||
|
|
||||||
D3DMATERIAL8 * Get()
|
void Activate(const LPDIRECT3DDEVICE9& pDx) const
|
||||||
{
|
{
|
||||||
return &m_cMaterial;
|
STATEMANAGER.SetMaterial(&m_cMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
D3DMATERIAL9 m_cMaterial; // the material object
|
||||||
D3DMATERIAL8 m_cMaterial; // the material object
|
};
|
||||||
};
|
|
File diff suppressed because it is too large
Load Diff
@ -29,17 +29,16 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#pragma warning (disable : 4786)
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// Include files
|
// Include files
|
||||||
|
|
||||||
#include "SpeedTreeMaterial.h"
|
#include "SpeedTreeMaterial.h"
|
||||||
#include <SpeedTreeRT.h>
|
#include <speedtree/SpeedTreeRT.h>
|
||||||
|
|
||||||
#include <d3d8.h>
|
#include <d3d9.h>
|
||||||
#include <d3d8types.h>
|
#include <d3d9types.h>
|
||||||
#include <d3dx8.h>
|
#include <directxsdk/d3dx9.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../eterLib/GrpObjectInstance.h"
|
#include "../eterLib/GrpObjectInstance.h"
|
||||||
@ -57,13 +56,12 @@
|
|||||||
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = NULL; } }
|
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = NULL; } }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// class CSpeedTreeWrapper declaration
|
// class CSpeedTreeWrapper declaration
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable:4100)
|
|
||||||
|
|
||||||
class CSpeedTreeWrapper : public CGraphicObjectInstance
|
class CSpeedTreeWrapper : public CGraphicObjectInstance
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ID = TREE_OBJECT
|
ID = TREE_OBJECT
|
||||||
@ -72,13 +70,15 @@ class CSpeedTreeWrapper : public CGraphicObjectInstance
|
|||||||
|
|
||||||
// Collision Data
|
// Collision Data
|
||||||
protected:
|
protected:
|
||||||
virtual void OnUpdateCollisionData(const CStaticCollisionDataVector * pscdVector);
|
UINT GetCollisionObjectCount();
|
||||||
virtual void OnUpdateHeighInstance(CAttributeInstance * pAttributeInstance) {}
|
void GetCollisionObject(UINT nIndex, CSpeedTreeRT::ECollisionObjectType& eType, float* pPosition, float* pDimensions);
|
||||||
virtual bool OnGetObjectHeight(float fX, float fY, float * pfHeight) { return false; }
|
virtual void OnUpdateCollisionData(const CStaticCollisionDataVector* pscdVector);
|
||||||
|
virtual void OnUpdateHeighInstance(CAttributeInstance* pAttributeInstance) {}
|
||||||
|
virtual bool OnGetObjectHeight(float fX, float fY, float* pfHeight) { return false; }
|
||||||
// Bounding Sphere
|
// Bounding Sphere
|
||||||
public:
|
public:
|
||||||
virtual bool GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius);
|
virtual bool GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool ms_bSelfShadowOn;
|
static bool ms_bSelfShadowOn;
|
||||||
|
|
||||||
@ -86,62 +86,47 @@ public:
|
|||||||
// methods from CGraphicObjectInstance
|
// methods from CGraphicObjectInstance
|
||||||
virtual void SetPosition(float x, float y, float z);
|
virtual void SetPosition(float x, float y, float z);
|
||||||
virtual void CalculateBBox();
|
virtual void CalculateBBox();
|
||||||
|
virtual void OnRender();
|
||||||
virtual void OnRender(); // Render 시에 메소드, 그러나 프리뷰나 특수한 경우에만 직접 Render 콜을 부르며
|
virtual void OnRenderPCBlocker();
|
||||||
// 그 이외에는 RenderBranches, RenderFronds 등의 메소드를 CSpeedTreeForest에서 호출한다.
|
|
||||||
virtual void OnBlendRender() {}
|
virtual void OnBlendRender() {}
|
||||||
virtual void OnRenderToShadowMap() {}
|
virtual void OnRenderToShadowMap() {}
|
||||||
virtual void OnRenderShadow() {}
|
virtual void OnRenderShadow() {}
|
||||||
virtual void OnRenderPCBlocker();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSpeedTreeWrapper();
|
CSpeedTreeWrapper();
|
||||||
virtual ~CSpeedTreeWrapper();
|
virtual ~CSpeedTreeWrapper();
|
||||||
|
|
||||||
const float * GetPosition();
|
|
||||||
static void SetVertexShaders(DWORD dwBranchVertexShader, DWORD dwLeafVertexShader);
|
|
||||||
|
|
||||||
// geometry
|
// geometry
|
||||||
bool LoadTree(const char * pszSptFile, const BYTE * c_pbBlock = NULL, unsigned int uiBlockSize = 0, unsigned int nSeed = 1, float fSize = -1.0f, float fSizeVariance = -1.0f);
|
bool LoadTree(const char* pszSptFile, const BYTE* c_pbBlock, unsigned int uiBlockSize, unsigned int nSeed = 1, float fSize = -1.0f, float fSizeVariance = -1.0f);
|
||||||
const float * GetBoundingBox(void) const { return m_afBoundingBox; }
|
const float* GetBoundingBox(void) const { return m_afBoundingBox; }
|
||||||
void GetTreeSize(float & r_fSize, float & r_fVariance);
|
|
||||||
UINT GetCollisionObjectCount();
|
|
||||||
void GetCollisionObject(unsigned int nIndex, CSpeedTreeRT::ECollisionObjectType& eType, float* pPosition, float* pDimensions);
|
|
||||||
|
|
||||||
// rendering
|
// rendering
|
||||||
void SetupBranchForTreeType(void) const;
|
void SetupBranchForTreeType(void) const;
|
||||||
void SetupFrondForTreeType(void) const;
|
void SetupFrondForTreeType(void) const;
|
||||||
void SetupLeafForTreeType(void) const;
|
void SetupLeafForTreeType(void) const;
|
||||||
void EndLeafForTreeType(void);
|
void EndLeafForTreeType(void);
|
||||||
|
|
||||||
#ifdef WRAPPER_USE_GPU_LEAF_PLACEMENT
|
|
||||||
void UploadLeafTables(unsigned int uiLocation) const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void RenderBranches(void) const;
|
void RenderBranches(void) const;
|
||||||
void RenderFronds(void) const;
|
void RenderFronds(void) const;
|
||||||
void RenderLeaves(void) const;
|
void RenderLeaves(void) const;
|
||||||
void RenderBillboards(void) const;
|
void RenderBillboards(void) const;
|
||||||
|
|
||||||
// instancing
|
// instancing
|
||||||
CSpeedTreeWrapper ** GetInstances(unsigned int& nCount);
|
CSpeedTreeWrapper** GetInstances(unsigned int& nCount);
|
||||||
CSpeedTreeWrapper * InstanceOf(void) const { return m_pInstanceOf; }
|
CSpeedTreeWrapper* InstanceOf(void) const { return m_pInstanceOf; }
|
||||||
CSpeedTreeWrapper * MakeInstance();
|
CSpeedTreeWrapper* MakeInstance(void);
|
||||||
void DeleteInstance(CSpeedTreeWrapper * pInstance);
|
void DeleteInstance(CSpeedTreeWrapper* pInstance);
|
||||||
CSpeedTreeRT * GetSpeedTree(void) const { return m_pSpeedTree; }
|
CSpeedTreeRT* GetSpeedTree(void) const { return m_pSpeedTree; }
|
||||||
|
|
||||||
// lighting
|
// lighting
|
||||||
const CSpeedTreeMaterial & GetBranchMaterial(void) const { return m_cBranchMaterial; }
|
const CSpeedTreeMaterial & GetBranchMaterial(void) const { return m_cBranchMaterial; }
|
||||||
const CSpeedTreeMaterial & GetFrondMaterial(void) const { return m_cFrondMaterial; }
|
const CSpeedTreeMaterial & GetFrondMaterial(void) const { return m_cFrondMaterial; }
|
||||||
const CSpeedTreeMaterial & GetLeafMaterial(void) const { return m_cLeafMaterial; }
|
const CSpeedTreeMaterial & GetLeafMaterial(void) const { return m_cLeafMaterial; }
|
||||||
float GetLeafLightingAdjustment(void) const { return m_pSpeedTree->GetLeafLightingAdjustment( ); }
|
float GetLeafLightingAdjustment(void) const { return m_pSpeedTree->GetLeafLightingAdjustment( ); }
|
||||||
|
|
||||||
// wind
|
// wind
|
||||||
void SetWindStrength(float fStrength) { m_pSpeedTree->SetWindStrength(fStrength); }
|
|
||||||
void Advance(void);
|
void Advance(void);
|
||||||
|
|
||||||
// utility
|
// utility
|
||||||
LPDIRECT3DTEXTURE8 GetBranchTexture(void) const;
|
|
||||||
void CleanUpMemory(void);
|
void CleanUpMemory(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -166,20 +151,21 @@ private:
|
|||||||
CSpeedTreeRT::SGeometry* m_pGeometryCache; // cache for pulling geometry from SpeedTree avoids lots of reallocation
|
CSpeedTreeRT::SGeometry* m_pGeometryCache; // cache for pulling geometry from SpeedTree avoids lots of reallocation
|
||||||
|
|
||||||
// branch buffers
|
// branch buffers
|
||||||
LPDIRECT3DVERTEXBUFFER8 m_pBranchVertexBuffer; // branch vertex buffer
|
LPDIRECT3DVERTEXBUFFER9 m_pBranchVertexBuffer; // branch vertex buffer
|
||||||
unsigned int m_unBranchVertexCount; // number of vertices in branches
|
unsigned int m_unBranchVertexCount; // number of vertices in branches
|
||||||
LPDIRECT3DINDEXBUFFER8 m_pBranchIndexBuffer; // branch index buffer
|
LPDIRECT3DINDEXBUFFER9 m_pBranchIndexBuffer; // branch index buffer
|
||||||
unsigned short* m_pBranchIndexCounts; // number of indexes per branch LOD level
|
unsigned short* m_pBranchIndexCounts; // number of indexes per branch LOD level
|
||||||
|
|
||||||
// frond buffers
|
// frond buffers
|
||||||
LPDIRECT3DVERTEXBUFFER8 m_pFrondVertexBuffer; // frond vertex buffer
|
LPDIRECT3DVERTEXBUFFER9 m_pFrondVertexBuffer; // frond vertex buffer
|
||||||
unsigned int m_unFrondVertexCount; // number of vertices in frond
|
unsigned int m_unFrondVertexCount; // number of vertices in frond
|
||||||
LPDIRECT3DINDEXBUFFER8 m_pFrondIndexBuffer; // frond index buffer
|
unsigned int m_unNumFrondLods;
|
||||||
unsigned short* m_pFrondIndexCounts; // number of indexes per frond LOD level
|
LPDIRECT3DINDEXBUFFER9* m_pFrondIndexBuffers;
|
||||||
|
unsigned short* m_pFrondIndexCounts;
|
||||||
|
|
||||||
// leaf buffers
|
// leaf buffers
|
||||||
unsigned short m_usNumLeafLods; // the number of leaf LODs
|
unsigned short m_usNumLeafLods; // the number of leaf LODs
|
||||||
LPDIRECT3DVERTEXBUFFER8* m_pLeafVertexBuffer; // leaf vertex buffer
|
LPDIRECT3DVERTEXBUFFER9* m_pLeafVertexBuffer; // leaf vertex buffer
|
||||||
bool* m_pLeavesUpdatedByCpu; // stores which LOD's have been updated already per frame
|
bool* m_pLeavesUpdatedByCpu; // stores which LOD's have been updated already per frame
|
||||||
|
|
||||||
// tree properties
|
// tree properties
|
||||||
@ -196,8 +182,8 @@ private:
|
|||||||
CGraphicImageInstance m_ShadowImageInstance; // shadow texture object (used if shadows are enabled)
|
CGraphicImageInstance m_ShadowImageInstance; // shadow texture object (used if shadows are enabled)
|
||||||
CGraphicImageInstance m_CompositeImageInstance;
|
CGraphicImageInstance m_CompositeImageInstance;
|
||||||
|
|
||||||
static DWORD ms_dwBranchVertexShader;
|
static unsigned int m_unNumWrappersActive;
|
||||||
static DWORD ms_dwLeafVertexShader;
|
|
||||||
};
|
|
||||||
|
|
||||||
#pragma warning(pop)
|
static LPDIRECT3DVERTEXSHADER9 ms_lpBranchVertexShader;
|
||||||
|
static LPDIRECT3DVERTEXSHADER9 ms_lpLeafVertexShader;
|
||||||
|
};
|
||||||
|
@ -1,19 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
//#include <crtdbg.h>
|
#include "CSpeedTreeDirectX.h"
|
||||||
|
|
||||||
//#include "Forest.h"
|
|
||||||
#include "SpeedTreeForestDirectX8.h"
|
|
||||||
|
|
||||||
// Armadillo nanomite protection
|
|
||||||
#if !defined(NANOBEGIN) && !defined(NANOEND)
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define NANOBEGIN
|
|
||||||
#define NANOEND
|
|
||||||
#else
|
|
||||||
#include <armadillo/SecuredSections.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user