#include "box.h"
#include <windows.h>
#include <iostream>
#include <glaux.h>
#include <tchar.h>
#include <math.h>
#include <glut.h>
#include "sky.h"
using namespace std;
#define M_PI 3.1415926;
#define n 1000;
GLint image=GL_RGB;
GLfloat border_color[]={1.00,0.00,0.00,1.00};
GLfloat env_color[]={1.00,1.00,1.00,1.00};
//纹理
GLuint picture[4][6];
char *pic[4][6]={{"frount.bmp","back.bmp","top.bmp","top.bmp","left.bmp","left.bmp"},//前后 上下 右左
{"MR.bmp","BEI.bmp","BEI.bmp","BEI.bmp","BEI.bmp","BEI.bmp"},
{"BEI.bmp","BEI.bmp","BEI.bmp","BEI.bmp","BEI.bmp","BEI.bmp"},
{"grass.bmp","grass.bmp","sky.bmp","ground.bmp","grass.bmp","grass.bmp"}
};
//【0】头
//【1】身体
//【2】手臂/腿
//[3]背景
GLuint *g;
GLint selectedIndex = 0;
GLint tmode=GL_MODULATE;
GLint parameter=GL_REPEAT;
GLfloat ax = -0.9f; //第一个张小盒的初始坐标
GLfloat ay = 0.0f;
GLfloat az = 0.0f;
GLfloat mx = 1.0f; //第一个张小盒的缩放倍数
GLfloat my = 1.0f;
GLfloat mz = 1.0f;
GLfloat thetaA[3] = { 0.0, 0.0, 0.0 }; //第一个张小盒每个轴的旋转角
//旋转角度
GLfloat xA[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };//左腿 右腿 左臂 右臂 身体 x坐标
GLfloat yA[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };//左腿 右腿 左臂 右臂 身体 y坐标
GLfloat zA[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };//左腿 右腿 左臂 右臂 身体 z坐标
//GLfloat light[3] = { 0.0, 20.0, 20.0 };
GLfloat m[16];
GLfloat light_ambient[]={1.0,1.0,1.0,1.0};//环境光
GLfloat light_diffuse[]={0.0,1.0,0.0,1.0};//散射光
GLfloat light_specular[]={1.0,1.0,1.0,1.0};//镜面反射光
GLfloat light_position[]={0.0,5.0,5.0,0.0};//光源位置
//GLfloat material_ambient[]={1.0,0.0,0.0,1.0};//环境光材质属性
//GLfloat material_diffuse[]={0.0,1.0,0.0,1.0};//散射光材质属性
//GLfloat material_specular[]={0.0,0.0,1.0,1.0};//镜面反射光材质属性
void shadow()
{
int i, j;
for (i = 0; i<16; i++) m[i] = 0.0;
m[0] = m[5] = m[10] = 1.0;
m[7] = -1.0 / (light_position[1] + 0.6);
}
void drawA()//绘制第一个张小盒
{
glRotatef(thetaA[0], 1.0, 0.0, 0.0);
glRotatef(thetaA[1], 0.0, 1.0, 0.0);
glRotatef(thetaA[2], 0.0, 0.0, 1.0);
glTranslatef(ax, ay, az);
glScalef(mx, my, mz);
glNormal3f(0.0, 1.3, 1.0);
drawLeftLeg(1);
drawRightLeg(1);
drawLeftArm(1);
drawRightArm(1);
drawBody(1);
}
GLfloat bx = 0.9f; //第二个张小盒的初始坐标
GLfloat by = 0.0f;
GLfloat bz = 0.0f;
GLfloat nx = 1.0f; //第二个张小盒的缩放倍数
GLfloat ny = 1.0f;
GLfloat nz = 1.0f;
GLfloat thetaB[3] = { 0.0, 0.0, 0.0 }; //第二个张小盒每个轴的旋转角
//旋转角度
GLfloat xB[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };//左腿 右腿 左臂 右臂 身体 x坐标
GLfloat yB[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };//左腿 右腿 左臂 右臂 身体 y坐标
GLfloat zB[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };//左腿 右腿 左臂 右臂 身体 z坐标
GLfloat cx = 0.0f; //球的初始坐标
GLfloat cy = 0.0f;
GLfloat cz = 0.0f;
GLfloat ox = 1.0f; //球的缩放倍数
GLfloat oy = 1.0f;
GLfloat oz = 1.0f;
GLfloat thetaC[3] = { 0.0, 0.0, 0.0 }; //球每个轴的旋转角
void drawB()//绘制第二个张小盒
{
glTranslatef(bx, by, bz);
glScalef(nx, ny, nz);
glRotatef(thetaB[0], 1.0, 0.0, 0.0);
glRotatef(thetaB[1], 0.0, 1.0, 0.0);
glRotatef(thetaB[2], 0.0, 0.0, 1.0);
//glNormal3f(0.0, 1.3, 1.0);
drawLeftLeg(2);
drawRightLeg(2);
drawLeftArm(2);
drawRightArm(2);
drawBody(2);
}
void drawLeftLeg(int id)
{
if (id == 2)
{
glPushMatrix();
//glColor3f(1.0, 0.5, 0.5);
glTranslatef(0, 0.15, 0);
glTranslatef(-0.07, -0.4, 0.0);
glRotatef(xB[0], 1.0, 0.0, 0.0);
glRotatef(yB[0], 0.0, 1.0, 0.0);
glRotatef(zB[0], 0.0, 0.0, 1.0);
glTranslatef(0, -0.15, 0);
changfangxing(vertices3,picture[2]);
//glColor3f(1.0, 0.0, 0.0);
changkuang(vertices3);//左腿
glPopMatrix();
}
else
{
glPushMatrix();
//glColor3f(1.0, 0.5, 0.5);
glTranslatef(0, 0.15, 0);
glTranslatef(-0.07, -0.4, 0.0);
glRotatef(xA[0], 1.0, 0.0, 0.0);
glRotatef(yA[0], 0.0, 1.0, 0.0);
glRotatef(zA[0], 0.0, 0.0, 1.0);
glTranslatef(0, -0.15, 0);
changfangxing(vertices3,picture[2]);
//glColor3f(1.0, 0.0, 0.0);
changkuang(vertices3);//左腿
glPopMatrix();
}
}
void drawRightLeg(int id)
{
if (id == 2)
{
glPushMatrix();
//glColor3f(1.0, 0.5, 0.5);
glTranslatef(0, 0.15, 0);
glTranslatef(0.07, -0.4, 0.0);
glRotatef(xB[1], 1.0, 0.0, 0.0);
glRotatef(yB[1], 0.0, 1.0, 0.0);
glRotatef(zB[1], 0.0, 0.0, 1.0);
glTranslatef(0, -0.15, 0);
changfangxing(vertices3,picture[2]);
//glColor3f(1.0, 0.0, 0.0);
changkuang(vertices3);//右腿
glPopMatrix();
}
else
{
glPushMatrix();
//glColor3f(1.0, 0.5, 0.5);
glTranslatef(0, 0.15, 0);
glTranslatef(0.07, -0.4, 0.0);
glRotatef(xA[1], 1.0, 0.0, 0.0);
glRotatef(yA[1], 0.0, 1.0, 0.0);
glRotatef(zA[1], 0.0, 0.0, 1.0);
glTranslatef(0, -0.15, 0);
changfangxing(vertices3,picture[2]);
//glColor3f(1.0, 0.0, 0.0);
changkuang(vertices3);//右腿
glPopMatrix();
}
}
void drawLeftArm(int id)
{
if (id == 1)
{
glPushMatrix();
//glColor3f(1.0, 0.5, 0.5);
glTranslatef(0.0, 0.17, 0.0);
glTranslatef(-0.4, -0.0, 0.0);
glRotatef(xA[2], 1.0, 0.0, 0.0);
glRotatef(yA[2], 0.0, 1.0, 0.0);
glRotatef(zA[2], 0.0, 0.0, 1.0);
glTranslatef(0.0, -0.17, 0.0);
changfangxing(vertices5,picture[2]);
//glColor3f(1.0, 0.0, 0.0);
changkuang(vertices5);//左胳膊
glPopMatrix();
}
else
{
glPushMatrix();
//glColor3f(1.0, 0.5, 0.5);
glTranslatef(0.0, 0.17, 0.0);
glTranslatef(-0.4, -0.0, 0.0);
glRotatef(xB[2], 1.0, 0.0, 0.0);
glRotatef(yB[2], 0.0, 1.0, 0.0);
glRotatef(zB[2], 0.0, 0.0, 1.0);
glTranslatef(0.0, -0.17, 0.0);
changfangxing(vertices5,picture[2]);
//glColor3f(1.0, 0.0, 0.0);
changkuang(vertices5);//左胳膊
glPopMatrix();
}
}
void drawRightArm(int id)
{
if (id == 1)
{
glPushMatrix();
//glColor3f(1.0, 0.5, 0.5);
glTranslatef(0.4, -0.0, 0.0);
glTranslatef(0.0, 0.17, 0.0);
glRotatef(xA[3], 1.0, 0.0, 0.0);
glRotatef(yA[3], 0.0, 1.0, 0.0);
glRotatef(zA[3], 0.0, 0.0, 1.0);
glTranslatef(0.0, -0.17, 0.0);
changfangxing(vertices4,picture[2]);
//glColor3f(1.0, 0.0, 0.0);
changkuang(vertices4);//右胳膊
glPopMatrix();
}
else{
glPushMatrix();
//glColor3f(1.0, 0.5, 0.5);
glTranslatef(0.4, -0.0, 0.0);
glTranslatef(0.0, 0.17, 0.0);
glRotatef(xB[3], 1.0, 0.0, 0.0);
glRotatef(yB[3], 0.0, 1.0, 0.0);
glRotatef(zB[3], 0.0, 0.0, 1.0);
glTranslatef(0.0, -0.17, 0.0);
changfangxing(vertices4,picture[2]);
//glColor3f(1.0, 0.0, 0.0);
changkuang(vertices4);//右胳膊
glPopMatrix();
}
}
void drawBody(int id)
{
glPushMatrix();
//glColor3f(1.0, 0.5, 0.5);
glTranslatef(0.0, 0.5, 0.0);
changfangxing(vertices1,picture[0]);
//glColor3f(1.0, 0.0, 0.0);
changkuang(vertices1);//脑袋
glPopMatrix();
glPushMatrix();
//glColor3f(1.0, 0.5, 0.5);
changfangxing(vertices2,picture[1]);
//glColor3f(1.0, 0.0, 0.0);
changkuang(vertices2);//身体
glPopMatrix();
glPushMatrix();
glColor3f(0.0, 0.0, 0.0);
glTranslatef(0.2, 0.5, 0.3);
glutSolidSphere(0.045f, 1000, 1000); //左眼
glPopMatrix();
glPushMatrix();
glColor3f(0.0, 0.0, 0.0);
glTranslatef(-0.2, 0.5, 0.3);
glutSolidSphere(0.045f, 1000, 1000); //右眼
glPopMatrix();
glPushMatrix();
glColor3f(0.0, 0.0, 0.0);
glTranslatef(0.0, 0.2, 0.31);
sanjiaoxing(vertices6); //嘴
glPopMatrix();
}
void drawBall(int a)//绘制皮球
{
if(a==0){
glPushMatrix();
glTranslatef(cx, cy, cz);
glScalef(ox, oy, oz);
glRotatef(thetaC[0], 1.0, 0.0, 0.0);
glRotatef(thetaC[1], 0.0, 1.0, 0.0);
glRotatef(thetaC[2], 0.0, 0.0, 1.0);
glTranslatef(0.0, -0.4, 0.0);
glutWireSphere(0.201, 10, 18);
GLfloat ball_ambient[]={1.0,0.0,0.0,1.0};
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,ball_ambient);//环境光材质属性
glColor3f(0.9,0.5,0.0);
glutSolidSphere(0.2, 100, 100);
glPopMatrix();
glPushMatrix();
glTranslatef(-cx, cy, cz);
glPopMatr
没有合适的资源?快使用搜索试试~ 我知道了~
Mr.box-(2).zip_opengl 阴影_课程设计
共23个文件
bmp:7个
obj:3个
pdb:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 44 浏览量
2022-09-24
20:19:33
上传
评论
收藏 6.13MB ZIP 举报
温馨提示
opengl的简单实现 课程设计:包括简单的绘制、光照、阴影、贴图等
资源推荐
资源详情
资源评论
收起资源包目录
Mr.box-(2).zip (23个子文件)
Mr.box
Mr.box
left.bmp 192KB
mingAn.cpp 31KB
BEI.bmp 192KB
Mr.box.vcproj.maple-PC.maple.user 1KB
Mr.box.vcproj 4KB
box.h 11KB
MR.bmp 192KB
back.bmp 192KB
frount.bmp 192KB
Mr.box.exe 84KB
top.bmp 934KB
ground.bmp 768KB
Debug
BuildLog.htm 6KB
Mr.box.exe.intermediate.manifest 621B
mingAn.obj 170KB
vc90.pdb 260KB
vc90.idb 611KB
mt.dep 65B
wenli.obj 1KB
sky.obj 9KB
Mr.box.ncb 12.5MB
Mr.box.sln 884B
Mr.box.suo 23KB
Debug
共 23 条
- 1
资源评论
- chunhan022022-11-14资源内容详细全面,与描述一致,对我很有用,有一定的使用价值。
我虽横行却不霸道
- 粉丝: 75
- 资源: 1万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功