资源简介
这是一个在VC6上实现的一个粒子系统,该系统用粒子模拟瀑布水流,系统产生很多粒子,粒子自由下落,打在地面的平面上又溅起再下落。每个粒子都有初速度和运动方向,粒子是用OpenGL的小球模拟的,粒子运动是用OpenGL的回调函数glutIdleFunc(animation)的animation()函数实现的。
代码片段和文件信息
/*
模拟瀑布的粒子系统
*/
#include
#include
#include
#include
// variables to keep track of the current rotation on each axis
GLfloat camPitch = 0.0 camYaw = 1.0 camRadius = 12.0;
int mxmy; // used to calculate mouse displacement
int mdown; // is a button down?
int buttonDown; // if so which button?
char *outfile = “windowDump.raw“;
typedef GLfloat point3[3];
GLfloat t=0.0; // parameter for the family of functions
#define HOWMANY 1000000
#define ToUpdate 100
int WIDTH = 500;
int HEIGHT = 500;
static GLubyte bufImage[500][500][3];
float particles[HOWMANY][7];
GLfloat white[] = {1.0 1.0 1.0 1.0};
GLfloat yellow[]= {1.0 1.0 0.0 1.0};
GLfloat mat_shininess[]={ 30.0 };
// function prototypes follow
GLfloat XX( int );
GLfloat ZZ( int );
void myinit( void );
float tweak(float);
void particlesInit(int);
void update(int);
void drawParticle(int);
void waterfall(void);
//void surface( void );
void display( void );
void reshape( int int );
void keyboard(unsigned char int int );
void animate( void );
void saveWindow(char * int int);
// initialize OpenGL and all necessary global variables
void myinit(void)
{
int i;
GLfloat light_pos0[]={ 0.0 10.0 10.0 1.0 }; // first light over z-axis
GLfloat light_col0[]={ 1.0 0.0 0.0 1.0 }; // and red
GLfloat amb_color0[]={ 0.3 0.0 0.0 1.0 }; // even ambiently
GLfloat light_pos1[]={ 5.0 10.0 -7.26 1.0 }; // second light back/right
GLfloat light_col1[]={ 0.0 1.0 0.0 1.0 }; // and green
GLfloat amb_color1[]={ 0.0 0.3 0.0 1.0 }; // even ambiently
GLfloat light_pos2[]={ -5.0 10.0 -7.26 1.0 }; // third light back/left
GLfloat light_col2[]={ 0.0 0.0 1.0 1.0 }; // and blue
GLfloat amb_color2[]={ 0.0 0.0 0.3 1.0 }; // even ambiently
// set up overall light data
GLfloat mat_specular[] ={ 0.8 0.8 0.8 1.0 };
glClearColor( 0.0 0.0 1.0 0.0 );
glShadeModel(GL_SMOOTH); // use gourand shading
glMaterialfv(GL_FRONT_AND_BACK GL_SPECULAR mat_specular );
glLightfv(GL_LIGHT0 GL_POSITION light_pos0 ); // light 0
glLightfv(GL_LIGHT0 GL_AMBIENT amb_color0 );
glLightfv(GL_LIGHT0 GL_SPECULAR light_col0 );
glLightfv(GL_LIGHT0 GL_DIFFUSE light_col0 );
glLightfv(GL_LIGHT1 GL_POSITION light_pos1 ); // light 1
glLightfv(GL_LIGHT1 GL_AMBIENT amb_color1 );
glLightfv(GL_LIGHT1 GL_SPECULAR light_col1 );
glLightfv(GL_LIGHT1 GL_DIFFUSE light_col1 );
glLightfv(GL_LIGHT2 GL_POSITION light_pos2 ); // light 2
glLightfv(GL_LIGHT2 GL_AMBIENT amb_color2 );
glLightfv(GL_LIGHT2 GL_SPECULAR light_col2 );
glLightfv(GL_LIGHT2 GL_DIFFUSE light_col2 );
glLig
- 上一篇:进程调度的设计与实现图形界面实现源代码
- 下一篇:点云数据滤波------数学形态学
相关资源
- 安卓c语言开发SDL2+opengles
- 交互式计算机图形学 第六版 OpenGL源代
- VC++基于OpenGL模拟的一个3维空间模型
- opengl绘制汽车.cpp
- opengl实现水流效果sph
- opengl源代码,全是精华!
- OpenGL迷宫山东大学图形学实验三
- opengl的立方体消隐算法
- vc++ opengl代码爆炸
- 我见过最漂亮的CS仿真程序openGL和C+
- 广东某工业大学的openGL课程设计
- 使用OpenGL实现多个小球在密闭空间内
- 利用openGL和C++实现光线跟踪绘图的完
- OpenGl C++太阳系小行星运行系统 可切换
- vc++和OpenGL实现三维地形实时动态显示
- C++实现利用OpenGL实现三维绘图
- 太阳、地球、月亮之间的运动图Open
- MFC 单文档 实现opengl 三维旋转 缩放
- OPENGL的烟花程序(代码)
- MFC+OpenGL三维建模与动画显示
- 基于opengl粒子系统实现喷泉的模拟
- 一个基于openGL的太阳系模型,太阳地
- vc6.0+opengl纯色五角星填充
- vc6.0+opengl动态绘制五角星
- NeHe_OpenGL教程完整版 里面有地址可以
- OpenGL简单——实现立方体贴上不同纹
- MFC实现dem的读取与现实
- VC++ OpenGL三维地形漫游
- OpenGL实现三维地形实时动态显示
- VC++中Opengl实现建筑物虚拟漫游
评论
共有 条评论