TinyGL 0.4.1 for MinGW
Macros | Functions | Variables
mech.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <windows.h>
#include <GL/gdi.h>
#include <GL/gl.h>
#include "glu.h"
#include "ui.h"

Go to the source code of this file.

Macros

#define SPHERE
 
#define COLOR
 
#define LIGHT
 
#define TORSO
 
#define HIP
 
#define SHOULDER
 
#define UPPER_ARM
 
#define LOWER_ARM
 
#define ROCKET_POD
 
#define UPPER_LEG
 
#define LOWER_LEG
 
#define NO_NORM
 
#define ANIMATION
 
#define DRAW_MECH
 
#define DRAW_ENVIRO
 
#define MOVE_LIGHT
 
#define GLUT
 
#define GLUT_KEY
 
#define GLUT_SPEC
 
#define SOLID_MECH_TORSO   1
 
#define SOLID_MECH_HIP   2
 
#define SOLID_MECH_SHOULDER   3
 
#define SOLID_MECH_UPPER_ARM   4
 
#define SOLID_MECH_FOREARM   5
 
#define SOLID_MECH_UPPER_LEG   6
 
#define SOLID_MECH_FOOT   7
 
#define SOLID_MECH_ROCKET   8
 
#define SOLID_MECH_VULCAN   9
 
#define SOLID_ENVIRO   10
 
#define ANKLE_RATE   3
 
#define HEEL_RATE   3
 
#define ROTATE_RATE   10
 
#define TILT_RATE   10
 
#define ELBOW_RATE   2
 
#define SHOULDER_RATE   5
 
#define LAT_RATE   5
 
#define CANNON_RATE   40
 
#define UPPER_LEG_RATE   3
 
#define UPPER_LEG_RATE_GROIN   10
 
#define LIGHT_TURN_RATE   10
 
#define VIEW_TURN_RATE   10
 
#define PI   3.141592654
 

Functions

void Heel1Add (void)
 
void Heel1Subtract (void)
 
void Heel2Add (void)
 
void Heel2Subtract (void)
 
void Ankle1Add (void)
 
void Ankle1Subtract (void)
 
void Ankle2Add (void)
 
void Ankle2Subtract (void)
 
void RotateAdd (void)
 
void RotateSubtract (void)
 
void MechTiltSubtract (void)
 
void MechTiltAdd (void)
 
void elbow1Add (void)
 
void elbow1Subtract (void)
 
void elbow2Add (void)
 
void elbow2Subtract (void)
 
void shoulder1Add (void)
 
void shoulder1Subtract (void)
 
void shoulder2Add (void)
 
void shoulder2Subtract (void)
 
void shoulder3Add (void)
 
void shoulder3Subtract (void)
 
void shoulder4Add (void)
 
void shoulder4Subtract (void)
 
void lat1Raise (void)
 
void lat1Lower (void)
 
void lat2Raise (void)
 
void lat2Lower (void)
 
void FireCannon (void)
 
void RaiseLeg1Forward (void)
 
void LowerLeg1Backwards (void)
 
void RaiseLeg1Outwards (void)
 
void LowerLeg1Inwards (void)
 
void RaiseLeg2Forward (void)
 
void LowerLeg2Backwards (void)
 
void RaiseLeg2Outwards (void)
 
void LowerLeg2Inwards (void)
 
void TurnRight (void)
 
void TurnLeft (void)
 
void TurnForwards (void)
 
void TurnBackwards (void)
 
void LightTurnRight (void)
 
void LightTurnLeft (void)
 
void LightForwards (void)
 
void LightBackwards (void)
 
void Box (float width, float height, float depth, char solid)
 
void Octagon (float side, float height, char solid)
 
void SetMaterial (GLfloat spec[], GLfloat amb[], GLfloat diff[], GLfloat shin[])
 
void MechTorso (char solid)
 
void MechHip (char solid)
 
void Shoulder (char solid)
 
void UpperArm (char solid)
 
void VulcanGun (char solid)
 
void ForeArm (char solid)
 
void UpperLeg (char solid)
 
void Foot (char solid)
 
void LowerLeg (char solid)
 
void RocketPod (char solid)
 
void Enviro (char solid)
 
void Toggle (void)
 
void disable (void)
 
void lighting (void)
 
void DrawMech (void)
 
void display (void)
 
void init (void)
 
void reshape (int w, int h)
 
void animation_walk (void)
 
void animation (void)
 
GLenum key (int key, GLenum mask)
 
void printHelp (void)
 
void idle (void)
 
int main (int argc, char **argv)
 
void draw ()
 

Variables

char leg = 0
 
int shoulder1 = 0
 
int shoulder2 = 0
 
int shoulder3 = 0
 
int shoulder4 = 0
 
int lat1 = 20
 
int lat2 = 20
 
int elbow1 = 0
 
int elbow2 = 0
 
int pivot = 0
 
int tilt = 10
 
int ankle1 = 0
 
int ankle2 = 0
 
int heel1 = 0
 
int heel2 = 0
 
int hip11 = 0
 
int hip12 = 10
 
int hip21 = 0
 
int hip22 = 10
 
int fire = 0
 
int solid_part = 0
 
int anim = 0
 
int turn = 0
 
int turn1 = 0
 
int lightturn = 0
 
int lightturn1 = 0
 
float elevation = 0.0
 
float distance = 0.0
 
float frame = 3.0
 
GLfloat mat_specular []
 
GLfloat mat_ambient []
 
GLfloat mat_diffuse []
 
GLfloat mat_shininess []
 
GLfloat mat_specular2 []
 
GLfloat mat_ambient2 []
 
GLfloat mat_diffuse2 []
 
GLfloat mat_shininess2 []
 
GLfloat mat_specular3 []
 
GLfloat mat_ambient3 []
 
GLfloat mat_diffuse3 []
 
GLfloat mat_shininess3 []
 
GLfloat mat_specular4 []
 
GLfloat mat_ambient4 []
 
GLfloat mat_diffuse4 []
 
GLfloat mat_shininess4 []
 
GLfloat mat_specular5 []
 
GLfloat mat_ambient5 []
 
GLfloat mat_diffuse5 []
 
GLfloat mat_shininess5 []
 

Macro Definition Documentation

◆ ANIMATION

#define ANIMATION

Definition at line 49 of file mech.c.

◆ ANKLE_RATE

#define ANKLE_RATE   3

Definition at line 88 of file mech.c.

◆ CANNON_RATE

#define CANNON_RATE   40

Definition at line 95 of file mech.c.

◆ COLOR

#define COLOR

Definition at line 38 of file mech.c.

◆ DRAW_ENVIRO

#define DRAW_ENVIRO

Definition at line 51 of file mech.c.

◆ DRAW_MECH

#define DRAW_MECH

Definition at line 50 of file mech.c.

◆ ELBOW_RATE

#define ELBOW_RATE   2

Definition at line 92 of file mech.c.

◆ GLUT

#define GLUT

Definition at line 60 of file mech.c.

◆ GLUT_KEY

#define GLUT_KEY

Definition at line 61 of file mech.c.

◆ GLUT_SPEC

#define GLUT_SPEC

Definition at line 62 of file mech.c.

◆ HEEL_RATE

#define HEEL_RATE   3

Definition at line 89 of file mech.c.

◆ HIP

#define HIP

Definition at line 41 of file mech.c.

◆ LAT_RATE

#define LAT_RATE   5

Definition at line 94 of file mech.c.

◆ LIGHT

#define LIGHT

Definition at line 39 of file mech.c.

◆ LIGHT_TURN_RATE

#define LIGHT_TURN_RATE   10

Definition at line 98 of file mech.c.

◆ LOWER_ARM

#define LOWER_ARM

Definition at line 44 of file mech.c.

◆ LOWER_LEG

#define LOWER_LEG

Definition at line 47 of file mech.c.

◆ MOVE_LIGHT

#define MOVE_LIGHT

Definition at line 52 of file mech.c.

◆ NO_NORM

#define NO_NORM

Definition at line 48 of file mech.c.

◆ PI

#define PI   3.141592654

Definition at line 104 of file mech.c.

◆ ROCKET_POD

#define ROCKET_POD

Definition at line 45 of file mech.c.

◆ ROTATE_RATE

#define ROTATE_RATE   10

Definition at line 90 of file mech.c.

◆ SHOULDER

#define SHOULDER

Definition at line 42 of file mech.c.

◆ SHOULDER_RATE

#define SHOULDER_RATE   5

Definition at line 93 of file mech.c.

◆ SOLID_ENVIRO

#define SOLID_ENVIRO   10

Definition at line 84 of file mech.c.

◆ SOLID_MECH_FOOT

#define SOLID_MECH_FOOT   7

Definition at line 81 of file mech.c.

◆ SOLID_MECH_FOREARM

#define SOLID_MECH_FOREARM   5

Definition at line 79 of file mech.c.

◆ SOLID_MECH_HIP

#define SOLID_MECH_HIP   2

Definition at line 76 of file mech.c.

◆ SOLID_MECH_ROCKET

#define SOLID_MECH_ROCKET   8

Definition at line 82 of file mech.c.

◆ SOLID_MECH_SHOULDER

#define SOLID_MECH_SHOULDER   3

Definition at line 77 of file mech.c.

◆ SOLID_MECH_TORSO

#define SOLID_MECH_TORSO   1

Definition at line 75 of file mech.c.

◆ SOLID_MECH_UPPER_ARM

#define SOLID_MECH_UPPER_ARM   4

Definition at line 78 of file mech.c.

◆ SOLID_MECH_UPPER_LEG

#define SOLID_MECH_UPPER_LEG   6

Definition at line 80 of file mech.c.

◆ SOLID_MECH_VULCAN

#define SOLID_MECH_VULCAN   9

Definition at line 83 of file mech.c.

◆ SPHERE

#define SPHERE

program : glutmech V1.1 author : Simon Parkinson-Bates. E-mail : sapb@.nosp@m.yall.nosp@m.ara.c.nosp@m.s.rm.nosp@m.it.ed.nosp@m.u.au Copyright Simon Parkinson-Bates. "source if freely avaliable to anyone to copy as long as they acknowledge me in their work."

Funtional features

  • online menu system avaliable by pressing left mouse button
  • online cascading help system avaliable, providing information on the several key strokes and what they do.
  • animation sequence coded which makes the mech walk through an environment. Shadows will soon be added to make it look more realistic.
  • menu control to view mech in wireframe or sold mode.
  • various key strokes avaliable to control idependently the mechs many joints.
  • various key strokes avaliable to view mech and environment from different angles
  • various key strokes avaliable to alter positioning of the single light source.

Program features

  • uses double buffering
  • uses display lists
  • uses glut to manage windows, callbacks, and online menu.
  • uses glpolygonfill() to maintain colors in wireframe and solid mode.

Definition at line 37 of file mech.c.

◆ TILT_RATE

#define TILT_RATE   10

Definition at line 91 of file mech.c.

◆ TORSO

#define TORSO

Definition at line 40 of file mech.c.

◆ UPPER_ARM

#define UPPER_ARM

Definition at line 43 of file mech.c.

◆ UPPER_LEG

#define UPPER_LEG

Definition at line 46 of file mech.c.

◆ UPPER_LEG_RATE

#define UPPER_LEG_RATE   3

Definition at line 96 of file mech.c.

◆ UPPER_LEG_RATE_GROIN

#define UPPER_LEG_RATE_GROIN   10

Definition at line 97 of file mech.c.

◆ VIEW_TURN_RATE

#define VIEW_TURN_RATE   10

Definition at line 99 of file mech.c.

Function Documentation

◆ animation()

void animation ( void  )

Definition at line 1383 of file mech.c.

◆ animation_walk()

void animation_walk ( void  )

Definition at line 1286 of file mech.c.

◆ Ankle1Add()

void Ankle1Add ( void  )

Definition at line 195 of file mech.c.

◆ Ankle1Subtract()

void Ankle1Subtract ( void  )

Definition at line 201 of file mech.c.

◆ Ankle2Add()

void Ankle2Add ( void  )

Definition at line 207 of file mech.c.

◆ Ankle2Subtract()

void Ankle2Subtract ( void  )

Definition at line 213 of file mech.c.

◆ Box()

void Box ( float  width,
float  height,
float  depth,
char  solid 
)

Definition at line 447 of file mech.c.

◆ disable()

void disable ( void  )

Definition at line 1067 of file mech.c.

◆ display()

void display ( void  )

Definition at line 1213 of file mech.c.

◆ draw()

void draw ( void  )

