| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 10745 人关注过本帖
标题:[原创]喷气式发动机模拟(OpenGL)-->starrysky转移
只看楼主 加入收藏
starrysky
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:华中科技大学EI -T0405
等 级:版主
威 望:11
帖 子:602
专家分:1
注 册:2005-9-12
收藏
 问题点数:0 回复次数:42 
[原创]喷气式发动机模拟(OpenGL)-->starrysky转移

dqNpYshP.rar (213.08 KB) [原创]喷气式发动机模拟(OpenGL)-->starrysky转移

最近看到不少学弟学妹们为了学习OpenGL而忙的一塌糊涂,就把去年我做的一个程序发出来 给大家共同学习一下。看到这个程序,我心里既高兴又痛苦,痛并着快乐吧,快乐的是这个 程序是我一手做出来的,不骗你们,里面所有的程序代码全是我一个人写的,让我相当有成就感。 痛苦的是,和我一组的其他几位同学没几个真正关心这个程序(程序占总分40分啊,还有额外的加分),只是在最后几个星期假情假意做了个文档 以示自己尽了分力,个别的重头到尾问都没问一句,挂个名而已。后来程序被老师看好,说是要进什么国家库,于是又到外面炫耀。 唉,要不是我很想把程序给做出来,看看效果,我真的不想做了,大不了一齐挂了,明年都重修去。 我不图名利,但我怕心寒。 不发牢骚了,言归正传。本程序编译环境:Borland C++build6.0 由于引入了粒子系统(共60000个粒子),而且为了达到很好的效果粒子用的是三棱锥而不是点,所以运算量很大 ,对电脑要求有点高,配置不好的电脑可以在头文件中将粒子个数改少一些。由于我将说明文档整和在了程序中, 有大量的图片要处理,所以编译时会很慢(我的电脑要50多秒 CPU p4 2.4G DDR400 512M 七彩虹 Radom9800se) 请耐心等待。 因为不是最终版所以有些BUG没改(编译没有问题,只是某些功能无法实现): 程序中由于按钮控制与键盘有冲突,所以键盘控制部分的语句不能被执行。只要在按钮函数中的开头和结尾加上2个函数就能解决.具体函数现在忘了,具体方法是先让按钮判别为无,再在点击按钮时激活按钮,按钮函数执行完时再判别为无,过几天再发出来。 有时候运行程序时看不到图形,但将窗口还原再最大化就又出现了(我的机子上没出现过这个问题,但在比较差的机子上出现过,估计是显卡问题,刷新不够)。这是因为在TFormMain(TComponent* Sender)中少了几句话,没有重建窗口,请大家参考紧跟着的FormResize(TObject *Sender)后自行添加。自己不试试是不会记住的。 因为音乐打包比较大,所以把音乐删除了,但保留了音乐控制语句,请大家自行添加. 还有什么问题的话请指出。 附件中包括完整源代码和一个已经编译好的可执行文件,直接运行可执行文件就可以看到效果了。注意,源代码不能用VC++6.0直接运行,因为格式不同,要修改一些地方才可以。

下面我把主要的头文件和函数发出来 //Unit1.h //--------------------------------------------------------------------------- #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #define Max 20000 //粒子数1 有3种不同的粒子 #define Max1 20000 //粒子数2 #define Max2 20000 //粒子数3 //-------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <ExtCtrls.hpp> #include <Menus.hpp> #include <gl\gl.h> #include <gl\glu.h> #include <math.h> //--------------------------------------------------------------------------- typedef struct //粒子系统所用的结构体 { bool active; GLfloat life; GLfloat fade; GLfloat r; GLfloat g; GLfloat b; GLfloat x; GLfloat y; GLfloat z; GLfloat xi; GLfloat yi; GLfloat zi; GLfloat xg; GLfloat yg; GLfloat zg; } particles;

//--------------------------------------------------------------------- class TFormMain : public TForm { __published: // IDE-managed Components TPanel *Control_Zone; TButton *Button5; TButton *Button6; TButton *Button7; TButton *Button8; TButton *Button9; TButton *Button10; TButton *Button11; TTimer *Timer1; TButton *Button12; TStaticText *StaticText5; TStaticText *StaticText7; TStaticText *StaticText8; TStaticText *StaticText9; TStaticText *StaticText10; TStaticText *StaticText11; TStaticText *StaticText12; TStaticText *StaticText13; TButton *Button13; TStaticText *StaticText14; TStaticText *StaticText15; TStaticText *StaticText16; TButton *Button14; TButton *Button15; TMainMenu *MainMenu1; TMenuItem *File1; TMenuItem *Exit1; TMenuItem *Help2; TMenuItem *About2; TMenuItem *SearchforHelpOn2; TMenuItem *Contents2; TMenuItem *File2; TMenuItem *PrintSetup1; TMenuItem *N2; TMenuItem *SaveAs1; TMenuItem *N1; TMenuItem *N3; TMenuItem *N4; TStaticText *StaticText6; TLabel *Label1; TButton *Button1; TButton *Button2; TButton *Button3; TButton *Button4; TButton *Button16; TButton *Button17;

void __fastcall FormResize( TObject *Sender); void __fastcall FormCreate( TObject *Sender); void __fastcall FormKeyDown( TObject *Sender, WORD &Key, TShiftState Shift); void __fastcall FormMouseMove( TObject *Sender, TShiftState Shift, int X,int Y); void __fastcall FormMouseDown( TObject *Sender, TMouseButton Button,TShiftState Shift, int X, int Y ); void __fastcall FormMouseUp( TObject *Sender, TMouseButton Button,TShiftState Shift, int X, int Y ); void __fastcall FormMouseWheelDown( TObject *Sender, TShiftState Shift, TPoint &MousePos, bool &Handled ); void __fastcall FormMouseWheelUp( TObject *Sender, TShiftState Shift, TPoint &MousePos, bool &Handled ); void __fastcall Button1Click(TObject *Sender);

void __fastcall Button5Click(TObject *Sender); void __fastcall Button6Click(TObject *Sender); void __fastcall Button7Click(TObject *Sender); void __fastcall Button8Click(TObject *Sender); void __fastcall Button9Click(TObject *Sender); void __fastcall Button10Click(TObject *Sender);

void __fastcall Timer1Timer(TObject *Sender); void __fastcall Button12Click(TObject *Sender); void __fastcall Button11Click(TObject *Sender); void __fastcall Button13Click(TObject *Sender); void __fastcall Button14Click(TObject *Sender); void __fastcall Button15Click(TObject *Sender); void __fastcall Exit1Click(TObject *Sender); void __fastcall SaveAs1Click(TObject *Sender); void __fastcall PrintSetup1Click(TObject *Sender); void __fastcall Contents2Click(TObject *Sender); void __fastcall N1Click(TObject *Sender); void __fastcall SearchforHelpOn2Click(TObject *Sender); void __fastcall About2Click(TObject *Sender); void __fastcall N3Click(TObject *Sender); void __fastcall N4Click(TObject *Sender);

void __fastcall Button2Click(TObject *Sender); void __fastcall Button17Click(TObject *Sender); void __fastcall Button4Click(TObject *Sender); void __fastcall Button3Click(TObject *Sender); void __fastcall Button16Click(TObject *Sender);

private: // User declarations HDC hdc; float w, h; int PixelFormat,x,y; int I,XX; float zoom,M,J,K,n,N,V,Angle,L,O,P; HGLRC hrc; GLuint list_of_objects,waike; Graphics::TBitmap* bitmap; BOOL Left_Button_Down,inclined,key_and_mouse_down;

int loop;

public: // User declarations __fastcall TFormMain(TComponent* Sender); void __fastcall IdleLoop(TObject*, bool&); void __fastcall SetPixelFormatDescriptor(); void __fastcall SetupLighting(); void __fastcall SetupTextures(); void __fastcall FormPaint( TObject *Sender ); void __fastcall FormDestroy( TObject *Sender );

void __fastcall Prepare_All(); void __fastcall Prepare_Wolun1(); void __fastcall Prepare_Top(); void __fastcall Prepare_FireRoom(); void __fastcall Prepare_Wolun2(); void __fastcall Prepare_WeiPen(); void __fastcall Prepare_Waike1(); void __fastcall Prepare_Waike2(); void __fastcall Prepare_Waike3(); void __fastcall Prepare_Smoke1(); void __fastcall Prepare_Smoke2(); void __fastcall Prepare_Smoke3(); void __fastcall Prepare_Waike11(); void __fastcall Prepare_Waike21(); void __fastcall Prepare_Waike31(); void __fastcall Normal(float*p1,float*p2,float*p3,float*n); void __fastcall Draw_Out_All(); void __fastcall Draw_Out_Wolun1(); void __fastcall Draw_Out_Top(); void __fastcall Draw_Out_FireRoom(); void __fastcall Draw_Out_Wolun2(); void __fastcall Draw_Out_WeiPen(); void __fastcall Draw_Out_Waike1(); void __fastcall Draw_Out_Waike2(); void __fastcall Draw_Out_Waike3(); void __fastcall Draw_Out_Waike11(); void __fastcall Draw_Out_Waike21(); void __fastcall Draw_Out_Waike31(); void __fastcall polarView(); void __fastcall Draw_Out_Smoke1(); void __fastcall Draw_Out_Smoke2(); void __fastcall Draw_Out_Smoke3(); void __fastcall ShowM(); particles particle[Max]; particles particle1[Max]; particles particle2[Max]; }; //--------------------------------------------------------------------------- extern PACKAGE TFormMain *FormMain; //--------------------------------------------------------------------------- #endif //Unit1.cpp //------------------------------------------------------------------------------ #include "stdio.h" #include <vcl.h> #include "Unit1.h" #include "Unit2.h" #include "Unit6.h" #include "Unit12.h" #include "Unit14.h" #include "Unit15.h" #include "math.h" //--------------------------------------------------------------------------- #pragma hdrstop #pragma package(smart_init) #pragma resource "*.dfm" TFormMain *FormMain; //------------------------------------------------------------------------------

//--------------------------------------------------------------------------- GLfloat Throttle=5; GLfloat glow=.4; GLfloat glowp=0; //------------------------------------------------------ __fastcall TFormMain::TFormMain(TComponent* Sender) //初始化窗口 : TForm(Sender) { hdc = GetDC(Handle); Control_Zone->Top = 100; Control_Zone->Left =3* FormMain->Width/4 + 1; Control_Zone->Width = FormMain->Width/4 - 32; Control_Zone->Height = FormMain->Height -32;

Application->OnIdle = IdleLoop; Left_Button_Down = FALSE; key_and_mouse_down = FALSE; inclined = TRUE;//FALSE; zoom = 0.99; } //--------------------------------------------------------------------------- void __fastcall TFormMain::FormResize(TObject *Sender) //重置窗口 { Control_Zone->Top = 0; Control_Zone->Left =ClientWidth-150; //3*ClientWidth/4+ Control_Zone->Width = 150; //ClientWidth/4- Control_Zone->Height= ClientHeight;

float nRange =75.0; w = 3*ClientWidth/4-1; h = ClientHeight; if( h==0 ) h = 1;

glViewport(0, 0, w, h); glMatrixMode( GL_PROJECTION ); glLoadIdentity();

if ( w<=h ) glOrtho( -nRange, nRange, -nRange*h/w,nRange*h/w,-nRange,nRange ); else glOrtho( -nRange*w/h,nRange*w/h,-nRange, nRange, -nRange,nRange );

glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); inclined = TRUE; key_and_mouse_down = FALSE; } void __fastcall TFormMain::IdleLoop(TObject*, bool& done) //系统空闲的时候做什么 { done = false;

if( inclined==FALSE ) { glRotatef( 15.0, 1.0, 0.0, 0.0 ); glRotatef( -45,0.0,1.0, 0.0 ); inclined = TRUE; } if( key_and_mouse_down==FALSE ) glRotatef( 0.05, 0,1.0, 0.0);

Draw_Out_All();

SwapBuffers(hdc); } //------------------------------------------------------------------------------ void __fastcall TFormMain::SetPixelFormatDescriptor() { PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR),1, PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER, PFD_TYPE_RGBA,24, 0,0,0,0,0,0, 0,0, 0,0,0,0,0, 32, 0, 0, PFD_MAIN_PLANE, 0, 0,0,0 }; PixelFormat = ChoosePixelFormat(hdc, &pfd); SetPixelFormat( hdc, PixelFormat, &pfd ); } void __fastcall TFormMain::SetupLighting() //设置光源 { float MaterialAmbient[] = { 0.6, 0.6, 0.6, 1.0 }; float MaterialDiffuse[] = { 0.8, 0.8, 0.8, 1.0 }; float MaterialSpecular[] = { 1.0, 1.0, 1.0, 1.0 }; float MaterialShininess[] = { 80.0 }; glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, MaterialAmbient ); glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialDiffuse ); glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, MaterialSpecular ); glMaterialfv( GL_FRONT_AND_BACK, GL_SHININESS, MaterialShininess);

float AmbientLightPosition[] = { 0, 0, 30.0, 0.0 }; float LightAmbient[] = { 0.5, 0.5, 0.5, 1.0 }; glLightfv(GL_LIGHT0, GL_POSITION, AmbientLightPosition);

glLightModelfv(GL_LIGHT_MODEL_AMBIENT, LightAmbient); glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE); //双面反光

glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); glEnable( GL_COLOR_MATERIAL );

glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );

glShadeModel( GL_SMOOTH ); glEnable(GL_POLYGON_SMOOTH); } void __fastcall TFormMain::FormPaint( TObject *Sender ) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glFlush(); }

void __fastcall TFormMain::FormDestroy( TObject *Sender ) {

} void __fastcall TFormMain::FormCreate(TObject *Sender) { hdc = GetDC( Handle ); SetPixelFormatDescriptor();

hrc = wglCreateContext( hdc ); if( hrc == NULL ) ShowMessage("对不起,GL设备描述表是空的。"); if( wglMakeCurrent(hdc, hrc) == false ) ShowMessage("对不起 MakeCurrent() 执行不了。"); w = ClientWidth; h = ClientHeight;

glEnable( GL_DEPTH_TEST ); glDisable( GL_CULL_FACE ); glClearColor(0.1f,0.1f, 0.3f, 0.0f); SetupLighting(); //********************************** Control_Zone->Top = 0; Control_Zone->Left =ClientWidth-150; //3*ClientWidth/4+ Control_Zone->Width = 150; // ClientWidth/4- Control_Zone->Height= ClientHeight;

float nRange =75.0; w = 3*ClientWidth/4-1; h = ClientHeight; if( h==0 ) h = 1;

glViewport(0, 0, w, h); glMatrixMode( GL_PROJECTION ); glLoadIdentity();

if ( w<=h ) glOrtho( -nRange, nRange, -nRange*h/w,nRange*h/w,-nRange,nRange ); else glOrtho( -nRange*w/h,nRange*w/h,-nRange, nRange, -nRange,nRange );

glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); inclined = TRUE; key_and_mouse_down = FALSE; //********************************** Prepare_All(); Prepare_Smoke1(); Prepare_Smoke2(); Prepare_Smoke3(); ShowM(); } //---------------------------------------------------------------------------

[此贴子已经被作者于2005-10-20 10:27:41编辑过]

搜索更多相关主题的帖子: OpenGL starrysky 喷气式 发动机 
2005-10-20 09:32
starrysky
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:华中科技大学EI -T0405
等 级:版主
威 望:11
帖 子:602
专家分:1
注 册:2005-9-12
收藏
得分:0 

void __fastcall TFormMain::FormKeyDown(TObject *Sender, WORD &Key,TShiftState Shift) //键盘控制,

{ if( Key == VK_UP ) { key_and_mouse_down=TRUE; glRotatef(-5, 1.0, 0.0, 0.0); } if( Key == VK_DOWN ) { key_and_mouse_down = TRUE; glRotatef( 5, 1.0, 0.0, 0.0); } if( Key == VK_LEFT ) { key_and_mouse_down = TRUE; glRotatef(-5, 0.0, 1.0, 0.0); } if( Key == VK_RIGHT ) { key_and_mouse_down = TRUE; glRotatef( 5, 0.0, 1.0, 0.0); } if( Key == VK_ESCAPE ) { glLoadIdentity(); glRotatef( 15.0, 1.0, 0.0, 0.0 ); glRotatef( -45.0, 0.0, 1.0, 0.0 ); inclined = TRUE; key_and_mouse_down = FALSE; } if( Key == VK_ADD ) { glScalef(1/zoom,1/zoom,1/zoom); } if( Key == VK_SUBTRACT ) { glScalef(zoom,zoom,zoom); } }

void __fastcall TFormMain::FormMouseDown(TObject *Sender,TMouseButton Button, TShiftState Shift, int X, int Y)//鼠标控制 { if( Button==mbLeft ) { Left_Button_Down = TRUE; key_and_mouse_down = TRUE; x = X; y = Y; } else if( Button==mbRight ) { glLoadIdentity(); glRotatef( 30, 1.0, 0.0, 0.0 ); glRotatef( 15, 0.0, 1.0, 0.0 ); inclined = TRUE;

Left_Button_Down = FALSE; key_and_mouse_down = FALSE; } else Left_Button_Down = FALSE; } void __fastcall TFormMain::FormMouseUp(TObject *Sender,TMouseButton Button, TShiftState Shift, int X, int Y) { Left_Button_Down = FALSE; } void __fastcall TFormMain::FormMouseMove(TObject *Sender,TShiftState Shift, int X, int Y) { if( Left_Button_Down==TRUE ) { if( x != X ) glRotatef( (X-x)/4, 0.0, 1.0, 0.0); if( y != Y ) glRotatef( (Y-y)/4, 1.0, 0.0, 0.0); x = X; y = Y; } } void __fastcall TFormMain::FormMouseWheelDown(TObject *Sender,TShiftState Shift, TPoint &MousePos, bool &Handled) { glScalef( zoom,zoom,zoom ); } void __fastcall TFormMain::FormMouseWheelUp(TObject *Sender,TShiftState Shift, TPoint &MousePos, bool &Handled) { glScalef( 1/zoom,1/zoom,1/zoom ); }

void __fastcall TFormMain::Normal( float*p1,float*p2,float*p3,float*n ) //三维坐标转置矩阵 { float A[3], B[3], l; A[0] = p1[0] - p2[0]; A[1] = p1[1] - p2[1]; A[2] = p1[2] - p2[2];

B[0] = p3[0] - p2[0]; B[1] = p3[1] - p2[1]; B[2] = p3[2] - p2[2];

n[0] = B[1]*A[2] - B[2]*A[1]; n[1] = B[2]*A[0] - B[0]*A[2]; n[2] = B[0]*A[1] - B[1]*A[0];

l = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]); if(l!=0) { n[0]=n[0]/l; n[1]=n[1]/l; n[2]=n[2]/l; } } //---- //------------------------------------------------------------------------------ void __fastcall TFormMain::Prepare_All() //做好准备工作 ,建立所有静态物体的模型 { list_of_objects = glGenLists(6); Prepare_Wolun1(); Prepare_Top(); Prepare_FireRoom(); Prepare_Wolun2(); Prepare_WeiPen(); waike=glGenLists(3); Prepare_Waike1(); Prepare_Waike2(); Prepare_Waike3(); Prepare_Waike11(); Prepare_Waike21(); Prepare_Waike31(); }


我的征途是星辰大海
2005-10-20 09:33
starrysky
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:华中科技大学EI -T0405
等 级:版主
威 望:11
帖 子:602
专家分:1
注 册:2005-9-12
收藏
得分:0 

// 以下是 Prepare_All()的子函数

void __fastcall TFormMain::Prepare_Wolun1() {

GLUquadricObj *quadObj; glNewList(list_of_objects,GL_COMPILE); int n; for(n=0;n<72;n++) { GLfloat p1[]={0,0,0}; GLfloat p2[]={-0.5,15*cos(3.141592653*(n+1)/36),15*sin(3.141592653*(n+1)/36)} ; GLfloat p3[]={0.5,15*cos(3.141592653*n/36),15*sin(3.141592653*n/36)};

GLfloat m[3];GLfloat n[3]; Normal(p1,p2,p3,m); Normal(p3,p2,p1,n); glBegin(GL_POLYGON); glColor3f(0.8,0.8,0.8); glNormal3f(m[0],m[1],m[2]); glVertex3f(p1[0],p1[1],p1[2]); glVertex3f(p2[0],p2[1],p2[2]); glVertex3f(p3[0],p3[1],p3[2]); glEnd(); }; glPushMatrix(); glColor3f(0.3,0.3,0.3); glTranslatef(-0.25,0,0); glRotatef( -90.0,0.0,1.0, 0.0 ); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); gluCylinder(quadObj,7.5,2.8,1,36,2); glPopMatrix();

glPushMatrix(); glColor3f(0.3,0.3,0.3); glTranslatef(1.25,0,0); glRotatef(-90.0,0.0,1.0, 0.0 ); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); gluCylinder(quadObj,2.8,7.5,1,36,2); glPopMatrix();

glPushMatrix(); glColor3f(0.3,0.3,0.3); glTranslatef(3.5,0,0); glRotatef(-90.0,0.0,1.0, 0.0 ); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); gluCylinder(quadObj,2.8,2.8,10,36,2); glPopMatrix();

glEndList(); }

void __fastcall TFormMain:: Prepare_Top() { GLUquadricObj *quadObj; glNewList(list_of_objects+1,GL_COMPILE); glPushMatrix(); glColor3f(0.3,0.3,0.3); glTranslatef(1.25,0,0); glRotatef(-90.0,0.0,1.0, 0.0 ); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); gluCylinder(quadObj,4.5,2.8,10,36,2); gluCylinder(quadObj,4.5,0,0,36,2); glColor3f(0.45,0.45,0.45); gluCylinder(quadObj,17,17,7,36,2); gluCylinder(quadObj,16,16,7,36,2); gluCylinder(quadObj,17,16,0,36,2); //------------------------------------ glColor3f(0.4,0.4,0.4); int n; for(n=0;n<12;n++) { GLfloat p1[]={0,0,0.1}; GLfloat p2[]={0,0,5}; GLfloat p3[]={16.8*cos(3.141592653/54+3.141592653*n/6),16.8*sin(3.141592653/54+3.141592653*n/6),0.1} ; GLfloat p4[]={16.8*cos(3.141592653/54+3.141592653*n/6),16.8*sin(3.141592653/54+3.141592653*n/6),5}; GLfloat p5[]={16.8*cos(-3.141592653/54+3.141592653*n/6),16.8*sin(-3.141592653/54+3.141592653*n/6),0.1} ; GLfloat p6[]={16.8*cos(-3.141592653/54+3.141592653*n/6),16.8*sin(-3.141592653/54+3.141592653*n/6),5}; GLfloat m[3];GLfloat n[3];

Normal(p1,p2,p3,m); glBegin(GL_POLYGON); glNormal3f(m[0],m[1],m[2]); glVertex3f(p1[0],p1[1],p1[2]); glVertex3f(p2[0],p2[1],p2[2]); glVertex3f(p4[0],p4[1],p4[2]); glVertex3f(p3[0],p3[1],p3[2]); glEnd();

Normal(p1,p2,p5,m); glBegin(GL_POLYGON); glNormal3f(m[0],m[1],m[2]); glVertex3f(p1[0],p1[1],p1[2]); glVertex3f(p2[0],p2[1],p2[2]); glVertex3f(p6[0],p6[1],p6[2]); glVertex3f(p5[0],p5[1],p5[2]); glEnd();

Normal(p1,p3,p5,m); glBegin(GL_POLYGON); glNormal3f(m[0],m[1],m[2]); glVertex3f(p1[0],p1[1],p1[2]); glVertex3f(p3[0],p3[1],p3[2]); glVertex3f(p5[0],p5[1],p5[2]); glEnd();

Normal(p4,p2,p6,m); glBegin(GL_POLYGON); glNormal3f(m[0],m[1],m[2]); glVertex3f(p2[0],p2[1],p2[2]); glVertex3f(p6[0],p6[1],p6[2]); glVertex3f(p4[0],p4[1],p4[2]); glEnd();

}; //--------------------------------------------------------------------- glColor3f(0.5,0.5,0.5); glTranslatef(0,0,7.0); gluCylinder(quadObj,17,16,0,36,2); glTranslatef(0,0,3.0); glColor3f(0.3,0.3,0.3); gluQuadricDrawStyle(quadObj,GLU_FILL); gluSphere(quadObj,2.8,72,72); glPopMatrix();

glEndList(); }

void __fastcall TFormMain:: Prepare_FireRoom() { GLUquadricObj *quadObj;int n; glNewList(list_of_objects+2,GL_COMPILE); glPushMatrix(); glColor3f(0.3,0.3,0.3); glTranslatef(-7.25,0,0); glRotatef( 90.0,0.0,1.0, 0.0 ); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); gluCylinder(quadObj,2.8,2.8,34,36,2); glTranslatef(0,0,5); glColor3f(0.4,0.4,0.6); gluCylinder(quadObj,2.8,3.5,0,36,2); gluCylinder(quadObj,3.5,3.5,20,36,2); glTranslatef(0,0,20); gluCylinder(quadObj,2.8,3.5,0,36,2); glPopMatrix(); //---------------------------------------

glPushMatrix(); glColor3f(0.3,0.3,0.3); glRotatef( 90.0,0.0,1.0, 0.0 ); gluCylinder(quadObj,8,8,20,36,2); glTranslatef(0,0,-4); gluCylinder(quadObj,10,8,4,36,2); gluCylinder(quadObj,10,14,0,36,2); gluCylinder(quadObj,14,16,4,36,2); glColor3f(1,1,1); for (n=0;n<12;n++) { glTranslatef(11*sin(3.141592653*n/6),11*cos(3.141592653*n/6),0.01); gluCylinder(quadObj,1,1.5,5,36,2); glTranslatef(-11*sin(3.141592653*n/6),-11*cos(3.141592653*n/6),-0.01); } glColor3f(0.3,0.3,0.3); glTranslatef(0,0,4); gluCylinder(quadObj,16,16,20,36,2); glTranslatef(0,0,20); gluCylinder(quadObj,8,10,4,36,2); gluCylinder(quadObj,16,14,4,36,2); glPopMatrix(); glEndList(); } void __fastcall TFormMain:: Prepare_Wolun2()

{ GLUquadricObj *quadObj; glNewList(list_of_objects+3,GL_COMPILE); int n1; for(n1=0;n1<36;n1++) { GLfloat p1[]={0,0,0}; GLfloat p2[]={-0.7,17*cos(3.141592653*(n1+1)/18),17*sin(3.141592653*(n1+1)/18)} ; GLfloat p3[]={0.7,17*cos(3.141592653*n1/18),17*sin(3.141592653*n1/18)};

GLfloat m[3]; Normal(p1,p2,p3,m); glBegin(GL_POLYGON); glColor3f(0.8,0.8,0.8); glNormal3f(m[0],m[1],m[2]); glVertex3f(p1[0],p1[1],p1[2]); glVertex3f(p2[0],p2[1],p2[2]); glVertex3f(p3[0],p3[1],p3[2]); glEnd(); }; glPushMatrix(); glColor3f(0.3,0.3,0.3); glTranslatef(-0.35,0,0); glRotatef( -90.0,0.0,1.0, 0.0 ); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); gluCylinder(quadObj,8.5,2.8,1,36,2); glPopMatrix();

glPushMatrix(); glColor3f(0.3,0.3,0.3); glTranslatef(1.35,0,0); glRotatef(-90.0,0.0,1.0, 0.0 ); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); gluCylinder(quadObj,2.8,8.5,1,36,2); glPopMatrix();

glPushMatrix(); glColor3f(0.3,0.3,0.3); glTranslatef(3.5,0,0); glRotatef(-90.0,0.0,1.0, 0.0 ); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); gluCylinder(quadObj,2.8,2.8,10,36,2); glPopMatrix();

glPushMatrix(); glRotatef(-90.0,0.0,1.0,0.0 ); glTranslatef(0,0,2.5); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); gluCylinder(quadObj,4,0,0,36,2); glTranslatef(0,0,-1); gluCylinder(quadObj,4,4,1,36,2);

gluCylinder(quadObj,4,5.5,0,36,2); glTranslatef(0,0,-1); gluCylinder(quadObj,5.5,5.5,1,36,2); gluCylinder(quadObj,5.5,7,0,36,2);

glTranslatef(0,0,-1); gluCylinder(quadObj,7,7,1,36,2); glPopMatrix();

glEndList(); }

void __fastcall TFormMain:: Prepare_WeiPen() { GLUquadricObj *quadObj; glColor3f(0.3,0.3,0.3); glNewList(list_of_objects+4,GL_COMPILE); glPushMatrix(); glRotatef(90.0,0.0,1.0,0.0 ); glTranslatef(0,0,30); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); gluCylinder(quadObj,2.8,2.8,5,36,2); glTranslatef(0,0,5); gluCylinder(quadObj,2.8,10,0,36,2); gluCylinder(quadObj,10,0,17,36,2); glPopMatrix(); glEndList(); } void __fastcall TFormMain:: Prepare_Waike1() {

GLUquadricObj *quadObj; glNewList(waike,GL_COMPILE); glPushMatrix(); glRotatef(90.0,0.0,1.0,0.0 ); glTranslatef(0,0,-35); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); glColor3f(0.4,0.4,0.4); gluCylinder(quadObj,16,16,5,36,2); glTranslatef(0,0,5); gluCylinder(quadObj,16,16.5,1,36,2); gluCylinder(quadObj,16.5,16.5,4,36,2);

glTranslatef(0,0,4); glColor3f(0.2,0.2,0.7); gluCylinder(quadObj,16.5,16,0.5,36,2); gluCylinder(quadObj,16,16,0.5,36,2); glTranslatef(0,0,0.5); gluCylinder(quadObj,16,16.5,0.5,36,2);

glColor3f(0.4,0.4,0.4); gluCylinder(quadObj,16.5,16.5,4,36,2);

glTranslatef(0,0,4); glColor3f(0.2,0.2,0.7); gluCylinder(quadObj,16.5,16,0.5,36,2);

glTranslatef(0,0,0.5); gluCylinder(quadObj,16,16.5,0.5,36,2);

glColor3f(0.4,0.4,0.4); gluCylinder(quadObj,16.5,16.5,4,36,2);

glTranslatef(0,0,4); glColor3f(0.2,0.2,0.7); gluCylinder(quadObj,16.5,16,0.5,36,2); glTranslatef(0,0,0.5); gluCylinder(quadObj,16,16.5,0.5,36,2);

glColor3f(0.4,0.4,0.4); gluCylinder(quadObj,16.5,16.5,4,36,2);

glTranslatef(0,0,4); glColor3f(0.2,0.2,0.7); gluCylinder(quadObj,16.5,16,0.5,36,2); glTranslatef(0,0,0.5); gluCylinder(quadObj,16,16.5,0.5,36,2);

glColor3f(0.4,0.4,0.4); gluCylinder(quadObj,16.5,16.5,4,36,2);

glTranslatef(0,0,4); gluCylinder(quadObj,16.5,15,1,36,2);

glPopMatrix(); glEndList(); } void __fastcall TFormMain:: Prepare_Waike2() { GLUquadricObj *quadObj; glNewList(waike+1,GL_COMPILE); glPushMatrix(); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); glColor3f(0.3,0.3,0.7); glRotatef(90.0,0.0,1.0,0.0 ); glTranslatef(0,0,-7); gluCylinder(quadObj,15,15,4,36,2); glTranslatef(0,0,4); gluCylinder(quadObj,15,16.5,2,36,2); glTranslatef(0,0,2); gluCylinder(quadObj,16.5,17,2,36,2); glTranslatef(0,0,2); gluCylinder(quadObj,17,17,20,36,2); glTranslatef(0,0,20); gluCylinder(quadObj,17,16.5,2,36,2); glTranslatef(0,0,2); gluCylinder(quadObj,16.5,15,2,36,2); gluCylinder(quadObj,15,15,3,36,2); glPopMatrix(); glEndList(); }


我的征途是星辰大海
2005-10-20 09:34
starrysky
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:华中科技大学EI -T0405
等 级:版主
威 望:11
帖 子:602
专家分:1
注 册:2005-9-12
收藏
得分:0 
void __fastcall TFormMain:: Prepare_Waike3() {

GLUquadricObj *quadObj; glNewList(waike+2,GL_COMPILE); glPushMatrix(); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); glColor3f(0.7,0.7,0.7); glRotatef(90.0,0.0,1.0,0.0 ); glTranslatef(0,0,26); gluCylinder(quadObj,15,18,0,36,2); gluCylinder(quadObj,18,18,0.5,36,2); glTranslatef(0,0,0.5); gluCylinder(quadObj,18,17.3,1,36,2); glTranslatef(0,0,1); gluCylinder(quadObj,17.3,17.8,3,36,2); glTranslatef(0,0,3); gluCylinder(quadObj,17.8,17.8,4.5,36,2); glTranslatef(0,0,4.5); gluCylinder(quadObj,12,19,0,36,2); glColor3f(0.9,0.9,0.9); gluCylinder(quadObj,19,19,1,36,2); gluCylinder(quadObj,12,12,1,36,2); glTranslatef(0,0,1); gluCylinder(quadObj,12,19,0,36,2); gluCylinder(quadObj,18.5,15.5,15,36,2); gluCylinder(quadObj,17.5,14.5,15,36,2); glColor3f(0.1,0.1,0.1); glTranslatef(0,0,15); gluCylinder(quadObj,14.5,15.5,0,36,2); gluCylinder(quadObj,15.5,11,12,36,2); gluCylinder(quadObj,14.5,10,12,36,2); glTranslatef(0,0,12); gluCylinder(quadObj,11,10,0,36,2); glColor3f(0.3,0.3,0.3); glPopMatrix(); glEndList(); } void __fastcall TFormMain:: Prepare_Waike11() {

GLUquadricObj *quadObj; glNewList(waike+3,GL_COMPILE); glPushMatrix(); glRotatef(90.0,0.0,1.0,0.0 ); glTranslatef(0,0,-35); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); glColor3f(0.6,0.6,0.6); gluCylinder(quadObj,16,16,5,36,2); glTranslatef(0,0,5); gluCylinder(quadObj,16,16.5,1,36,2); gluCylinder(quadObj,16.5,16.5,4,36,2);

glTranslatef(0,0,4); glColor3f(0.8,0.8,0.3); gluCylinder(quadObj,16.5,16,0.5,36,2); gluCylinder(quadObj,16,16,0.5,36,2); glTranslatef(0,0,0.5); gluCylinder(quadObj,16,16.5,0.5,36,2);

glColor3f(0.6,0.6,0.6); gluCylinder(quadObj,16.5,16.5,4,36,2);

glTranslatef(0,0,4); glColor3f(0.8,0.8,0.3); gluCylinder(quadObj,16.5,16,0.5,36,2);

glTranslatef(0,0,0.5); gluCylinder(quadObj,16,16.5,0.5,36,2);

glColor3f(0.6,0.6,0.6); gluCylinder(quadObj,16.5,16.5,4,36,2);

glTranslatef(0,0,4); glColor3f(0.8,0.8,0.3); gluCylinder(quadObj,16.5,16,0.5,36,2); glTranslatef(0,0,0.5); gluCylinder(quadObj,16,16.5,0.5,36,2);

glColor3f(0.6,0.6,0.6); gluCylinder(quadObj,16.5,16.5,4,36,2);

glTranslatef(0,0,4); glColor3f(0.8,0.8,0.3); gluCylinder(quadObj,16.5,16,0.5,36,2); glTranslatef(0,0,0.5); gluCylinder(quadObj,16,16.5,0.5,36,2);

glColor3f(0.6,0.6,0.6); gluCylinder(quadObj,16.5,16.5,4,36,2);

glTranslatef(0,0,4); gluCylinder(quadObj,16.5,15,1,36,2);

glPopMatrix(); glEndList(); } void __fastcall TFormMain:: Prepare_Waike21() { GLUquadricObj *quadObj; glNewList(waike+4,GL_COMPILE); glPushMatrix(); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); glColor3f(0.7,0.7,0.3); glRotatef(90.0,0.0,1.0,0.0 ); glTranslatef(0,0,-7); gluCylinder(quadObj,15,15,4,36,2); glTranslatef(0,0,4); gluCylinder(quadObj,15,16.5,2,36,2); glTranslatef(0,0,2); gluCylinder(quadObj,16.5,17,2,36,2); glTranslatef(0,0,2); gluCylinder(quadObj,17,17,20,36,2); glTranslatef(0,0,20); gluCylinder(quadObj,17,16.5,2,36,2); glTranslatef(0,0,2); gluCylinder(quadObj,16.5,15,2,36,2); gluCylinder(quadObj,15,15,3,36,2); glPopMatrix(); glEndList(); }

void __fastcall TFormMain:: Prepare_Waike31() {

GLUquadricObj *quadObj; glNewList(waike+5,GL_COMPILE); glPushMatrix(); quadObj=gluNewQuadric(); gluQuadricNormals(quadObj,GLU_SMOOTH); glColor3f(0.3,0.7,0.3); glRotatef(90.0,0.0,1.0,0.0 ); glTranslatef(0,0,26); gluCylinder(quadObj,15,18,0,36,2); gluCylinder(quadObj,18,18,0.5,36,2); glTranslatef(0,0,0.5); gluCylinder(quadObj,18,17.3,1,36,2); glTranslatef(0,0,1); gluCylinder(quadObj,17.3,17.8,3,36,2); glTranslatef(0,0,3); gluCylinder(quadObj,17.8,17.8,4.5,36,2); glTranslatef(0,0,4.5); gluCylinder(quadObj,12,19,0,36,2); glColor3f(0.1,0.9,0.1); gluCylinder(quadObj,19,19,1,36,2); gluCylinder(quadObj,12,12,1,36,2); glTranslatef(0,0,1); gluCylinder(quadObj,12,19,0,36,2); gluCylinder(quadObj,18.5,15.5,15,36,2); gluCylinder(quadObj,17.5,14.5,15,36,2); glColor3f(0.1,0.7,0.1); glTranslatef(0,0,15); gluCylinder(quadObj,14.5,15.5,0,36,2); gluCylinder(quadObj,15.5,11,12,36,2); gluCylinder(quadObj,14.5,10,12,36,2); glTranslatef(0,0,12); gluCylinder(quadObj,11,10,0,36,2); glPopMatrix(); glEndList(); }


我的征途是星辰大海
2005-10-20 09:34
starrysky
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:华中科技大学EI -T0405
等 级:版主
威 望:11
帖 子:602
专家分:1
注 册:2005-9-12
收藏
得分:0 

//------------------------------------------------------------------------------ void __fastcall TFormMain::Draw_Out_All() //控制画图的函数,相当于装配工,按要求画出需要的图形,参数由按钮控制 { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

if(K==0){ //音乐开关

} //粒子开关 if(J==0){ if(N==0.5&&I!=10) { if(M==0) { Draw_Out_Smoke2(); Draw_Out_Smoke1(); Draw_Out_Smoke3(); } else if((M==1&&I==5)||(M==1&&I==6)) { glPushMatrix(); glTranslatef(26,0,0); Draw_Out_Smoke2(); Draw_Out_Smoke1(); Draw_Out_Smoke3(); glPopMatrix(); } else if((M==1&&I==8)||(M==1&&I==7)||(M==1&&I==9)) { glPushMatrix(); glTranslatef(-5,0,0); Draw_Out_Smoke2(); Draw_Out_Smoke1(); Draw_Out_Smoke3(); glPopMatrix(); } else if((M==1&&I==11)||(M==1&&I==12)) { glPushMatrix(); glTranslatef(-30,0,0); Draw_Out_Smoke2(); Draw_Out_Smoke1(); Draw_Out_Smoke3(); glPopMatrix(); } else if((M==1&&I==0)||(M==1&&I==1)) {

Draw_Out_Smoke2(); Draw_Out_Smoke1(); Draw_Out_Smoke3();

} } }

if(I==0) { Draw_Out_Top(); Draw_Out_Wolun1(); Draw_Out_FireRoom(); Draw_Out_Wolun2(); Draw_Out_WeiPen(); Draw_Out_Waike1(); Draw_Out_Waike2(); Draw_Out_Waike3();

}

if(I==1) { Draw_Out_Wolun1(); GLdouble equ[4]={0,0,-1,0} ; glClipPlane(GL_CLIP_PLANE0,equ); glEnable(GL_CLIP_PLANE0); Draw_Out_FireRoom(); glDisable(GL_CLIP_PLANE0); GLdouble equ1[4]={0,-1,0,0} ; glClipPlane(GL_CLIP_PLANE1,equ1); glEnable(GL_CLIP_PLANE1); Draw_Out_FireRoom(); glDisable(GL_CLIP_PLANE1); Draw_Out_Wolun2(); Draw_Out_WeiPen(); Draw_Out_Top(); }

if(I==5){ //第一 if (M==0) { Draw_Out_Top(); Draw_Out_Wolun1(); Draw_Out_FireRoom(); Draw_Out_Wolun2(); Draw_Out_WeiPen(); Draw_Out_Waike2(); Draw_Out_Waike3(); //*************************************************change color if(L==1) Draw_Out_Waike11(); else if(L==0) Draw_Out_Waike1(); } else if(M==1) { glPushMatrix(); glTranslatef(26,0,0); Draw_Out_Wolun1(); Draw_Out_Top(); Draw_Out_Waike1();glPopMatrix(); } }

if(I==6){ if (M==0) { Draw_Out_Wolun1(); Draw_Out_FireRoom(); Draw_Out_Wolun2(); Draw_Out_WeiPen(); Draw_Out_Waike2(); Draw_Out_Waike3(); Draw_Out_Top();

} else if(M==1) { glPushMatrix(); glTranslatef(26,0,0); Draw_Out_Wolun1(); Draw_Out_Top(); glPopMatrix(); } }

if(I==7){ //燃烧室 if (M==0) { Draw_Out_Top(); Draw_Out_Waike1(); Draw_Out_Wolun1(); Draw_Out_FireRoom(); Draw_Out_WeiPen(); Draw_Out_Wolun2(); Draw_Out_Waike3(); if(O==1) Draw_Out_Waike21(); else if(O==0) Draw_Out_Waike2(); } else if(M==1) { glPushMatrix(); glTranslatef(-5,0,0); Draw_Out_FireRoom(); Draw_Out_Waike2(); glPopMatrix(); } } if(I==8){ if (M==0) { Draw_Out_Top(); Draw_Out_Waike1(); Draw_Out_Wolun1(); Draw_Out_WeiPen(); Draw_Out_Wolun2(); Draw_Out_Waike3(); //*************************************************change color GLdouble equ[4]={0,0,-1,0} ; glClipPlane(GL_CLIP_PLANE0,equ); glEnable(GL_CLIP_PLANE0); Draw_Out_FireRoom(); glDisable(GL_CLIP_PLANE0); GLdouble equ1[4]={0,-1,0,0} ; glClipPlane(GL_CLIP_PLANE1,equ1); glEnable(GL_CLIP_PLANE1); Draw_Out_FireRoom(); glDisable(GL_CLIP_PLANE1); //*************************************************************************************//***** } else if(M==1) { glPushMatrix(); glTranslatef(-5,0,0); GLdouble equ[4]={0,0,-1,0} ; glClipPlane(GL_CLIP_PLANE0,equ); glEnable(GL_CLIP_PLANE0); Draw_Out_FireRoom(); glDisable(GL_CLIP_PLANE0); GLdouble equ1[4]={0,-1,0,0} ; glClipPlane(GL_CLIP_PLANE1,equ1); glEnable(GL_CLIP_PLANE1); Draw_Out_FireRoom(); glDisable(GL_CLIP_PLANE1); glPopMatrix(); } } if(I==9){ //切割 if (M==0) { Draw_Out_Top(); Draw_Out_Waike1(); Draw_Out_Wolun1(); Draw_Out_WeiPen(); Draw_Out_Wolun2(); Draw_Out_Waike3(); GLdouble equ[4]={0,0,-1,0} ; glClipPlane(GL_CLIP_PLANE0,equ); glEnable(GL_CLIP_PLANE0); Draw_Out_FireRoom(); Draw_Out_Waike2(); glDisable(GL_CLIP_PLANE0); } else if(M==1) { glPushMatrix(); glTranslatef(-5,0,0); GLdouble equ[4]={0,0,-1,0} ; glClipPlane(GL_CLIP_PLANE0,equ); glEnable(GL_CLIP_PLANE0); Draw_Out_FireRoom(); Draw_Out_Waike2(); glDisable(GL_CLIP_PLANE0); glPopMatrix(); } } if(I==10){ glPushMatrix(); glTranslatef(-5,0,0); //特写 GLdouble equ[4]={0,0,-1,0} ; glClipPlane(GL_CLIP_PLANE0,equ); glEnable(GL_CLIP_PLANE0); Draw_Out_FireRoom(); Draw_Out_Waike2(); glDisable(GL_CLIP_PLANE0); Draw_Out_Smoke3(); glPopMatrix();

}

if(I==11){ //第二 轴流压缩室 if (M==0) { Draw_Out_Top(); Draw_Out_Wolun1(); Draw_Out_FireRoom(); Draw_Out_Wolun2(); Draw_Out_WeiPen(); Draw_Out_Waike1(); Draw_Out_Waike2(); //*************************************************change color if(P==1) Draw_Out_Waike31(); else if(P==0) Draw_Out_Waike3(); } else if(M==1) { glPushMatrix(); glTranslatef(-30,0,0); Draw_Out_WeiPen(); Draw_Out_Waike3(); Draw_Out_Wolun2(); glPopMatrix(); } }

if(I==12){ if (M==0) { Draw_Out_Top(); Draw_Out_Waike1(); Draw_Out_Wolun1(); Draw_Out_FireRoom(); Draw_Out_Waike2(); //*************************************************change color Draw_Out_Wolun2(); Draw_Out_WeiPen(); } else if(M==1) { glPushMatrix(); glTranslatef(-30,0,0); Draw_Out_Wolun2(); Draw_Out_WeiPen(); glPopMatrix();

}

}

if(I==13) { Close(); } glFlush(); SwapBuffers(hdc); }

void __fastcall TFormMain::Draw_Out_Wolun1() {

glPushMatrix(); n+=N; polarView(); glTranslatef(-28,0,0); glCallList(list_of_objects); glTranslatef(4,0,0); glCallList(list_of_objects); glTranslatef(3.5,0,0); glCallList(list_of_objects); glTranslatef(3,0,0); glCallList(list_of_objects); glTranslatef(2.5,0,0); glCallList(list_of_objects); glTranslatef(2,0,0); glCallList(list_of_objects); glTranslatef(1.75,0,0); glCallList(list_of_objects); glTranslatef(1.5,0,0); glCallList(list_of_objects); glPopMatrix(); } void __fastcall TFormMain::Draw_Out_Top() {

glPushMatrix(); glTranslatef(-36,0,0); glCallList(list_of_objects+1); glPopMatrix();

}


我的征途是星辰大海
2005-10-20 09:36
starrysky
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:华中科技大学EI -T0405
等 级:版主
威 望:11
帖 子:602
专家分:1
注 册:2005-9-12
收藏
得分:0 

void __fastcall TFormMain::Draw_Out_FireRoom() {

glPushMatrix(); glTranslatef(0,0,0); glCallList(list_of_objects+2); glPopMatrix();

}

void __fastcall TFormMain::Draw_Out_Wolun2() {

glPushMatrix(); n+=N; polarView(); glTranslatef(30,0,0); glCallList(list_of_objects+3); glTranslatef(4,0,0); glCallList(list_of_objects+3); glPopMatrix();

}

void __fastcall TFormMain::Draw_Out_WeiPen() {

glPushMatrix(); glTranslatef(5,0,0); glCallList(list_of_objects+4); glPopMatrix();

} void __fastcall TFormMain::Draw_Out_Waike1() {

glPushMatrix(); glCallList(waike); glPopMatrix();

}

void __fastcall TFormMain::Draw_Out_Waike2() {

glPushMatrix(); glCallList(waike+1); glPopMatrix();

}

void __fastcall TFormMain::Draw_Out_Waike3() {

glPushMatrix(); glTranslatef(0,0,0); glCallList(waike+2); glPopMatrix();

} void __fastcall TFormMain::Draw_Out_Waike11() {

glPushMatrix(); glCallList(waike+3); glPopMatrix();

}

void __fastcall TFormMain::Draw_Out_Waike21() {

glPushMatrix(); glCallList(waike+4); glPopMatrix();

}

void __fastcall TFormMain::Draw_Out_Waike31() {

glPushMatrix(); glTranslatef(0,0,0); glCallList(waike+5); glPopMatrix();

}

void __fastcall TFormMain::Button1Click(TObject *Sender) { key_and_mouse_down=TRUE; glRotatef(-5, 1.0, 0.0, 0.0); }

void __fastcall TFormMain::Button5Click(TObject *Sender) //第一轴流压缩室 { I=5; if(L==0) L=1; else L=0;

} //---------------------------------------------------------------------------

