📄 scrapeffect.cpp
字号:
// ScrapEffect.cpp: implementation of the CScrapEffect class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ScrapEffect.h"
#include "AnimFrame.h"
#include "EffectModel.h"
#include "EffectBillBoard.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CScrapEffect::CScrapEffect()
{
m_pAnimScrapMesh = NULL;
m_pModelScrapMesh = NULL;
m_pSprScrapMesh = NULL;
m_pAnimScrapFog = NULL;
m_pBillScrapFog = NULL;
m_pSprScrapBillFog = NULL;
m_nAlpha = 0;
}
CScrapEffect::~CScrapEffect()
{
SAFE_DELETE(m_pAnimScrapMesh);
SAFE_DELETE(m_pModelScrapMesh);
SAFE_DELETE(m_pSprScrapMesh);
SAFE_DELETE(m_pAnimScrapFog);
SAFE_DELETE(m_pBillScrapFog);
SAFE_DELETE(m_pSprScrapBillFog);
}
void CScrapEffect::Create()
{
m_pModelScrapMesh = new CEffectModel;
m_pModelScrapMesh->LoadFile(".\\data\\Game\\Effect\\Scrap.MC1");
m_pAnimScrapMesh = new CAnimSequence;
m_pAnimScrapMesh->AddFrame(".\\data\\Game\\Effect\\bullet1.jpg", 0.15f);
m_pAnimScrapMesh->AddFrame(".\\data\\Game\\Effect\\bullet2.jpg", 0.15f);
m_pAnimScrapMesh->AddFrame(".\\data\\Game\\Effect\\bullet3.jpg", 0.15f);
m_pAnimScrapMesh->SetLoop(5);
m_pSprScrapMesh = new CSpriteMesh;
m_pSprScrapMesh->SetAnim( m_pAnimScrapMesh );
m_pSprScrapMesh->SetModel( m_pModelScrapMesh );
m_pBillScrapFog = new CEffectBillBoard;
m_pBillScrapFog->Create();
m_pAnimScrapFog = new CAnimSequence;
m_pAnimScrapFog ->AddFrame(".\\data\\Game\\Effect\\抛胶飘 刚瘤.png", 0.15f);
m_pSprScrapBillFog = new CSpriteBillBoard;
m_pSprScrapBillFog->SetAnim( m_pAnimScrapFog );
m_pSprScrapBillFog->SetBillBoard( m_pBillScrapFog );
for(int i=0;i<5;i++)
{
m_pSprScrapBillFogEx[i] = new CSpriteBillBoard;
m_pSprScrapBillFogEx[i]->SetAnim( m_pAnimScrapFog );
m_pSprScrapBillFogEx[i]->SetBillBoard( m_pBillScrapFog );
m_pSprScrapBillFogEx[i]->SetSize(0.01f+i*0.02f);
}
//m_pSprScrapBillFog->SetSize(5.0f);
m_nAlpha = 255;
}
HRESULT CScrapEffect::Invalidate()
{
m_pModelScrapMesh->ReleaseVertexIndex();
m_pBillScrapFog->Release();
return S_OK;
}
HRESULT CScrapEffect::Restore()
{
m_pModelScrapMesh->CreateVertexIndexBuffer();
m_pBillScrapFog->Create();
return S_OK;
}
void CScrapEffect::SetEmitter( CEffect * pEffect, D3DXVECTOR3 vPos, D3DXVECTOR3 vNomal, int nMaterial )
{
// if(m_pSprScrapBillFogEx[0]->Timer()->IsRunning())
// return;
float fPos = 0.0f;
for(int i=0;i<5;i++)
{
D3DXVECTOR3 vPosEx = (vPos+(vNomal*fPos));
//D3DXVECTOR3 vPosEx = (vPos+(vNomal*fPos));
m_pSprScrapBillFogEx[i]->Pos() = D3DXVECTOR3(vPosEx.x,vPosEx.y,vPosEx.z);
m_pSprScrapBillFogEx[i]->SetSize(0.05f);
fPos+=0.45f;
}
m_nAlpha = 200;
// m_pSprScrapBillFog->Pos() = vPos+vNomal;
// 傲 荤款靛绰 咯扁辑 持磊.. 弊霸 唱阑淀 窍促..
// 嘎绰 荤款靛鄂促.
if(g_pSound->IsPlaySound( 2 ))
{
g_pSound->StopSound(2);
}
//荤款靛 唱坷绰 困摹甫 悸泼.
g_pSound->PlaySound(2, FALSE);
}
void CScrapEffect::Update( float fElapsedTime )
{
for(int i=0;i<5;i++)
{
float fSize = m_pSprScrapBillFogEx[i]->GetSize() + 0.1f*(float)i;
float fRoll = m_pSprScrapBillFogEx[i]->GetRotationRoll()+fElapsedTime;
m_pSprScrapBillFogEx[i]->SetSize(fSize);
m_pSprScrapBillFogEx[i]->SetRotationRoll(fRoll);
m_pSprScrapBillFogEx[i]->Alpha() = m_nAlpha;
}
// m_nAlpha -= 1;
// if(m_nAlpha < 20)
// m_nAlpha = 0;
//m_pSprBullet->SetSize(RandomNumber(1.0f, 3.0f));
// RandomNumber(1.0f, 3.0f)
// m_pSprBullet->();
// if (m_pTimer->GetTime() > m_fTime )
// {
// m_pTimer->Stop();
// m_pSprBullet->Timer().Stop();
// }
}
void CScrapEffect::Render( CMCGTimer * pTimer, D3DXMATRIX &matWorld )
{
// g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE);
// g_pApp->GetD3dDevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
// g_pApp->GetD3dDevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
//g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE);
// g_pApp->GetD3dDevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
// g_pApp->GetD3dDevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
// g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
// g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
// g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );
g_pApp->GetD3dDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE );
//----------------------------------------------------------------------
// 舅颇喉坊爹
g_pApp->GetD3dDevice()->SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_ARGB(m_nAlpha,255,255,255));
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ALPHAREF, 0x10 );
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATER );
// g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ZENABLE, FALSE );
// g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
// g_pApp->GetD3dDevice()->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE);
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE);
// m_pSprScrapBillFog->SetTimer( pTimer );
// m_pSprScrapBillFog->Render(matWorld);
for(int i=0;i<5;i++)
{
m_pSprScrapBillFogEx[i]->SetTimer( pTimer );
// m_pSprScrapBillFogEx[i]->SetSize(4.0f);
m_pSprScrapBillFogEx[i]->Render(matWorld);
}
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ZENABLE, FALSE);
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE);
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
m_pSprScrapMesh->SetTimer( pTimer );
//烙矫 捞棋飘 荤捞令 犬厘
m_pSprScrapMesh->SetSize(5.0f);
m_pSprScrapMesh->Render(matWorld);
g_pApp->GetD3dDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
g_pApp->GetD3dDevice()->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
g_pApp->GetD3dDevice()->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE );
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
g_pApp->GetD3dDevice()->SetRenderState( D3DRS_ZENABLE, TRUE );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -