Beispiel #1
0
        private void drawReflectedShadow(IShadowingGraphicComponent component, float[] drawingTranslation, float[] drawingRotation, float[] lightPosition)
        {
            GL.glDisable(GL.GL_LIGHTING);
            GL.glPushMatrix();

            GL.glScalef(1, 1, -1);
            beginStencil(eStencils.ReflectedFloor);

            float[] matrix = getShadowMatrix(eShadowMatrices.Floor, lightPosition);

            GL.glTranslatef(0, 0.01f, 0);
            GL.glMultMatrixf(matrix);

            GL.glTranslatef(drawingTranslation[0], drawingTranslation[1], drawingTranslation[2]);
            GL.glRotatef(drawingRotation[0], 1, 0, 0);
            GL.glRotatef(drawingRotation[1], 0, 1, 0);
            GL.glRotatef(drawingRotation[2], 0, 0, 1);

            GL.glColor3f(0.15f, 0.15f, 0.15f);
            component.DrawShadow();

            stopStencil();
            GL.glPopMatrix();
            GL.glEnable(GL.GL_LIGHTING);
        }
Beispiel #2
0
        private void multiplyMatrixAndDrawComponentShadow(float[] matrix, IShadowingGraphicComponent component, float[] drawingTranslation, float[] drawingRotation)
        {
            GL.glPushMatrix();

            GL.glMultMatrixf(matrix);
            GL.glTranslatef(drawingTranslation[0], drawingTranslation[1], drawingTranslation[2]);
            GL.glRotatef(drawingRotation[0], 1, 0, 0);
            GL.glRotatef(drawingRotation[1], 0, 1, 0);
            GL.glRotatef(drawingRotation[2], 0, 0, 1);
            component.DrawShadow();

            GL.glPopMatrix();
        }
Beispiel #3
0
        public void DrawComponentShadows(float[] lightPosition, IShadowingGraphicComponent component, float[] drawingTranslation, float[] drawingRotation)
        {
            GL.glDisable(GL.GL_LIGHTING);

            GL.glColor3f(0.15f, 0.15f, 0.15f);

            // floor shadow
            beginStencil(eStencils.Floor);
            float[] matrix = getShadowMatrix(eShadowMatrices.Floor, lightPosition);

            GL.glPushMatrix();
            GL.glTranslatef(0, 0.01f, 0);
            multiplyMatrixAndDrawComponentShadow(matrix, component, drawingTranslation, drawingRotation);
            multiplyMatrixAndDrawComponentShadow(matrix, this, new float[] { 0, 0, 0 }, new float[] { 0, 0, 0 });             // drawing skyscraper shadow on the floor
            GL.glPopMatrix();

            // roof shadow
            beginStencil(eStencils.Roof);
            matrix = getShadowMatrix(eShadowMatrices.Roof, lightPosition);

            GL.glPushMatrix();
            GL.glTranslatef(0, 0.01f, 0);
            multiplyMatrixAndDrawComponentShadow(matrix, component, drawingTranslation, drawingRotation);
            GL.glPopMatrix();

            GL.glColor3f(0.20f, 0.20f, 0.20f);

            // upper back wall shadow
            beginStencil(eStencils.UpperBackWall);
            matrix = getShadowMatrix(eShadowMatrices.UpperBackWall, lightPosition);

            GL.glPushMatrix();
            GL.glTranslatef(0, 0, -0.01f);
            multiplyMatrixAndDrawComponentShadow(matrix, component, drawingTranslation, drawingRotation);
            GL.glPopMatrix();

            // upper left wall shadow
            beginStencil(eStencils.UpperLeftWall);
            matrix = getShadowMatrix(eShadowMatrices.UpperLeftWall, lightPosition);

            GL.glPushMatrix();
            GL.glTranslatef(-0.01f, 0, 0);
            multiplyMatrixAndDrawComponentShadow(matrix, component, drawingTranslation, drawingRotation);
            GL.glPopMatrix();

            // upper right wall shadow
            beginStencil(eStencils.UpperRightWall);
            matrix = getShadowMatrix(eShadowMatrices.UpperRightWall, lightPosition);

            GL.glPushMatrix();
            GL.glTranslatef(0.01f, 0, 0);
            multiplyMatrixAndDrawComponentShadow(matrix, component, drawingTranslation, drawingRotation);
            GL.glPopMatrix();

            // bottom front wall shadow
            beginStencil(eStencils.BottomFrontWall);
            matrix = getShadowMatrix(eShadowMatrices.BottomFrontWall, lightPosition);

            GL.glPushMatrix();
            GL.glTranslatef(0, 0, 0.01f);
            multiplyMatrixAndDrawComponentShadow(matrix, component, drawingTranslation, drawingRotation);
            GL.glPopMatrix();

            // bottom back wall shadow
            beginStencil(eStencils.BottomBackWall);
            matrix = getShadowMatrix(eShadowMatrices.BottomBackWall, lightPosition);

            GL.glPushMatrix();
            GL.glTranslatef(0, 0, -0.01f);
            multiplyMatrixAndDrawComponentShadow(matrix, component, drawingTranslation, drawingRotation);
            GL.glPopMatrix();

            // bottom left wall shadow
            beginStencil(eStencils.BottomLeftWall);
            matrix = getShadowMatrix(eShadowMatrices.BottomLeftWall, lightPosition);

            GL.glPushMatrix();
            GL.glTranslatef(-0.01f, 0, 0);
            multiplyMatrixAndDrawComponentShadow(matrix, component, drawingTranslation, drawingRotation);
            GL.glPopMatrix();

            // bottom right wall shadow
            beginStencil(eStencils.BottomRightWall);
            matrix = getShadowMatrix(eShadowMatrices.BottomRightWall, lightPosition);

            GL.glPushMatrix();
            GL.glTranslatef(0.01f, 0, 0);
            multiplyMatrixAndDrawComponentShadow(matrix, component, drawingTranslation, drawingRotation);
            GL.glPopMatrix();

            // disable stencil
            stopStencil();

            GL.glEnable(GL.GL_LIGHTING);
        }