资源简介
OpenGL编程实现绘制房子,树,月亮,3D,可以进行旋转

代码片段和文件信息
#include
#include
#include
#include
#include
//---------------喷泉相关------------------------------------
struct particle
{
float t; // 粒子的寿命
float v; // 粒子的运动速度
float d; // 粒子的运动方向
float x y z; // 粒子的位置坐标
float xd zd; // X 和 Z 方向上的增量
char type; // 粒子的状态(移动或淡化)
float a; // 粒子淡化的 alpha 值
struct particle *next *prev;
};
struct particle *fn=NULL; /* Fountains 链表结构*/
int timep=17;
//--------------------------------------------------------------------
float flag=1.0;
GLfloat theta=3.1415*0.2fai=3.1415*0.7;
GLfloat P0X=120.0*sin(theta)*sin(fai)P0Y=120*cos(fai)P0Z=120.0*cos(theta)*sin(fai);
int windowwwindowh; //窗口的宽和高
static GLuint texName; //纹理组的名称
//依序为月亮、侧面、地面
GLuint drawwalllistmoonlistrooflisttreeliststoolliststartList; //贴环境纹理的显示列表
GLUquadricObj *qobj;
//------------------------------------------------------------
GLfloat ctrlpoints[4][4][3];
GLfloat texpts[2][2][2] = {{{0.7 0.7} {0.7 1}}
{{1 0.7} {1 1}}};
//-----------------------喷泉相关-----------------------------
void AddParticles()
{
struct particle *tempp;
int i;
for (i=0; i<15; i++)
{
tempp = (struct particle *)malloc(sizeof(struct particle));
if (fn) fn->prev = tempp;
tempp->next = fn;
fn = tempp;
tempp->t = -9.9;
tempp->v = (float)(rand() % 200000)/100000+1; // 速度
tempp->d = (float)(rand() % 400)/100-2; // 方向角度
// 开始运动的坐标
tempp->x = 0;
tempp->y = 0;
tempp->z = i*2;
tempp->xd = cos((tempp->d*3.14159)/180)*tempp->v/4;
tempp->zd = sin((tempp->d*3.14159)/180)*tempp->v;
tempp->type = 0;
tempp->a = 1;
}
}
// 移动粒子
void MoveParticles()
{
struct particle *tempp;
{
tempp = fn;
while (tempp)
{
if (tempp->type == 0) // 如果粒子是运动的
{
tempp->x += tempp->xd;
tempp->z += tempp->zd;
tempp->y = -(9.8*(tempp->t*tempp->t/4))/2+122.5; // 计算高度
tempp->t += 0.1; // 寿命递增
if (tempp->y < 0) tempp->type = 1; // 如果粒子落到地上,则粒子淡化
}
else // 粒子落到地上
{
tempp->y = -(9.8*(tempp->t*tempp->t/4))/2+122.5;
}
tempp = tempp->next; //进行下一个粒子的计算
}
}
}
// 删除粒子
void DeleteParticles()
{
struct particle *tempp *temp1;
{
tempp = fn;
while (tempp)
{
if ((tempp->type == 1) && (tempp->a <= 0)) // 粒子死亡
{
// 删除粒子
temp1 = tempp->prev;
tempp->prev->next = tempp->next;
if (tempp->next) tempp->next->prev = temp1;
free(tempp);
tempp = temp1;
}
tempp = tempp->next;
}
}
}
void timf(int value)
{
glutPostRedisplay();
glutTimerFunc(timep timf 0);
}
//-------------------------------------------------------------
void readimage(char
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 196664 2005-06-12 17:52 source code\door.bmp
文件 196664 2005-06-13 00:05 source code\floor.bmp
文件 196664 2005-06-12 15:10 source code\moon.bmp
文件 20534 2005-06-18 23:05 source code\Pond.cpp
文件 49208 2005-06-12 16:34 source code\roof.bmp
文件 49208 2005-06-12 19:05 source code\starlow.bmp
..A.SH. 21504 2005-06-18 23:06 source code\Thumbs.db
文件 227071 2007-04-11 16:16 月色.pdf
目录 0 2005-06-18 23:06 source code
----------- --------- ---------- ----- ----
957735 10
相关资源
- OpenGL参考手册
- Qt Creator opengl实现四元数鼠标控制轨迹
- 中科院 编译原理 习题及解答
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 华北科技学院计算机系认识实习报告
- 北京邮电大学 计算机院 复试机试
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 课程设计——医院病房管理系统
- 武汉大学测绘学院大地测量学编程-
- 武汉大学测绘学院大地测量学编程-
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- OPENGL实现世界上最小的3D游戏
- 医院后勤管理系统
- 由国家自然科学基金委员会U1232105和中
- 二院型号FPGA 硬件描述语言编程准则
- 埃塞俄比亚东北部Dessie转诊医院的糖
- CommVault为番禺中心医院新医改护航
- VS2012OpenGL配置所需要的全部libdllh文件
- 稳健中推进 天津市第一中心医院的信
- 飞康CDP保障天津肿瘤医院数据备份与
评论
共有 条评论