private void CreatePropAtMousePosition(int MouseX, int MouseY)
        {
            if (lstItemChoices.SelectedNode != null)
            {
                TreeNode        SelectedNode         = lstItemChoices.SelectedNode;
                BillboardSystem ActiveParticleSystem = lstItemChoices.SelectedNode.Tag as BillboardSystem;

                if (ActiveParticleSystem == null && lstItemChoices.SelectedNode.Parent != null)
                {
                    SelectedNode         = lstItemChoices.SelectedNode.Parent;
                    ActiveParticleSystem = lstItemChoices.SelectedNode.Parent.Tag as BillboardSystem;
                }
                if (ActiveParticleSystem != null)
                {
                    Vector3 NearScreenPoint = new Vector3(MouseX, MouseY, 0);
                    Vector3 FarScreenPoint  = new Vector3(MouseX, MouseY, 1);
                    Vector3 NearWorldPoint  = AnimationBackgroundViewer.GraphicsDevice.Viewport.Unproject(NearScreenPoint,
                                                                                                          AnimationBackgroundViewer.ActiveAnimationBackground.Projection,
                                                                                                          AnimationBackgroundViewer.ActiveAnimationBackground.View, Matrix.Identity);
                    Vector3 FarWorldPoint = AnimationBackgroundViewer.GraphicsDevice.Viewport.Unproject(FarScreenPoint,
                                                                                                        AnimationBackgroundViewer.ActiveAnimationBackground.Projection,
                                                                                                        AnimationBackgroundViewer.ActiveAnimationBackground.View, Matrix.Identity);

                    Vector3 Direction = FarWorldPoint - NearWorldPoint;

                    float   zFactor        = -NearWorldPoint.Y / Direction.Y;
                    Vector3 ZeroWorldPoint = NearWorldPoint + Direction * zFactor;

                    ActiveParticleSystem.AddParticle(ZeroWorldPoint);
                    SelectedNode.Nodes.Add("Prop " + (SelectedNode.Nodes.Count + 1));
                }
            }
        }
Exemplo n.º 2
0
        public override void Load(ContentManager Content, GraphicsDevice g)
        {
            VehiculeDrawablePart = new BillboardSystem("Units/Racing/Sprites/Back", 2, 1, BlendState.NonPremultiplied, true, Content, g);
            VehiculeDrawablePart.Parameters["Size"].SetValue(new Vector2(188 * 0.1f, 112 * 0.1f));
            VehiculeDrawablePart.AddParticle(Vector3.Zero);

            DicVehiculeSpritePerAngle.Add(0, Content.Load <Texture2D>("Units/Racing/Sprites/Back"));
            DicVehiculeSpritePerAngle.Add(5, Content.Load <Texture2D>("Units/Racing/Sprites/Back5"));
            DicVehiculeSpritePerAngle.Add(10, Content.Load <Texture2D>("Units/Racing/Sprites/Back10"));
            DicVehiculeSpritePerAngle.Add(25, Content.Load <Texture2D>("Units/Racing/Sprites/Back25"));
            DicVehiculeSpritePerAngle.Add(35, Content.Load <Texture2D>("Units/Racing/Sprites/Back35"));
            DicVehiculeSpritePerAngle.Add(45, Content.Load <Texture2D>("Units/Racing/Sprites/Back45"));
            DicVehiculeSpritePerAngle.Add(65, Content.Load <Texture2D>("Units/Racing/Sprites/Back45"));
            DicVehiculeSpritePerAngle.Add(90, Content.Load <Texture2D>("Units/Racing/Sprites/Back45"));

            DicVehiculeSpritePerAngle.Add(-5, FlipTexture2D(DicVehiculeSpritePerAngle[5]));
            DicVehiculeSpritePerAngle.Add(-10, FlipTexture2D(DicVehiculeSpritePerAngle[10]));
            DicVehiculeSpritePerAngle.Add(-25, FlipTexture2D(DicVehiculeSpritePerAngle[25]));
            DicVehiculeSpritePerAngle.Add(-35, FlipTexture2D(DicVehiculeSpritePerAngle[35]));
            DicVehiculeSpritePerAngle.Add(-45, FlipTexture2D(DicVehiculeSpritePerAngle[45]));
            DicVehiculeSpritePerAngle.Add(-65, FlipTexture2D(DicVehiculeSpritePerAngle[65]));
            DicVehiculeSpritePerAngle.Add(-90, FlipTexture2D(DicVehiculeSpritePerAngle[90]));
        }