Esempio n. 1
0
 public void RenderizzaAlone(LogiX_Engine lxe, Camera cam)
 {
     lxe.SetCullMode(CullMode.Clockwise);
     lxe.SetLightMode(true, true);
     lxe.SetAlphaMode();
     light.Direction = cam.Position;
     light.Enabled = true;
     light.SetDirectionalLight();
     model.Scaling = new VertexData(0.48f, 0.48f, 0.48f);
     model.meshTexture = null;
     XTexture.ResetTextures();
     model.SetModelMatrices();
     Alone.SetMaterial();
     model.DrawSubset(0);
     XMaterial.ResetMaterials();
     model.UnSetModelMatrices();
     light.Enabled = false;
     light.SetDirectionalLight();
     lxe.UnSetAlphaMode();
     lxe.SetLightMode(true, false);
     lxe.SetCullMode(CullMode.CounterClockwise);
 }
Esempio n. 2
0
        /// <summary>
        /// Controlla l'oggetto Camera (specificato da LogiX_Technologies.Camera) traslando il suo punto di osservazione (specificato da LogiX_Technologies.Camera.Look) insieme con il suo punto di posizione (specificato da LogiX_Technologies.Camera.Position). Generalmente viene utilizzato contemporaneamente al metodo di rotazione della Camera da parte del Mouse [specificato da LogiX_Technologies.Mouse.RotateCamera(Camera Camera)], inserendo nei valori "float AngleX" e "float AngleY" di questo metodo le rispettive proprietà del mouse (specificate da LogiX_Technologies.Mouse.AngleX e da LogiX_Technologies.Mouse.AngleY)
        /// </summary>
        /// <param name="Forward"></param>
        /// <param name="Backward"></param>
        /// <param name="Left"></param>
        /// <param name="Right"></param>
        /// <param name="Up"></param>
        /// <param name="Down"></param>
        /// <param name="Camera"></param>
        /// <param name="AngleX"></param>
        /// <param name="AngleY"></param>
        /// <param name="Speed"></param>
        /// <returns></returns>
        public bool MoveCamera(Key Forward, Key Backward, Key Left, Key Right, Key Up, Key Down, Camera Camera, float AngleX, float AngleY, float Speed)
        {
            try
            {
                if (KeyboardState[Forward])
                {
                    movement.X = -(float)Math.Cos(AngleX) * (float)Math.Sin(AngleY) * Speed;
                    movement.Y = (float)Math.Cos(AngleY) * Speed;
                    movement.Z = (float)Math.Sin(AngleX) * (float)Math.Sin(AngleY) * Speed;
                    Camera.Look = Camera.Look + movement;
                    Camera.Position = Camera.Position + movement;
                }
                if (KeyboardState[Backward])
                {
                    movement.X = (float)Math.Cos(AngleX) * (float)Math.Sin(AngleY) * Speed;
                    movement.Y = -(float)Math.Cos(AngleY) * Speed;
                    movement.Z = -(float)Math.Sin(AngleX) * (float)Math.Sin(AngleY) * Speed;
                    Camera.Look = Camera.Look + movement;
                    Camera.Position = Camera.Position + movement;
                }
                if (KeyboardState[Left])
                {
                    movement.X = -(float)Math.Sin(AngleX) * (float)Math.Sin(AngleY) * Speed;
                    movement.Y = 0;
                    movement.Z = -(float)Math.Cos(AngleX) * (float)Math.Sin(AngleY) * Speed;
                    Camera.Look = Camera.Look + movement;
                    Camera.Position = Camera.Position + movement;
                }
                if (KeyboardState[Right])
                {
                    movement.X = (float)Math.Sin(AngleX) * (float)Math.Sin(AngleY) * Speed;
                    movement.Y = 0;
                    movement.Z = (float)Math.Cos(AngleX) * (float)Math.Sin(AngleY) * Speed;
                    Camera.Look = Camera.Look + movement;
                    Camera.Position = Camera.Position + movement;
                }
                if (KeyboardState[Up])
                {
                    Camera.Position.Y = Camera.Position.Y + 1 * Speed;
                    Camera.Look.Y = Camera.Look.Y + 1 * Speed;
                }
                if (KeyboardState[Down])
                {
                    Camera.Position.Y = Camera.Position.Y - 1 * Speed;
                    Camera.Look.Y = Camera.Look.Y - 1 * Speed;
                }

                return true;
            }
            catch
            {
                if (AmICorrect == true)
                    Error("OnMoveCamera");
                return false;
            }
        }
Esempio n. 3
0
        private void SetObjects()
        {
            //lxe.SetAutoEngine(this, true);
            //lxe.SetManualEngine(this, LogiX_Engine.CurrentDisplayHeight, LogiX_Engine.CurrentDisplayWitdh, LogiX_Engine.CurrentDisplayRefreshRate, Format.X8R8G8B8, 0, SwapEffect.Discard, DeviceType.Hardware, CreateFlags.SoftwareVertexProcessing, MultiSampleType.FourSamples);
            lxe.SetManualEngine(this, 0, SwapEffect.Discard, DeviceType.Hardware, CreateFlags.SoftwareVertexProcessing, MultiSampleType.FourSamples);

            cam = new Camera(new VertexData(0,0,-1000), VertexData.Empty, new VertexData(0,1,0),(float)Math.PI/4, 2.0f, 10000000000, 1);

            //cam.AspectRatio = (float)LogiX_Engine.CurrentDisplayWitdh / (float)LogiX_Engine.CurrentDisplayHeight;
            cam.AspectRatio = (float)this.ClientSize.Width / (float)this.ClientSize.Height;
            mouse = new Mouse(this);
            mouse.DistanceForCameraTrackBall = 7000;
            cam.FieldOfView = 2 * (float)Math.PI / 6;
            keyboard = new Keyboard(this);

            Sole = new Sole();
            sunlight = new PointLight(new VertexData(0, 0, 0), Color.FromArgb(50, 50, 50), Color.FromArgb(15,15,15), Color.OrangeRed, 10000000000000000000);
            sunlight.Attenuation0 = 1;
            lxe.SetRenderState(XTeam.LogiX_Technologies.RenderStates.Solid);
            Terra = new Pianeta(149.6f, 6370, 0.48f, 1, 365, new XTexture("MEDIA\\texterrahd.jpg"), "Terra");
            Venere = new Pianeta(108, 6052, 0, -117, 224.70059f, new XTexture("MEDIA\\venusmap.jpg"), "Venere");
            Mercurio = new Pianeta(57.909f, 2440, 0, 58.6462f, 87.969f, new XTexture("MEDIA\\mercury.jpg"), "Mercurio");
            Marte = new Pianeta(228, 3392.8f, 0, 1.025957f, 686.979f, new XTexture("MEDIA\\mars.jpg"), "Marte");
            Giove = new Pianeta(778.412f, 71492, 0, 0.413538021f, 4333.2867f, new XTexture("MEDIA\\jupiter.jpg"), "Giove");
            Saturno = new Pianeta(1426.725413f, 60268, 0.47f, 0.449375f, 10756.1995f, new XTexture("MEDIA\\saturn.jpg"), "Saturno");
            Urano = new Pianeta(2870.972220f, 25559, 1.71f, -0.71875f, 30685.55f, new XTexture("MEDIA\\uranus.jpg"), "Urano");
            Nettuno = new Pianeta(4498.252900f, 24764, 0.49f, 0.67125f, 60223.3528f,new XTexture("MEDIA\\neptune.jpg"), "Nettuno");
            Luna = new Satellite(Terra, 384.400f, 1738, 0, 28, 28, new XTexture("MEDIA\\texlunahd.jpg"), "Luna");
            Phobos = new Satellite(Marte, 9.377f, 200, 0, 1, 0.2916666f, new XTexture("MEDIA\\texphobos.jpg"), "Phobos", new Model("MEDIA\\phobos.x", 0));
            Deimos = new Satellite(Marte, 23.460f, 200, 0, 0.31891023f, 0.31891023f, new XTexture("MEDIA\\deimos.jpg"), "Deimos", new Model("MEDIA\\deimos.x", 0));
            Io = new Satellite(Giove, 421.700f, 1821.3f, 0, 1.769137786f, 1.769137786f, new XTexture("MEDIA\\io.jpg"), "Io");
            Europa = new Satellite(Giove, 671.034f, 1560.8f, 0, 3.551181041f, 3.551181041f, new XTexture("MEDIA\\europa.jpg"), "Europa");
            Ganimede = new Satellite(Giove, 1070.400f, 2631.2f, 0, 7.15455296f, 7.15455296f, new XTexture("MEDIA\\ganimede.jpg"), "Ganimede");
            Callisto = new Satellite(Giove, 1882.700f, 2410.3f, 0, 16.6890184f, 16.6890184f, new XTexture("MEDIA\\callisto.jpg"), "Ganimede");

            Sky = new CieloStellato();
            info = new PrintScreen("arial", 16);
            PianetaSelezionato = Terra;
            mod = new Model("MEDIA\\Sfera4.x", 0);
            RingColor = new XTexture("MEDIA\\saturnringcolor.jpg");
            RingPattern = new XTexture("MEDIA\\saturnringpattern.jpg");
            Saturno.CreaAnelli(RingColor, RingPattern);
            Urano.CreaAnelli(new XTexture("MEDIA\\uranusringcolour1.jpg"), new XTexture("MEDIA\\uranusringtrans.png"));

            if (!hdEnable)
            {
                hd1 = hd2 = hd3 = hd4 = hd5 = hd6 = hd7 = hd8 = hd9 = hd10 = hd11 = hd12 = hd13 = hd14 = hd15 = true;

            }
        }
