⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tree.cpp

📁 3D游戏展示程序
💻 CPP
字号:
//--------------------------------------------------
//  Desc: 3D tree
//  Author: artsylee/2007.2.25
//--------------------------------------------------

#include "Tree.h"

CTree::CTree()
{
}

CTree::~CTree()
{
}

void CTree::RenderTree(D3DXVECTOR3 pos, HeightmapVertex *pVertex, DWORD *pIndex)
{
	/*
	D3DXMATRIX offset;
	D3DXMatrixTranslation(&offset, pos.xpos, pos.ypos, pos.zpos);
	g_pD3DDevice->SetTransform(D3DTS_WORLD, &offset);
	*/
	DWORD orig = *pIndex;
	int m_szTree = 1;
	int m_height = 60;
	for(int i=0; i<8; i++)
	{
		pVertex[(*pIndex)++] = HeightmapVertex(-m_szTree*sinf(i*45*0.0174533f)*0.1f, m_height, 
											  -m_szTree*cosf(i*45*0.0174533f)*0.1f, 0xffffffff, i*0.3f, 0);
		pVertex[(*pIndex)++] = HeightmapVertex(-m_szTree*sinf(i*45*0.0174533f), 0, 
											  -m_szTree*cosf(i*45*0.0174533f) , 0xffffffff, i*0.3f, 8);
		pVertex[(*pIndex)++] = HeightmapVertex(-m_szTree*sinf((i+1)*45*0.0174533f), 0, 
											  -m_szTree*cosf((i+1)*45*0.0174533f), 0xffffffff, i*0.3f+0.3f, 8);

		pVertex[(*pIndex)++] = HeightmapVertex(-m_szTree*sinf((i+1)*45*0.0174533f), 0, 
											  -m_szTree*cosf((i+1)*45*0.0174533f), 0xffffffff, i*0.3f+0.3f, 8);
		pVertex[(*pIndex)++] = HeightmapVertex(-m_szTree*sinf((i+1)*45*0.0174533f)*0.1f, m_height, 
											  -m_szTree*cosf((i+1)*45*0.0174533f)*0.1f, 0xffffffff, i*0.3f+0.3f, 0);
		pVertex[(*pIndex)++] = HeightmapVertex(-m_szTree*sinf(i*45*0.0174533f)*0.1f, m_height, 
											  -m_szTree*cosf(i*45*0.0174533f)*0.1f, 0xffffffff, i*0.3f, 0);
	}

	for(int i=orig; i<orig+48; i++)
	{
		pVertex[i].x = pVertex[i].x+pos.x;
		pVertex[i].y = pVertex[i].y+pos.y;
		pVertex[i].z = pVertex[i].z+pos.z;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -