#include "stdafx.h" #define GL_PI 3.1415f GLfloat xRot = 0.45f; GLfloat yRot = 0.35f; GLboolean bCull = glIsEnabled(GL_CULL_FACE); GLboolean bDepth = glIsEnabled(GL_DEPTH_TEST); GLboolean bOutline = (GLboolean)true; GLenum shademode = GL_FLAT; GLfloat ex = 0.0f; GLfloat ey = 75.0f; GLfloat ez = -120.0f; GLfloat delta = 0.01f; GLfloat deltaR = 0.01f; /////////////////////////////////////////////////////////// GLfloat iniLuz[4] = { 0.f, 100.f, 0.f, 1.f }, Luz[4], MatSombra[16], Piso[] = { 0.f, 1.f, 0.f, 150 }, ALFA = 0.25f; void gltMakeShadowMatrix(GLfloat vPlaneEquation[], GLfloat vLightPos[], GLfloat destMat[]) { GLfloat dot; // Dot product of plane and light position dot = vPlaneEquation[0] * vLightPos[0] + vPlaneEquation[1] * vLightPos[1] + vPlaneEquation[2] * vLightPos[2] + vPlaneEquation[3] * vLightPos[3]; // Now do the projection // First column destMat[0] = dot - vLightPos[0] * vPlaneEquation[0]; destMat[4] = 0.0f - vLightPos[0] * vPlaneEquation[1]; destMat[8] = 0.0f - vLightPos[0] * vPlaneEquation[2]; destMat[12] = 0.0f - vLightPos[0] * vPlaneEquation[3]; // Second column destMat[1] = 0.0f - vLightPos[1] * vPlaneEquation[0]; destMat[5] = dot - vLightPos[1] * vPlaneEquation[1]; destMat[9] = 0.0f - vLightPos[1] * vPlaneEquation[2]; destMat[13] = 0.0f - vLightPos[1] * vPlaneEquation[3]; // Third Column destMat[2] = 0.0f - vLightPos[2] * vPlaneEquation[0]; destMat[6] = 0.0f - vLightPos[2] * vPlaneEquation[1]; destMat[10] = dot - vLightPos[2] * vPlaneEquation[2]; destMat[14] = 0.0f - vLightPos[2] * vPlaneEquation[3]; // Fourth Column destMat[3] = 0.0f - vLightPos[3] * vPlaneEquation[0]; destMat[7] = 0.0f - vLightPos[3] * vPlaneEquation[1]; destMat[11] = 0.0f - vLightPos[3] * vPlaneEquation[2]; destMat[15] = dot - vLightPos[3] * vPlaneEquation[3]; } void luz(){ glColor3f(1.0f, 1.0f, 0.0f); glPushMatrix(); glTranslatef(Luz[0], Luz[1], Luz[2]); glScalef(5.f, 5.f, 5.f); glutSolidSphere(1., 20, 20); glPopMatrix(); } void SetupRC() { Luz[0] = iniLuz[0]; Luz[1] = iniLuz[1]; Luz[2] = iniLuz[2]; Luz[3] = iniLuz[3]; // Black background glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //// Set drawing color to green //glColor3f(0.0f, 1.0f, 0.0f); // Set color shading model to flat glShadeModel(shademode); // Clockwise-wound polygons are front facing; this is reversed // because we are using triangle fans glFrontFace(GL_CW); } void cuadro_sin_color(){ glBegin(GL_QUADS); glVertex3f(1.0f, 1.0f, .0f); glVertex3f(1.0f, -1.0f, .0f); glVertex3f(-1.0f, -1.0f, .0f); glVertex3f(-1.0f, 1.0f, .0f); glEnd(); } void lineas_en_piso_1(){ glBegin(GL_LINES); int L = 10; for (int i = 0; i