?? car.cpp
字號(hào):
#include <windows.h>
#include <gl/Gl.h>
#include <gl/glut.h>
#include "mobjfile.h"
#include "car.h"
Car::Car(void)
{
MinLengthVertex = MaxLengthVertex = 0;
MinWidthVertex = MaxWidthVertex = 0;
MinHeightVertex = MinHeightVertex = 0;
ScalerFactor = 1;
}
Car::~Car(void)
{
if ( vList ) glDeleteLists(CarList,1);
}
void Car::Draw()
{
if ( vList ) glCallList(CarList);
}
void Car::LoadCarFile(const char *fileName)
{
LoadFile(fileName);
MinLengthVertex = MaxLengthVertex = vList[1].P[0];
MinWidthVertex = MaxWidthVertex = vList[1].P[1];
MinHeightVertex = MaxHeightVertex = vList[1].P[2];
if ( vList )
for(int i = 2 ; i < NumOfVertex + 1 ; i++) {
if ( vList[i].P[0] < MinLengthVertex ) MinLengthVertex = vList[i].P[0];
if ( vList[i].P[0] > MaxLengthVertex ) MaxLengthVertex = vList[i].P[0];
if ( vList[i].P[1] < MinWidthVertex ) MinWidthVertex = vList[i].P[1];
if ( vList[i].P[1] > MaxWidthVertex ) MaxWidthVertex = vList[i].P[1];
if ( vList[i].P[2] < MinHeightVertex ) MinHeightVertex = vList[i].P[2];
if ( vList[i].P[2] > MaxHeightVertex ) MaxHeightVertex = vList[i].P[2];
}
CarList = glGenLists(1);
glNewList(CarList,GL_COMPILE);
glBegin(GL_TRIANGLES);
for(int i = 0 ; i < NumOfFace ; i++)
for(int j = 0 ; j < 3 ; j++) {
glColor4fv(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();
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -