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

📄 tree.cpp

📁 一個簡單的游戲設計...好好玩的
💻 CPP
字号:
#include <windows.h>
#include <gl/Gl.h>
#include <gl/glut.h>
#include "mobjfile.h"
#include "tree.h"
#include <iostream>
using namespace std;

Tree::Tree(void)
{
	ScalerFactor = 1;
}

Tree::~Tree(void)
{
	if ( vList ) glDeleteLists(TreeList,1);
}

void Tree::Draw()
{
	if ( vList ) glCallList(TreeList);
}

void Tree::LoadTreeFile(const char *fileName)
{
	LoadFile(fileName);

	TreeList = glGenLists(1);

	glNewList(TreeList,GL_COMPILE);
		glBegin(GL_TRIANGLES);
		for(int i = 0 ; i < NumOfFace ; i++)
			for(int j = 0 ; j < 3 ; j++) {

				glColor3fv(mList[fList[i][j].IndexOfMaterial].Ka);

				glNormal3fv(nList[fList[i][2 - j].IndexOfNormal].P);
				glVertex3f(vList[fList[i][2 - j].IndexOfVertex].P[0] * ScalerFactor,
					       vList[fList[i][2 - j].IndexOfVertex].P[1] * ScalerFactor,
						   vList[fList[i][2 - j].IndexOfVertex].P[2] * ScalerFactor);
			}
		glEnd();
	glEndList();

}

⌨️ 快捷键说明

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