📄 game3deffectex.cpp
字号:
// Game3DEffectEx.cpp: implementation of the CGame3DEffectEx class.
//
//////////////////////////////////////////////////////////////////////
#include "Game3DEffectEx.h"
#include "3DEffect.h"
#include "GamedataSet.h"
#include "3DRolePart.h"
#include "3DRoleData.h"
#include "3DRole.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CGame3DEffectEx::CGame3DEffectEx()
{
m_setInfo.clear();
this->Clear();
m_nOffsetY = 0;
m_Height = 0;
m_bOblique = true;
m_fX = 0.0;
m_fY = 0.0;
m_fZ = 0.0;
}
CGame3DEffectEx::~CGame3DEffectEx()
{
this->Clear();
}
//-------------------------------------------------------------------
void CGame3DEffectEx::Show(CMyPos posWorld)
{
int nAmount = m_setInfo.size();
for(int i = 0; i < nAmount; i++)
{
Game3DEffectExInfo* pInfo = m_setInfo[i];
if(pInfo)
{
CMyPos myPosWorld;
myPosWorld = posWorld;
myPosWorld.y += m_nOffsetY;
this->Show(pInfo, myPosWorld);
}
}
}
//-------------------------------------------------------------------
DWORD CGame3DEffectEx::GetPartAmount(int nIndex)
{
if(nIndex >= m_setInfo.size() || nIndex < 0)
return 0;
Game3DEffectExInfo* pInfo = m_setInfo[nIndex];
if(pInfo)
return pInfo->nInfoAmount;
return 0;
}
//-------------------------------------------------------------------
void CGame3DEffectEx::SetBlend(int nIndex, int nPartIndex, int nASB, int nADB)
{
if(nIndex >= m_setInfo.size() || nIndex < 0)
return;
Game3DEffectExInfo* pInfo = m_setInfo[nIndex];
if(pInfo)
{
if(nPartIndex < 0 || nPartIndex >= pInfo->nInfoAmount)
return;
if(!pInfo->pIDInfo)
return;
Game3DEffectIdInfo* pMyIDInfo = pInfo->pIDInfo + nPartIndex;
pMyIDInfo->nASB = nASB;
pMyIDInfo->nADB = nADB;
}
}
//-------------------------------------------------------------------
void CGame3DEffectEx::GetBlend(int nIndex, int nPartIndex, int &nASB, int &nADB)
{
if(nIndex >= m_setInfo.size() || nIndex < 0)
return;
Game3DEffectExInfo* pInfo = m_setInfo[nIndex];
if(pInfo)
{
if(nPartIndex < 0 || nPartIndex >= pInfo->nInfoAmount)
return;
if(!pInfo->pIDInfo)
return;
Game3DEffectIdInfo* pMyIDInfo = pInfo->pIDInfo + nPartIndex;
nASB = pMyIDInfo->nASB;
nADB = pMyIDInfo->nADB;
}
}
//-------------------------------------------------------------------
void CGame3DEffectEx::Show(Game3DEffectExInfo* pInfo, C3DRolePart* pPart, const char* pszVMesh)
{
if(!pInfo)
return;
if(!pInfo->bShow)
return;
if(!pPart)
return;
if(!pszVMesh)
return;
Game3DEffectExInfo* pMyInfo = pInfo;
int nAmount = pInfo->nInfoAmount;
for(int i = 0; i < nAmount; i++)
{
Game3DEffectIdInfo* pIDInfo = pInfo->pIDInfo+i;
// get effect
C3DEffect* pEffect = g_objGameDataSet.Get3DEffect(pIDInfo->idEffect);
if(!pEffect)
return;
// get txeture of effect
C3DTexture* pTexture = g_objGameDataSet.Get3DTexture(pIDInfo->idTexture);
if(!pTexture)
return;
// set the texture
pEffect->SetTexture(pTexture);
pEffect->SetFrames(pMyInfo->dwCurrentFrameIndex);
// restore shape info
pEffect->RestoreShapeInfo(pIDInfo->pShapeInfoBuf);
// setpos
C3DObjPartInfo* pInfo = pPart->GetInfo(0);
if(!pInfo)
return;
C3DObj* pObj = g_objGameDataSet.Get3DObj(pInfo->idMesh);
if(!pObj)
return;
pEffect->Bind(pObj, (char*)pszVMesh);
pEffect->Draw(false, pIDInfo->nASB, pIDInfo->nADB);
pEffect->BackupShapeInfo(pIDInfo->pShapeInfoBuf);
}
}
//-------------------------------------------------------------------
void CGame3DEffectEx::Show(C3DRole* p3DRole, CMyPos posWorld)
{
if(!p3DRole && p3DRole->m_pArmor)
return;
for(int i = 0; i < m_setInfo.size(); i++)
{
Game3DEffectExInfo* pInfo = m_setInfo[i];
char szIndex[64];
for(int i = 0; i < strlen(pInfo->szIndex)+1; i ++)
{
szIndex[i] = pInfo->szIndex[i];
if(szIndex[i] == '+')
szIndex[i] = ' ';
}
char szStr[64];
char szVMesh[64];
if (2 != sscanf(szIndex, "%s %s", szStr, szVMesh))
{
if(pInfo)
{
this->Show(pInfo, posWorld);
}
}
else
{
if(pInfo)
{
C3Motion* pMotion = p3DRole->m_pArmor->GetVirtualMotion(szVMesh);
if(pMotion)
this->Show(pInfo, p3DRole->m_pArmor, szVMesh);
}
}
}
this->Process();
}
//-------------------------------------------------------------------
void CGame3DEffectEx::Show(C3DRolePart* pPart)
{
if(!pPart)
return;
for(int i = 0; i < m_setInfo.size(); i++)
{
Game3DEffectExInfo* pInfo = m_setInfo[i];
if(pInfo)
{
this->Show(pInfo, pPart);
}
}
this->Process();
}
//-------------------------------------------------------------------
void CGame3DEffectEx::SetPos ( int nX, int nY, int nRotate, float fScale )
{
/*effect->Move ( nX, 0, nY );
effect->Rotate ( 0, 0, D3DXToRadian ( nRotate ) );
effect->Scale ( fScale, fScale, fScale );*/
}
//-------------------------------------------------------------------
void CGame3DEffectEx::Rotate(float x, float y, float z)
{
m_fX = x;
m_fY = y;
m_fZ = z;
/*
int nAmount = m_setInfo.size();
for(int i = 0; i < nAmount; i ++)
{
Game3DEffectExInfo* pInfo = m_setInfo[i];
if(pInfo)
{
int nInfoAmount = pInfo->nInfoAmount;
for(int i = 0; i < nInfoAmount; i++)
{
Game3DEffectIdInfo* pIDInfo = pInfo->pIDInfo+i;
// get effect
C3DEffect* pEffect = g_objGameDataSet.Get3DEffect(pIDInfo->idEffect);
if (pEffect)
pEffect->Rotate(x, y, z);
}
}
}*/
}
//-------------------------------------------------------------------
void CGame3DEffectEx::Scale(float x, float y, float z)
{
int nAmount = m_setInfo.size();
for(int i = 0; i < nAmount; i ++)
{
Game3DEffectExInfo* pInfo = m_setInfo[i];
if(pInfo)
{
int nInfoAmount = pInfo->nInfoAmount;
for(int i = 0; i < nInfoAmount; i++)
{
Game3DEffectIdInfo* pIDInfo = pInfo->pIDInfo+i;
// get effect
C3DEffect* pEffect = g_objGameDataSet.Get3DEffect(pIDInfo->idEffect);
if (pEffect)
pEffect->Scale(x, y, z);
}
}
}
}
//-------------------------------------------------------------------
void CGame3DEffectEx::SetHeight ( float fHeight )
{
m_Height = fHeight;
}
//-------------------------------------------------------------------
void CGame3DEffectEx::Show(Game3DEffectExInfo* pInfo, C3DRolePart* pPart)
{
if(!pInfo)
return;
if(!pInfo->bShow)
return;
if(!pPart)
return;
Game3DEffectExInfo* pMyInfo = pInfo;
int nAmount = pInfo->nInfoAmount;
for(int i = 0; i < nAmount; i++)
{
Game3DEffectIdInfo* pIDInfo = pInfo->pIDInfo+i;
// get effect
C3DEffect* pEffect = g_objGameDataSet.Get3DEffect(pIDInfo->idEffect);
if(!pEffect)
return;
// get txeture of effect
C3DTexture* pTexture = g_objGameDataSet.Get3DTexture(pIDInfo->idTexture);
if(!pTexture)
return;
// set the texture
pEffect->SetTexture(pTexture);
pEffect->SetFrames(pMyInfo->dwCurrentFrameIndex);
// restore shape info
pEffect->RestoreShapeInfo(pIDInfo->pShapeInfoBuf);
// setpos
C3DObjPartInfo* pInfo = pPart->GetInfo(0);
if(!pInfo)
return;
C3DObj* pObj = g_objGameDataSet.Get3DObj(pInfo->idMesh);
if(!pObj)
return;
pEffect->Bind(pObj);
pEffect->Draw(false, pIDInfo->nASB, pIDInfo->nADB);
pEffect->BackupShapeInfo(pIDInfo->pShapeInfoBuf);
}
}
//-------------------------------------------------------------------
void CGame3DEffectEx::Show(Game3DEffectExInfo* pInfo, CMyPos posWorld)
{
if(!pInfo)
return;
if(!pInfo->bShow)
return;
int nAmount = pInfo->nInfoAmount;
for(int i = 0; i < nAmount; i++)
{
Game3DEffectIdInfo* pIDInfo = pInfo->pIDInfo+i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -