资源简介

VC++天空盒(skyBox)实现(含源代码)
动态天空等

资源截图

代码片段和文件信息

#include “StdAfx.h“
#include “SkyBox.h“

CSkyBox::CSkyBox(IDirect3DDevice9 *pDevice)
{
pDevice->CreateVertexBuffer((24 * sizeof(VertexSky))D3DUSAGE_WRITEONLYD3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1D3DPOOL_MANAGED&m_PVB0);
pDevice->CreateIndexBuffer(36*sizeof(WORD)D3DUSAGE_WRITEONLYD3DFMT_INDEX16D3DPOOL_MANAGED&m_PIB0);
VertexSky *pV;
float size=24200.0f;
float size1=5000.0f;
m_PVB->Lock(00(void**)&pV0);
//TOP上表面
pV[0]=VertexSky(-sizesize-1020 size0.0f1.0f0.0f0.0f0.0f);//0
pV[1]=VertexSky(-sizesize-1020-size0.0f1.0f0.0f0.0f1.0f);//1
pV[2]=VertexSky( sizesize-1020-size0.0f1.0f0.0f1.0f1.0f);//2
pV[3]=VertexSky( sizesize-1020 size0.0f1.0f0.0f1.0f0.0f);//3
//FRONT 前表面
pV[4]=VertexSky(-size size+size1-size0.0f0.0f-1.0f1.0f0.0f);//1
pV[5]=VertexSky( size size+size1-size0.0f0.0f-1.0f0.0f0.0f);//2
pV[6]=VertexSky(-size-size+size1-size0.0f0.0f-1.0f1.0f1.0f);//5
pV[7]=VertexSky( size-size+size1-size0.0f0.0f-1.0f0.0f1.0f);//6
//BUTTON 下表面
//pV[8]= VertexSky(-size-size-size0.0f-1.0f0.0f0.0f0.0f);//5
//pV[9]= VertexSky( size-size-size0.0f-1.0f0.0f1.0f0.0f);//6
//pV[10]=VertexSky( size-size size0.0f-1.0f0.0f1.0f1.0f);//7
//pV[11]=VertexSky(-size-size size0.0f-1.0f0.0f0.0f1.0f);//4
//BACK 背面
pV[12]=VertexSky(-size size+size1size0.0f0.0f1.0f0.0f0.0f);//0
pV[13]=VertexSky( size size+size1size0.0f0.0f1.0f1.0f0.0f);//3
pV[14]=VertexSky( size-size+size1size0.0f0.0f1.0f1.0f1.0f);//7
pV[15]=VertexSky(-size-size+size1size0.0f0.0f1.0f0.0f1.0f);//4
//LEFT 左面
pV[16]=VertexSky(-size size+size1 size-1.0f0.0f0.0f0.0f0.0f);//0
pV[17]=VertexSky(-size size+size1-size-1.0f0.0f0.0f1.0f0.0f);//1
pV[18]=VertexSky(-size-size+size1-size-1.0f0.0f0.0f1.0f1.0f);//5
pV[19]=VertexSky(-size-size+size1 size-1.0f0.0f0.0f0.0f1.0f);//4
//RIGHT 右面
pV[20]=VertexSky(size size+size1-size1.0f0.0f0.0f0.0f0.0f);//2
pV[21]=VertexSky(size size+size1 size1.0f0.0f0.0f1.0f0.0f);//3
pV[22]=VertexSky(size-size+size1 size1.0f0.0f0.0f1.0f1.0f);//7
pV[23]=VertexSky(size-size+size1-size1.0f0.0f0.0f0.0f1.0f);//6

m_PVB->Unlock();

WORD *pW;
m_PIB->Lock(00(void**)&pW0);
pW[0]=1;pW[1]=3;pW[2]=0;
pW[3]=2;pW[4]=3;pW[5]=1;

pW[6]=6;pW[7]=5;pW[8]=4;
pW[9]=6;pW[10]=7;pW[11]=5;

pW[18]=14;pW[19]=15;pW[20]=12;
pW[21]=13;pW[22]=14;pW[23]=12;

pW[24]=16;pW[25]=19;pW[26]=18;
pW[27]=17;pW[28]=16;pW[29]=18;

pW[30]=23;pW[31]=21;pW[32]=20;
pW[33]=22;pW[34]=21;pW[35]=23;
m_PIB->Unlock();

ZeroMemory(&m_materialsizeof(D3DMATERIAL9));
m_material.Diffuse=D3DXCOLOR(1.0f1.0f1.0f1.0f);
m_material.Emissive=D3DXCOLOR(1.0f1.0f1.0f1.0f);


::D3DXCreateTextureFromFile(pDevice_T(“.\\Picture\\Sky\\SunSky.png“)&m_pTexture);
pDevice->SetSamplerState(0D3DSAMP_MAGFILTERD3DTEXF_LINEAR);
pDevice->SetSamplerState(0D3DSAMP_MINFILTERD3DTE

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3571  2010-05-27 04:54  SkyBox.cpp

     文件        600  2010-10-27 23:43  SkyBox.h

----------- ---------  ---------- -----  ----

                 4171                    2


评论

共有 条评论