Beispiel #1
0
        public PointOfInterest(Vector3D initialPosition, bool autoPlay)
        {
            this.Position.Px = initialPosition.Px;
            this.Position.Py = initialPosition.Py;
            this.Position.Pz = initialPosition.Pz;

            if (autoPlay)
            {
                this.setSoundPosition();
                this.playSound();
            }
        }
Beispiel #2
0
        public SoundEffect(int id, int bid, IntPtr b, Vector3D pos, Vector3D v, bool l, float p, float g)
        {
            this.SoundID = id;
            this.BufferID = bid;

            this.Buffer = b;            
            this.Position = pos;
            this.Velocity = v;

            this.Looping = l ? Al.AL_TRUE : Al.AL_FALSE;
            this.Pitch = p;
            this.Gain = g;
        }
Beispiel #3
0
        public void drawArea(Vector3D pos)
        {
            Gl.glBegin(Gl.GL_QUADS);
                Gl.glVertex3d(pos.Px + this.Adjustment.Px + this.Dimensions.Px, pos.Py + this.Adjustment.Py + 2.0, pos.Pz + this.Adjustment.Pz + this.Dimensions.Pz);
                Gl.glVertex3d(pos.Px + this.Adjustment.Px - this.Dimensions.Px, pos.Py + this.Adjustment.Py + 2.0, pos.Pz + this.Adjustment.Pz + this.Dimensions.Pz);
                Gl.glVertex3d(pos.Px + this.Adjustment.Px - this.Dimensions.Px, pos.Py + this.Adjustment.Py + 2.0, pos.Pz + this.Adjustment.Pz - this.Dimensions.Pz);
                Gl.glVertex3d(pos.Px + this.Adjustment.Px + this.Dimensions.Px, pos.Py + this.Adjustment.Py + 2.0, pos.Pz + this.Adjustment.Pz - this.Dimensions.Pz);
            Gl.glEnd();

            //Gl.glBegin(Gl.GL_QUADS);
            //Gl.glVertex3d(pos.Px + this.Adjustment.Px + this.Dimensions.Px * 2, pos.Py + this.Adjustment.Py + 1.0, pos.Pz + this.Adjustment.Pz + this.Dimensions.Pz * 2);
            //Gl.glVertex3d(pos.Px + this.Adjustment.Px - this.Dimensions.Px * 2, pos.Py + this.Adjustment.Py + 1.0, pos.Pz + this.Adjustment.Pz + this.Dimensions.Pz * 2);
            //Gl.glVertex3d(pos.Px + this.Adjustment.Px - this.Dimensions.Px * 2, pos.Py + this.Adjustment.Py + 1.0, pos.Pz + this.Adjustment.Pz - this.Dimensions.Pz * 2);
            //Gl.glVertex3d(pos.Px + this.Adjustment.Px + this.Dimensions.Px * 2, pos.Py + this.Adjustment.Py + 1.0, pos.Pz + this.Adjustment.Pz - this.Dimensions.Pz * 2);
            //Gl.glEnd();
        }
Beispiel #4
0
        public double angle(Vector3D ov)
        {
            //Vector3D v1 = this.normalize();
            //Vector3D v2 = ov.normalize();

            //return Utilities.toDegrees(Math.Acos(v1.dotProduct(v2)));
            //return Utilities.toDegrees(Math.Atan2(v1.crossProduct(v2).Length, v1.dotProduct(v2)));

            //return Utilities.toDegrees(Math.Atan2(this.Px - ov.Px, this.Pz - ov.Pz));
            return Utilities.toDegrees(Math.Atan2(this.Px - ov.Px, this.Pz - ov.Pz));

            //double d = Math.Atan2(this.Px - ov.Px, this.Pz - ov.Pz);

            //d = d < 0.0 ? d + 2 * Math.PI : d;

            //return Utilities.toDegrees(d);
        }
Beispiel #5
0
 public PointOfInterest(Vector3D initialPosition)
 {
     this.Position.Px = initialPosition.Px;
     this.Position.Py = initialPosition.Py;
     this.Position.Pz = initialPosition.Pz;
 }
Beispiel #6
0
 public void setSoundPosition(Vector3D p)
 {
     if (Assets.Instance.Sounds.ContainsKey(this.SoundName))
     {
         Al.alSource3f(Assets.Instance.Sounds[this.SoundName].SoundID, Al.AL_POSITION, (float)p.Px, (float)p.Py, (float)p.Pz);
     }
 }
Beispiel #7
0
 /// <summary>
 /// Não implementado
 /// </summary>
 /// <exception cref="NotImplementedException">NotImplementedException</exception>
 /// <param name="position"></param>
 public void setSoundPosition(Vector3D position)
 {
     throw new NotImplementedException();
 }
Beispiel #8
0
        /// <summary>
        /// Detecta de existiu uma colisão com Outros objectos 3D da simulação.
        /// Esses objectos deverão implementar a interface IReal que indica que um é objecto é real e colidível
        /// </summary>
        /// <param name="futurePosition">A posição futura da personagem</param>
        /// <param name="objects">Os objectos 3D da simulação. Provavelmente são os mesmos que estão a ser enviados para o Renderer</param>
        /// <returns>Se colidiu ou não</returns>
        /// 
        /// TODO: Extender a outros tipos de objectos
        public bool collidesWithObjects(Vector3D futurePosition, List<IReal> objects)
        {
            bool collided = false;

            foreach (IReal obj in objects)
            {
                if ((futurePosition.Px <= obj.Position.Px + obj.ColisionArea.Adjustment.Px + obj.ColisionArea.Dimensions.Px
                        && futurePosition.Px >= obj.Position.Px + obj.ColisionArea.Adjustment.Px - obj.ColisionArea.Dimensions.Px)

                        && (futurePosition.Pz <= obj.Position.Pz + obj.ColisionArea.Adjustment.Pz + obj.ColisionArea.Dimensions.Pz
                        && futurePosition.Pz >= obj.Position.Pz + obj.ColisionArea.Adjustment.Pz - obj.ColisionArea.Dimensions.Pz))
                {                        
                    collided = true;
                    break;
                }                
            }

            return collided;
        }
Beispiel #9
0
        /// <summary>
        /// Calcula a posição seguinte da personagem para efeitos de colisão
        /// Apenas existem duas possibilidades de movimento (frente, trás) já que os movimentos
        /// Esquerda/Direita são rotações
        /// </summary>
        /// <param name="direction">A direcção em que se está a movimentar a personagem</param>
        /// <returns>Vector3D que indica a próxima posição</returns>
        public Vector3D calculateNextPosition(CharacterDirection direction)
        {
            Vector3D nextPosition = new Vector3D();

            if (direction == CharacterDirection.Front)
            {
                nextPosition.Px = this.Position.Px + Math.Cos(this.Angle) * this.Velocity;
                nextPosition.Pz = this.Position.Pz + Math.Sin(-this.Angle) * this.Velocity;
            }
            else if (direction == CharacterDirection.Back)
            {
                nextPosition.Px = this.Position.Px - Math.Cos(this.Angle) * this.Velocity;
                nextPosition.Pz = this.Position.Pz - Math.Sin(-this.Angle) * this.Velocity;
            }

            return nextPosition;
        }
Beispiel #10
0
 public double distance(Vector3D ov)
 {
     return Math.Sqrt(Math.Pow(this.Px - ov.Px, 2.0) + Math.Pow(this.Py - ov.Py, 2.0) + Math.Pow(this.Pz - ov.Pz, 2.0));
 }
Beispiel #11
0
 public Vector3D crossProduct(Vector3D ov)
 {
     return new Vector3D((this.Py * ov.Pz) - (ov.Py * this.Pz),
                         (this.Pz * ov.Px) - (ov.Pz * this.Px),
                         (this.Px * ov.Py) - (ov.Px * this.Py));
 }
Beispiel #12
0
 public double dotProduct(Vector3D ov)
 {
     return (this.Px * ov.Px) + (this.Py * ov.Py) + (this.Pz * ov.Pz);
 }
Beispiel #13
0
 public Vector3D subtract(Vector3D ov)
 {
     return new Vector3D(this.Px - ov.px, this.Py - ov.Py, this.Pz - ov.Pz);
 }
Beispiel #14
0
 public Vector3D sum(Vector3D ov)
 {
     return new Vector3D(this.Px + ov.px, this.Py + ov.Py, this.Pz + ov.Pz);
 }
Beispiel #15
0
 public void setPosition(Vector3D v)
 {
     Al.alSource3f(Assets.Instance.Sounds[this.SoundName].SoundID, Al.AL_POSITION, (float)v.Px, (float)v.Py, (float)v.Pz);
 }