void __fastcall TFormMain::Button6Click(TObject *Sender) { I=6; } //---------------------------------------------------------------------------

void __fastcall TFormMain::Button7Click(TObject *Sender) // 燃烧室 { I=7; if(O==0) O=1; else O=0; } //---------------------------------------------------------------------------

void __fastcall TFormMain::Button8Click(TObject *Sender) { I=8; } //---------------------------------------------------------------------------

void __fastcall TFormMain::Button9Click(TObject *Sender) { I=9; } //---------------------------------------------------------------------------

void __fastcall TFormMain::Button10Click(TObject *Sender) { I=10; } //--------------------------------------------------------------------------- void __fastcall TFormMain::Button11Click(TObject *Sender) { I=11; if(P==0) P=1; else P=0; } //---------------------------------------------------------------------------

void __fastcall TFormMain::Button12Click(TObject *Sender) { I=12; } //--------------------------------------------------------------------------- void __fastcall TFormMain::Button13Click(TObject *Sender) { I=13; } //--------------------------------------------------------------------------- void __fastcall TFormMain::Button14Click(TObject *Sender) { I=0; } //---------------------------------------------------------------------------

void __fastcall TFormMain::Button15Click(TObject *Sender) { I=1; } //---------------------------------------------------------------------------

void __fastcall TFormMain::Timer1Timer(TObject *Sender) {

Timer1->Interval=10;

Draw_Out_Wolun1(); Draw_Out_Wolun2(); Yield(); Timer1->Enabled=true; } //--------------------------------------------------------------------------- void __fastcall TFormMain::polarView() { glRotatef(n,1.0,0.0,0.0 ); }

[此贴子已经被作者于2005-10-20 10:22:25编辑过]


我的征途是星辰大海
2005-10-20 09:36
starrysky
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:华中科技大学EI -T0405
等 级:版主
威 望:11
帖 子:602
专家分:1
注 册:2005-9-12
收藏
得分:0 

//-----------粒子系统------------------------------------------------- void __fastcall TFormMain::Prepare_Smoke1() ///******************************************** {

for (loop=0;loop<Max;loop++) {

particle[loop].active=true; particle[loop].life=1.0f; particle[loop].fade=0.075f; particle[loop].z= 3; V = (GLfloat((rand()%5))+2)/5; Angle = GLfloat(rand()%360); particle[loop].zg = .15; particle[loop].xi = sin(3.141592653*Angle/180) * V; particle[loop].yi = cos(3.141592653*Angle/180) * V; particle[loop].zi = ((rand()%10)-5)/5; }

} void __fastcall TFormMain::Draw_Out_Smoke1() { glPushMatrix(); glColor4f(1,1,1,0.5); glRotatef(90,0.0,1.0,0.0 ) ; glTranslatef(0,0,60); //**************************************** glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); GLfloat exhaust_r, exhaust_g, exhaust_b; exhaust_r = 1; exhaust_g = 0.6; exhaust_b = 0;

//******************************************* for (loop=0;loop<Max;loop++) { GLfloat x=particle[loop].x; GLfloat y=particle[loop].y; GLfloat z=particle[loop].z;

glColor4f(particle[loop].r,particle[loop].g,particle[loop].b,particle[loop].life/2); glBegin(GL_TRIANGLE_STRIP); glVertex3f(x,y,z+0.5f); glVertex3f(x-0.5f,y-0.35f,z-0.35); glVertex3f(x+0.5f,y-0.9f,z-0.35); glVertex3f(x,y+0.5,z-0.35); glVertex3f(x,y,z+0.5f); glVertex3f(x-0.5f,y-0.35f,z-0.35); glEnd();

particle[loop].x+=particle[loop].xi/80; particle[loop].y+=particle[loop].yi/80; particle[loop].z+=particle[loop].zi/70; particle[loop].xi*=1; particle[loop].yi*=1; particle[loop].zi*=1; particle[loop].zi+=particle[loop].zg; particle[loop].life-=particle[loop].fade; if(particle[loop].y*particle[loop].y+particle[loop].x*particle[loop].x>81) { particle[loop].r=exhaust_r; particle[loop].g=exhaust_g; particle[loop].b=exhaust_b;

particle[loop].life=1.0f; particle[loop].fade=GLfloat(rand()%100)/7500+0.0075f;

particle[loop].z= 3.f; V = (GLfloat((rand()%5))+2)/5; Angle = GLfloat(rand()%360);

particle[loop].xi = sin(3.141592653*Angle/180) * V; particle[loop].yi = cos(3.141592653*Angle/180) * V; particle[loop].zi = ((rand()%10)-5)/5+ Throttle*8; }

if (particle[loop].life<0.05f) { particle[loop].r=exhaust_r; particle[loop].g=exhaust_g; particle[loop].b=exhaust_b;

particle[loop].life=1.0f; particle[loop].fade=GLfloat(rand()%100)/7500+0.0075f; particle[loop].z= 3.f; V = (GLfloat((rand()%5))+2)/5; Angle = GLfloat(rand()%360); particle[loop].xi = sin(3.141592653*Angle/180) * V; particle[loop].yi = cos(3.141592653*Angle/180) * V; particle[loop].zi = ((rand()%10)-5)/5+ Throttle*8; } } glPopMatrix(); glDisable(GL_BLEND); glColor4f(0.3,0.3,0.3,0); }

void __fastcall TFormMain::Prepare_Smoke2() ///******************************************** {

