glColor4f() private method

private glColor4f ( float red, float green, float blue, float alpha ) : void
red float
green float
blue float
alpha float
return void
示例#1
0
        private void DrawSea()
        {
            GL.glDisable(GL.GL_LIGHTING);
            float dup = GlobalProperties.seaDuplicates;

            GL.glEnable(GL.GL_TEXTURE_2D);
            GL.glColor4f(1.0f, 1.0f, 1.0f, 0.3f);

            GL.glBindTexture(GL.GL_TEXTURE_2D, Textures[0]);
            GL.glBegin(GL.GL_QUADS);

            float cor = GlobalProperties.seaSize / 2;

            GL.glTexCoord2f(0, 0);
            GL.glVertex3f(-cor, -cor, 0.0f);
            GL.glTexCoord2f(0, dup);
            GL.glVertex3f(cor, -cor, 0.0f);
            GL.glTexCoord2f(dup, dup);
            GL.glVertex3f(cor, cor, 0.0f);
            GL.glTexCoord2f(dup, 0);
            GL.glVertex3f(-cor, cor, 0.0f);

            GL.glEnd();
            GL.glDisable(GL.GL_TEXTURE_2D);
            GL.glEnable(GL.GL_LIGHTING);
        }
        public void Drawlake()
        {
            float[] lake_ambuse = { 0.0117f, 0.4296f, 0.6562f, 0.3f };
            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, lake_ambuse);

            for (int ll = 0; ll < 6; ll++)
            {
                GL.glPushMatrix();

                GL.glTranslated(160 - (ll * 70), 0, 0);
                GL.glColor4f(0.0117f, 0.4296f, 0.6562f, 0.5f);
                GL.glRotatef(90, 1, 0, 0);
                GLU.gluDisk(obj, 0, lake_size, 30, 30);// size of lake

                GL.glPopMatrix();
            }
        }
示例#3
0
        private void DrawBackground()
        {
            GL.glDisable(GL.GL_LIGHTING);
            GL.glEnable(GL.GL_TEXTURE_2D);
            GL.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);

            GL.glBindTexture(GL.GL_TEXTURE_2D, Textures[4]);

            float cor = GlobalProperties.seaSize / 2;

            GLUquadric obj = GLU.gluNewQuadric();

            GLU.gluQuadricTexture(obj, 4);
            GLU.gluCylinder(obj, cor, cor, cor, 32, 32);
            GLU.gluDeleteQuadric(obj);

            GL.glDisable(GL.GL_TEXTURE_2D);
            GL.glEnable(GL.GL_LIGHTING);
        }
示例#4
0
        public void update_cube_map_rotations()
        {
            GL.glTranslatef(0.0f, 0.0f, -1.4f);

            GL.glRotatef(cubemapXYZAngles[0], 1.0f, 0.0f, 0.0f);
            GL.glRotatef(cubemapXYZAngles[1], 0.0f, 1.0f, 0.0f);
            GL.glRotatef(cubemapXYZAngles[2], 0.0f, 0.0f, 1.0f);

            GL.glDisable(GL.GL_LIGHTING);
            GL.glDisable(GL.GL_TEXTURE_2D);

            DrawBounds();

            GL.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
            GL.glEnable(GL.GL_TEXTURE_2D);
            DrawTexturedCube();
            GL.glColor4f(1.0f, 1.0f, 1.0f, 1);
            GL.glDisable(GL.GL_TEXTURE_2D);
        }
示例#5
0
        public void Draw(int picFrontSide)
        {
            GL.glDisable(GL.GL_LIGHTING);
            GL.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            GL.glEnable(GL.GL_TEXTURE_2D);
            GL.glEnable(GL.GL_BLEND);
            GL.glEnable(GL.GL_CULL_FACE);

            if (picFrontSide == 1)
            {
                GL.glCullFace(GL.GL_FRONT); //front side of pictures
            }
            else
            {
                GL.glCullFace(GL.GL_BACK); //back side of pictures
            }
            DrawWallsWithTextures(picFrontSide);
            ApplyTransformation();
        }
示例#6
0
        public void Draw()
        {
            pos[0] = -4 + (float)xExisOrigin + (float)ScrollValue[11];
            pos[1] = 15 + (float)yExisOrigin + (float)ScrollValue[12];
            pos[2] = 15 + (float)ScrollValue[13];


            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }

            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            GL.glLoadIdentity();


            // not trivial
            double [] ModelVievMatrixBeforeSpecificTransforms = new double[16];
            double [] CurrentRotationTraslation = new double[16];

            GLU.gluLookAt(ScrollValue[0], ScrollValue[1], ScrollValue[2],
                          ScrollValue[3], ScrollValue[4], ScrollValue[5],
                          ScrollValue[6], ScrollValue[7], ScrollValue[8]);
            GL.glTranslatef(0.0f, 0.0f, -30.0f);

            GL.glRotatef(105, 0, 0, 1);
            GL.glRotatef(70, 0, 1, 0);
            GL.glRotatef(15, 1, 0, 0);
            //save current ModelView Matrix values
            //in ModelVievMatrixBeforeSpecificTransforms array
            //ModelView Matrix ========>>>>>> ModelVievMatrixBeforeSpecificTransforms
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            //ModelView Matrix was saved, so
            GL.glLoadIdentity(); // make it identity matrix

            //make transformation in accordance to KeyCode
            float delta;

            if (intOptionC != 0)
            {
                delta = 5.0f * Math.Abs(intOptionC) / intOptionC; // signed 5

                switch (Math.Abs(intOptionC))
                {
                case 1:
                    GL.glRotatef(delta, 1, 0, 0);
                    break;

                case 2:
                    GL.glRotatef(delta, 0, 1, 0);
                    break;

                case 3:
                    GL.glRotatef(delta, 0, 0, 1);
                    break;

                case 4:
                    GL.glTranslatef(delta / 20, 0, 0);
                    break;

                case 5:
                    GL.glTranslatef(0, delta / 20, 0);
                    break;

                case 6:
                    GL.glTranslatef(0, 0, delta / 20);
                    break;
                }
            }
            //as result - the ModelView Matrix now is pure representation
            //of KeyCode transform and only it !!!

            //save current ModelView Matrix values
            //in CurrentRotationTraslation array
            //ModelView Matrix =======>>>>>>> CurrentRotationTraslation
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);

            //The GL.glLoadMatrix function replaces the current matrix with
            //the one specified in its argument.
            //The current matrix is the
            //projection matrix, modelview matrix, or texture matrix,
            //determined by the current matrix mode (now is ModelView mode)
            GL.glLoadMatrixd(AccumulatedRotationsTraslations); //Global Matrix

            //The GL.glMultMatrix function multiplies the current matrix by
            //the one specified in its argument.
            //That is, if M is the current matrix and T is the matrix passed to
            //GL.glMultMatrix, then M is replaced with M • T
            GL.glMultMatrixd(CurrentRotationTraslation);

            //save the matrix product in AccumulatedRotationsTraslations
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);

            //replace ModelViev Matrix with stored ModelVievMatrixBeforeSpecificTransforms
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            //multiply it by KeyCode defined AccumulatedRotationsTraslations matrix
            GL.glMultMatrixd(AccumulatedRotationsTraslations);


            //REFLECTION//DrawAxes();

            //REFLECTION b
            intOptionB += 1;  //for rotation
            intOptionC += 10; //for rotation
            // without REFLECTION was only DrawAll();
            // now
            //!!!!------sky box
            GL.glPushMatrix();
            GL.glPushAttrib(GL.GL_CURRENT_BIT);
            GL.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);


            GL.glEnable(GL.GL_TEXTURE_2D);
            GL.glDisable(GL.GL_BLEND);
            GL.glRotatef(90, 1, 0, 0);
            DrawTexturedCube();
            GL.glPopAttrib();
            GL.glPopMatrix();
            /////
            GL.glEnable(GL.GL_BLEND);
            GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);


            //only floor, draw only to STENCIL buffer
            GL.glEnable(GL.GL_STENCIL_TEST);
            GL.glStencilOp(GL.GL_REPLACE, GL.GL_REPLACE, GL.GL_REPLACE);
            GL.glStencilFunc(GL.GL_ALWAYS, 1, 0xFFFFFFFF); // draw floor always
            GL.glColorMask((byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE);
            GL.glDisable(GL.GL_DEPTH_TEST);

            DrawFloor3();

            // restore regular settings
            GL.glColorMask((byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE);
            GL.glEnable(GL.GL_DEPTH_TEST);

            // reflection is drawn only where STENCIL buffer value equal to 1
            GL.glStencilFunc(GL.GL_EQUAL, 1, 0xFFFFFFFF);
            GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP);

            GL.glEnable(GL.GL_STENCIL_TEST);

            // draw reflected scene
            GL.glPushMatrix();
            GL.glScalef(1, 1, -1); //swap on Z axis
            GL.glEnable(GL.GL_CULL_FACE);
            GL.glCullFace(GL.GL_BACK);
            DrawFigures();

            GL.glCullFace(GL.GL_FRONT);
            DrawFigures();

            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();

            // really draw floor
            //( half-transparent ( see its color's alpha byte)))
            // in order to see reflected objects
            GL.glDepthMask((byte)GL.GL_FALSE);

            DrawFloor3();

            GL.glDepthMask((byte)GL.GL_TRUE);
            // Disable GL.GL_STENCIL_TEST to show All, else it will be cut on GL.GL_STENCIL
            GL.glDisable(GL.GL_STENCIL_TEST);



            DrawFigures();



            GL.glDisable(GL.GL_TEXTURE_2D);

            GL.glFlush();
            WGL.wglSwapBuffers(m_uint_DC);
        }
示例#7
0
        public void DrawRobot(bool isForShades)
        {
            GL.glPushMatrix();
            if (!isForShades)
            {
                GL.glColor4f(0f, 0f, 0.4f, 1f);
                GL.glEnable(GL.GL_COLOR_MATERIAL);
                GL.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, 51.2f);
                GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, chrome_ambient);
                GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, chrome_diffuse);
                GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, chrome_specular);
            }

            GL.glTranslated(0, 0, 7.5);

            GL.glRotatef(180, 0, 1, 0);
            GL.glRotatef(-alfa, 0, 0, 1);
            GL.glTranslated(0, 0, updn);
            GL.glRotatef(bodyAngle, 0, 1, 0);
            GL.glPushMatrix();


            //torso
            if (isForShades)
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }

            GLU.gluCylinder(obj, 1.0, 1.0, 4.0, 50, 3);
            GLU.gluDisk(obj, 0, 1, 40, 20);
            GL.glTranslated(0, 0, 4);
            GLU.gluDisk(obj, 0, 1, 40, 20);
            GL.glTranslated(0, 0, -4);
            //head
            GL.glTranslated(0, 0, -r * 3);
            GLU.gluSphere(obj, r * 3, 20, 20);

            GL.glPopMatrix();

            GL.glPushMatrix();
            //right_upper_ARM

            GL.glTranslated(0, 1.3, 0.3);

            GL.glRotatef(right_upper_ARM_yangle, 0, 1, 0);
            GL.glRotatef(right_upper_ARM_xangle, 1, 0, 0);
            if (!isForShades)
            {
                GL.glColor3f(0.4f, 0.6f, 0f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluSphere(obj, r * 1.4, 20, 20);
            if (!isForShades)
            {
                GL.glColor3f(0, 0, 1f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3);
            //right_lower_ARM
            GL.glTranslated(0, 0, 1.7);
            GL.glRotatef(right_lower_ARM_angle, 0, 1, 0);
            if (!isForShades)
            {
                GL.glColor3f(0.4f, 0.6f, 0f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluSphere(obj, r * 1.1, 20, 20);
            if (!isForShades)
            {
                GL.glColor3f(0, 0, 1f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3);

            GL.glPopMatrix();

            GL.glPushMatrix();

            //left_upper_ARM

            GL.glTranslated(0, -1.3, 0.3);
            GL.glRotatef(left_upper_ARM_yangle, 0, 1, 0);
            GL.glRotatef(left_upper_ARM_xangle, 1, 0, 0);
            if (!isForShades)
            {
                GL.glColor3f(0.4f, 0.6f, 0f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluSphere(obj, r * 1.4, 20, 20);
            if (!isForShades)
            {
                GL.glColor3f(0, 0, 1f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3);

            //left_lower_ARM

            /////
            GL.glTranslated(0, 0, 1.7);
            GL.glRotatef(left_lower_ARM_angle, 0, 1, 0);
            if (!isForShades)
            {
                GL.glColor3f(0.4f, 0.6f, 0f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluSphere(obj, r * 1.1, 20, 20);
            if (!isForShades)
            {
                GL.glColor3f(0, 0, 1f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3);

            GL.glPopMatrix();

            GL.glPushMatrix();

            //left_LEG

            GL.glTranslated(0, -0.7, 4.2);
            GL.glRotatef(right_upper_LEG_angle, 0, 1, 0);
            if (!isForShades)
            {
                GL.glColor3f(0.4f, 0.6f, 0f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluSphere(obj, r * 1.5, 20, 20);
            if (!isForShades)
            {
                GL.glColor3f(0, 0, 1f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3);
            GL.glTranslated(0, 0, 1.7);

            // right_lower_LEG

            GL.glRotatef(right_lower_LEG_angle, 0, 1, 0);
            if (!isForShades)
            {
                GL.glColor3f(0.4f, 0.6f, 0f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluSphere(obj, r * 1.1, 20, 20);
            if (!isForShades)
            {
                GL.glColor3f(0, 0, 1f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3);

            GL.glPopMatrix();

            GL.glPushMatrix();

            //right_LEG

            GL.glTranslated(0, 0.7, 4.2);
            GL.glRotatef(left_upper_LEG_angle, 0, 1, 0);
            if (!isForShades)
            {
                GL.glColor3f(0.4f, 0.6f, 0f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluSphere(obj, r * 1.5, 20, 20);
            if (!isForShades)
            {
                GL.glColor3f(0, 0, 1f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3);
            GL.glTranslated(0, 0, 1.7);
            //left_lower_LEG
            GL.glRotatef(left_lower_LEG_angle, 0, 1, 0);
            if (!isForShades)
            {
                GL.glColor3f(0.4f, 0.6f, 0f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluSphere(obj, r * 1.1, 20, 20);
            if (!isForShades)
            {
                GL.glColor3f(0, 0, 1f);
            }
            else
            {
                GL.glColor3f(0.2f, 0.2f, 0.2f);
            }
            GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3);

            GL.glPopMatrix();

            GL.glPopMatrix();
        }