def display(): twDisplayInit(1,1,1) twCamera() sunLightSource() # as a light source twGround() drawSunObject() if DrawBlockp: twColor(Red,0,0) ObjectDrawers[DrawObjectId]() # we don't want lighting effects on the shadow! glDisable(GL_LIGHTING) glPushMatrix() glTranslatef(*SunPos) # STEP 1: move origin to light pos # project onto negative of sun's Y coordinate PM = projectionMatrix(-1*SunPos[1]) glMultMatrixf(PM); # STEP 2: flattens out the objects glTranslatef(*twVectorScale(SunPos,-1)) # STEP 3: translate back shadowColor = (0.5,0.5,0.5) twColor(shadowColor,0,0) ObjectDrawers[DrawObjectId]() glPopMatrix() glFlush() glutSwapBuffers()
def display(): twDisplayInit(1,1,1) twCamera() sunLightSource() # as a light source drawSunObject() teapotColor = (0,0.6,0) twColor(teapotColor,0,64) drawBasicTeapot() # we don't want lighting effects on the shadow! glDisable(GL_LIGHTING) glPushMatrix() glTranslatef(*SunPos) # STEP 1: move origin to light pos # project onto negative of sun's Y coordinate PM = projectionMatrix(-1*SunPos[1]) glMultMatrixf(PM); # STEP 2: flattens out the objects glTranslatef(*twVectorScale(SunPos,-1)) # STEP 3: translate back shadowColor = (0.5,0.5,0.5) glColor3fv(shadowColor) drawBasicTeapot() # STEP 4: draw the object in shadow color glPopMatrix() glFlush() glutSwapBuffers()