Ejemplo n.º 1
0
        /// <summary>
        ///  Iscrtavanje OpenGL kontrole.
        /// </summary>
        public void Draw()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
            // TODO 2.1: skaliranje i translacija balona na scenu

            Gl.glPushMatrix();
            Gl.glTranslatef(0.0f, 0.0f, -m_sceneDistance);
            Gl.glRotatef(m_xRotation, 1.0f, 0.0f, 0.0f);
            Gl.glRotatef(m_yRotation, 0.0f, 1.0f, 0.0f);
            Gl.glScalef(35.0f, 35.0f, 35.0f);

            // da gleda sa strane gde se vide i antena i balon i prednja strana
            Glu.gluLookAt(0.0f, 0.0f, 0.0f,
                          -1.0f, 0.0f, -1.0f,
                          0.0f, 1.0f, 0.0f);

            Gl.glPushMatrix();
            Gl.glTranslated(SunX, SunY, SunZ);
            Gl.glColor3ub(255, 255, 102);
            // fiksiranje izvora svetlosti na sunce
            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, new float[] { (float)SunX, (float)SunY, (float)SunZ, 1.0f });
            Glu.gluSphere(m_gluObj, 15.0f, 128, 128);               // sun
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glColor3ub(0, 255, 0);
            Gl.glTranslated(GreenX, GreenY, GreenZ);
            Gl.glLightfv(Gl.GL_LIGHT2, Gl.GL_POSITION, new float[] { (float)GreenX, (float)GreenY, (float)GreenZ, 1.0f });
            Glu.gluSphere(m_gluObj, 5.0f, 128, 128);                // green light
            Gl.glLightfv(Gl.GL_LIGHT2, Gl.GL_SPOT_DIRECTION, new float[] { 0.0f, -1.0f, 0.0f });
            Gl.glPopMatrix();

            // balloon model draw at world.....
            Gl.glPushMatrix();

            Gl.glScalef(BallonScale * 0.01f, BallonScale * 0.01f, BallonScale * 0.01f);
            if (MainForm.BALOON_TYPE != 0)
            {
                Gl.glScalef(BallonScale + 100.0f, BallonScale + 100.0f, BallonScale + 100.0f);   //za drugi model
            }
            else
            {
                Gl.glTranslated(m_balloon.X, m_balloon.Y, m_balloon.Z);           // za prvi model
            }
            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_ADD);   // nacin stapanja GL_ADD za model
            Gl.glRotatef(BallonRotation, 0.0f, 1.0f, 0.0f);                       // rotiraj oko svoje ose balon
            m_balloon.Draw();
            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_DECAL); // nacin stapanja
            Gl.glPopMatrix();

            // TODO 2.2: postavljanje balona ispred hangara, tako sto postavljam hangar iza balona :))
            Gl.glPushMatrix();
            Gl.glTranslatef(20.0f, -20.0f, -60.0f);
            Gl.glScalef(4.0f, 4.0f, 4.0f);
            Gl.glColor3ub(255, 255, 102);               // zutom da iscrta antenu i drzac- zlatna
            m_hangar.Draw();
            Gl.glPopMatrix();
            // terrain load
            m_terrain.Draw();

            Gl.glPopMatrix();

            writeVectorText();

            // Oznaci kraj iscrtavanja
            Gl.glFlush();
        }