Ejemplo n.º 1
0
Archivo: Shots.cs Proyecto: 4nu81/3dlab
        /// <summary>
        /// Constructor für Schuss
        /// </summary>
        /// <param name="cam">Kameraobjekt dient zur ermittlung der Position und Ausrichtung</param>
        /// <param name="Dir">Richtung in die der Schuss fliegen soll (wird intern normiert)</param>
        /// <param name="Red">Rotanteil in der Farbe</param>
        /// <param name="Green">Grünanteil in der Farbe</param>
        /// <param name="Blue">Blauanteil in der Farbe</param>
        /// <param name="Speed">Bewegungsgeschwindigkeit</param>
        public Shot(Camera cam, Point3 Dir, float Red, float Green, float Blue, float Speed)
        {
            // Richtung gleich normieren
            float n = (float)Math.Sqrt(Math.Pow(Dir.x, 2) + Math.Pow(Dir.y, 2) + Math.Pow(Dir.z, 2));
            _Dir.x = Dir.x / n;
            _Dir.y = Dir.y / n;
            _Dir.z = Dir.z / n;

            _Pos.x = __InitPos.x = -cam.X;
            _Pos.y = __InitPos.y = -cam.Y;
            _Pos.z = __InitPos.z = -cam.Z;

            _AngleX = cam.angleX;
            _AngleZ = cam.angleZ;

            _Red = Red;
            _Green = Green;
            _Blue = Blue;
            _Speed = Speed;
            _Birthtime = DateTime.Now;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Zeichenroutine für die Skybox
        /// </summary>
        /// <param name="c">Das Kameraobjekt um Ausrichtung im Raum zu ermitteln.</param>
        public void DrawSky(Camera c)
        {
            if (DoDrawSkybox)
            {
                float dist = 0.5f;

                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glLoadIdentity();
                Gl.glPushAttrib(Gl.GL_ENABLE_BIT);

                Gl.glEnable(Gl.GL_TEXTURE_2D);
                Gl.glDisable(Gl.GL_DEPTH_TEST);
                Gl.glDisable(Gl.GL_LIGHTING);
                Gl.glDisable(Gl.GL_BLEND);

                Gl.glRotatef(c.angleX, 1.0f, 0.0f, 0.0f);			// rotate on the X-axis
                Gl.glRotatef(c.angleZ, 0.0f, 0.0f, 1.0f);			// rotate on the Z-axis
                Gl.glColor4f(1f, 1f, 1f, 1f);

                Gl.glBindTexture(Gl.GL_TEXTURE_2D, _skybox[1]);
                Gl.glBegin(Gl.GL_QUADS);
                // Unten
                Gl.glTexCoord2f(1.0f, 1.0f);			// top right of texture
                Gl.glVertex3f(dist, dist, dist);		// top right of quad
                Gl.glTexCoord2f(0.0f, 1.0f);			// top left of texture
                Gl.glVertex3f(-dist, dist, dist);		// top left of quad
                Gl.glTexCoord2f(0.0f, 0.0f);			// bottom left of texture
                Gl.glVertex3f(-dist, -dist, dist);	    // bottom left of quad
                Gl.glTexCoord2f(1.0f, 0.0f);			// bottom right of texture
                Gl.glVertex3f(dist, -dist, dist);		// bottom right of quad
                Gl.glEnd();

                Gl.glBindTexture(Gl.GL_TEXTURE_2D, _skybox[2]);
                Gl.glBegin(Gl.GL_QUADS);
                // Ground
                Gl.glTexCoord2f(1.0f, 1.0f);			// top right of texture
                Gl.glVertex3f(-dist, dist, -dist);	// top right of quad
                Gl.glTexCoord2f(0.0f, 1.0f);			// top left of texture
                Gl.glVertex3f(dist, dist, -dist);		// top left of quad
                Gl.glTexCoord2f(0.0f, 0.0f);			// bottom left of texture
                Gl.glVertex3f(dist, -dist, -dist);	// bottom left of quad
                Gl.glTexCoord2f(1.0f, 0.0f);			// bottom right of texture
                Gl.glVertex3f(-dist, -dist, -dist);	// bottom right of quad
                Gl.glEnd();

                Gl.glBindTexture(Gl.GL_TEXTURE_2D, _skybox[3]);
                Gl.glBegin(Gl.GL_QUADS);
                // Up
                Gl.glTexCoord2f(1.0f, 1.0f);			// top right of texture
                Gl.glVertex3f(dist, dist, -dist);		// top right of quad
                Gl.glTexCoord2f(0.0f, 1.0f);			// top left of texture
                Gl.glVertex3f(-dist, dist, -dist);	// top left of quad
                Gl.glTexCoord2f(0.0f, 0.0f);			// bottom left of texture
                Gl.glVertex3f(-dist, dist, dist);		// bottom left of quad
                Gl.glTexCoord2f(1.0f, 0.0f);			// bottom right of texture
                Gl.glVertex3f(dist, dist, dist);		// bottom right of quad
                Gl.glEnd();

                Gl.glBindTexture(Gl.GL_TEXTURE_2D, _skybox[4]);
                Gl.glBegin(Gl.GL_QUADS);
                // Right Face
                Gl.glTexCoord2f(1.0f, 1.0f);			// top right of texture
                Gl.glVertex3f(dist, dist, -dist);		// top right of quad
                Gl.glTexCoord2f(0.0f, 1.0f);			// top left of texture
                Gl.glVertex3f(dist, dist, dist);		// top left of quad
                Gl.glTexCoord2f(0.0f, 0.0f);			// bottom left of texture
                Gl.glVertex3f(dist, -dist, dist);		// bottom left of quad
                Gl.glTexCoord2f(1.0f, 0.0f);			// bottom right of texture
                Gl.glVertex3f(dist, -dist, -dist);	// bottom right of quad
                Gl.glEnd();

                Gl.glBindTexture(Gl.GL_TEXTURE_2D, _skybox[5]);
                Gl.glBegin(Gl.GL_QUADS);
                // Left Face
                Gl.glTexCoord2f(0.0f, 1.0f);			// top right of texture
                Gl.glVertex3f(dist, -dist, dist);		// top right of quad
                Gl.glTexCoord2f(0.0f, 0.0f);			// top left of texture
                Gl.glVertex3f(-dist, -dist, dist);	    // top left of quad
                Gl.glTexCoord2f(1.0f, 0.0f);			// bottom left of texture
                Gl.glVertex3f(-dist, -dist, -dist);	    // bottom left of quad
                Gl.glTexCoord2f(1.0f, 1.0f);			// bottom right of texture
                Gl.glVertex3f(dist, -dist, -dist);	    // bottom right of quad
                Gl.glEnd();

                Gl.glBindTexture(Gl.GL_TEXTURE_2D, _skybox[0]);
                Gl.glBegin(Gl.GL_QUADS);
                // Left Face
                Gl.glTexCoord2f(1.0f, 1.0f);			// top right of texture
                Gl.glVertex3f(-dist, dist, dist);		// top right of quad
                Gl.glTexCoord2f(0.0f, 1.0f);			// top left of texture
                Gl.glVertex3f(-dist, dist, -dist);	// top left of quad
                Gl.glTexCoord2f(0.0f, 0.0f);			// bottom left of texture
                Gl.glVertex3f(-dist, -dist, -dist);	// bottom left of quad
                Gl.glTexCoord2f(1.0f, 0.0f);			// bottom right of texture
                Gl.glVertex3f(-dist, -dist, dist);	// bottom right of quad
                Gl.glEnd();

                Gl.glPopAttrib();
                Gl.glPopMatrix();
            }
        }
Ejemplo n.º 3
0
Archivo: Shots.cs Proyecto: 4nu81/3dlab
        /// <summary>
        /// Schuss wird gezeichnet
        /// </summary>
        /// <param name="cam">Kameraobjekt</param>
        public void Draw(Camera cam)
        {
            float X = _Pos.x;
            float Y = _Pos.y;
            float Z = _Pos.z;
            float DX = _Dir.x;
            float DY = _Dir.y;
            float DZ = _Dir.z;
            float dx = Size;
            float dy = Size * 3;
            float dz = Size;

            Gl.glPushMatrix();

            Gl.glTranslatef(X, Y, Z);

            Gl.glRotatef(-_AngleZ, 0, 0, 1);
            Gl.glRotatef(-_AngleX - 90, 1, 0, 0);

            X = 0;
            Y = 0;
            Z = 0;
            Gl.glEnable(Gl.GL_CULL_FACE_MODE);
            Gl.glColor3f(_Red, _Green, _Blue);

            Gl.glBegin(Gl.GL_POLYGON);
            Gl.glVertex3f(X, Y, Z);
            Gl.glVertex3f(X + dx, Y - dy, Z - dz);
            Gl.glVertex3f(X + dx, Y + dy, Z - dz);
            Gl.glVertex3f(X - dx, Y + dy, Z - dz);
            Gl.glEnd();

            Gl.glBegin(Gl.GL_POLYGON);
            Gl.glVertex3f(X - dx, Y - dy, Z - dz);
            Gl.glVertex3f(X + dx, Y - dy, Z - dz);
            Gl.glVertex3f(X + dx, Y - dy, Z + dz);
            Gl.glVertex3f(X - dx, Y - dy, Z + dz);
            Gl.glEnd();

            Gl.glBegin(Gl.GL_POLYGON);
            Gl.glVertex3f(X - dx, Y - dy, Z - dz);
            Gl.glVertex3f(X - dx, Y + dy, Z - dz);
            Gl.glVertex3f(X - dx, Y + dy, Z + dz);
            Gl.glVertex3f(X - dx, Y - dy, Z + dz);
            Gl.glEnd();

            Gl.glBegin(Gl.GL_POLYGON);
            Gl.glVertex3f(X + dx, Y + dy, Z + dz);
            Gl.glVertex3f(X + dx, Y + dy, Z - dz);
            Gl.glVertex3f(X + dx, Y - dy, Z - dz);
            Gl.glVertex3f(X + dx, Y - dy, Z + dz);
            Gl.glEnd();

            Gl.glBegin(Gl.GL_POLYGON);
            Gl.glVertex3f(X + dx, Y + dy, Z + dz);
            Gl.glVertex3f(X + dx, Y + dy, Z - dz);
            Gl.glVertex3f(X - dx, Y + dy, Z - dz);
            Gl.glVertex3f(X - dx, Y + dy, Z + dz);
            Gl.glEnd();

            Gl.glBegin(Gl.GL_POLYGON);
            Gl.glVertex3f(X + dx, Y + dy, Z + dz);
            Gl.glVertex3f(X - dx, Y + dy, Z + dz);
            Gl.glVertex3f(X - dx, Y - dy, Z + dz);
            Gl.glVertex3f(X + dx, Y - dy, Z + dz);
            Gl.glEnd();

            Gl.glPopMatrix();
        }