Esempio n. 4
0
 /// <summary>
 /// Attiva l'effetto avanzato Water
 /// </summary>
 /// <param name="cam"></param>
 /// <param name="LightPosition"></param>
 /// <param name="vAlpha"></param>
 /// <param name="WaveHeight"></param>
 /// <param name="WaveSpeed"></param>
 /// <param name="WaveLenght"></param>
 /// <param name="TexturesDimension"></param>
 /// <returns></returns>
 public bool BeginWaterEffect(Camera cam, VertexData LightPosition, float vAlpha, float WaveHeight, float WaveSpeed, float WaveLenght, float TexturesDimension)
 {
     try
     {
         Effect.Begin(FX.None);
         matrix = LogiX_Engine.Device.Transform.View * LogiX_Engine.Device.Transform.Projection * LogiX_Engine.Device.Transform.World;
         Matrix.TransposeMatrix(matrix);
         Effect.SetValue(EffectHandles[0], matrix);
         Effect.SetValue(EffectHandles[1], new float[3] { LightPosition.X, LightPosition.Y, LightPosition.Z });
         Effect.SetValue(EffectHandles[2], new float[4] { cam.Position.X, cam.Position.Y, cam.Position.Z, 0 });
         Effect.SetValue(EffectHandles[3], (float)Environment.TickCount / 1000);
         Effect.SetValue(EffectHandles[4], vAlpha);
         Effect.SetValue(EffectHandles[5], WaveHeight);
         Effect.SetValue(EffectHandles[6], WaveSpeed);
         Effect.SetValue(EffectHandles[7], WaveLenght);
         Effect.SetValue(EffectHandles[8], TexturesDimension);
         Effect.SetValue(EffectHandles[9], BaseTextures[0]);
         Effect.SetValue(EffectHandles[10], BaseTextures[1]);
         Effect.SetValue(EffectHandles[11], BaseTextures[2]);
         Effect.SetValue(EffectHandles[12], BaseTextures[3]);
         Effect.SetValue(EffectHandles[13], BaseTextures[4]);
         Effect.SetValue(EffectHandles[14], BaseTextures[5]);
         Effect.SetValue(EffectHandles[15], BaseTextures[6]);
         Effect.CommitChanges();
         Effect.BeginPass(0);
         return true;
     }
     catch
     {
         if (AmICorrect == true)
             Error("OnBeginEffect");
         return false;
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Predispone l'oggetto CubeMap ad essere generato dall'ambiente circostante (Rendering to target) (da utilizzare all'esterno del GameLoop)
 /// </summary>
 /// <param name="EdgeLength"></param>
 /// <returns></returns>
 public bool InitializeRenderToCube(int EdgeLength)
 {
     try
     {
         viewport = new Viewport();
         viewport.MaxZ = 1;
         viewport.Width = EdgeLength;
         viewport.Height = EdgeLength;
         LogiX_Engine.Device.RenderState.NormalizeNormals = true;
         cube = new CubeTexture(LogiX_Engine.Device, EdgeLength, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);
         renderToEnvy = new RenderToEnvironmentMap(LogiX_Engine.Device, EdgeLength, 1, Format.X8R8G8B8, true, DepthFormat.D16);
         cam = new Camera(new VertexData(0, 0, 0), new VertexData(0, 0, 0));
         cam.FarPlane = 100000;
         cam.AspectRatio = 1;
         cam.FieldOfView = (float)Math.PI / 2;
         path = null;
         correct = true;
         return true;
     }
     catch
     {
         Error("OnInitializeRenderToCube");
         return false;
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Attiva l'effetto base Reflect
 /// </summary>
 /// <param name="cam"></param>
 /// <param name="ReflectionRatio"></param>
 /// <param name="BumpMapped"></param>
 /// <returns></returns>
 public bool BeginReflectEffect(Camera cam, float ReflectionRatio, bool BumpMapped)
 {
     try
     {
         Effect.Begin(FX.None);
         Effect.SetValue(EffectHandles[0], new float[3] { cam.Position.X, cam.Position.Y, cam.Position.Z });
         matrix = LogiX_Engine.Device.Transform.View;
         Matrix.TransposeMatrix(matrix);
         Effect.SetValue(EffectHandles[1], matrix);
         matrix = LogiX_Engine.Device.Transform.View;
         matrix = matrix * LogiX_Engine.Device.Transform.Projection;
         Matrix.TransposeMatrix(matrix);
         Effect.SetValue(EffectHandles[2], matrix);
         Effect.SetValue(EffectHandles[3], ReflectionRatio);
         Effect.SetValue(EffectHandles[4], BaseTextures[0]);
         Effect.SetValue(EffectHandles[5], CubeTextures[0]);
         Effect.SetValue(EffectHandles[6], BumpMapped);
         Effect.CommitChanges();
         Effect.BeginPass(0);
         return true;
     }
     catch
     {
         if (AmICorrect == true)
             Error("OnBeginEffect");
         return false;
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Attiva l'effetto base PerPixelDirectionalLight
 /// </summary>
 /// <param name="cam"></param>
 /// <param name="LightDirection"></param>
 /// <param name="mat"></param>
 /// <returns></returns>
 public bool BeginPerPixelDirectionalLightEffect(Camera cam, VertexData LightDirection, XMaterial mat)
 {
     try
     {
         Effect.Begin(FX.None);
         matrix = LogiX_Engine.Device.Transform.View * LogiX_Engine.Device.Transform.Projection;
         Matrix.TransposeMatrix(matrix);
         Effect.SetValue(EffectHandles[0], matrix);
         matrix = LogiX_Engine.Device.Transform.World;
         Matrix.TransposeMatrix(matrix);
         Effect.SetValue(EffectHandles[1], matrix);
         Effect.SetValue(EffectHandles[2], new float[3] { -LightDirection.X, -LightDirection.Y, -LightDirection.Z });
         Effect.SetValue(EffectHandles[3], new float[3] { cam.Position.X, cam.Position.Y, cam.Position.Z });
         Effect.SetValue(EffectHandles[4], BaseTextures[0]);
         Effect.SetValue(EffectHandles[5], new float[4] { mat.Specular.R / 255, mat.Specular.G / 255, mat.Specular.B / 255, mat.Specular.A / 255 });
         Effect.SetValue(EffectHandles[6], new float[4] { mat.Diffuse.R / 255, mat.Diffuse.G / 255, mat.Diffuse.B / 255, mat.Diffuse.A / 255 });
         Effect.SetValue(EffectHandles[7], mat.SpecularSharpness);
         Effect.CommitChanges();
         Effect.BeginPass(0);
         return true;
     }
     catch
     {
         if (AmICorrect == true)
             Error("OnBeginEffect");
         return false;
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Attiva l'effetto avanzato Glass
 /// </summary>
 /// <param name="cam"></param>
 /// <param name="BaseColor"></param>
 /// <param name="RefractionScale"></param>
 /// <param name="Ambient"></param>
 /// <param name="IndexOfRefracrionRatio"></param>
 /// <param name="ReflectionScale"></param>
 /// <param name="Alpha"></param>
 /// <returns></returns>
 public bool BeginGlassEffect(Camera cam, Color BaseColor, float RefractionScale, float Ambient, float IndexOfRefracrionRatio, float ReflectionScale, float Alpha)
 {
     try
     {
         Effect.Begin(FX.None);
         matrix = LogiX_Engine.device.Transform.View * LogiX_Engine.device.Transform.Projection;
         Matrix.TransposeMatrix(matrix);
         Effect.SetValue(EffectHandles[0], matrix);
         Effect.SetValue(EffectHandles[1], new float[4] { cam.Position.X, cam.Position.Y, cam.Position.Z, 1.0f });
         Effect.SetValue(EffectHandles[2], RefractionScale);
         Effect.SetValue(EffectHandles[3], BaseColor.ToArgb());
         Effect.SetValue(EffectHandles[4], Ambient);
         Effect.SetValue(EffectHandles[5], IndexOfRefracrionRatio);
         Effect.SetValue(EffectHandles[6], ReflectionScale);
         Effect.SetValue(EffectHandles[7], CubeTextures[0]);
         Effect.SetValue(EffectHandles[8], Alpha);
         matrix = LogiX_Engine.device.Transform.World;
         Matrix.TransposeMatrix(matrix);
         Effect.SetValue(EffectHandles[9], matrix);
         Effect.CommitChanges();
         Effect.BeginPass(0);
         return true;
     }
     catch
     {
         Error("OnBeginEffect");
         return false;
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Controlla l'oggetto Camera (specificato da LogiX_Technologies.Camera) ruotando il suo punto di osservazione (specificato da LogiX_Technologies.Camera.Look) attorno al suo punto di posizione nello spazio (specificato da LogiX_Technologies.Camera.Position) con il Mouse. 
 /// </summary>
 /// <param name="Camera"></param>
 /// <returns></returns>
 public bool RotateCamera(Camera Camera)
 {
     try
     {
         cam = Camera;
         angleX = angleX + 0.005f * CurrentX;
         angleY = angleY + 0.005f * CurrentY;
         Camera.Look.X = Camera.Position.X - (float)Math.Cos(angleX) * (float)Math.Sin(angleY);
         if (angleY > 0)
         {
             Camera.Look.Y = Camera.Position.Y + (float)Math.Cos(angleY);
         }
         if (angleY <= 0)
         {
             angleY = 0.001f;
             Camera.Look.Y = Camera.Position.Y + (float)Math.Cos(angleY);
         }
         if (angleY >= Math.PI)
         {
             angleY = (float)Math.PI - 0.001f;
             Camera.Look.Y = Camera.Position.Y + (float)Math.Cos(angleY);
         }
         Camera.Look.Z = Camera.Position.Z + (float)Math.Sin(angleX) * (float)Math.Sin(angleY);
         return true;
     }
     catch
     {
         if (AmICorrect == true)
             Error("OnRotateCamera");
         return false;
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Controlla l'oggetto Camera (specificato da LogiX_Technologies.Camera) ruotando il suo punto di posizione nello spazio (specificato da LogiX_Technologies.Camera.Position) attorno al suo punto di osservazione (specificato da LogiX_Technologies.Camera.Look) con il Mouse. 
        /// </summary>
        /// <param name="Camera"></param>
        /// <param name="Look"></param>
        /// <param name="Speed"></param>
        /// <returns></returns>
        public bool CameraTrackBall(Camera Camera, VertexData Look, float Speed, float SpeedScaling, float Sensibility)
        {
            try
            {
                cam = Camera;
                speedScaling = SpeedScaling;
                angleX = angleX + 0.005f * CurrentX * Sensibility;
                angleY = angleY + 0.005f * CurrentY * Sensibility;
                angleZ = angleZ + 0.005f * CurrentZ * Speed;
                Camera.Look = Look;
                if (angleY > 0)
                {
                    if (angleZ < 0)
                    {
                        if (angleY < (float)Math.PI)
                        {
                            Camera.Position.Y = Look.Y + 1000 * ((float)Math.Pow(angleZ, 5) / SpeedScaling) * (float)Math.Cos(angleY);
                            Camera.Position.X = Look.X + 1000 * ((float)Math.Pow(angleZ, 5) / SpeedScaling) * (float)Math.Cos(angleX) * (float)Math.Sin(angleY);
                            Camera.Position.Z = Look.Z + 1000 * ((float)Math.Pow(angleZ, 5) / SpeedScaling) * (float)Math.Sin(angleX) * (float)Math.Sin(angleY);
                        }
                        else
                        {
                            angleY = (float)Math.PI - 0.001f;
                            Camera.Position.Y = Look.Y + 1000 * ((float)Math.Pow(angleZ, 5) / SpeedScaling) * (float)Math.Cos(angleY);
                            Camera.Position.X = Look.X + 1000 * ((float)Math.Pow(angleZ, 5) / SpeedScaling) * (float)Math.Cos(angleX) * (float)Math.Sin(angleY);
                            Camera.Position.Z = Look.Z + 1000 * ((float)Math.Pow(angleZ, 5) / SpeedScaling) * (float)Math.Sin(angleX) * (float)Math.Sin(angleY);
                        }
                    }
                    else
                    {
                        angleZ = -0.00001f;
                    }
                }
                if (angleY <= 0)
                {
                    angleY = 0.01f;
                    Camera.Position.Y = Look.Y + 1000 * ((float)Math.Pow(angleZ, 5) / SpeedScaling) * (float)Math.Cos(angleY);
                    Camera.Position.X = Look.X + 1000 * ((float)Math.Pow(angleZ, 5) / SpeedScaling) * (float)Math.Cos(angleX) * (float)Math.Sin(angleY);
                    Camera.Position.Z = Look.Z + 1000 * ((float)Math.Pow(angleZ, 5) / SpeedScaling) * (float)Math.Sin(angleX) * (float)Math.Sin(angleY);
                }

                correct = true;
                return true;
            }
            catch
            {
                correct = false;
                return false;
            }
        }