// CloudScene.cpp: implementation of the CCloudScene class. // ////////////////////////////////////////////////////////////////////// #include "CloudScene.h" #include "SceneManager.h" #include "GMMemory.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CCloudScene::CCloudScene() { } CCloudScene::~CCloudScene() { } void CCloudScene::Create() { m_fTrans[0]=0.0f; m_fTrans[1]=0.0f; m_fTrans[2]=0.0f; m_fTrans[3]=0.0f; m_CloudOctaveBlendTexture.Create(SHADOWSIZE,SHADOWSIZE); float fDivAng=(3.141597f*2.0f)/CLOUDDIVIDE; m_CloudVertex[0].v=vector3(0.0f,100000.0f,0.0f); m_CloudVertex[0].spec.c=0x0; m_CloudVertex[0].diff.c=0xffffffff; m_CloudVertex[0].tu=0.0f; m_CloudVertex[0].tv=0.0f; for(int i=1;iGetPosition(); matrix mat; mat.Translation(vector3(vecViewPos->x,0.0f,vecViewPos->z)); pd3dDevice->SetTransform(D3DTS_WORLD,mat); pd3dDevice->SetRenderState( D3DRS_LIGHTING,FALSE); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_CURRENT); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TEXTURE|D3DTA_COMPLEMENT); //pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TEXTURE); //pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SUBTRACT ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,D3DTOP_ADD); //pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,D3DTOP_SELECTARG); //pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SUBTRACT); pd3dDevice->SetVertexShader(LVERTEXFVF); //pd3dDevice->SetRenderState( D3DRS_FOGENABLE,FALSE); pd3dDevice->SetRenderState( D3DRS_SRCBLEND,D3DBLEND_ONE); pd3dDevice->SetRenderState( D3DRS_DESTBLEND,D3DBLEND_SRCCOLOR); // //pd3dDevice->SetRenderState( D3DRS_SRCBLEND,D3DBLEND_SRCCOLOR); //pd3dDevice->SetRenderState( D3DRS_DESTBLEND,D3DBLEND_INVSRCCOLOR); pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE); for(int i=0;iSetTexture(0,m_CloudOctaveBlendTexture.GetTexture()); pd3dDevice->SetTexture(1,NULL); pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,CLOUDVERTEX,m_CloudVertex,sizeof(LVertex)); //pd3dDevice->SetRenderState( D3DRS_FOGENABLE,TRUE); } void CCloudScene::Update(LPDIRECT3DDEVICE8 pd3dDevice,float fTime) { TLVertex pVertex[4]; float fTextureSize=SHADOWSIZE; pVertex[0].v.x=0.0f; pVertex[1].v.x=0.0f; pVertex[2].v.x=fTextureSize; pVertex[3].v.x=fTextureSize; pVertex[1].v.y=0.0f; pVertex[3].v.y=0.0f; pVertex[0].v.y=fTextureSize; pVertex[2].v.y=fTextureSize; pVertex[0].tu=0.0f; pVertex[1].tu=0.0f; pVertex[3].tu=1.0f; pVertex[2].tu=1.0f; pVertex[1].tv=0.0f; pVertex[3].tv=0.0f; pVertex[0].tv=1.0f; pVertex[2].tv=1.0f; for(int i=0;i<4;i++) { pVertex[i].w=0.1f; pVertex[i].v.z=0.1f; pVertex[i].Diffuse.c=0xffffffff; pVertex[i].Specular.c=0x0; } static DWORD c=0; c++; m_CloudOctaveBlendTexture.Begin(pd3dDevice); pd3dDevice->Clear(0,NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET,0x000000ff, 1.0f, 0); pd3dDevice->BeginScene(); pd3dDevice->SetRenderState( D3DRS_LIGHTING,FALSE); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_CURRENT); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TEXTURE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 ); pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_DISABLE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU); pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE); pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE); pd3dDevice->SetTexture(1,NULL); pVertex[0].tu=0.0f+m_fTrans[0]; pVertex[1].tu=0.0f+m_fTrans[0]; pVertex[3].tu=1.0f+m_fTrans[0]; pVertex[2].tu=1.0f+m_fTrans[0]; pVertex[1].tv=0.0f+m_fTrans[0]; pVertex[3].tv=0.0f+m_fTrans[0]; pVertex[0].tv=1.0f+m_fTrans[0]; pVertex[2].tv=1.0f+m_fTrans[0]; pVertex[0].Diffuse.c=pVertex[1].Diffuse.c=pVertex[2].Diffuse.c=pVertex[3].Diffuse.c=0xffffffff; pd3dDevice->SetVertexShader(TLVERTEXFVF); pd3dDevice->SetTexture(0,m_CloudOctaveTexture[0].GetTexture()); pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(TLVertex)); pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,TRUE); pVertex[0].tu=0.0f+m_fTrans[1]; pVertex[1].tu=0.0f+m_fTrans[1]; pVertex[3].tu=1.0f+m_fTrans[1]; pVertex[2].tu=1.0f+m_fTrans[1]; pVertex[1].tv=0.0f+m_fTrans[1]; pVertex[3].tv=0.0f+m_fTrans[1]; pVertex[0].tv=1.0f+m_fTrans[1]; pVertex[2].tv=1.0f+m_fTrans[1]; pVertex[0].Diffuse.c=pVertex[1].Diffuse.c=pVertex[2].Diffuse.c=pVertex[3].Diffuse.c=0xff7f7f7f; pd3dDevice->SetTexture(0,m_CloudOctaveTexture[1].GetTexture()); pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(TLVertex)); pVertex[0].tu=0.0f+m_fTrans[2]; pVertex[1].tu=0.0f+m_fTrans[2]; pVertex[3].tu=1.0f+m_fTrans[2]; pVertex[2].tu=1.0f+m_fTrans[2]; pVertex[1].tv=0.0f+m_fTrans[2]; pVertex[3].tv=0.0f+m_fTrans[2]; pVertex[0].tv=1.0f+m_fTrans[2]; pVertex[2].tv=1.0f+m_fTrans[2]; pVertex[0].Diffuse.c=pVertex[1].Diffuse.c=pVertex[2].Diffuse.c=pVertex[3].Diffuse.c=0xff3f3f3f; pd3dDevice->SetTexture(0,m_CloudOctaveTexture[2].GetTexture()); pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(TLVertex)); pVertex[0].tu=0.0f+m_fTrans[3]; pVertex[1].tu=0.0f+m_fTrans[3]; pVertex[3].tu=1.0f+m_fTrans[3]; pVertex[2].tu=1.0f+m_fTrans[3]; pVertex[1].tv=0.0f+m_fTrans[3]; pVertex[3].tv=0.0f+m_fTrans[3]; pVertex[0].tv=1.0f+m_fTrans[3]; pVertex[2].tv=1.0f+m_fTrans[3]; pVertex[0].Diffuse.c=pVertex[1].Diffuse.c=pVertex[2].Diffuse.c=pVertex[3].Diffuse.c=0xff1f1f1f; pd3dDevice->SetTexture(0,m_CloudOctaveTexture[3].GetTexture()); pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(TLVertex)); // pd3dDevice->EndScene(); m_CloudOctaveBlendTexture.End(pd3dDevice); m_fTrans[0]+=0.00001f; m_fTrans[1]+=0.00004f; m_fTrans[2]+=0.00008f; m_fTrans[3]+=0.00010f; pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE); pd3dDevice->SetRenderState( D3DRS_LIGHTING,TRUE); pd3dDevice->SetRenderState( D3DRS_FOGENABLE,TRUE); } void CCloudScene::SetColor(DWORD dwColor, DWORD dwCenterColor, DWORD *dwLayerColor) { m_CloudVertex[0].diff.c=dwCenterColor; for(int i=1;i