for (loop=0;loop<Max;loop++) {

particle1[loop].active=true; particle1[loop].life=1.0f; particle1[loop].fade=1; particle1[loop].z= 3; V = (GLfloat((rand()%5))+2)/5; Angle = GLfloat(rand()%360); particle1[loop].zg = .15; particle1[loop].xi = sin(3.141592653*Angle/180) * V; particle1[loop].yi = cos(3.141592653*Angle/180) * V; particle1[loop].zi = ((rand()%10)-5)/5; }

} void __fastcall TFormMain::Draw_Out_Smoke2() { glPushMatrix(); glColor4f(1,1,1,0.5); glRotatef(90,0.0,1.0,0.0 ) ; glTranslatef(0,0,-60); //**************************************** glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); GLfloat exhaust_r, exhaust_g, exhaust_b; exhaust_r = 0.9; exhaust_g = 0.9; exhaust_b = 0.9;

//******************************************* for (loop=0;loop<Max;loop++) { GLfloat x=particle1[loop].x; GLfloat y=particle1[loop].y; GLfloat z=particle1[loop].z;

glColor4f(particle1[loop].r,particle1[loop].g,particle1[loop].b,1-particle1[loop].life); glBegin(GL_TRIANGLE_STRIP); glVertex3f(x,y,z+0.3f); glVertex3f(x-0.3f,y-0.10f,z-0.10); glVertex3f(x+0.3f,y-0.3f,z-0.10); glVertex3f(x,y+0.3,z-0.10); glVertex3f(x,y,z+0.3f); glVertex3f(x-0.3f,y-0.10f,z-0.10); glEnd();

particle1[loop].x+=particle1[loop].xi/40; particle1[loop].y+=particle1[loop].yi/40; particle1[loop].z+=particle1[loop].zi/76; particle1[loop].xi*=1; particle1[loop].yi*=1; particle1[loop].zi*=1; particle1[loop].zi+=particle1[loop].zg; particle1[loop].life-=particle1[loop].fade; if(particle1[loop].y*particle1[loop].y+particle1[loop].x*particle1[loop].x>210.25) { particle1[loop].r=exhaust_r; particle1[loop].g=exhaust_g; particle1[loop].b=exhaust_b;

particle1[loop].life=1.0f; particle1[loop].fade=GLfloat(rand()%100)/7500+0.01f;

particle1[loop].z= 3.f; V = (GLfloat((rand()%5))+2)/5; Angle = GLfloat(rand()%360);

particle1[loop].xi = sin(3.141592653*Angle/180) * V; particle1[loop].yi = cos(3.141592653*Angle/180) * V; particle1[loop].zi = ((rand()%10)-5)/5+ Throttle*8; }

if (particle1[loop].life<0.05f) { particle1[loop].r=exhaust_r; particle1[loop].g=exhaust_g; particle1[loop].b=exhaust_b;

particle1[loop].life=1.0f; particle1[loop].fade=GLfloat(rand()%100)/7500+0.0075f; particle1[loop].z= 3.f; V = (GLfloat((rand()%5))+2)/5; Angle = GLfloat(rand()%360); particle1[loop].xi = sin(3.141592653*Angle/180) * V; particle1[loop].yi = cos(3.141592653*Angle/180) * V; particle1[loop].zi = ((rand()%10)-5)/5+ Throttle*8; } } glPopMatrix(); glDisable(GL_BLEND); glColor4f(0.3,0.3,0.3,0); }

void __fastcall TFormMain::Prepare_Smoke3() { int n1; for(n1=0;n1<12;n1++){ for (loop=n*Max2/12;loop<(n+1)*Max2/12;loop++) {

particle2[loop].active=true; particle2[loop].life=1.0f; particle2[loop].fade=1; particle2[loop].x=sin(n1*3.141592653/6)*(10+(rand()%40)/10); particle2[loop].y=cos(n1*3.141592653/6)*(10+(rand()%40)/10); particle2[loop].z= 3; V = (GLfloat((rand()%5))+2)/5; Angle = GLfloat(rand()%360); particle2[loop].zg = .15; particle2[loop].xi = sin(3.141592653*Angle/180) * V; particle2[loop].yi = cos(3.141592653*Angle/180) * V; particle2[loop].zi = ((rand()%10)-5)/5; } }

} void __fastcall TFormMain::Draw_Out_Smoke3() { glPushMatrix(); glColor4f(1,0,0,0.5); glRotatef(90,0.0,1.0,0.0 ) ; glTranslatef(0,0,-2); //**************************************** glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); GLfloat exhaust_r, exhaust_g, exhaust_b; exhaust_r = 0.9; exhaust_g = 0.4; exhaust_b = 0;

//******************************************* for (loop=0;loop<Max2;loop++) { GLfloat x=particle2[loop].x; GLfloat y=particle2[loop].y; GLfloat z=particle2[loop].z;

glColor4f(particle2[loop].r,particle2[loop].g,particle2[loop].b,0.7); glBegin(GL_TRIANGLE_STRIP); glVertex3f(x,y,z+0.5f); glVertex3f(x-0.5f,y-0.350f,z-0.35); glVertex3f(x+0.5f,y-0.5f,z-0.35); glVertex3f(x,y+0.5,z-0.35); glVertex3f(x,y,z+0.5f); glVertex3f(x-0.5f,y-0.35f,z-0.35); glEnd();

particle2[loop].x+=particle2[loop].xi/40; particle2[loop].y+=particle2[loop].yi/40; particle2[loop].z+=particle2[loop].zi/38;

particle2[loop].zi+=particle2[loop].zg; particle2[loop].life-=particle2[loop].fade;

if(particle2[loop].y*particle2[loop].y+particle2[loop].x*particle2[loop].x>225|| particle2[loop].y*particle2[loop].y+particle2[loop].x*particle2[loop].x<64) {

int n1; n1= rand()%12; particle2[loop].life=1.0f; particle2[loop].fade=1; particle2[loop].x=sin(n1*3.141592653/6)*(10+(rand()%40)/10); particle2[loop].y=cos(n1*3.141592653/6)*(10+(rand()%40)/10); particle2[loop].z= 3; V = (GLfloat((rand()%5))+2)/5; Angle = GLfloat(rand()%360); particle2[loop].zg = .15; particle2[loop].xi = sin(3.141592653*Angle/180) * V; particle2[loop].yi = cos(3.141592653*Angle/180) * V; particle2[loop].zi = ((rand()%10)-5)/5;

} if (particle2[loop].life<0.38f) { particle2[loop].x*=0.97; particle2[loop].y*=0.97;

}

if (particle2[loop].life<0.05f) { particle2[loop].r=exhaust_r; particle2[loop].g=exhaust_g; particle2[loop].b=exhaust_b;

particle2[loop].life=1.0f; particle2[loop].fade=GLfloat(rand()%100)/7500+0.0075f; particle2[loop].z= 3.f; V = (GLfloat((rand()%5))+2)/5; Angle = GLfloat(rand()%360); particle2[loop].xi = sin(3.141592653*Angle/180) * V; particle2[loop].yi = cos(3.141592653*Angle/180) * V; particle2[loop].zi = ((rand()%10)-5)/5+ Throttle*3.2; }

} glPopMatrix(); glDisable(GL_BLEND); glColor4f(0.3,0.3,0.3,0); }


我的征途是星辰大海
2005-10-20 09:37
starrysky
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:华中科技大学EI -T0405
等 级:版主
威 望:11
帖 子:602
专家分:1
注 册:2005-9-12
收藏
得分:0 

上传有大小限制,附件内容有变化,删除了文档和音乐以及大部分的控置语句和全部的按钮,修正了全部的BUG.
保留了粒子效果,是个简化版(好像简的太多了),原来那个有90多M,压缩后6.5M,现在只有400多k了,压缩后200多K。
对电脑的要求降低了很多,编译的很快.但程序的功能减少了不少
欢迎大家讨论

[此贴子已经被作者于2007-9-23 17:19:49编辑过]


我的征途是星辰大海
2005-10-20 09:55
starrysky
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:华中科技大学EI -T0405
等 级:版主
威 望:11
帖 子:602
专家分:1
注 册:2005-9-12
收藏
得分:0 
发个截图给大家看看
[IMG]C:\Documents and Settings\starrysky\My Documents\My Pictures\1.jpg[/IMG]

我的征途是星辰大海
2005-10-20 10:05
starrysky
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:华中科技大学EI -T0405
等 级:版主
威 望:11
帖 子:602
专家分:1
注 册:2005-9-12
收藏
得分:0 
[IMG]C:\Documents and Settings\starrysky\My Documents\My Pictures\3.jpg[/IMG]

[此贴子已经被作者于2005-10-20 10:14:52编辑过]



我的征途是星辰大海
2005-10-20 10:11
快速回复:[原创]喷气式发动机模拟(OpenGL)-->starrysky转移
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020658 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved