#include <windows.h> // Standard Header For Most Programs
#include <gl/glut.h> // The GL Utility Toolkit (Glut) Header
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "tgaload.h"
#pragma comment( lib, "opengl32.lib" ) // Search For OpenGL32.lib While Linking
#pragma comment( lib, "glu32.lib" )
#define ColoredVertex(c, v) { glColor3fv(c); glVertex3fv(v); }
#define M_PI 3.14159265358979323846
static float c=M_PI/180.0f;
static int du=90,oldmy=-1,oldmx=-1;
static float r=1.5f,h=0.0f;
GLint texList[1];
GLuint texture_id[2];
GLUquadricObj *sphere;
GLUquadricObj *cylinder;
void Mouse(int button, int state, int x, int y)
{
if(state==GLUT_DOWN)
oldmx=x,oldmy=y;
}
void onMouseMove(int x,int y)
{
du+=x-oldmx;
h+=0.03f*(y-oldmy);
if(h>1.0f) h=1.0f;
else if(h<-1.0f) h=-1.0f;
oldmx=x,oldmy=y;
}
void drawLeftWings()
{
static int list=0;
//top wing
GLfloat PointA[] = { 0.0, 0.02, 0.0};
GLfloat PointB[] = { -0.1, 0.9, -0.32};
GLfloat PointC[] = { -0.1, 0.35, -0.36};
GLfloat PointD[] = { 0.0, 0.0, 0.0};
//middle wing
GLfloat PointA2[] = { 0.0, 0.02, 0.0};
GLfloat PointB2[] = { -0.1, 0.26, -0.37};
GLfloat PointC2[] = { -0.1, -0.2, -0.36};
GLfloat PointD2[] = { 0.0, 0.0, 0.0};
//bottom wing
GLfloat PointA1[] = { 0.0, 0.02, 0.0};
GLfloat PointB1[] = { -0.1, -0.25, -0.3};
GLfloat PointC1[] = { -0.1, -0.85, -0.3};
GLfloat PointD1[] = { 0.0, 0.0, 0.0};
GLfloat ColorR[] = {1, 0, 0};
GLfloat ColorG[] = {0, 1, 0};
GLfloat ColorB[] = {0, 0, 1};
GLfloat ColorY[] = {1, 1, 0};
list = glGenLists(1);
glNewList(list, GL_COMPILE);
glBegin(GL_TRIANGLES);
// ABC
ColoredVertex(ColorR, PointA);
ColoredVertex(ColorG, PointB);
ColoredVertex(ColorB, PointC);
// ACD
ColoredVertex(ColorR, PointA);
ColoredVertex(ColorB, PointC);
ColoredVertex(ColorY, PointD);
// CBD
ColoredVertex(ColorB, PointC);
ColoredVertex(ColorG, PointB);
ColoredVertex(ColorY, PointD);
// BAD
ColoredVertex(ColorG, PointB);
ColoredVertex(ColorR, PointA);
ColoredVertex(ColorY, PointD);
// ABC1
ColoredVertex(ColorR, PointA1);
ColoredVertex(ColorG, PointB1);
ColoredVertex(ColorB, PointC1);
// ACD1
ColoredVertex(ColorR, PointA1);
ColoredVertex(ColorB, PointC1);
ColoredVertex(ColorY, PointD1);
// CBD1
ColoredVertex(ColorB, PointC1);
ColoredVertex(ColorG, PointB1);
ColoredVertex(ColorY, PointD1);
// BAD1
ColoredVertex(ColorG, PointB1);
ColoredVertex(ColorR, PointA1);
ColoredVertex(ColorY, PointD1);
// ABC2
ColoredVertex(ColorR, PointA2);
ColoredVertex(ColorG, PointB2);
ColoredVertex(ColorB, PointC2);
// ACD2
ColoredVertex(ColorR, PointA2);
ColoredVertex(ColorB, PointC2);
ColoredVertex(ColorY, PointD2);
// CBD2
ColoredVertex(ColorB, PointC2);
ColoredVertex(ColorG, PointB2);
ColoredVertex(ColorY, PointD2);
// BAD2
ColoredVertex(ColorG, PointB2);
ColoredVertex(ColorR, PointA2);
ColoredVertex(ColorY, PointD2);
glEnd();
glEndList();
glCallList(list);
}
void drawRightWings()
{
static int list=0;
//top wing
GLfloat PointA[] = { 0.0, 0.02, 0.0};
GLfloat PointB[] = { 0.1, 0.9, -0.32};
GLfloat PointC[] = { 0.1, 0.35, -0.36};
GLfloat PointD[] = { 0.0, 0.0, 0.0};
//middle wing
GLfloat PointA2[] = { 0.0, 0.02, 0.0};
GLfloat PointB2[] = { 0.1, 0.26, -0.37};
GLfloat PointC2[] = { 0.1, -0.2, -0.36};
GLfloat PointD2[] = { 0.0, 0.0, 0.0};
//bottom wing
GLfloat PointA1[] = { 0.0, 0.02, 0.0};
GLfloat PointB1[] = { 0.1, -0.25, -0.3};
GLfloat PointC1[] = { 0.1, -0.85, -0.3};
GLfloat PointD1[] = { 0.0, 0.0, 0.0};
GLfloat ColorR[] = {1, 0, 0};
GLfloat ColorG[] = {0, 1, 0};
GLfloat ColorB[] = {0, 0, 1};
GLfloat ColorY[] = {1, 1, 0};
list = glGenLists(1);
glNewList(list, GL_COMPILE);
glBegin(GL_TRIANGLES);
// ABC
ColoredVertex(ColorR, PointA);
ColoredVertex(ColorG, PointB);
ColoredVertex(ColorB, PointC);
// ACD
ColoredVertex(ColorR, PointA);
ColoredVertex(ColorB, PointC);
ColoredVertex(ColorY, PointD);
// CBD
ColoredVertex(ColorB, PointC);
ColoredVertex(ColorG, PointB);
ColoredVertex(ColorY, PointD);
// BAD
ColoredVertex(ColorG, PointB);
ColoredVertex(ColorR, PointA);
ColoredVertex(ColorY, PointD);
// ABC1
ColoredVertex(ColorR, PointA1);
ColoredVertex(ColorG, PointB1);
ColoredVertex(ColorB, PointC1);
// ACD1
ColoredVertex(ColorR, PointA1);
ColoredVertex(ColorB, PointC1);
ColoredVertex(ColorY, PointD1);
// CBD1
ColoredVertex(ColorB, PointC1);
ColoredVertex(ColorG, PointB1);
ColoredVertex(ColorY, PointD1);
// BAD1
ColoredVertex(ColorG, PointB1);
ColoredVertex(ColorR, PointA1);
ColoredVertex(ColorY, PointD1);
// ABC2
ColoredVertex(ColorR, PointA2);
ColoredVertex(ColorG, PointB2);
ColoredVertex(ColorB, PointC2);
// ACD2
ColoredVertex(ColorR, PointA2);
ColoredVertex(ColorB, PointC2);
ColoredVertex(ColorY, PointD2);
// CBD2
ColoredVertex(ColorB, PointC2);
ColoredVertex(ColorG, PointB2);
ColoredVertex(ColorY, PointD2);
// BAD2
ColoredVertex(ColorG, PointB2);
ColoredVertex(ColorR, PointA2);
ColoredVertex(ColorY, PointD2);
glEnd();
glEndList();
glCallList(list);
}
void drawTail(GLUquadric* gluQ, GLfloat tailAng2)
{
glPushMatrix();
glRotatef(180.0, 0.0, 1.0, 0.0);
gluSphere(gluQ, 0.32, 30, 25);
glTranslatef(0.0, 0.0, 0.2);
glRotatef(tailAng2, 1.0, 0.0, 0.0);
gluCylinder(gluQ, 0.15, 0.13, 0.36, 30, 25);
glTranslatef(0.0, 0.0, 0.4);
gluSphere(gluQ, 0.28, 30, 25);
glTranslatef(0.0, 0.0, 0.15);
glRotatef(-30.0, 1.0, 0.0, 0.0);
gluCylinder(gluQ, 0.14, 0.12, 0.3, 30, 25);
glTranslatef(0.0, 0.0, 0.3);
gluSphere(gluQ, 0.17, 30, 25);
glTranslatef(0.0, 0.0, 0.07);
glRotatef(-30.0, 1.0, 0.0, 0.0);
gluCylinder(gluQ, 0.11, 0.09, 0.2, 30, 25);
glTranslatef(0.0, 0.0, 0.19);
gluSphere(gluQ, 0.11, 30, 25);
glTranslatef(0.0, 0.0, 0.11);
glutSolidTorus(0.03, 0.05, 20, 15);
glTranslatef(0.0, 0.0, 0.03);
glutSolidTorus(0.025, 0.045, 20, 15);
glTranslatef(0.0, 0.0, 0.025);
glutSolidTorus(0.02, 0.04, 20, 15);
glTranslatef(0.0, 0.0, 0.015);
glutSolidCone(0.045, 0.1, 30, 25);
glPopMatrix();
}
void drawSnowman(GLUquadric* gluQ, GLfloat wingAng, GLfloat tailAng1, GLfloat tailAng2)
{
/*glColorMaterial(GL_FRONT, GL_AMBIENT);
glColor3f(0.75, 0.75, 0.75);
glColorMaterial(GL_FRONT, GL_EMISSION);
glColor3f(0.0, 0.2, 0.0);
glColorMaterial(GL_FRONT, GL_SPECULAR);
glColor3f(0.75, 0.75, 0.75);
glColorMaterial(GL_FRONT, GL_DIFFUSE);
glColor3f(0.75, 0.75, 0.75);*/
glPushMatrix();
//body
glColor3f(1.0, 1.0, 1.0);
gluSphere(gluQ, 0.4, 26, 13);//bottom
glPushMatrix();
glRotatef(tailAng1, 0.0, 1.0, 0.0);
glTranslatef(0.0, 0.0, -0.45);
drawTail(gluQ, tailAng2);
glPopMatrix();
glTranslatef(0.0, 0.55, 0.0);
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
龙虫旋转彩色.zip (72个子文件)
龙虫旋转彩色
.vs
Project2.1
v15
.suo 17KB
flowerRedbg.tga 192KB
Project2.1.sln 1KB
flowerGreenbg.tga 192KB
wireWave.tga 192KB
Project2.1
.vs
Project2.1
v15
Browse.VC.db 32.14MB
.suo 27KB
Project2.1.sln 897B
Project2.1
tgaload.h 4KB
Project2.1.vcxproj.filters 1KB
Project2.1.vcxproj 3KB
flowerRedbg.tga 192KB
tgaload.cpp 11KB
flowerGreenbg.tga 192KB
dragonSkin.tga 192KB
wireWave.tga 192KB
Project2.1.vcxproj.user 165B
pheonixFeather.tga 192KB
flowerBluebg.tga 192KB
Debug
vc110.idb 651KB
link.7316.read.1.tlog 2B
CL.write.1.tlog 2KB
link.7588-cvtres.write.1.tlog 2B
CL.read.1.tlog 67KB
link.7316-cvtres.write.1.tlog 2B
link.7316-rc.read.1.tlog 2B
link.7588.write.1.tlog 2B
tgaload.obj 48KB
link.4344.write.1.tlog 2B
Project2.1.tlog
CL.write.1.tlog 1KB
CL.read.1.tlog 39KB
CL.command.1.tlog 1KB
link.delete.1.tlog 824B
Project2.1.lastbuildstate 242B
link.write.1.tlog 618B
link.command.1.tlog 1KB
link.read.1.tlog 4KB
cl.command.1.tlog 2KB
link-cvtres.read.1.tlog 2B
link.7316-cvtres.read.1.tlog 2B
link.4344-cvtres.write.1.tlog 2B
link.4344-rc.read.1.tlog 2B
link.4344-rc.write.1.tlog 2B
link.7588-rc.read.1.tlog 2B
Project2.1.lastbuildstate 77B
link.7588-rc.write.1.tlog 2B
link.write.1.tlog 648B
link.7316-rc.write.1.tlog 2B
link-rc.write.1.tlog 2B
link-cvtres.write.1.tlog 2B
link.command.1.tlog 1KB
link-rc.read.1.tlog 2B
link.read.1.tlog 3KB
vc110.pdb 148KB
vc141.idb 403KB
link.7588-cvtres.read.1.tlog 2B
link.4344-cvtres.read.1.tlog 2B
link.7588.read.1.tlog 2B
link.7316.write.1.tlog 2B
Main.obj 116KB
vc141.pdb 164KB
Project2.1.log 885B
link.4344.read.1.tlog 2B
butterfly.tga 192KB
Main.cpp 24KB
Project2.1.v11.suo 23KB
Project2.1.sdf 27.94MB
Debug
Project2.1.pdb 532KB
Project2.1.ilk 528KB
Project2.1.exe 80KB
flowerBluebg.tga 192KB
Project2.1.exe 69KB
共 72 条
- 1
资源评论
脸上来点笑噻
- 粉丝: 19
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Python学习资料&项目源码-天气应用程序
- PostgreSQL JDBC 驱动包,最新的基于 jdk 1.6 的 jdbc 驱动包
- s,p,j,spj建表.sql
- 资源专区-课程设计-编程作业-计算机网络基础资源-计算机网络、现代通信组网相关的教程&案例&相关项目
- ST3007SRG-VB一款SOT23封装P-Channel场效应MOS管
- 资源专区-课程设计-编程作业-【docker配置使用】资源&&详细讲解使用
- 基于microPython开发单片机实现utf-8转gb2312
- kmp算法的C语言实现项目源代码课设.zip
- dbeaver-ce-24.1.0
- 资源专区-小白必看-通信仿真资源-傅里叶变换、滤波器、FFT等经典算法
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功