From 790fee53b52351101b618ca1c6c008d1d9ffde85 Mon Sep 17 00:00:00 2001 From: Rusty Striker Date: Tue, 8 Aug 2023 20:12:58 +0300 Subject: [PATCH] cow got a flashlight yay --- cow.c | 24 +++++++++++++++++++++++- mmn_17.c | 9 +-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/cow.c b/cow.c index f4a21f1..03129b0 100644 --- a/cow.c +++ b/cow.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -163,6 +164,27 @@ void drawCow(char cowsPOV) { glScalef(0.2, 1.0, 0.2); glutSolidSphere(1.0, 8, 8); glPopMatrix(); // Tails(from sonic the hedgehog) + // Give the cow a little flashlight because its dark outside + glPushMatrix(); // fl + glTranslatef(0.5, -1.2, 1.4); + glColor3f(0.3, 0.3 ,0.3); + glutSolidCylinder(0.3, 2.0, 8, 1); + glTranslatef(0.0, 0.0, 2.0); + glRotatef(180.0, 0.0, 1.0, 0.0); + glutSolidCone(0.6, 0.6, 8, 2); + glEnable(GL_LIGHT0); + // Directional light - aka light + GLfloat light1[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat lightColor[] = {0.9, 0.9, 0.1, 1.0}; + GLfloat dir[] = { 0.0, 0.0, -1.0 }; + glLightfv(GL_LIGHT0, GL_POSITION, light1); + glLightfv(GL_LIGHT0, GL_AMBIENT, lightColor); + glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor); + glLightfv(GL_LIGHT0, GL_SPECULAR, lightColor); + glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir); + glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 30.0); + glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 2.0); + glPopMatrix(); // fl glPopMatrix(); // cow pos glColor3f(1.0, 1.0, 1.0); glDisable(GL_COLOR_MATERIAL); @@ -199,6 +221,6 @@ void setCameraToCowPOV() { glRotatef(-headRot.y, 0.0, 1.0, 0.0); glTranslatef(0.0, 0.0, -5.0); // body - glTranslatef(-cowPos.x, -cowPos.y, -cowPos.z); glRotatef(-cowRot, 0.0, 1.0, 0.0); + glTranslatef(-cowPos.x, -cowPos.y, -cowPos.z); } \ No newline at end of file diff --git a/mmn_17.c b/mmn_17.c index 8ed6871..31f7c3b 100644 --- a/mmn_17.c +++ b/mmn_17.c @@ -272,14 +272,7 @@ void drawWorld(void) { // Ambient light GLfloat ambient[] = { slidersN.ambientRed->value, slidersN.ambientGreen->value, slidersN.ambientBlue->value, 1.0 }; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); - // glEnable(GL_LIGHT0); - // // Directional light - aka light - // GLfloat light1[] = { 0.0, 1.0, 0.0, 0.0 }; - // glLightfv(GL_LIGHT0, GL_POSITION, light1); - // GLfloat lightColor[] = {0.5, 0.4, 0.1, 1.0}; - // glLightfv(GL_LIGHT0, GL_AMBIENT, lightColor); - // glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor); - // glLightfv(GL_LIGHT0, GL_SPECULAR, lightColor); + // GL_LIGHT0 is reserved for the cow's flashlight // user light glEnable(GL_LIGHT1); GLfloat ulPos[] = { lightPos.x, lightPos.y, lightPos.z, 1.0 };