📄 3dtools.cpp
字号:
// (C) Copyright 1996 by Anthony J. Carin. All Rights Reserved.
#include "stdafx.h"
#include <3dtools.h>
#include <bmpsurf.h>
#include <levels.h>
tc3dtools::tc3dtools()
{
m_material[0] =
m_material[1] =
m_material[2] = 0.7f;
m_material[3] = 1.0f;
m_lightposition[0] = 1.0f;
m_lightposition[1] = 2.0f;
m_lightposition[2] = 0.0f;
m_lightposition[3] = 1.0f;
}
void tc3dtools::material(tccolor& c)
{
m_material[0] = c.rvalue();
m_material[1] = c.gvalue();
m_material[2] = c.bvalue();
glMaterialfv(GL_FRONT, GL_AMBIENT, m_material);
}
void tc3dtools::reset()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
}
void tc3dtools::lookat(coordinate& camera, coordinate& aim)
{
bmpsurf *bsurf;
bsurf = Game->Bmpsurfs()->First();
while (bsurf)
{
#ifdef EDITOR
if (!Game->LevelPtr()->selection)
#endif
if (bsurf->intersects(camera, aim))
camera = bsurf->intersectingpoint();
bsurf = Game->Bmpsurfs()->Next();
}
gluLookAt(camera.x(), camera.y(), camera.z(),
aim.x(), aim.y(), aim.z(),
aim.x(), aim.y()+100, aim.z());
}
void tc3dtools::lightposition(coordinate &c)
{
m_lightposition[0] = c.x();
m_lightposition[1] = c.y();
m_lightposition[2] = c.z();
glLightfv(GL_LIGHT0, GL_POSITION, m_lightposition);
}
void tc3dtools::finish()
{
glFinish();
SwapBuffers(wglGetCurrentDC());
}
void tc3dtools::beginbmp()
{
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
}
void tc3dtools::endbmp()
{
glEnd();
glDisable(GL_TEXTURE_2D);
}
void tc3dtools::bmpvertex1(float x, float y, float z)
{
glTexCoord2f(1.0f, 0.0f);
glVertex3f(x, y, z);
}
void tc3dtools::bmpvertex2(float x, float y, float z)
{
glTexCoord2f(0.0f, 0.0f);
glVertex3f(x, y, z);
}
void tc3dtools::bmpvertex3(float x, float y, float z)
{
glTexCoord2f(0.0f, 1.0f);
glVertex3f(x, y, z);
}
void tc3dtools::bmpvertex4(float x, float y, float z)
{
glTexCoord2f(1.0f, 1.0f);
glVertex3f(x, y, z);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -