Esempio n. 1
0
        private void ConstructorHotSpace(String name, String[] listTextures)
        {
            this.graphicsDevice = PanoEngine.PEGraphicsDevice;
            this.name = name;

            //inicializar lista de hotspots
            listaHotSpot = new List<HotSpot>();

            //inicializar lista de gotos
            listaGoTo = new List<GoTo>();

            //Inicializar caras del hot space

            faces = new Sprite3D[4];
            if (listTextures != null)
            {
                faces[0] = new Sprite3D(16.0f, 9.0f, listTextures[0]);
                faces[1] = new Sprite3D(16.0f, 9.0f, listTextures[1]);
                faces[2] = new Sprite3D(16.0f, 9.0f, listTextures[2]);
                faces[3] = new Sprite3D(16.0f, 9.0f, listTextures[3]);
            }
            else
            {
                faces[0] = new Sprite3D(16.0f, 9.0f, null);
                faces[1] = new Sprite3D(16.0f, 9.0f, null);
                faces[2] = new Sprite3D(16.0f, 9.0f, null);
                faces[3] = new Sprite3D(16.0f, 9.0f, null);
            }

            //Puesto que los cuadrados se crean en la posicion 0 0 0 debo de trasladarlos y rotarlos para
            //formar un cubo con las caras hacia dentro
            faces[0].Position = new Vector3(0.0f, 0.0f, -faces[0].Ancho / 2);

            faces[1].Rotation = Matrix.CreateRotationY(-MathHelper.PiOver2);
            faces[1].Position = new Vector3(faces[1].Ancho / 2, 0.0f, 0.0f);

            faces[2].Rotation = Matrix.CreateRotationY(MathHelper.Pi);
            faces[2].Position = new Vector3(0.0f, 0.0f, faces[2].Ancho / 2);

            faces[3].Rotation = Matrix.CreateRotationY(MathHelper.PiOver2);
            faces[3].Position = new Vector3(-faces[3].Ancho / 2, 0.0f, 0.0f);

            effect = new BasicEffect(graphicsDevice);
        }
Esempio n. 2
0
        public static bool Intersects(Sprite3D s, Vector2 pointer, Viewport v, Camera cam)
        {
            Vector3 nearPoint = new Vector3(pointer, 0);
            Vector3 farPoint = new Vector3(pointer, 1);

            nearPoint = v.Unproject(nearPoint, cam.Projection, cam.View, Matrix.Identity);
            farPoint = v.Unproject(farPoint, cam.Projection, cam.View, Matrix.Identity);

            Vector3 direction = farPoint - nearPoint;
            direction.Normalize();

            Ray r = new Ray(nearPoint, direction);

            BoundingSphere bs = s.GetBoundingSphere();

            return (bs.Intersects(r) != null) ? true : false;
        }