From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- Bachelor/GDV2/Praktikum-OpenGL/fussi/Wuerfel.cpp | 105 +++++ Bachelor/GDV2/Praktikum-OpenGL/fussi/Wuerfel.h | 3 + Bachelor/GDV2/Praktikum-OpenGL/fussi/field.bmp | Bin 0 -> 12342 bytes Bachelor/GDV2/Praktikum-OpenGL/fussi/field.jpg | Bin 0 -> 24462 bytes Bachelor/GDV2/Praktikum-OpenGL/fussi/field.odg | Bin 0 -> 8711 bytes Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.dsp | 109 +++++ Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.dsw | 29 ++ Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.ncb | Bin 0 -> 58368 bytes Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.opt | Bin 0 -> 48640 bytes Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.plg | 25 ++ Bachelor/GDV2/Praktikum-OpenGL/fussi/main.cpp | 511 +++++++++++++++++++++++ 11 files changed, 782 insertions(+) create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/Wuerfel.cpp create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/Wuerfel.h create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/field.bmp create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/field.jpg create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/field.odg create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.dsp create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.dsw create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.ncb create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.opt create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.plg create mode 100644 Bachelor/GDV2/Praktikum-OpenGL/fussi/main.cpp (limited to 'Bachelor/GDV2/Praktikum-OpenGL/fussi') diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/Wuerfel.cpp b/Bachelor/GDV2/Praktikum-OpenGL/fussi/Wuerfel.cpp new file mode 100644 index 0000000..c5703d2 --- /dev/null +++ b/Bachelor/GDV2/Praktikum-OpenGL/fussi/Wuerfel.cpp @@ -0,0 +1,105 @@ +#include +#include +#include "Wuerfel.h" + + +void Wuerfel(GLfloat fSeitenL) +{ + glBegin(GL_POLYGON);//Vorderseite + glColor4f(1.,0.,0.,1.); //ROT + glVertex3f(-fSeitenL, -fSeitenL, +fSeitenL); + glColor4f(1.0, 1.0, 0.0 ,1.0f); //GELB + glVertex3f(+fSeitenL, -fSeitenL, +fSeitenL); + glColor4f(1.0f,1.0f,1.0f,1.0f); //WEISS + glVertex3f(+fSeitenL, +fSeitenL, +fSeitenL); + glColor4f(1.0f,0.0f,1.0f,1.0f); //MAGENTA + glVertex3f(-fSeitenL, +fSeitenL, +fSeitenL); + glEnd(); + +#ifdef SCHRITTWEITE + glFlush(); + Sleep(2000); +#endif + + glBegin(GL_POLYGON);//Rueckseite + glColor4f(0., 1., 1., 1.); //CYAN + glVertex3f(+fSeitenL, +fSeitenL, -fSeitenL); + glColor4f(0., 1., 0., 1.); //GRUEN + glVertex3f(+fSeitenL, -fSeitenL, -fSeitenL); + glColor4f(0., 0., 0., 1.); //SCHWARZ + glVertex3f(-fSeitenL, -fSeitenL, -fSeitenL); + glColor4f(0., 0., 1., 1.); //BLAU + glVertex3f(-fSeitenL, +fSeitenL, -fSeitenL); + glEnd(); + +#ifdef SCHRITTWEITE + glFlush(); + Sleep(2000); +#endif + + glBegin(GL_POLYGON);//Rechte Seite + glColor4f(1., 1., 0., 1.); //GELB + glVertex3f(+fSeitenL, -fSeitenL, +fSeitenL); + glColor4f(0., 1., 0., 1.); //GRUEN + glVertex3f(+fSeitenL, -fSeitenL, -fSeitenL); + glColor4f(0., 1., 1., 1.); //CYAN + glVertex3f(+fSeitenL, +fSeitenL, -fSeitenL); + glColor4f(1., 1., 1., 1.); //WEISS + glVertex3f(+fSeitenL, +fSeitenL, +fSeitenL); + glEnd(); + +#ifdef SCHRITTWEITE + glFlush(); + Sleep(2000); +#endif + + glBegin(GL_POLYGON);//Linke Seite + glColor4f(0., 0., 1., 1.); //BLAU + glVertex3f(-fSeitenL, +fSeitenL, -fSeitenL); + glColor4f(0., 0., 0., 1.); //SCHWARZ + glVertex3f(-fSeitenL, -fSeitenL, -fSeitenL); + glColor4f(1., 0., 0., 1.); //ROT + glVertex3f(-fSeitenL, -fSeitenL, +fSeitenL); + glColor4f(1., 0., 1., 1.); //MAGENTA + glVertex3f(-fSeitenL, +fSeitenL, +fSeitenL); + glEnd(); + +#ifdef SCHRITTWEITE + glFlush(); + Sleep(2000); +#endif + + glBegin(GL_POLYGON);//Bodenflaeche + glColor4f(0., 0., 0., 1.); //SCHWARZ + glVertex3f(-fSeitenL, -fSeitenL, -fSeitenL); + glColor4f(0., 1., 0., 1.); //GRUEN + glVertex3f(+fSeitenL, -fSeitenL, -fSeitenL); + glColor4f(1., 1.,0., 1.); //GELB + glVertex3f(+fSeitenL, -fSeitenL, +fSeitenL); + glColor4f(1., 0., 0., 1.); //ROT + glVertex3f(-fSeitenL, -fSeitenL, +fSeitenL); + glEnd(); + +#ifdef SCHRITTWEITE + glFlush(); + Sleep(2000); +#endif + + glBegin(GL_POLYGON);//Deckflaeche + glColor4f(1.f, 0.f, 1.f, 1.f); //MAGENTA + glVertex3f(-fSeitenL, +fSeitenL, +fSeitenL); + glColor4f(1.f, 1.f, 1.f, 1.f); //WEISS + glVertex3f(+fSeitenL, +fSeitenL, +fSeitenL); + glColor4f(0.f, 1.f, 1.f, 1.f); //CYAN + glVertex3f(+fSeitenL, +fSeitenL, -fSeitenL); + glColor4f(0.f, 0.f, 1.f, 1.f); //BLAU + glVertex3f(-fSeitenL, +fSeitenL, -fSeitenL); + glEnd(); + +#ifdef SCHRITTWEITE + glFlush(); + Sleep(2000); +#endif + + return; +} \ No newline at end of file diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/Wuerfel.h b/Bachelor/GDV2/Praktikum-OpenGL/fussi/Wuerfel.h new file mode 100644 index 0000000..371c1a8 --- /dev/null +++ b/Bachelor/GDV2/Praktikum-OpenGL/fussi/Wuerfel.h @@ -0,0 +1,3 @@ +//#define SCHRITTWEITE + +void Wuerfel( GLfloat fSeitenL ); diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/field.bmp b/Bachelor/GDV2/Praktikum-OpenGL/fussi/field.bmp new file mode 100644 index 0000000..9661182 Binary files /dev/null and b/Bachelor/GDV2/Praktikum-OpenGL/fussi/field.bmp differ diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/field.jpg b/Bachelor/GDV2/Praktikum-OpenGL/fussi/field.jpg new file mode 100644 index 0000000..2a49384 Binary files /dev/null and b/Bachelor/GDV2/Praktikum-OpenGL/fussi/field.jpg differ diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/field.odg b/Bachelor/GDV2/Praktikum-OpenGL/fussi/field.odg new file mode 100644 index 0000000..b969afe Binary files /dev/null and b/Bachelor/GDV2/Praktikum-OpenGL/fussi/field.odg differ diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.dsp b/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.dsp new file mode 100644 index 0000000..3016077 --- /dev/null +++ b/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.dsp @@ -0,0 +1,109 @@ +# Microsoft Developer Studio Project File - Name="fussi" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=fussi - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "fussi.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "fussi.mak" CFG="fussi - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "fussi - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "fussi - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "fussi - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "fussi - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glaux.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "fussi - Win32 Release" +# Name "fussi - Win32 Debug" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\main.cpp +# End Source File +# Begin Source File + +SOURCE=.\Wuerfel.cpp +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Wuerfel.h +# End Source File +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.dsw b/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.dsw new file mode 100644 index 0000000..d2bd323 --- /dev/null +++ b/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! + +############################################################################### + +Project: "fussi"=.\fussi.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.ncb b/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.ncb new file mode 100644 index 0000000..bad8f2c Binary files /dev/null and b/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.ncb differ diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.opt b/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.opt new file mode 100644 index 0000000..1e56c71 Binary files /dev/null and b/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.opt differ diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.plg b/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.plg new file mode 100644 index 0000000..fc1d4ac --- /dev/null +++ b/Bachelor/GDV2/Praktikum-OpenGL/fussi/fussi.plg @@ -0,0 +1,25 @@ + + +
+

Build Log

+

+--------------------Configuration: fussi - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\gast\LOCALS~1\Temp\RSP69.tmp" with contents +[ +kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glaux.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/fussi.pdb" /debug /machine:I386 /out:"Debug/fussi.exe" /pdbtype:sept +.\Debug\main.obj +.\Debug\Wuerfel.obj +] +Creating command line "link.exe @C:\DOCUME~1\gast\LOCALS~1\Temp\RSP69.tmp" +

Output Window

+Linking... + + + +

Results

+fussi.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/Bachelor/GDV2/Praktikum-OpenGL/fussi/main.cpp b/Bachelor/GDV2/Praktikum-OpenGL/fussi/main.cpp new file mode 100644 index 0000000..35ffc81 --- /dev/null +++ b/Bachelor/GDV2/Praktikum-OpenGL/fussi/main.cpp @@ -0,0 +1,511 @@ +#include +#include +#include +#include +#include +#include "Wuerfel.h" + +#define ball_radius 0.22 +#define goal_width 7.32 +#define goal_height 2.44 + +GLfloat green[]={0.0,1.0,0.0,1.0}; +GLfloat white[]={1.0,1.0,1.0,1.0}; + +GLfloat mat_ball[]={1.0,1.0,1.0,1.0}; +GLfloat mat_lines[]={1.0,1.0,1.0,1.0}; +GLfloat mat_goal[]={1.0,1.0,1.0,1.0}; +GLfloat mat_board[]={1.0,0.0,0.0,1.0}; +GLfloat mat_field[]={0.0,1.0,0.0,1.0}; + +GLfloat light0_pos[]={1.0,30.0,25.0,1.0}; +GLfloat light1_pos[]={1.0,30.0,50.0,1.0}; +GLfloat light_col[]={1.0,1.0,1.0,1.0}; + +GLfloat field_topleft[]={-39.5, 0.0, 52.f}; +GLfloat field_topright[]={39.5, 0.0, 52.f}; +GLfloat field_bottomleft[]={-39.5, 0.0, -52.f}; +GLfloat field_bottomright[]={39.5, 0.0, -52.f}; + +GLfloat board_topleft[]={-1.0, 1.0, 0.5}; +GLfloat board_topright[]={1.0, 1.0, 0.5}; +GLfloat board_bottomleft[]={-1.0, 0.0, 0.0}; +GLfloat board_bottomright[]={1.0, 0.0, 0.0}; + +GLfloat ball_x = 3.9; +GLfloat ball_y = ball_radius; +GLfloat ball_z = 19.9; +GLfloat t = 37.5; + +GLfloat pl1 = -30; +GLfloat pl2 = 0; +GLfloat pl3 = 0; + +GLfloat cam_x = 30.; +GLfloat cam_y = 5.; +GLfloat cam_z = 25.; + +GLuint texture_id[1]; + +int dir = 0; +int z=0; + +int LoadGLTextures(); + +void animate_player1(int); +void animate_player2(int); +void animate_player3(int); +void do_nothing(int n); + + +// wrapper function for vector form +void glTranslatefv(GLfloat *); + +void glTranslatefv(GLfloat *p) +{ + glTranslatef(p[0],p[1],p[2]); +} + +//void animate_ball2(int n); +//void animate_ball3(int n); + +void init(void) +{ + LoadGLTextures(); // Jump To Texture Loading Routine ( NEW ) + glEnable(GL_LINE_SMOOTH); + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + glEnable (GL_LIGHT0); + glLightfv( GL_LIGHT0, GL_POSITION, light0_pos ); + glLightfv( GL_LIGHT0, GL_DIFFUSE, light_col ); + glEnable (GL_LIGHT1); + glLightfv( GL_LIGHT1, GL_POSITION, light1_pos ); + glLightfv( GL_LIGHT1, GL_DIFFUSE, light_col ); + glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations +} + +AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image +{ + FILE *File=NULL; // File Handle + + if (!Filename) // Make Sure A Filename Was Given + { + return NULL; // If Not Return NULL + } + + File=fopen(Filename,"r"); // Check To See If The File Exists + + if (File) // Does The File Exist? + { + fclose(File); // Close The Handle + return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer + } + + return NULL; // If Load Failed Return NULL +} + +int LoadGLTextures() // Load Bitmaps And Convert To Textures +{ + int Status=FALSE; // Status Indicator + + AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture + + memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL + + // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit + if (TextureImage[0]=LoadBMP("field.bmp")) + { + Status=TRUE; // Set The Status To TRUE + + glGenTextures(1, &texture_id[0]); // Create The Texture + + // Typical Texture Generation Using Data From The Bitmap + glBindTexture(GL_TEXTURE_2D, texture_id[0]); + glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + } + + if (TextureImage[0]) // If Texture Exists + { + if (TextureImage[0]->data) // If Texture Image Exists + { + free(TextureImage[0]->data); // Free The Texture Image Memory + } + + free(TextureImage[0]); // Free The Image Structure + } + + return Status; // Return The Status +} + +void field(void) +{ + glEnable(GL_TEXTURE_2D); // Enable Texture Mapping ( NEW ) + glLoadIdentity(); + glPushMatrix(); + glBindTexture ( GL_TEXTURE_2D, texture_id[0] ); + //glMaterialfv( GL_FRONT, GL_DIFFUSE, mat_field ); + glBegin(GL_POLYGON); + //glColor4fv(green); + glTexCoord2f(0.0f, 0.0f); glVertex3fv(field_topleft); + glTexCoord2f(1.0f, 0.0f); glVertex3fv(field_topright); + glTexCoord2f(1.0f, 1.0f); glVertex3fv(field_bottomright); + glTexCoord2f(0.0f, 1.0f); glVertex3fv(field_bottomleft); + glEnd(); + glPopMatrix(); + glDisable(GL_TEXTURE_2D); +} + +void boards() +{ + glLoadIdentity(); + glMaterialfv( GL_FRONT, GL_DIFFUSE, mat_board ); + glPushMatrix(); + glTranslatef(0.0,0.0,52.0); + glScalef(39.5,1.0,1.0); + glBegin(GL_POLYGON); + glVertex3fv(board_topleft); + glVertex3fv(board_topright); + glVertex3fv(board_bottomright); + glVertex3fv(board_bottomleft); + glEnd(); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-39.5, 0.0 ,0.0); + glRotatef(-90, 0.0, 1.0, 0.0); + glScalef(52.0, 1.0, 1.0); + glBegin(GL_POLYGON); + glVertex3fv(board_topleft); + glVertex3fv(board_topright); + glVertex3fv(board_bottomright); + glVertex3fv(board_bottomleft); + glEnd(); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(39.5, 0.0, 0.0); + glRotatef(90, 0.0, 1.0, 0.0); + glScalef(52.0 , 1.0,1.0); + glBegin(GL_POLYGON); + glVertex3fv(board_topleft); + glVertex3fv(board_topright); + glVertex3fv(board_bottomright); + glVertex3fv(board_bottomleft); + glEnd(); + glPopMatrix(); +} + +void ball(void) +{ + glMaterialfv( GL_FRONT, GL_DIFFUSE, mat_ball ); + glColor4fv(white); + glLoadIdentity(); + glPushMatrix(); + glTranslatef(ball_x,ball_y,ball_z); + glutSolidSphere(ball_radius,20,20); + glPopMatrix(); +} + + +void goal() +{ + glLoadIdentity(); + glPushMatrix(); + glMaterialfv( GL_FRONT, GL_DIFFUSE, mat_goal ); + glTranslatef(0.0, 0.0, 50.0); + glPushMatrix(); + glTranslatef(goal_width / 2.0, 0.0, 0.0); + glRotatef(90,1.0,0.0,0.0); + glScalef(0.12, 0.12, goal_height); + // post + Wuerfel(1.0); + glPopMatrix(); + glPushMatrix(); + glTranslatef(- (goal_width / 2.0), 0.0, 0.0); + glRotatef(90,1.0,0.0,0.0); + glScalef(0.12, 0.12, goal_height); + // post + Wuerfel(1.0); + glPopMatrix(); + glPushMatrix(); + glTranslatef(0.0, goal_height, 0.0); + glScalef(goal_width/2.0,0.12,0.12 ); + // crossbar + Wuerfel(1.0); + glPopMatrix(); + glPopMatrix(); +} + +void player(int playerNr, GLfloat *pos) +{ + GLUquadricObj* left_lower_leg; + GLUquadricObj* right_lower_leg; + GLUquadricObj* left_upper_leg; + GLUquadricObj* right_upper_leg; + GLUquadricObj* torso; + GLUquadricObj* left_lower_arm; + GLUquadricObj* right_lower_arm; + GLUquadricObj* left_upper_arm; + GLUquadricObj* right_upper_arm; + + left_lower_leg = gluNewQuadric(); + right_lower_leg = gluNewQuadric(); + left_upper_leg = gluNewQuadric(); + right_upper_leg = gluNewQuadric(); + torso = gluNewQuadric(); + left_lower_arm = gluNewQuadric(); + right_lower_arm = gluNewQuadric(); + left_upper_arm = gluNewQuadric(); + right_upper_arm = gluNewQuadric(); + + glLoadIdentity(); + glPushMatrix(); + glColor4fv(white); + // + //glTranslatef(0.0, 5.8, 0.0); + glTranslatef(0.0, 1.6, 0.0); + glTranslatefv(pos); + switch (playerNr) { + case 1: + glRotatef(-90, 0.0, 1.0, 0.0); + break; + case 2: + glRotatef(90, 0.0, 1.0, 0.0); + break; + case 3: + break; + } + glRotatef(90, 1.0, 0.0, 0.0); + //glScalef(3,3,3); + // torso + + gluCylinder(torso, 0.25, 0.25, 0.8, 20, 20); + + glPushMatrix(); + glTranslatef(0.2, 0.0, 0.8); + switch (playerNr) { + case 1: + glRotatef(-pl1, 1.0, 0.0, 0.0); + break; + case 2: + glRotatef(-pl2, 1.0, 0.0, 0.0); + break; + case 3: + glRotatef(-pl3, 1.0, 0.0, 0.0); + break; + } + gluCylinder(left_upper_leg, 0.10, 0.10, 0.45, 20, 20); + glPushMatrix(); + glTranslatef(0.0, 0.0, 0.45); + switch (playerNr) { + case 1: + glRotatef(-pl1*2, 1.0, 0.0, 0.0); + break; + case 2: + glRotatef(-pl2*2, 1.0, 0.0, 0.0); + break; + case 3: + glRotatef(-pl3*2, 1.0, 0.0, 0.0); + break; + } + gluCylinder(left_lower_leg, 0.05, 0.05, 0.35, 20, 20); + glPopMatrix(); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-0.2, 0.0, 0.8); + gluCylinder(right_upper_leg, 0.10, 0.10, 0.45, 20, 20); + glPushMatrix(); + glTranslatef(0.0, 0.0, 0.45); + gluCylinder(right_lower_leg, 0.05, 0.05, 0.35, 20, 20); + glPopMatrix(); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(0.35, 0.0, 0.0); + glRotatef(45, 1.0, 0.0, 0.0); + gluCylinder(left_upper_arm, 0.10, 0.10, 0.45, 20, 20); + glPushMatrix(); + glTranslatef(0.0, 0.0, 0.45); + glRotatef(-90,1.0, 0.0, 0.0); + gluCylinder(left_lower_arm, 0.05, 0.05, 0.35, 20, 20); + glPopMatrix(); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-0.35, 0.0, 0.0); + glRotatef(45, 1.0, 0.0, 0.0); + gluCylinder(right_upper_arm, 0.10, 0.10, 0.45, 20, 20); + glPushMatrix(); + glTranslatef(0.0, 0.0, 0.45); + glRotatef(-90,1.0, 0.0, 0.0); + gluCylinder(right_lower_arm, 0.05, 0.05, 0.35, 20, 20); + glPopMatrix(); + glPopMatrix(); + + // head + glTranslatef(0.0, 0.0, -0.2); + glutSolidSphere(0.2,20,20); + glPopMatrix(); +} + +//void animate() +void animate_player1(int n) +//void animate_player1() +{ + //cam_x+=0.1; + //cam_z-=0.1; + //int dir = 0; + + int move=30; + + if (ball_x >= -4) + ball_x-=.2; + if ( (pl1 < move) && dir == 0) + pl1++; + else if ((pl1 > -move) && dir == 1) + pl1--; + else if (pl1 == move) + dir = 1; + else if (pl1 == -move) + //dir = 0; + { + z=2; + glutTimerFunc(50,animate_player2,z); + } + if (z==1) + glutTimerFunc(50,animate_player1,z); + //glutIdleFunc(animate_player2); + //z++; + //if (z>51) + // glutTimerFunc(10,animate_player2,2); + //else + // exit(0); + glutPostRedisplay(); + //std::cout << "here " << n << std::endl; +} + +void animate_player2(int n) +//void animate_player2() +{ + //int dir = 0; + int move=30; + + if (ball_x <= -3) + ball_x+=.2; + if ( (pl2 < move) && dir == 0) + pl2++; + else if ((pl2 > -move) && dir == 1) + pl2--; + else if (pl2 == move) + dir = 1; + else if (pl2 == -move) + //dir = 0; + { + z=3; + glutTimerFunc(50,animate_player3,z); + } + if (z==2) + glutTimerFunc(50,animate_player2,z); + //glutIdleFunc(animate_player3); + //z++; + //if (z>51) + // glutTimerFunc((int) z*10,animate_player3,3); + //else + // exit(0); + glutPostRedisplay(); + //std::cout << "here " << n << std::endl; +} + +void animate_player3(int n) +//void animate_player3() +{ + //int dir = 0; + int move=30; + + if (ball_z <= 51) + ball_z+=.4; + if ( (pl3 < move) && dir == 0) + pl3++; + else if ((pl3 > -move) && dir == 1) + pl3--; + else if (pl3 == move) + dir = 1; + else if (pl3 == -move) + //dir = 0; + glutTimerFunc(50,do_nothing,0); + //z++; + //if (z<51) + //glutTimerFunc((int) z*10,animate_player3,0); + if (z==3) + glutTimerFunc(50,animate_player3,z); + //glutIdleFunc(animate_player3); + //else + // exit(0); + glutPostRedisplay(); + //std::cout << "here " << n << std::endl; +} + +void do_nothing(int n) +{ +} + +void RenderScene(void) +{ + GLfloat pos_pl1[]={4.0, .0, 20.0}; + GLfloat pos_pl2[]={-4.0, .0, 20.0}; + GLfloat pos_pl3[]={0.0, .0, 19.0}; + + //glClearColor(0.f, 0.f, 0.f, 0.f); + glClearColor(0.32f, 0.85f, 1.f, 0.f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glViewport(0,0,glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT)); // Reset The Current Viewport + + glMatrixMode(GL_PROJECTION); // Select The Projection Matrix + glLoadIdentity(); // Reset The Projection Matrix + + // Calculate The Aspect Ratio Of The Window + gluPerspective(90.0f,glutGet(GLUT_WINDOW_WIDTH)/glutGet(GLUT_WINDOW_HEIGHT),1.0f,100.0f); // View Depth of 100 + gluLookAt(cam_x, cam_y, cam_z, + 0., 1., 25., + 0., 1., 0.); + glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix + //glLoadIdentity(); // Reset The Modelview Matrix + ball(); + goal(); + field(); + boards(); + glLoadIdentity(); + //glTranslatef(0.0, 4.0, 0.0); + glPushMatrix(); + // glTranslatef(4.0, 1.6, 20.0); + player(1,pos_pl1); + glPopMatrix(); + glPushMatrix(); + // glTranslatef(-4.0, 1.6, 20.0); + player(2,pos_pl2); + glPopMatrix(); + glPushMatrix(); + // glTranslatef(0.0, 1.6, 16.0); + player(3,pos_pl3); + glPopMatrix(); + glutSwapBuffers(); +} +int main(int argc, char **argv) +{ + glutInit( &argc, argv ); + glutInitWindowSize(800,600); + glutInitDisplayMode( GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH ); + glutCreateWindow("Fussball Animation"); + glutDisplayFunc( RenderScene ); + //glutIdleFunc(animate_player1); + //for (int i=0;i<100;i++) + z=1; + glutTimerFunc(1,animate_player1,z); + init(); + glutMainLoop(); + return 0; +} \ No newline at end of file -- cgit v1.2.3