Definition at line 1759 of file mech.c.

◆ DrawMech()

void DrawMech ( void  )

Definition at line 1105 of file mech.c.

◆ elbow1Add()

void elbow1Add ( void  )

Definition at line 243 of file mech.c.

◆ elbow1Subtract()

void elbow1Subtract ( void  )

Definition at line 249 of file mech.c.

◆ elbow2Add()

void elbow2Add ( void  )

Definition at line 255 of file mech.c.

◆ elbow2Subtract()

void elbow2Subtract ( void  )

Definition at line 261 of file mech.c.

◆ Enviro()

void Enviro ( char  solid)

Definition at line 1027 of file mech.c.

◆ FireCannon()

void FireCannon ( void  )

Definition at line 339 of file mech.c.

◆ Foot()

void Foot ( char  solid)

Definition at line 860 of file mech.c.

◆ ForeArm()

void ForeArm ( char  solid)

Definition at line 772 of file mech.c.

◆ Heel1Add()

void Heel1Add ( void  )

Definition at line 171 of file mech.c.

◆ Heel1Subtract()

void Heel1Subtract ( void  )

Definition at line 177 of file mech.c.

◆ Heel2Add()

void Heel2Add ( void  )

Definition at line 183 of file mech.c.

◆ Heel2Subtract()

void Heel2Subtract ( void  )

Definition at line 189 of file mech.c.

◆ idle()

void idle ( void  )

Definition at line 1723 of file mech.c.

◆ init()

void init ( void  )
  • glEnable( GL_CULL_FACE );*‍/
  • glEnable( GL_DEPTH_TEST ); *‍/

Definition at line 1252 of file mech.c.

◆ key()

GLenum key ( int  key,
GLenum  mask 
)

Definition at line 1390 of file mech.c.

◆ lat1Lower()

void lat1Lower ( void  )

Definition at line 321 of file mech.c.

◆ lat1Raise()

void lat1Raise ( void  )

Definition at line 315 of file mech.c.

◆ lat2Lower()

void lat2Lower ( void  )

Definition at line 333 of file mech.c.

◆ lat2Raise()

void lat2Raise ( void  )

Definition at line 327 of file mech.c.

◆ LightBackwards()

void LightBackwards ( void  )

Definition at line 438 of file mech.c.

◆ LightForwards()

void LightForwards ( void  )

Definition at line 432 of file mech.c.

◆ lighting()

void lighting ( void  )

Definition at line 1076 of file mech.c.

◆ LightTurnLeft()

void LightTurnLeft ( void  )

Definition at line 426 of file mech.c.

◆ LightTurnRight()

void LightTurnRight ( void  )

Definition at line 420 of file mech.c.

◆ LowerLeg()

void LowerLeg ( char  solid)

Definition at line 875 of file mech.c.

◆ LowerLeg1Backwards()

void LowerLeg1Backwards ( void  )

Definition at line 351 of file mech.c.

◆ LowerLeg1Inwards()

void LowerLeg1Inwards ( void  )

Definition at line 363 of file mech.c.

◆ LowerLeg2Backwards()

void LowerLeg2Backwards ( void  )

Definition at line 375 of file mech.c.

◆ LowerLeg2Inwards()

void LowerLeg2Inwards ( void  )

Definition at line 387 of file mech.c.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1747 of file mech.c.

◆ MechHip()

void MechHip ( char  solid)

Definition at line 604 of file mech.c.

◆ MechTiltAdd()

void MechTiltAdd ( void  )

Definition at line 237 of file mech.c.

◆ MechTiltSubtract()

void MechTiltSubtract ( void  )

Definition at line 231 of file mech.c.

◆ MechTorso()

void MechTorso ( char  solid)

Definition at line 583 of file mech.c.

◆ Octagon()

void Octagon ( float  side,
float  height,
char  solid 
)

Definition at line 507 of file mech.c.

◆ printHelp()

void printHelp ( void  )

Definition at line 1637 of file mech.c.

◆ RaiseLeg1Forward()

void RaiseLeg1Forward ( void  )

Definition at line 345 of file mech.c.

◆ RaiseLeg1Outwards()

void RaiseLeg1Outwards ( void  )

Definition at line 357 of file mech.c.

◆ RaiseLeg2Forward()

void RaiseLeg2Forward ( void  )

Definition at line 369 of file mech.c.

◆ RaiseLeg2Outwards()

void RaiseLeg2Outwards ( void  )

Definition at line 381 of file mech.c.

◆ reshape()

void reshape ( int  w,
int  h 
)

Definition at line 1273 of file mech.c.

◆ RocketPod()

void RocketPod ( char  solid)

Definition at line 971 of file mech.c.

◆ RotateAdd()

void RotateAdd ( void  )

Definition at line 219 of file mech.c.

◆ RotateSubtract()

void RotateSubtract ( void  )

Definition at line 225 of file mech.c.

◆ SetMaterial()

void SetMaterial ( GLfloat  spec[],
GLfloat  amb[],
GLfloat  diff[],
GLfloat  shin[] 
)

Definition at line 573 of file mech.c.

◆ Shoulder()

void Shoulder ( char  solid)

Definition at line 636 of file mech.c.

◆ shoulder1Add()

void shoulder1Add ( void  )

Definition at line 267 of file mech.c.

◆ shoulder1Subtract()

void shoulder1Subtract ( void  )

Definition at line 273 of file mech.c.

◆ shoulder2Add()

void shoulder2Add ( void  )

Definition at line 279 of file mech.c.

◆ shoulder2Subtract()

void shoulder2Subtract ( void  )

Definition at line 285 of file mech.c.

◆ shoulder3Add()

void shoulder3Add ( void  )

Definition at line 291 of file mech.c.

◆ shoulder3Subtract()

void shoulder3Subtract ( void  )

Definition at line 297 of file mech.c.

◆ shoulder4Add()

void shoulder4Add ( void  )

Definition at line 303 of file mech.c.

◆ shoulder4Subtract()

void shoulder4Subtract ( void  )

Definition at line 309 of file mech.c.

◆ Toggle()

void Toggle ( void  )

Definition at line 1058 of file mech.c.

◆ TurnBackwards()

void TurnBackwards ( void  )

Definition at line 414 of file mech.c.

◆ TurnForwards()

void TurnForwards ( void  )

Definition at line 408 of file mech.c.

◆ TurnLeft()

void TurnLeft ( void  )

Definition at line 402 of file mech.c.

◆ TurnRight()

void TurnRight ( void  )

Definition at line 396 of file mech.c.

◆ UpperArm()

void UpperArm ( char  solid)

Definition at line 661 of file mech.c.

◆ UpperLeg()

void UpperLeg ( char  solid)

Definition at line 794 of file mech.c.

◆ VulcanGun()

void VulcanGun ( char  solid)

Definition at line 718 of file mech.c.

Variable Documentation

◆ anim

int anim = 0

Definition at line 112 of file mech.c.

◆ ankle1

int ankle1 = 0

Definition at line 110 of file mech.c.

◆ ankle2

int ankle2 = 0

Definition at line 110 of file mech.c.

◆ distance

float distance = 0.0

Definition at line 114 of file mech.c.

◆ elbow1

int elbow1 = 0

Definition at line 110 of file mech.c.

◆ elbow2

int elbow2 = 0

Definition at line 110 of file mech.c.

◆ elevation

float elevation = 0.0

Definition at line 114 of file mech.c.

◆ fire

int fire = 0

Definition at line 111 of file mech.c.

◆ frame

float frame = 3.0

Definition at line 114 of file mech.c.

◆ heel1

int heel1 = 0

Definition at line 110 of file mech.c.

◆ heel2

int heel2 = 0

Definition at line 111 of file mech.c.

◆ hip11

int hip11 = 0

Definition at line 111 of file mech.c.

◆ hip12

int hip12 = 10

Definition at line 111 of file mech.c.

◆ hip21

int hip21 = 0

Definition at line 111 of file mech.c.

◆ hip22

int hip22 = 10

Definition at line 111 of file mech.c.

◆ lat1

int lat1 = 20

Definition at line 109 of file mech.c.

◆ lat2

int lat2 = 20

Definition at line 109 of file mech.c.

◆ leg

char leg = 0

Definition at line 107 of file mech.c.

◆ lightturn

int lightturn = 0

Definition at line 112 of file mech.c.

◆ lightturn1

int lightturn1 = 0

Definition at line 112 of file mech.c.

◆ mat_ambient

GLfloat mat_ambient[]
Initial value:
=
{0.24725, 0.1995, 0.0745, 1.0}

Definition at line 123 of file mech.c.

◆ mat_ambient2

GLfloat mat_ambient2[]
Initial value:
=
{0.19225, 0.19225, 0.19225, 1.0}

Definition at line 132 of file mech.c.

◆ mat_ambient3

GLfloat mat_ambient3[]
Initial value:
=
{0.25, 0.20725, 0.20725, 1.0}

Definition at line 141 of file mech.c.

◆ mat_ambient4

GLfloat mat_ambient4[]
Initial value:
=
{0.0215, 0.1745, 0.0215, 1.0}

Definition at line 150 of file mech.c.

◆ mat_ambient5

GLfloat mat_ambient5[]
Initial value:
=
{0.0, 0.0, 0.0, 1.0}

Definition at line 159 of file mech.c.

◆ mat_diffuse

GLfloat mat_diffuse[]
Initial value:
=
{0.75164, 0.60648, 0.22648, 1.0}

Definition at line 125 of file mech.c.

◆ mat_diffuse2

GLfloat mat_diffuse2[]
Initial value:
=
{0.50754, 0.50754, 0.50754, 1.0}

Definition at line 134 of file mech.c.

◆ mat_diffuse3

GLfloat mat_diffuse3[]
Initial value:
=
{1, 0.829, 0.829, 1.0}

Definition at line 143 of file mech.c.

◆ mat_diffuse4

GLfloat mat_diffuse4[]
Initial value:
=
{0.07568, 0.61424, 0.07568, 1.0}

Definition at line 152 of file mech.c.

◆ mat_diffuse5

GLfloat mat_diffuse5[]
Initial value:
=
{0.5, 0.5, 0.0, 1.0}

Definition at line 161 of file mech.c.

◆ mat_shininess

GLfloat mat_shininess[]
Initial value:
=
{128.0 * 0.4}

Definition at line 127 of file mech.c.

◆ mat_shininess2

GLfloat mat_shininess2[]
Initial value:
=
{128.0 * 0.6}

Definition at line 136 of file mech.c.

◆ mat_shininess3

GLfloat mat_shininess3[]
Initial value:
=
{128.0 * 0.088}

Definition at line 145 of file mech.c.

◆ mat_shininess4

GLfloat mat_shininess4[]
Initial value:
=
{128 * 0.6}

Definition at line 154 of file mech.c.

◆ mat_shininess5

GLfloat mat_shininess5[]
Initial value:
=
{128.0 * 0.25}

Definition at line 163 of file mech.c.

◆ mat_specular

GLfloat mat_specular[]
Initial value:
=
{0.628281, 0.555802, 0.366065, 1.0}

Definition at line 121 of file mech.c.

◆ mat_specular2

GLfloat mat_specular2[]
Initial value:
=
{0.508273, 0.508273, 0.508373, 1.0}

Definition at line 130 of file mech.c.

◆ mat_specular3

GLfloat mat_specular3[]
Initial value:
=
{0.296648, 0.296648, 0.296648, 1.0}

Definition at line 139 of file mech.c.

◆ mat_specular4

GLfloat mat_specular4[]
Initial value:
=
{0.633, 0.727811, 0.633, 1.0}

Definition at line 148 of file mech.c.

◆ mat_specular5

GLfloat mat_specular5[]
Initial value:
=
{0.60, 0.60, 0.50, 1.0}

Definition at line 157 of file mech.c.

◆ pivot

int pivot = 0

Definition at line 110 of file mech.c.

◆ shoulder1

int shoulder1 = 0

Definition at line 109 of file mech.c.

◆ shoulder2

int shoulder2 = 0

Definition at line 109 of file mech.c.

◆ shoulder3

int shoulder3 = 0

Definition at line 109 of file mech.c.

◆ shoulder4

int shoulder4 = 0

Definition at line 109 of file mech.c.

◆ solid_part

int solid_part = 0

Definition at line 111 of file mech.c.

◆ tilt

int tilt = 10

Definition at line 110 of file mech.c.

◆ turn

int turn = 0

Definition at line 112 of file mech.c.

◆ turn1

int turn1 = 0

Definition at line 112 of file mech.c.