Пример #1
0
        public MainMenu()
        {
            InitializeComponent();

            SlimDX.Vector4 c = GlobalSettings.GridColor;
            colorFill.Color      = Color.FromArgb(Convert.ToByte(c.W * 255), Convert.ToByte(c.X * 255), Convert.ToByte(c.Y * 255), Convert.ToByte(c.Z * 255));
            gridPos.NumericValue = Rendering.Grid.Position.Y;

            chkRenderLights.IsChecked  = GlobalSettings.RenderLights;
            chkRenderGrid.IsChecked    = GlobalSettings.RenderGrid;
            chkRenderVolume.IsChecked  = GlobalSettings.RenderVolumes;
            chkPhysics.IsChecked       = !PhysicsEngine.Paused;
            chkPhysicsCamera.IsChecked = false;

            List <BaseGameObject> weatherSettings = WorldData.GetObjectsByType(typeof(WeatherSetting));

            foreach (BaseGameObject s in weatherSettings)
            {
                ComboBoxItem i = new ComboBoxItem();
                i.Name       = s.BaseObjectId;
                i.Content    = s.BaseObjectName;
                i.IsSelected = s.BaseObjectId == "defaultWeather";
                ddlSetWeather.Items.Add(i);
            }
        }
Пример #2
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInBodies.PluginIO.IsConnected)
            {
                int cnt = this.FInBodies.SliceCount;
                this.FOutPosition.SliceCount         = cnt;
                this.FOutUserIndex.SliceCount        = cnt;
                this.FOutClipped.SliceCount          = cnt;
                this.FOutJointPosition.SliceCount    = cnt * 25;
                this.FOutJointState.SliceCount       = cnt * 25;
                this.FOutJointID.SliceCount          = cnt * 25;
                this.FOutJointOrientation.SliceCount = cnt * 25;

                int jc = 0;
                for (int i = 0; i < cnt; i++)
                {
                    Body sk = this.FInBodies[i];

                    Joint ce = sk.Joints[JointType.SpineBase];
                    this.FOutPosition[i]  = new Vector3(ce.Position.X, ce.Position.Y, ce.Position.Z);
                    this.FOutUserIndex[i] = (int)sk.TrackingId;

                    Vector4 clip = Vector4.Zero;
                    clip.X = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Left));
                    clip.Y = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Right));
                    clip.Z = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Top));
                    clip.W = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Bottom));

                    this.FOutClipped[i] = clip;

                    foreach (Joint joint in sk.Joints.Values)
                    {
                        Microsoft.Kinect.Vector4 bo = sk.JointOrientations[joint.JointType].Orientation;
                        this.FOutJointID[jc]       = joint.JointType.ToString();
                        this.FOutJointPosition[jc] = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z);

                        this.FOutJointOrientation[jc] = new Quaternion(bo.X, bo.Y, bo.Z, bo.W);
                        this.FOutJointState[jc]       = joint.TrackingState.ToString();
                        jc++;
                    }
                }
            }
            else
            {
                this.FOutPosition.SliceCount         = 0;
                this.FOutUserIndex.SliceCount        = 0;
                this.FOutJointID.SliceCount          = 0;
                this.FOutJointPosition.SliceCount    = 0;
                this.FOutJointState.SliceCount       = 0;
                this.FOutJointOrientation.SliceCount = 0;
                this.FOutClipped.SliceCount          = 0;
            }
        }
        private Point GetWorlCoordinateFromMouseCoordinate(Point mouseCoordinate)
        {
            Point ret = new Point();

            SlimDX.Matrix projection = _device.GetTransform(TransformState.Projection);
            SlimDX.Matrix view       = _device.GetTransform(TransformState.View);

            SlimDX.Matrix transform = view * projection;
            transform.Invert();

            SlimDX.Vector3 vecMouse = new Vector3((float)((mouseCoordinate.X / ActualWidthDpi) - 0.5f) * 2.0f, (float)-((mouseCoordinate.Y / ActualHeightDpi) - 0.5f) * 2.0f, 0);
            SlimDX.Vector4 vecWorld = Vector3.Transform(vecMouse, transform);

            ret.X = vecWorld.X;
            ret.Y = vecWorld.Y;

            return(ret);
        }
Пример #4
0
        private void ChangeLightColor(object sender, RoutedEventArgs e)
        {
            ColorPickerControl.ColorPickerDialog cPicker = new ColorPickerControl.ColorPickerDialog();
            cPicker.ColorChanging += new RoutedPropertyChangedEventHandler <Color>(cPicker_ColorChanging);


            SlimDX.Vector4 c = GlobalSettings.GridColor;
            cPicker.StartingColor = Color.FromArgb(Convert.ToByte(c.W * 255), Convert.ToByte(c.X * 255), Convert.ToByte(c.Y * 255), Convert.ToByte(c.Z * 255));;
            cPicker.Owner         = Window.GetWindow(this);

            bool?dialogResult = cPicker.ShowDialog();

            if (dialogResult != null && (bool)dialogResult == true)
            {
                Color sc = cPicker.SelectedColor;
                colorFill.Color = sc;
                Color4 c3 = new Color4((float)(sc.A / 255.0), (float)(sc.R / 255.0), (float)(sc.G / 255.0), (float)(sc.B / 255.0));
                GlobalSettings.GridColor = new Vector4(c3.Red, c3.Green, c3.Blue, c3.Alpha);
            }
        }
Пример #5
0
        public void Read(out SlimDX.Vector4 data)
        {
            int length = Marshal.SizeOf(typeof(SlimDX.Vector4));

            if (CurPtr() + length > mSize)
            {
                data = new SlimDX.Vector4();
                OnReadError();
                return;
            }

            unsafe
            {
                fixed(SlimDX.Vector4 *pValue = &data)
                {
                    Marshal.Copy(mHandle, mPos, (IntPtr)pValue, length);
                }
            }
            mPos += length;
        }
Пример #6
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.FInRuntime[0].SkeletonFrameReady += SkeletonReady;
                    }
                }

                this.FInvalidateConnect = false;
            }

            if (this.FInvalidate)
            {
                if (this.lastframe != null)
                {
                    List <Skeleton> skels = new List <Skeleton>();
                    float           z     = float.MaxValue;
                    int             id    = -1;

                    lock (m_lock)
                    {
                        foreach (Skeleton sk in this.lastframe)
                        {
                            if (sk.TrackingState == SkeletonTrackingState.Tracked)
                            {
                                skels.Add(sk);
                            }
                        }
                    }

                    int cnt = skels.Count;
                    this.FOutCount[0] = cnt;

                    this.FOutPosition.SliceCount      = cnt;
                    this.FOutUserIndex.SliceCount     = cnt;
                    this.FOutClipped.SliceCount       = cnt;
                    this.FOutJointPosition.SliceCount = cnt * 20;
                    this.FOutJointState.SliceCount    = cnt * 20;
                    this.FOutJointID.SliceCount       = cnt * 20;
                    this.FOutFrameNumber[0]           = this.frameid;


                    int jc = 0;
                    for (int i = 0; i < cnt; i++)
                    {
                        Skeleton sk = skels[i];
                        this.FOutPosition[i]  = new Vector3(sk.Position.X, sk.Position.Y, sk.Position.Z);
                        this.FOutUserIndex[i] = sk.TrackingId;

                        SlimDX.Vector4 clip = SlimDX.Vector4.Zero;
                        clip.X = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Left));
                        clip.Y = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Right));
                        clip.Z = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Top));
                        clip.W = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Bottom));

                        this.FOutClipped[i] = clip;

                        foreach (Joint joint in sk.Joints)
                        {
                            this.FOutJointID[jc]       = joint.JointType.ToString();
                            this.FOutJointPosition[jc] = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z);
                            this.FOutJointState[jc]    = joint.TrackingState.ToString();

                            jc++;
                        }
                    }
                }
                else
                {
                    this.FOutCount[0]                 = 0;
                    this.FOutPosition.SliceCount      = 0;
                    this.FOutUserIndex.SliceCount     = 0;
                    this.FOutJointID.SliceCount       = 0;
                    this.FOutJointPosition.SliceCount = 0;
                    this.FOutJointState.SliceCount    = 0;
                    this.FOutFrameNumber[0]           = 0;
                }
                this.FInvalidate = false;
            }
        }
Пример #7
0
 public void ToD3DVector4_Test()
 {
     var actual = new Irelia.Render.Vector4(0.1f, 0.22f, 0.33f, 0.444f);
     var expected = new SlimDX.Vector4(actual.x, actual.y, actual.z, actual.w);
     Assert.AreEqual(expected, actual.ToD3DVector4());
 }
Пример #8
0
 public void FromColor_ToD3DVector4_Test()
 {
     var actual = new Color(0.1f, 0.22f, 0.333f, 0.4444f);
     var expected = new SlimDX.Vector4(actual.r, actual.g, actual.b, actual.a);
     Assert.AreEqual(expected, actual.ToD3DVector4());
 }
Пример #9
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.FInRuntime[0].SkeletonFrameReady += SkeletonReady;
                    }
                }

                this.FInvalidateConnect = false;
            }

            if (this.FInvalidate)
            {
                if (this.lastframe != null)
                {
                    List <Body> skels   = new List <Body>();
                    List <int>  indices = new List <int>();
                    lock (m_lock)
                    {
                        for (int i = 0; i < this.lastframe.Length; i++)
                        {
                            if (this.lastframe[i].IsTracked)
                            {
                                skels.Add(this.lastframe[i]);
                                indices.Add(i);
                            }
                        }
                    }

                    int cnt = skels.Count;
                    this.FOutCount[0] = cnt;

                    this.FOutPosition.SliceCount         = cnt;
                    this.FOutUserIndex.SliceCount        = cnt;
                    this.FOutShortIndex.SliceCount       = cnt;
                    this.FOutClipped.SliceCount          = cnt;
                    this.FOutJointPosition.SliceCount    = cnt * 25;
                    this.FOutJointState.SliceCount       = cnt * 25;
                    this.FOutJointID.SliceCount          = cnt * 25;
                    this.FOutJointPositionRGB.SliceCount = cnt * 25;
                    this.FOutJointOrientation.SliceCount = cnt * 25;
                    this.FOutFrameNumber[0] = this.frameid;


                    int jc = 0;
                    for (int i = 0; i < cnt; i++)
                    {
                        Body sk = skels[i];

                        Joint ce = sk.Joints[JointType.SpineBase];
                        this.FOutPosition[i]   = new Vector3(ce.Position.X, ce.Position.Y, ce.Position.Z);
                        this.FOutUserIndex[i]  = sk.TrackingId.ToString();
                        this.FOutShortIndex[i] = indices[i];

                        Vector4 clip = Vector4.Zero;
                        clip.X = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Left));
                        clip.Y = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Right));
                        clip.Z = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Top));
                        clip.W = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Bottom));

                        this.FOutClipped[i] = clip;

                        foreach (Joint joint in sk.Joints.Values)
                        {
                            var jrgb = this.runtime.Runtime.CoordinateMapper.MapCameraPointToColorSpace(joint.Position);

                            Microsoft.Kinect.Vector4 bo = sk.JointOrientations[joint.JointType].Orientation;
                            this.FOutJointID[jc]       = joint.JointType.ToString();
                            this.FOutJointPosition[jc] = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z);

                            this.FOutJointOrientation[jc] = new Quaternion(bo.X, bo.Y, bo.Z, bo.W);
                            this.FOutJointState[jc]       = joint.TrackingState.ToString();

                            this.FOutJointPositionRGB[jc] = new Vector2(jrgb.X, jrgb.Y);
                            jc++;
                        }
                    }
                }
                else
                {
                    this.FOutCount[0]                    = 0;
                    this.FOutPosition.SliceCount         = 0;
                    this.FOutUserIndex.SliceCount        = 0;
                    this.FOutJointID.SliceCount          = 0;
                    this.FOutJointPosition.SliceCount    = 0;
                    this.FOutJointState.SliceCount       = 0;
                    this.FOutFrameNumber[0]              = 0;
                    this.FOutJointOrientation.SliceCount = 0;
                }
                this.FInvalidate = false;
            }
        }
Пример #10
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                }

                if (this.FInRuntime.PluginIO.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.FInRuntime[0].SkeletonFrameReady += SkeletonReady;
                    }
                }

                this.FInvalidateConnect = false;
            }

            if (this.FInvalidate)
            {
                if (this.lastframe != null)
                {
                    List <Body> skels = new List <Body>();
                    float       z     = float.MaxValue;
                    int         id    = -1;

                    lock (m_lock)
                    {
                        foreach (Body sk in this.lastframe)
                        {
                            if (sk.IsTracked)
                            {
                                skels.Add(sk);
                            }
                        }
                    }

                    int cnt = skels.Count;
                    this.FOutCount[0] = cnt;

                    this.FOutPosition.SliceCount         = cnt;
                    this.FOutUserIndex.SliceCount        = cnt;
                    this.FOutClipped.SliceCount          = cnt;
                    this.FOutJointPosition.SliceCount    = cnt * 25;
                    this.FOutJointState.SliceCount       = cnt * 25;
                    this.FOutJointID.SliceCount          = cnt * 25;
                    this.FOutJointOrientation.SliceCount = cnt * 25;
                    this.FOutFrameNumber[0]         = this.frameid;
                    this.FOutWearGlasses.SliceCount = cnt;
                    this.FOutHappy.SliceCount       = cnt;
                    this.FOutNeutral.SliceCount     = cnt;


                    int jc = 0;
                    for (int i = 0; i < cnt; i++)
                    {
                        Body sk = skels[i];

                        Joint ce = sk.Joints[JointType.SpineBase];
                        this.FOutPosition[i]    = new Vector3(ce.Position.X, ce.Position.Y, ce.Position.Z);
                        this.FOutUserIndex[i]   = (int)sk.TrackingId;
                        this.FOutWearGlasses[i] = sk.Appearance[Appearance.WearingGlasses];
                        this.FOutHappy[i]       = sk.Expressions[Expression.Happy];
                        this.FOutNeutral[i]     = sk.Expressions[Expression.Neutral];

                        //var t = sk.Expressions[Expression.]

                        Vector4 clip = Vector4.Zero;
                        clip.X = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Left));
                        clip.Y = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Right));
                        clip.Z = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Top));
                        clip.W = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Bottom));

                        this.FOutClipped[i] = clip;

                        foreach (Joint joint in sk.Joints.Values)
                        {
                            Microsoft.Kinect.Vector4 bo = sk.JointOrientations[joint.JointType].Orientation;
                            this.FOutJointID[jc]       = joint.JointType.ToString();
                            this.FOutJointPosition[jc] = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z);

                            this.FOutJointOrientation[jc] = new Quaternion(bo.X, bo.Y, bo.Z, bo.W);
                            this.FOutJointState[jc]       = joint.TrackingState.ToString();
                            jc++;
                        }
                    }
                }
                else
                {
                    this.FOutCount[0]                    = 0;
                    this.FOutPosition.SliceCount         = 0;
                    this.FOutUserIndex.SliceCount        = 0;
                    this.FOutJointID.SliceCount          = 0;
                    this.FOutJointPosition.SliceCount    = 0;
                    this.FOutJointState.SliceCount       = 0;
                    this.FOutFrameNumber[0]              = 0;
                    this.FOutJointOrientation.SliceCount = 0;
                    this.FOutWearGlasses.SliceCount      = 0;
                }
                this.FInvalidate = false;
            }
        }
Пример #11
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInvalidateConnect)
            {
                if (runtime != null)
                {
                    this.runtime.SkeletonFrameReady -= SkeletonReady;
                }

                if (this.FInRuntime.IsConnected)
                {
                    //Cache runtime node
                    this.runtime = this.FInRuntime[0];

                    if (runtime != null)
                    {
                        this.FInRuntime[0].SkeletonFrameReady += SkeletonReady;
                    }
                }

                this.FInvalidateConnect = false;
            }

            if (this.FInvalidate)
            {
                if (this.lastframe != null)
                {
                    List <Skeleton> skels = new List <Skeleton>();
                    lock (m_lock)
                    {
                        foreach (Skeleton sk in this.lastframe)
                        {
                            if (sk.TrackingState == SkeletonTrackingState.Tracked)
                            {
                                skels.Add(sk);
                            }
                        }
                    }

                    int cnt = skels.Count;
                    this.FOutCount[0] = cnt;

                    this.FOutPosition.SliceCount           = cnt;
                    this.FOutUserIndex.SliceCount          = cnt;
                    this.FOutClipped.SliceCount            = cnt;
                    this.FOutJointPosition.SliceCount      = cnt * 20;
                    this.FOutJointColorPosition.SliceCount = cnt * 20;
                    this.FOutJointDepthPosition.SliceCount = cnt * 20;
                    this.FOutJointState.SliceCount         = cnt * 20;
                    this.FOutJointID.SliceCount            = cnt * 20;
                    this.FOutJointOrientation.SliceCount   = cnt * 20;
                    this.FOutJointWOrientation.SliceCount  = cnt * 20;
                    this.FOutJointTo.SliceCount            = cnt * 20;
                    this.FOutJointFrom.SliceCount          = cnt * 20;
                    this.FOutFrameNumber[0] = this.frameid;


                    int jc = 0;
                    for (int i = 0; i < cnt; i++)
                    {
                        Skeleton sk = skels[i];
                        this.FOutPosition[i]  = new Vector3(sk.Position.X, sk.Position.Y, sk.Position.Z);
                        this.FOutUserIndex[i] = sk.TrackingId;

                        Vector4 clip = Vector4.Zero;
                        clip.X = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Left));
                        clip.Y = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Right));
                        clip.Z = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Top));
                        clip.W = Convert.ToSingle(sk.ClippedEdges.HasFlag(FrameEdges.Bottom));

                        this.FOutClipped[i] = clip;

                        foreach (Joint joint in sk.Joints)
                        {
                            this.FOutJointFrom[jc] = sk.BoneOrientations[joint.JointType].StartJoint.ToString();
                            this.FOutJointTo[jc]   = sk.BoneOrientations[joint.JointType].EndJoint.ToString();
                            BoneRotation bo  = sk.BoneOrientations[joint.JointType].HierarchicalRotation;
                            BoneRotation bow = sk.BoneOrientations[joint.JointType].AbsoluteRotation;
                            this.FOutJointID[jc]       = joint.JointType.ToString();
                            this.FOutJointPosition[jc] = new Vector3(joint.Position.X, joint.Position.Y, joint.Position.Z);

                            ColorImagePoint cp = this.runtime.Runtime.CoordinateMapper.MapSkeletonPointToColorPoint(joint.Position, ColorImageFormat.RgbResolution640x480Fps30);
                            this.FOutJointColorPosition[jc] = new Vector2(cp.X, cp.Y);
                            DepthImagePoint dp = this.runtime.Runtime.CoordinateMapper.MapSkeletonPointToDepthPoint(joint.Position, DepthImageFormat.Resolution320x240Fps30);
#pragma warning disable
                            this.FOutJointDepthPosition[jc] = new Vector4(dp.X, dp.Y, dp.Depth, dp.PlayerIndex);
#pragma warning restore
                            this.FOutJointOrientation[jc]  = new Quaternion(bo.Quaternion.X, bo.Quaternion.Y, bo.Quaternion.Z, bo.Quaternion.W);
                            this.FOutJointWOrientation[jc] = new Quaternion(bow.Quaternion.X, bow.Quaternion.Y, bow.Quaternion.Z, bow.Quaternion.W);
                            this.FOutJointState[jc]        = joint.TrackingState.ToString();
                            jc++;
                        }
                    }
                }
                else
                {
                    this.FOutCount[0]                      = 0;
                    this.FOutPosition.SliceCount           = 0;
                    this.FOutUserIndex.SliceCount          = 0;
                    this.FOutJointID.SliceCount            = 0;
                    this.FOutJointPosition.SliceCount      = 0;
                    this.FOutJointState.SliceCount         = 0;
                    this.FOutFrameNumber[0]                = 0;
                    this.FOutJointOrientation.SliceCount   = 0;
                    this.FOutJointWOrientation.SliceCount  = 0;
                    this.FOutJointTo.SliceCount            = 0;
                    this.FOutJointFrom.SliceCount          = 0;
                    this.FOutJointColorPosition.SliceCount = 0;
                    this.FOutJointDepthPosition.SliceCount = 0;
                }
                this.FInvalidate = false;
            }
        }
Пример #12
0
        static Map.Map Random(SlimDX.Direct3D9.Device device, System.Drawing.SizeF size, int nHeightIncs, int nSplatDraws, int nProps)
        {
            var m = Map.Map.New(new Client.Game.Map.MapSettings
            {
                Size = size
            }, device);

            m.MainCharacter.Position = new SlimDX.Vector3(m.Settings.Size.Width / 2f, m.Settings.Size.Height / 2f, 0);

            Random r = new Random();

            // Heightmap
            Graphics.Editors.GroundTextureEditor e = new Graphics.Editors.GroundTextureEditor
            {
                Size            = m.Settings.Size,
                SoftwareTexture = new Graphics.Software.Texture <Graphics.Software.Texel.R32F>[] { new Graphics.Software.Texture <Graphics.Software.Texel.R32F>(m.Ground.Heightmap) },
                Pencil          = new Graphics.Editors.GroundTexturePencil
                {
                    Color  = new SlimDX.Vector4(1, 0, 0, 0),
                    Radius = 5,
                    Type   = Graphics.Editors.GroundTexturePencilType.Add
                }
            };
            e.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler(
                (o, args) => m.Ground.UpdatePieceMeshes(args.ChangedRegion));
            for (int i = 0; i < nHeightIncs; i++)
            {
                var p = new Graphics.Editors.GroundTexturePencil
                {
                    Radius = 1 + (float)(r.NextDouble() * 10),
                    Color  = new SlimDX.Vector4((float)(r.NextDouble() * 2 - 1), 0, 0, 0),
                    Type   = Graphics.Editors.GroundTexturePencilType.Add
                };
                e.Draw(
                    new SlimDX.Vector2((float)(r.NextDouble() * m.Settings.Size.Width),
                                       (float)(r.NextDouble() * m.Settings.Size.Height)),
                    p);
            }

            // Splatmap
            e = new Graphics.Editors.GroundTextureEditor
            {
                Size            = m.Settings.Size,
                SoftwareTexture = new Graphics.Software.Texture <Graphics.Software.Texel.A8R8G8B8>[] {
                    new Graphics.Software.Texture <Graphics.Software.Texel.A8R8G8B8>(
                        Graphics.TextureUtil.ReadTexture <Graphics.Software.Texel.A8R8G8B8>(m.Ground.SplatMap1.Resource9, 0))
                },
                Texture9 = new SlimDX.Direct3D9.Texture[] { m.Ground.SplatMap1.Resource9 },
                Pencil   = new Graphics.Editors.GroundTexturePencil
                {
                    Color  = new SlimDX.Vector4(1, 0, 0, 0),
                    Radius = 5,
                    Type   = Graphics.Editors.GroundTexturePencilType.Add
                }
            };
            for (int i = 0; i < nSplatDraws; i++)
            {
                SlimDX.Vector4 v = Vector4.Zero;
                float          d = (float)r.NextDouble();
                switch (r.Next(5))
                {
                case 0:
                    v = new Vector4(d, -d, -d, -d);
                    break;

                case 1:
                    v = new Vector4(-d, d, -d, -d);
                    break;

                case 2:
                    v = new Vector4(-d, -d, d, -d);
                    break;

                case 3:
                    v = new Vector4(-d, -d, -d, d);
                    break;

                case 4:
                    v = new Vector4(-d, -d, -d, -d);
                    break;
                }
                var p = new Graphics.Editors.GroundTexturePencil
                {
                    Radius = 1 + (float)(r.NextDouble() * 10),
                    Color  = v,
                    Type   = Graphics.Editors.GroundTexturePencilType.AddSaturate
                };
                e.Draw(
                    new SlimDX.Vector2((float)(r.NextDouble() * m.Settings.Size.Width),
                                       (float)(r.NextDouble() * m.Settings.Size.Height)),
                    p);
            }

            // Props
            List <Type> propTypes = new List <Type>();

            foreach (var v in typeof(Map.Props.Prop).Assembly.GetTypes())
            {
                if (typeof(Map.Props.Prop).IsAssignableFrom(v))
                {
                    propTypes.Add(v);
                }
            }
            propTypes.Remove(typeof(Map.Props.Prop));
            for (int i = 0; i < nProps; i++)
            {
                var p = (Map.Props.Prop)Activator.CreateInstance(propTypes[r.Next(propTypes.Count)]);
                p.Position = new SlimDX.Vector3(
                    (float)(r.NextDouble() * m.Settings.Size.Width),
                    (float)(r.NextDouble() * m.Settings.Size.Height), 0);

                float rotation = (float)(2 * Math.PI * r.NextDouble());
                p.Rotation = Quaternion.RotationAxis(Vector3.UnitZ, rotation);

                p.Position = m.Ground.GetHeight(p.Position);
                m.DynamicsRoot.AddChild(p);
            }

            m.MainCharacter.Position = m.Ground.GetHeight(m.MainCharacter.Position);

            return(m);
        }
Пример #13
0
 public static PMath.Vector4 ToPhx(this SDX.Vector4 v)
 {
     return(new PMath.Vector4(v.X, v.Y, v.Z, v.W));
 }
Пример #14
0
 public static Color ToDrawingColor(this Vector4 color)
 {
     return(Color.FromArgb((int)(color.W * 255f).Clamp(0, 255), (int)(color.X * 255f).Clamp(0, 255), (int)(color.Y * 255f).Clamp(0, 255),
                           (int)(color.Z * 255f).Clamp(0, 255)));
 }
Пример #15
0
 public static Vector3 GetVector3(this Vector4 vec)
 {
     return(new Vector3(vec.X, vec.Y, vec.Z));
 }