• 大小: 55.85MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2023-02-21
  • 语言: 其他
  • 标签: openGL  电梯运动  

资源简介

这是一个用openGL写的一个电梯运动的实验,实现了电梯的上下移动的模拟!

资源截图

代码片段和文件信息

#include “StdAfx.h“
#include “Animation.h“



CAnimation::CAnimation(void)
{
eleTopLeftX = -2.0f;
eleTopLeftY = 5.7f;
}


CAnimation::~CAnimation(void)
{
}


// 绘制背景图
void CAnimation::drawBack()
{
GLfloat topLeftX = -6.0f;
GLfloat topLeftY =  3.6f;
GLfloat topRightX = -2.0f;
GLfloat topRightY = 3.6f;


glColor3f(0.4f0.4f0.4f);

glLineWidth(1);
glBegin(GL_QUADS); // 绘制三角形
glVertex3f(-6.0f 5.7f 0.0f); // 左上
glVertex3f( 6.0f 5.7f 0.0f); // 右上
glVertex3f( 6.0f 5.6f 0.0f); // 右下
glVertex3f(-6.0f 5.6f 0.0f);
glEnd();

for(int i = 0; i < 4; i++)
{
glBegin(GL_QUADS);
glVertex3f(topLeftX topLeftY 0);
glVertex3f(topRightX topRightY 0);
glVertex3f(topRightX topRightY - 0.1 0);
glVertex3f(topLeftX topLeftY - 0.1 0);
glEnd();
glBegin(GL_QUADS);
glVertex3f(topLeftX * -1 topLeftY 0);
glVertex3f(topRightX * -1 topRightY 0);
glVertex3f(topRightX * -1 topRightY - 0.1 0);
glVertex3f(topLeftX * -1 topLeftY - 0.1 0);
glEnd();

topLeftY -= 2.2;
topRightY -= 2.2;
}

glBegin(GL_QUADS); // 绘制三角形
glVertex3f(-6.0f topLeftY 0.0f); // 左上
glVertex3f( 6.0f topLeftY 0.0f); // 右上
glVertex3f( 6.0f topLeftY - 0.1 0.0f); // 右下
glVertex3f(-6.0f topLeftY - 0.1 0.0f);
glEnd();


glBegin(GL_QUADS);
glVertex3f(-2.1 5.7 0);
glVertex3f(-2.0 5.7 0);
glVertex3f(-2.0 -5.3 0);
glVertex3f(-2.1 -5.3 0);
glEnd();

glBegin(GL_QUADS);
glVertex3f(2.1 5.7 0);
glVertex3f(2.0 5.7 0);
glVertex3f(2.0 -5.3 0);
glVertex3f(2.1 -5.3 0);
glEnd();

}

void CAnimation::drawElevator()
{
glColor3f(0.0f0.0f0.0f);
glBegin(GL_LINES);
glVertex3f(eleTopLeftX + 2 eleTopLeftY 0);
glVertex3f(eleTopLeftX + 2 eleTopLeftY - 2.2 0);
glEnd();

glColor3f(0.3f0.4f0.4f);
glBegin(GL_QUADS);
glVertex3f(eleTopLeftX eleTopLeftY 0.0f);
glVertex3f(eleTopLeftX + 4 eleTopLeftY 0.0f);
glVertex3f(eleTopLeftX + 4 eleTopLeftY - 2.2 0.0f);
glVertex3f(eleTopLeftX eleTopLeftY - 2.2 0.0f);
glEnd();


}

void CAnimation::nextFram(int thisFloor int nextFloor)
{
int isDown = 0;
GLfloat temp = 0;
if(thisFloor - nextFloor > 0)
isDown = 1;
else 
isDown = 0;

if(isDown)
{
temp = 5.7 + (nextFloor - 5) * 2.2 + 0.1 ;
if(this->eleTopLeftY >= temp)
this->eleTopLeftY -= 0.04;
}
else
{
temp = 5.7 + (nextFloor - 5) * 2.2 ;
if(this->eleTopLeftY < temp)
this->eleTopLeftY += 0.04;

}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-09-04 08:49  Elevator\
     目录           0  2013-09-04 08:48  Elevator\Debug\
     文件      238592  2013-06-03 22:44  Elevator\Debug\Elevator.exe
     文件     2140176  2013-06-03 22:44  Elevator\Debug\Elevator.ilk
     文件     6048768  2013-06-03 22:44  Elevator\Debug\Elevator.pdb
     目录           0  2013-09-04 08:49  Elevator\Elevator\
     文件    69488640  2013-06-04 00:41  Elevator\Elevator.sdf
     文件         891  2013-06-03 19:20  Elevator\Elevator.sln
     文件       21504  2013-06-04 00:41  Elevator\Elevator.suo
     文件        2571  2013-06-04 00:28  Elevator\Elevator\Animation.cpp
     文件         352  2013-06-03 22:21  Elevator\Elevator\Animation.h
     目录           0  2013-09-04 08:49  Elevator\Elevator\Debug\
     文件       16662  2013-06-03 22:44  Elevator\Elevator\Debug\Animation.obj
     文件        4498  2013-06-03 22:44  Elevator\Elevator\Debug\cl.command.1.tlog
     文件       74142  2013-06-03 22:44  Elevator\Elevator\Debug\CL.read.1.tlog
     文件        6354  2013-06-03 22:44  Elevator\Elevator\Debug\CL.write.1.tlog
     文件         667  2013-06-03 19:21  Elevator\Elevator\Debug\Elevator.exe.embed.manifest
     文件         732  2013-06-03 19:21  Elevator\Elevator\Debug\Elevator.exe.embed.manifest.res
     文件         381  2013-06-03 22:44  Elevator\Elevator\Debug\Elevator.exe.intermediate.manifest
     文件          68  2013-06-03 22:44  Elevator\Elevator\Debug\Elevator.lastbuildstate
     文件        2466  2013-06-03 22:44  Elevator\Elevator\Debug\Elevator.log
     文件       57308  2013-06-03 22:34  Elevator\Elevator\Debug\Elevator.obj
     文件    36962304  2013-06-03 19:21  Elevator\Elevator\Debug\Elevator.pch
     文件       85036  2013-06-03 19:21  Elevator\Elevator\Debug\Elevator.res
     文件         707  2013-06-03 19:21  Elevator\Elevator\Debug\Elevator.vcxprojResolveAssemblyReference.cache
     文件           0  2013-06-03 19:21  Elevator\Elevator\Debug\Elevator.write.1.tlog
     文件       56529  2013-06-03 22:34  Elevator\Elevator\Debug\ElevatorDoc.obj
     文件       44655  2013-06-03 22:39  Elevator\Elevator\Debug\ElevatorView.obj
     文件         206  2013-06-03 19:21  Elevator\Elevator\Debug\Elevator_manifest.rc
     文件           2  2013-06-03 22:44  Elevator\Elevator\Debug\link-cvtres.read.1.tlog
     文件           2  2013-06-03 22:44  Elevator\Elevator\Debug\link-cvtres.write.1.tlog
............此处省略89个文件信息

评论

共有 条评论