protected override void OnConstruct()
 {
     base.OnConstruct();
     ClearChildren();
     details.Size = new SlimDX.Vector2(Size.X, details.Size.Y);
     AddChild(new Label
     {
         Text = "Program Configuration Warnings",
         Size = new SlimDX.Vector2(Size.X, 20)
     });
     AddChild(details);
     float y = details.Size.Y + details.Position.Y;
     foreach (var warn in Common.ProgramConfigurationInformation.Warnings)
     {
         var v = warn;
         Button b;
         AddChild(b = new Button
         {
             Text = "[" + v.Module + "] " + v.Text,
             Size = new SlimDX.Vector2(Size.X, 20),
             Position = new SlimDX.Vector2(0, y),
             TextAnchor = Orientation.Left
         });
         b.MouseEnter += new EventHandler((o, e) => details.Text =
             "Name: " + v.Text + "\n" +
             "Module: " + v.Module + "\nImportance: " + v.Importance + "\nType: " + v.Type +
                 "\nDescription: " + v.Description);
         b.MouseLeave += new EventHandler((o, e) => details.Text = "");
         y += 20;
     }
     Size = new SlimDX.Vector2(Size.X, y);
 }
Esempio n. 2
0
        protected override void OnConstruct()
        {
            base.OnConstruct();
            ClearChildren();
            details.Size = new SlimDX.Vector2(Size.X, details.Size.Y);
            AddChild(new Label
            {
                Text = "Program Configuration Warnings",
                Size = new SlimDX.Vector2(Size.X, 20)
            });
            AddChild(details);
            float y = details.Size.Y + details.Position.Y;

            foreach (var warn in Common.ProgramConfigurationInformation.Warnings)
            {
                var    v = warn;
                Button b;
                AddChild(b = new Button
                {
                    Text       = "[" + v.Module + "] " + v.Text,
                    Size       = new SlimDX.Vector2(Size.X, 20),
                    Position   = new SlimDX.Vector2(0, y),
                    TextAnchor = Orientation.Left
                });
                b.MouseEnter += new EventHandler((o, e) => details.Text =
                                                     "Name: " + v.Text + "\n" +
                                                     "Module: " + v.Module + "\nImportance: " + v.Importance + "\nType: " + v.Type +
                                                     "\nDescription: " + v.Description);
                b.MouseLeave += new EventHandler((o, e) => details.Text = "");
                y            += 20;
            }
            Size = new SlimDX.Vector2(Size.X, y);
        }
Esempio n. 3
0
        public void MakeIslandShape(Array2D <float> arr)
        {
            var mid                   = arr.Size.ToVector2() * 0.5f;
            var deviation             = mid.X * 2;
            Func <float, float> gauss = p => (float)Math.Exp(-(p * p) / (2 * deviation));

            var m         = arr.Size.X;
            var maxHeight = 1;

            var a = maxHeight / (m * m / 4f);


            Func <float, float> func = p => - p * (p - arr.Size.X) * a;



            for (int x = 0; x < arr.Size.X; x++)
            {
                for (int y = 0; y < arr.Size.Y; y++)
                {
                    var centralized = new SlimDX.Vector2(x, y) - mid;
                    var factor      = func(x) * func(y);
                    var value       = arr[new Point2(x, y)];
                    var amount      = 0f;
                    arr[new Point2(x, y)] = (value * factor) * (1 - amount) + amount * value;
                    //arr[new Point2(x, y)] = func(x) * func(y);
                }
            }
        }
Esempio n. 4
0
        public OptionScreen()
        {
            Anchor = global::Graphics.Orientation.Center;
            AddChild(new Label
            {
                Text = Locale.Resource.Options,
                Font = new Graphics.Content.Font
                {
                    SystemFont = Fonts.HugeSystemFont,
                    Color      = System.Drawing.Color.White
                },
                AutoSize   = AutoSizeMode.Full,
                Anchor     = global::Graphics.Orientation.Top,
                Background = null,
                Position   = new SlimDX.Vector2(0, 10),
            });
            AddChild(Audio);
            AddChild(Controls);
            AddChild(Video);

            AddChild(BackToMainMenu);

            Audio.Click    += new EventHandler(Audio_Click);
            Controls.Click += new EventHandler(Controls_Click);
            Video.Click    += new EventHandler(Video_Click);

            BackToMainMenu.Click += new EventHandler(BackToMainMenu_Click);
            Size       = new SlimDX.Vector2(100, 320);
            ControlBox = false;
        }
Esempio n. 5
0
 public void Write(SlimDX.Vector2 data)
 {
     unsafe
     {
         SlimDX.Vector2 *pPtr = &data;
         Write((IntPtr)pPtr, sizeof(SlimDX.Vector2));
     }
 }
Esempio n. 6
0
 void _MouseClick(object sender, MouseEventArgs e)
 {
     mMouseLastPos = new SlimDX.Vector2(e.X, e.Y);
     if (MousePress != null)
     {
         MousePress(e.X, e.Y, e.Button);
     }
 }
Esempio n. 7
0
 void _MouseDown(object sender, MouseEventArgs e)
 {
     mMouseLastPos = new SlimDX.Vector2(e.X, e.Y);
     if (MouseDown != null)
     {
         MouseDown(e.X, e.Y, e.Button);
     }
 }
Esempio n. 8
0
        public RoundQuadDescriptor(float cornerRadius = 0.1f, bool enableCenter = true, int cornerResolution = 6)
            : base(PrimitiveType.RoundQuad)
        {
            var size = new SlimDX.Vector2(cornerRadius > 0 ? 0.5f - cornerRadius : 0.5f);

            Settings = new RoundRect()
            {
                InnerRadius = size, OuterRadius = cornerRadius * 0.5f, EnableCenter = enableCenter, CornerResolution = cornerResolution
            };
        }
 public void DrawLine(System.Drawing.Pen p, float x1, float y1, float x2, float y2)
 {
     Begin();
     line.Antialias = AntiAlias;
     line.Width     = p.Width;
     SlimDX.Vector2[] v = new SlimDX.Vector2[] {
         transform.Transform(new SlimDX.Vector2(x1, y1)),
         transform.Transform(new SlimDX.Vector2(x2, y2))
     };
     line.Draw(v, new SlimDX.Color4(p.Color));
 }
Esempio n. 10
0
        public SlimDX.Vector2 Transform(SlimDX.Vector2 v2)
        {
            var v = MathNet.Numerics.LinearAlgebra.Matrix <float> .Build.Dense(3, 1);

            v[0, 0] = v2.X;
            v[1, 0] = v2.Y;
            v[2, 0] = 1;
            var t  = matrix * v;
            var vt = new SlimDX.Vector2(t[0, 0], t[1, 0]);

            return(vt);
        }
Esempio n. 11
0
 public void DrawLines(Pen p, PointF[] list)
 {
     Begin();
     line.Antialias = AntiAlias;
     line.Width     = p.Width;
     SlimDX.Vector2[] v = new SlimDX.Vector2[list.Length];
     for (int i = 0; i < list.Length; i++)
     {
         v[i] = transform.Transform(new SlimDX.Vector2(list[i].X, list[i].Y));
     }
     line.Draw(v, new SlimDX.Color4(p.Color));
 }
Esempio n. 12
0
 public void DrawRectangle(System.Drawing.Pen p, float x, float y, float width, float height)
 {
     Begin();
     line.Antialias = AntiAlias;
     line.Width     = p.Width;
     SlimDX.Vector2[] v = new SlimDX.Vector2[] {
         transform.Transform(new SlimDX.Vector2(x, y)),
         transform.Transform(new SlimDX.Vector2(x + width, y)),
         transform.Transform(new SlimDX.Vector2(x + width, y + height)),
         transform.Transform(new SlimDX.Vector2(x, y + height)),
         transform.Transform(new SlimDX.Vector2(x, y))
     };
     line.Draw(v, new SlimDX.Color4(p.Color));
 }
Esempio n. 13
0
        void _MouseMoved(object sender, MouseEventArgs e)
        {
            if (mMouseLastPos.HasValue == false)
            {
                mMouseLastPos = new SlimDX.Vector2(e.X, e.Y);
            }

            if (MouseMoved != null)
            {
                MouseMoved(e.X, e.Y, e.Button, (new SlimDX.Vector2(e.X, e.Y) - mMouseLastPos.Value));
            }

            mMouseLastPos = new SlimDX.Vector2(e.X, e.Y);
        }
        public RenderTreeVisualizer()
        {
            bars = new List<ProgressBar>();
            Updateable = true;
            Size = new SlimDX.Vector2(200, 200);

            for (int i = 0; i < 5; i++)
            {
                ProgressBar p = new ProgressBar
                {
                    Position = new SlimDX.Vector2(0, i * 20),
                    TextAnchor = Orientation.Left,
                    Size = new SlimDX.Vector2(200, 20)
                };
                bars.Add(p);
                AddChild(p);
            }
        }
        public RenderTreeVisualizer()
        {
            bars       = new List <ProgressBar>();
            Updateable = true;
            Size       = new SlimDX.Vector2(200, 200);

            for (int i = 0; i < 5; i++)
            {
                ProgressBar p = new ProgressBar
                {
                    Position   = new SlimDX.Vector2(0, i * 20),
                    TextAnchor = Orientation.Left,
                    Size       = new SlimDX.Vector2(200, 20)
                };
                bars.Add(p);
                AddChild(p);
            }
        }
Esempio n. 16
0
        bool ISprite.Render(SpriteRenderer renderer)
        {
            foreach (var line in this.lines)
            {
                this.d3dLine.Width = line.Size;

                if (this.d3dLine.Begin().IsFailure)
                    return false;

                var vertexList = new SlimDX.Vector2[2] { line.Start.ToD3DVector2(), line.End.ToD3DVector2() };
                if (this.d3dLine.Draw(vertexList, line.Color.ToD3DColor4()).IsFailure)
                {
                    this.d3dLine.End();
                    return false;
                }

                if (this.d3dLine.End().IsFailure)
                    return false;
            }

            return true;
        }
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            FOver.SliceCount       = FTransforms.SliceCount;
            FInputIndex.SliceCount = FTransforms.SliceCount;
            FClicked.SliceCount    = FTransforms.SliceCount;

            if (dirty)
            {
                for (int y = 0; y < FTransforms.SliceCount; y++)
                {
                    FOver[y]       = false;
                    FClicked[y]    = false;
                    FInputIndex[y] = 0;
                }
                dirty = false;
            }

            if (FEnabled[0])
            {
                for (int y = 0; y < FTransforms.SliceCount; y++)
                {
                    for (int x = 0; x < FTouchPosition.SliceCount; x++)
                    {
                        SlimDX.Vector2 trv = SlimDX.Vector2.TransformCoordinate(FTouchPosition[x], SlimDX.Matrix.Invert(FTransforms[y]));
                        if (trv.X > -0.5f && trv.Y > -0.5f && trv.X < 0.5f && trv.Y < 0.5f)
                        {
                            dirty          = true;
                            FOver[y]       = true;
                            FInputIndex[y] = FTouchId[x];
                            if (FTouchNew[x])
                            {
                                FClicked[y] = true;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 18
0
        public AudioOptionsWindow(bool inGame)
        {
            Size          = new SlimDX.Vector2(500, 400);
            audioSettings = new PublicAudioSettings(inGame);
            CreateTitle(Locale.Resource.SoundSettingsTitle);

            openedInGame = inGame;

            percentages = new List <string>();
            percentages.Add("0%");
            percentages.Add("10%");
            percentages.Add("20%");
            percentages.Add("30%");
            percentages.Add("40%");
            percentages.Add("50%");
            percentages.Add("60%");
            percentages.Add("70%");
            percentages.Add("80%");
            percentages.Add("90%");
            percentages.Add("100%");

            int i = 0;

            foreach (var v in typeof(PublicAudioSettings).GetProperties())
            {
                if (v.IsDefined(typeof(VolumeControllerAttribute), false))
                {
                    Label t;
                    AddChild(t = new Label
                    {
                        Anchor     = textBoxOrientation,
                        Background = null,
                        Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * i),
                        Size       = textBoxSize,
                    });

                    StoneDropDownBar s;

                    AddChild(s = new StoneDropDownBar
                    {
                        Anchor   = dropBoxOrientation,
                        Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * i)
                    });

                    switch (v.Name)
                    {
                    case "MasterVolume":
                        t.Text = Locale.Resource.SoundMasterVolume;
                        Program.Instance.Tooltip.SetToolTip(s, Locale.Resource.AudioMasterToolTip);
                        break;

                    case "AmbientVolume":
                        t.Text = Locale.Resource.SoundAmbientVolume;
                        Program.Instance.Tooltip.SetToolTip(s, Locale.Resource.AudioAmbientToolTip);
                        break;

                    case "MusicVolume":
                        t.Text = Locale.Resource.SoundMusicVolume;
                        Program.Instance.Tooltip.SetToolTip(s, Locale.Resource.AudioMusicToolTip);
                        break;

                    case "SoundVolume":
                        t.Text = Locale.Resource.SoundEffectsVolume;
                        Program.Instance.Tooltip.SetToolTip(s, Locale.Resource.AudioSoundEffectsToolTip);
                        break;

                    default:
                        break;
                    }

                    dropDownBars.Add(s);
                    for (int j = 0; j < percentages.Count; j++)
                    {
                        s.AddItem(percentages[j]);
                    }
                    i++;

                    if (audioSettings.AudioDevice.IsValid)
                    {
                        s.SelectedItem = "" + Math.Round((float)v.GetValue(audioSettings, null) * 100f) + "%";
                    }
                }
            }
            if (!inGame)
            {
                if (Program.Instance != null && Program.Instance.SoundManager != null)
                {
                    var sm = Program.Instance.SoundManager;
                    IEnumerable <AudioDevice> audioDevices = sm.AudioDeviceList;

                    AddChild(new Label
                    {
                        Anchor     = textBoxOrientation,
                        Background = null,
                        Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * i),
                        Size       = textBoxSize,
                        Text       = Locale.Resource.SoundAudioDriver
                    });

                    StoneDropDownBar t;
                    AddChild(t = new StoneDropDownBar
                    {
                        Anchor = dropBoxOrientation,
                        Font   = new Graphics.Content.Font
                        {
                            Color      = System.Drawing.Color.White,
                            SystemFont = Fonts.SmallSystemFont
                        },
                        Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * i)
                    });

                    Program.Instance.Tooltip.SetToolTip(t, Locale.Resource.AudioDriverToolTip);

                    dropDownBars.Add(t);
                    foreach (var device in audioDevices)
                    {
                        t.AddItem(device);
                    }
                    i++;

                    if (audioSettings.AudioDevice.IsValid)
                    {
                        t.SelectedItem = audioSettings.AudioDevice;
                    }
                }
            }
        }
Esempio n. 19
0
 public ProgramConfigurationInformationControl()
 {
     Size = new SlimDX.Vector2(400, 0);
     Common.ProgramConfigurationInformation.WarningsChanged +=
         new Action(() => Invalidate());
 }
Esempio n. 20
0
		public override void Render()
		{
			SlimDX.Direct3D11.DepthStencilState oldDSState = DeviceManager.Instance.context.OutputMerger.DepthStencilState;
			SlimDX.Direct3D11.BlendState oldBlendState = DeviceManager.Instance.context.OutputMerger.BlendState;
			SlimDX.Direct3D11.RasterizerState oldRasterizerState = DeviceManager.Instance.context.Rasterizer.State;
			SlimDX.Direct3D11.VertexShader oldVertexShader = DeviceManager.Instance.context.VertexShader.Get();
			SlimDX.Direct3D11.Buffer[] oldVSCBuffers = DeviceManager.Instance.context.VertexShader.GetConstantBuffers(0, 10);
			SlimDX.Direct3D11.PixelShader oldPixelShader = DeviceManager.Instance.context.PixelShader.Get();
			SlimDX.Direct3D11.Buffer[] oldPSCBuffers = DeviceManager.Instance.context.PixelShader.GetConstantBuffers(0, 10);
			SlimDX.Direct3D11.ShaderResourceView[] oldShaderResources = DeviceManager.Instance.context.PixelShader.GetShaderResources(0, 10);
			SlimDX.Direct3D11.GeometryShader oldGeometryShader = DeviceManager.Instance.context.GeometryShader.Get();

			base.Render();

			DeviceManager.Instance.context.OutputMerger.DepthStencilState = oldDSState;
			DeviceManager.Instance.context.OutputMerger.BlendState = oldBlendState;
			DeviceManager.Instance.context.Rasterizer.State = oldRasterizerState;
			DeviceManager.Instance.context.VertexShader.Set(oldVertexShader);
			DeviceManager.Instance.context.VertexShader.SetConstantBuffers(oldVSCBuffers, 0, 10);
			DeviceManager.Instance.context.PixelShader.Set(oldPixelShader);
			DeviceManager.Instance.context.PixelShader.SetConstantBuffers(oldPSCBuffers, 0, 10);
			DeviceManager.Instance.context.PixelShader.SetShaderResources(oldShaderResources, 0, 10);
			DeviceManager.Instance.context.GeometryShader.Set(oldGeometryShader);

			foreach (RenderInstance instance in _renderInstances)
			{
				if (instance.Name == null)
				{
					continue;
				}

				SlimDX.Matrix world = instance.Transform;
				SlimDX.Matrix view = CameraManager.Instance.frameCamera.View;
				SlimDX.Matrix projection = CameraManager.Instance.frameCamera.Perspective;

				//SlimDX.Matrix viewProj = view * projection;
				SlimDX.Matrix worldViewProjection = world * view * projection;
				SlimDX.Direct3D11.Viewport vp = DeviceManager.Instance.context.Rasterizer.GetViewports()[0];
				SlimDX.Vector3 position3D = SlimDX.Vector3.Project(SlimDX.Vector3.Zero, vp.X, vp.Y, vp.Width, vp.Height, vp.MinZ, vp.MaxZ, worldViewProjection);
				SlimDX.Vector2 position2D = new SlimDX.Vector2(position3D.X, position3D.Y);

				if (position3D.Z < vp.MaxZ)
				{
					SlimDX.Vector3 objPos = SlimDX.Vector3.Zero;
					objPos = SlimDX.Vector3.TransformCoordinate(objPos, instance.Transform);
					SlimDX.Vector3 camPos = CameraManager.Instance.frameCamera.eye;
					SlimDX.Vector3 objOffset = objPos - camPos;
					float scale = Math.Min(2.0f, 5.0f / (float)Math.Sqrt(Math.Max(1.0f, objOffset.Length())));

					RenderManager.Instance.DrawString(instance.Name, position2D, 16 * scale, new SlimDX.Color4(1.0f, 1.0f, 1.0f));
				}
			}

			DeviceManager.Instance.context.OutputMerger.DepthStencilState = oldDSState;
			DeviceManager.Instance.context.OutputMerger.BlendState = oldBlendState;
			DeviceManager.Instance.context.Rasterizer.State = oldRasterizerState;
			DeviceManager.Instance.context.VertexShader.Set(oldVertexShader);
			DeviceManager.Instance.context.VertexShader.SetConstantBuffers(oldVSCBuffers, 0, 10);
			DeviceManager.Instance.context.PixelShader.Set(oldPixelShader);
			DeviceManager.Instance.context.PixelShader.SetConstantBuffers(oldPSCBuffers, 0, 10);
			DeviceManager.Instance.context.PixelShader.SetShaderResources(oldShaderResources, 0, 10);
			DeviceManager.Instance.context.GeometryShader.Set(oldGeometryShader);
		}
 public static Microsoft.Xna.Framework.Vector2 xna(this SlimDX.Vector2 v)
 {
     return(new Microsoft.Xna.Framework.Vector2(v.X, v.Y));
 }
Esempio n. 22
0
        void MouseMove(int x, int y, System.Windows.Forms.MouseButtons pressedButtons, SlimDX.Vector2 diff)
        {
            if (mModelMover == null)
            {
                return;
            }

            if (pressedButtons == System.Windows.Forms.MouseButtons.None)
            {
                return;
            }

            if (Video.Input.InputManager.Input.IsAsyncKeyDown(System.Windows.Forms.Keys.Menu))
            {
                var matrix = getMatrix();
                if ((pressedButtons & System.Windows.Forms.MouseButtons.Left) != 0)
                {
                    mModelMover.moveModel(SlimDX.Vector3.TransformNormal(SlimDX.Vector3.UnitX, matrix), diff.X / 6.0f);
                    HadModelMovement = true;
                }
                if ((pressedButtons & System.Windows.Forms.MouseButtons.Middle) != 0)
                {
                    mModelMover.moveModel(SlimDX.Vector3.TransformNormal(SlimDX.Vector3.UnitY, matrix), diff.X / 6.0f);
                    HadModelMovement = true;
                }
                if ((pressedButtons & System.Windows.Forms.MouseButtons.Right) != 0)
                {
                    mModelMover.moveModel(SlimDX.Vector3.TransformNormal(SlimDX.Vector3.UnitZ, matrix), -diff.Y / 6.0f);
                    HadModelMovement = true;
                }
            }
            else if (Video.Input.InputManager.Input.IsAsyncKeyDown(System.Windows.Forms.Keys.ControlKey))
            {
                if ((pressedButtons & System.Windows.Forms.MouseButtons.Left) != 0)
                {
                    mModelMover.rotateModel(SlimDX.Vector3.UnitX, diff.X / 10.0f);
                    HadModelMovement = true;
                }

                if ((pressedButtons & System.Windows.Forms.MouseButtons.Middle) != 0)
                {
                    mModelMover.rotateModel(SlimDX.Vector3.UnitY, diff.X / 10.0f);
                    HadModelMovement = true;
                }

                if ((pressedButtons & System.Windows.Forms.MouseButtons.Right) != 0)
                {
                    mModelMover.rotateModel(SlimDX.Vector3.UnitZ, diff.X / 10.0f);
                    HadModelMovement = true;
                }
            }
        }
Esempio n. 23
0
 public void SetVolumeScale2D3D(SlimDX.Vector2 scale)
 {
     System.Volume2DScale = scale.X;
     System.Volume3DScale = scale.Y;
 }
Esempio n. 24
0
        protected bool WritePkg(PackageWriter pkg, System.Reflection.PropertyInfo i)
        {
            var propType = i.PropertyType;

            if (propType == typeof(System.SByte))
            {
                pkg.Write(System.Convert.ToSByte(i.GetValue(this, null)));
            }
            else if (propType == typeof(System.Int16))
            {
                pkg.Write(System.Convert.ToInt16(i.GetValue(this, null)));
            }
            else if (propType == typeof(System.Int32))
            {
                pkg.Write(System.Convert.ToInt32(i.GetValue(this, null)));
            }
            else if (propType == typeof(System.Int64))
            {
                pkg.Write(System.Convert.ToInt64(i.GetValue(this, null)));
            }
            else if (propType == typeof(System.Byte))
            {
                pkg.Write(System.Convert.ToByte(i.GetValue(this, null)));
            }
            else if (propType == typeof(System.UInt16))
            {
                pkg.Write(System.Convert.ToUInt16(i.GetValue(this, null)));
            }
            else if (propType == typeof(System.UInt32))
            {
                pkg.Write(System.Convert.ToUInt32(i.GetValue(this, null)));
            }
            else if (propType == typeof(System.UInt64))
            {
                pkg.Write(System.Convert.ToUInt64(i.GetValue(this, null)));
            }
            else if (propType == typeof(System.Single))
            {
                pkg.Write(System.Convert.ToSingle(i.GetValue(this, null)));
            }
            else if (propType == typeof(System.Double))
            {
                pkg.Write(System.Convert.ToDouble(i.GetValue(this, null)));
            }
            else if (propType == typeof(System.Guid))
            {
                System.Guid id = (System.Guid)(i.GetValue(this, null));
                pkg.Write(id);
            }
            else if (propType == typeof(SlimDX.Vector2))
            {
                SlimDX.Vector2 id = (SlimDX.Vector2)(i.GetValue(this, null));
                pkg.Write(id);
            }
            else if (propType == typeof(SlimDX.Vector3))
            {
                SlimDX.Vector3 id = (SlimDX.Vector3)(i.GetValue(this, null));
                pkg.Write(id);
            }
            else if (propType == typeof(SlimDX.Vector4))
            {
                SlimDX.Vector4 id = (SlimDX.Vector4)(i.GetValue(this, null));
                pkg.Write(id);
            }
            else if (propType == typeof(SlimDX.Quaternion))
            {
                SlimDX.Quaternion id = (SlimDX.Quaternion)(i.GetValue(this, null));
                pkg.Write(id);
            }
            else if (propType == typeof(SlimDX.Matrix))
            {
                SlimDX.Matrix id = (SlimDX.Matrix)(i.GetValue(this, null));
                pkg.Write(id);
            }
            else if (propType == typeof(System.DateTime))
            {
                System.DateTime id = (System.DateTime)(i.GetValue(this, null));
                pkg.Write(id);
            }
            else if (propType == typeof(System.String))
            {
                System.String str = (System.String)(i.GetValue(this, null));
                pkg.Write(str);
            }
            else if (propType == typeof(System.Byte[]))
            {
                System.Byte[] str = (System.Byte[])(i.GetValue(this, null));
                pkg.Write(str);
            }
            else
            {
                return(false);
            }
            return(true);
        }
Esempio n. 25
0
        public VideoOptionsWindow()
        {
            //Layout
            Anchor = global::Graphics.Orientation.Center;
            Size   = new SlimDX.Vector2(500, 510);

            CreateTitle(Locale.Resource.VideoSettingsTitle);

            AddChild(new Label()
            {
                Anchor     = textBoxOrientation,
                Background = null,
                Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * 0),
                Size       = textBoxSize,
                Text       = Locale.Resource.VideoOverallVideo
            });

            AddChild(overall = new StoneDropDownBar()
            {
                Anchor   = dropBoxOrientation,
                Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * 0)
            });
            Program.Instance.Tooltip.SetToolTip(overall, Locale.Resource.VideoOverallToolTip);

            //overall.AddItem(new DropDownItemVideoQuality(VideoQualities.Custom));
            //overall.AddItem(new DropDownItemVideoQuality(VideoQualities.Low));
            //if (Graphics.GraphicsDevice.SettingConverters.PixelShaderVersion.Major >= 3)
            //{
            //    overall.AddItem(new DropDownItemVideoQuality(VideoQualities.Medium));
            //    overall.AddItem(new DropDownItemVideoQuality(VideoQualities.High));
            //    overall.AddItem(new DropDownItemVideoQuality(VideoQualities.Ultra));
            //}

            //overall.SelectedItem = new DropDownItemVideoQuality(videoSettings.VideoQuality);
            overall.Updateable = true;
            overall.Update    += new Graphics.UpdateEventHandler(overall_Update);

            #region VideoSettings

            #region AnimationQuality

            AddChild(new Label()
            {
                Anchor     = textBoxOrientation,
                Background = null,
                Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * 1),
                Size       = textBoxSize,
                Text       = Locale.Resource.VideoAnimation
            });

            AddChild(animation = new StoneDropDownBar()
            {
                Anchor   = dropBoxOrientation,
                Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * 1)
            });

            Program.Instance.Tooltip.SetToolTip(animation, Locale.Resource.VideoAnimationToolTip);

            //animation.AddItem(new DropDownItemAnimationQuality(Graphics.Renderer.Settings.AnimationQualities.Low));
            //if (Graphics.GraphicsDevice.SettingConverters.PixelShaderVersion.Major >= 3)
            //{
            //    animation.AddItem(new DropDownItemAnimationQuality(Graphics.Renderer.Settings.AnimationQualities.Medium));
            //    animation.AddItem(new DropDownItemAnimationQuality(Graphics.Renderer.Settings.AnimationQualities.High));
            //}
            //animation.SelectedItem = new DropDownItemAnimationQuality(videoSettings.Animations);

            #endregion

            #region AntiAliasing

            AddChild(new Label()
            {
                Anchor     = textBoxOrientation,
                Background = null,
                Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * 2),
                Size       = textBoxSize,
                Text       = Locale.Resource.VideoAntiAliasing
            });

            AddChild(antiAliasing = new StoneDropDownBar()
            {
                Anchor   = dropBoxOrientation,
                Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * 2),
            });

            Program.Instance.Tooltip.SetToolTip(antiAliasing, Locale.Resource.VideoAntiAliasingToolTip);

            //foreach (var a in global::Graphics.GraphicsDevice.SettingConverters.AntiAliasingConverter.MultiSampleTypes)
            //    antiAliasing.AddItem(new DropDownItem<SlimDX.Direct3D9.MultisampleType>(a));

            //antiAliasing.SelectedItem = new DropDownItemAntiAliasing(videoSettings.AntiAliasing);

            #endregion

            #region LightingQuality

            AddChild(new Label()
            {
                Anchor     = textBoxOrientation,
                Background = null,
                Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * 3),
                Size       = textBoxSize,
                Text       = Locale.Resource.VideoLightingQuality
            });

            AddChild(lightingQuality = new StoneDropDownBar()
            {
                Anchor   = dropBoxOrientation,
                Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * 3),
            });

            Program.Instance.Tooltip.SetToolTip(lightingQuality, Locale.Resource.VideoLightingToolTip);

            //lightingQuality.AddItem(new DropDownItemLightingQuality(Graphics.Renderer.Settings.LightingQualities.Low));
            //if (Graphics.GraphicsDevice.SettingConverters.PixelShaderVersion.Major >= 3)
            //{
            //    lightingQuality.AddItem(new DropDownItemLightingQuality(Graphics.Renderer.Settings.LightingQualities.Medium));
            //    lightingQuality.AddItem(new DropDownItemLightingQuality(Graphics.Renderer.Settings.LightingQualities.High));
            //}
            //lightingQuality.SelectedItem = new DropDownItemLightingQuality(videoSettings.Lighting);

            #endregion

            #region Resolution

            AddChild(new Label()
            {
                Anchor     = textBoxOrientation,
                Background = null,
                Clickable  = false,
                Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * 4),
                Size       = textBoxSize,
                Text       = Locale.Resource.VideoResolution
            });

            AddChild(resolution = new StoneDropDownBar()
            {
                Anchor   = dropBoxOrientation,
                Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * 4),
            });

            Program.Instance.Tooltip.SetToolTip(resolution, Locale.Resource.VideoResolutionToolTip);

            //if (videoSettings.WindowMode == global::Graphics.WindowMode.Fullscreen)
            //{
            //    foreach (var a in global::Graphics.GraphicsDevice.SettingConverters.ResolutionListConverter.Resolutions)
            //        resolution.AddItem(a.ToString());

            //    resolution.SelectedItem = videoSettings.Resolution.ToString();
            //}

            #endregion

            #region ShadowQuality

            AddChild(new Label()
            {
                Anchor     = textBoxOrientation,
                Background = null,
                Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * 5),
                Size       = textBoxSize,
                Text       = Locale.Resource.VideoShadowQuality
            });

            AddChild(shadowQuality = new StoneDropDownBar()
            {
                Anchor   = dropBoxOrientation,
                Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * 5),
            });

            Program.Instance.Tooltip.SetToolTip(shadowQuality, Locale.Resource.VideoShadowsToolTip);

            //shadowQuality.AddItem(new DropDownItemShadowQuality(Graphics.Renderer.Settings.ShadowQualities.NoShadows));
            //if (Graphics.GraphicsDevice.SettingConverters.PixelShaderVersion.Major >= 3)
            //{
            //    shadowQuality.AddItem(new DropDownItemShadowQuality(Graphics.Renderer.Settings.ShadowQualities.Lowest));
            //    shadowQuality.AddItem(new DropDownItemShadowQuality(Graphics.Renderer.Settings.ShadowQualities.Low));
            //    shadowQuality.AddItem(new DropDownItemShadowQuality(Graphics.Renderer.Settings.ShadowQualities.Medium));
            //    shadowQuality.AddItem(new DropDownItemShadowQuality(Graphics.Renderer.Settings.ShadowQualities.High));
            //    shadowQuality.AddItem(new DropDownItemShadowQuality(Graphics.Renderer.Settings.ShadowQualities.Highest));
            //}
            //if (videoSettings.Shadows == Graphics.Renderer.Settings.ShadowQualities.NoShadows)
            //    shadowQuality.SelectedItem = new DropDownItemShadowQuality(Graphics.Renderer.Settings.ShadowQualities.NoShadows);
            //else
            //    shadowQuality.SelectedItem = new DropDownItemShadowQuality(videoSettings.Shadows);

            #endregion

            #region TerrainQuality

            AddChild(new Label()
            {
                Anchor     = textBoxOrientation,
                Background = null,
                Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * 6),
                Size       = textBoxSize,
                Text       = Locale.Resource.VideoTerrainQuality
            });

            AddChild(terrainQuality = new StoneDropDownBar()
            {
                Anchor   = dropBoxOrientation,
                Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * 6),
            });

            Program.Instance.Tooltip.SetToolTip(terrainQuality, Locale.Resource.VideoTerrainToolTip);

            //terrainQuality.AddItem(new DropDownItemTerrainQuality(Graphics.Renderer.Settings.TerrainQualities.Low));
            //if (Graphics.GraphicsDevice.SettingConverters.PixelShaderVersion.Major >= 3)
            //{
            //    terrainQuality.AddItem(new DropDownItemTerrainQuality(Graphics.Renderer.Settings.TerrainQualities.Medium));
            //    terrainQuality.AddItem(new DropDownItemTerrainQuality(Graphics.Renderer.Settings.TerrainQualities.High));
            //}
            //terrainQuality.SelectedItem = new DropDownItemTerrainQuality(videoSettings.Terrain);

            #endregion

            #region TextureFiltering

            AddChild(new Label()
            {
                Anchor     = textBoxOrientation,
                Background = null,
                Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * 7),
                Size       = textBoxSize,
                Text       = Locale.Resource.VideoTextureFiltering
            });

            AddChild(textureFiltering = new StoneDropDownBar()
            {
                Anchor   = dropBoxOrientation,
                Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * 7),
            });

            Program.Instance.Tooltip.SetToolTip(textureFiltering, Locale.Resource.VideoTextureFilterToolTip);

            //foreach (var tf in global::Graphics.GraphicsDevice.SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict)
            //    textureFiltering.AddItem(new DropDownItemTextureFiltering(tf.Key));

            //textureFiltering.SelectedItem = new DropDownItemTextureFiltering(videoSettings.TextureFiltering.TextureFilter);

            #endregion

            #region VSync

            AddChild(new Label
            {
                Anchor     = textBoxOrientation,
                Background = null,
                Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * 8),
                Size       = textBoxSize,
                Text       = Locale.Resource.VideoVerticalSync
            });

            AddChild(vSync = new StoneDropDownBar
            {
                Anchor   = dropBoxOrientation,
                Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * 8),
            });

            Program.Instance.Tooltip.SetToolTip(vSync, Locale.Resource.VideoVerticalSyncToolTip);

            //vSync.AddItem(new DropDownItemVerticalSync(Graphics.GraphicsDevice.VerticalSyncMode.Off));
            //vSync.AddItem(new DropDownItemVerticalSync(Graphics.GraphicsDevice.VerticalSyncMode.On));

            //vSync.SelectedItem = new DropDownItemVerticalSync(videoSettings.VerticalSync);

            #endregion

            #region WindowMode

            AddChild(new Label
            {
                Anchor     = textBoxOrientation,
                Background = null,
                Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY + textBoxPositionOffset * 9),
                Size       = textBoxSize,
                Text       = Locale.Resource.VideoWindowMode
            });

            AddChild(windowMode = new StoneDropDownBar
            {
                Anchor   = dropBoxOrientation,
                Position = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + dropBoxPositionOffset * 9),
            });

            Program.Instance.Tooltip.SetToolTip(windowMode, Locale.Resource.VideoDisplayModeToolTip);

            //windowMode.AddItem(new DropDownItemWindowMode(WindowMode.Fullscreen));
            //windowMode.AddItem(new DropDownItemWindowMode(WindowMode.FullscreenWindowed));
            //windowMode.AddItem(new DropDownItemWindowMode(WindowMode.Windowed));

            //windowMode.SelectedItem = new DropDownItemWindowMode(videoSettings.WindowMode);

            //if(videoSettings.WindowMode == WindowMode.Fullscreen)
            //    resolution.Disabled = false;
            //else
            //    resolution.Disabled = true;

            #endregion

            #endregion
        }
Esempio n. 26
0
        void Render(GameTime RenderTime)
        {
            lock (queue)
            {
                if (queue.Count > 0)
                {
                    render = queue.Dequeue();
                }
            }

            spriteRenderer.Begin(SpriteFlags.SortTexture | SpriteFlags.SortDepthFrontToBack | SpriteFlags.AlphaBlend);

            //if (engine.UseTextureFilter)
            //{
            //    device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Anisotropic);
            //    device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Anisotropic);
            //    device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Anisotropic);
            //}
            //else
            {
                device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Point);
                device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point);
                device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Point);
            }

            // TODO engine scale
            spriteRenderer.Transform = SlimDX.Matrix.Scaling(new SlimDX.Vector3(renderScale, renderScale, 1));

            SlimDX.Matrix lineMatrix = SlimDX.Matrix.AffineTransformation2D(1, new SlimDX.Vector2(), 0, new SlimDX.Vector2());
            // TODO engine scale
            //lineMatrix = SlimDX.Matrix.Transformation2D(new SlimDX.Vector2(), 0, new SlimDX.Vector2(engine.Scale.x, engine.Scale.y), new SlimDX.Vector2(), 0, new SlimDX.Vector2());
            lineMatrix = SlimDX.Matrix.Transformation2D(new SlimDX.Vector2(), 0, new SlimDX.Vector2(renderScale, renderScale), new SlimDX.Vector2(), 0, new SlimDX.Vector2());
            lineMatrix = spriteRenderer.Transform;
            lineRenderer.Begin();

            // application render
            engine.MainTarget.elapsed = RenderTime.Elapsed;

            float currentFactor = 1;

            if (render != null)
            {
                foreach (RenderEntity entity in render)
                {
                    if (entity is SpriteEntity)
                    {
                        SpriteEntity sprite = entity as SpriteEntity;
                        // diposed texture links may remain in queue after direct3d reset, just skip them
                        if (sprite.Texture.Disposed)
                        {
                            continue;
                        }

                        // if sprite resolution changed, then update transform matrix
                        if (currentFactor != sprite.Factor)
                        {
                            currentFactor = sprite.Factor;
                            // TODO engine scale
                            //spriteRenderer.Transform = SlimDX.Matrix.Scaling(new SlimDX.Vector3(engine.Scale.x * sprite.Factor, engine.Scale.y * sprite.Factor, 1));
                            spriteRenderer.Transform = SlimDX.Matrix.Scaling(new SlimDX.Vector3(renderScale * sprite.Factor, renderScale * sprite.Factor, 1));
                        }

                        // recompute position for not 1:1 sprite resolutions
                        SlimDX.Vector3 pos = sprite.Position;
                        if (currentFactor != 1)
                        {
                            pos.X /= currentFactor;
                            pos.Y /= currentFactor;
                        }

                        spriteRenderer.Draw(sprite.Texture, sprite.Rectangle, new SlimDX.Vector3(0, 0, 0), pos, sprite.Color);
                    }
                    else if (entity is LineEntity)
                    {
                        LineEntity       line = entity as LineEntity;
                        SlimDX.Vector3[] vec  = new SlimDX.Vector3[] { line.Start, line.End };
                        SlimDX.Vector4[] v    = SlimDX.Vector3.Transform(vec, ref lineMatrix);

                        SlimDX.Vector2[] vec2 = new SlimDX.Vector2[] { new SlimDX.Vector2(v[0].X, v[0].Y), new SlimDX.Vector2(v[1].X, v[1].Y) };
                        lineRenderer.Draw(vec2, line.Color);
                    }
                }
            }

            lineRenderer.End();

            blendOverlay.BlockFadeOut = engine.IsLoading || blockBlend;
            blendOverlay.Render(RenderTime, spriteRenderer);
            if (engine.MusicBlend)
            {
                engine.Music.Volume = 1 - BlendState;
            }
            else
            {
                engine.Music.Volume = 1;
            }

            spriteRenderer.End();

            errorOverlay.Render(RenderTime, spriteRenderer);

            loadingOverlay.Render(RenderTime, spriteRenderer);
        }
Esempio n. 27
0
 public void WritePODObject(System.Object obj)
 {
     System.Type type = obj.GetType();
     if (type == typeof(System.SByte))
     {
         Write(System.Convert.ToSByte(obj));
     }
     else if (type == typeof(System.Int16))
     {
         Write(System.Convert.ToInt16(obj));
     }
     else if (type == typeof(System.Int32))
     {
         Write(System.Convert.ToInt32(obj));
     }
     else if (type == typeof(System.Int64))
     {
         Write(System.Convert.ToInt64(obj));
     }
     else if (type == typeof(System.Byte))
     {
         Write(System.Convert.ToByte(obj));
     }
     else if (type == typeof(System.UInt16))
     {
         Write(System.Convert.ToUInt16(obj));
     }
     else if (type == typeof(System.UInt32))
     {
         Write(System.Convert.ToUInt32(obj));
     }
     else if (type == typeof(System.UInt64))
     {
         Write(System.Convert.ToUInt64(obj));
     }
     else if (type == typeof(System.Single))
     {
         Write(System.Convert.ToSingle(obj));
     }
     else if (type == typeof(System.Double))
     {
         Write(System.Convert.ToDouble(obj));
     }
     else if (type == typeof(System.Guid))
     {
         //Guid id = Guid.Parse(obj.ToString());
         System.Guid id = (System.Guid)(obj);
         Write(id);
     }
     else if (type == typeof(SlimDX.Vector2))
     {
         SlimDX.Vector2 v = (SlimDX.Vector2)(obj);
         Write(v);
     }
     else if (type == typeof(SlimDX.Vector3))
     {
         //Guid id = Guid.Parse(obj.ToString());
         SlimDX.Vector3 v = (SlimDX.Vector3)(obj);
         Write(v);
     }
     else if (type == typeof(SlimDX.Vector4))
     {
         SlimDX.Vector4 v = (SlimDX.Vector4)(obj);
         Write(v);
     }
     else if (type == typeof(SlimDX.Quaternion))
     {
         SlimDX.Quaternion q = (SlimDX.Quaternion)(obj);
         Write(q);
     }
     else if (type == typeof(SlimDX.Matrix))
     {
         SlimDX.Matrix mat = (SlimDX.Matrix)(obj);
         Write(mat);
     }
     else if (type == typeof(System.String))
     {
         System.String str = (System.String)(obj);
         Write(str);
     }
     else if (type == typeof(DataWriter))
     {
         var dr = (DataWriter)(obj);
         Write(dr);
     }
 }
Esempio n. 28
0
        public ControlsOptionsWindow()
        {
            Size = new SlimDX.Vector2(500, 520);
            CreateTitle(Locale.Resource.Controls);
            keys.Clear();
            int i = 0;

            foreach (var v in typeof(PublicControlsSettings).GetProperties())
            {
                var a = Attribute.GetCustomAttributes(v, false);
                foreach (ControlsAttribute type in a)
                {
                    Label t;
                    AddChild(t = new Label
                    {
                        Anchor     = textBoxOrientation,
                        Background = null,
                        Position   = new SlimDX.Vector2(textBoxPositionX, textBoxPositionStartY * 1.25f + textBoxPositionOffset * i * 1.5f),
                        Size       = textBoxSize
                    });

                    switch (v.Name)
                    {
                    case "MeleeWeapon":
                        t.Text = Locale.Resource.ControlMelee;
                        break;

                    case "RangedWeapon":
                        t.Text = Locale.Resource.ControlRanged;
                        break;

                    case "MoveForward":
                        t.Text = Locale.Resource.ControlMoveForward;
                        break;

                    case "MoveBackward":
                        t.Text = Locale.Resource.ControlMoveBackward;
                        break;

                    case "StrafeLeft":
                        t.Text = Locale.Resource.ControlStrafeLeft;
                        break;

                    case "StrafeRight":
                        t.Text = Locale.Resource.ControlStrafeRight;
                        break;

                    case "Jump":
                        t.Text = Locale.Resource.ControlJump;
                        break;

                    default:
                        t.Text = v.Name;
                        break;
                    }

                    ControlBox c;
                    AddChild(c = new ControlBox(Util.KeyToString((System.Windows.Forms.Keys)v.GetValue(Program.ControlsSettings, null)))
                    {
                        Anchor     = dropBoxOrientation,
                        Position   = new SlimDX.Vector2(dropBoxPositionX, dropBoxPositionStartY + 7.5f + dropBoxPositionOffset * i * 1.5f),
                        TextAnchor = global::Graphics.Orientation.Center
                    });
                    c.OnChanging        += new EventHandler(t_OnChanging);
                    c.SwitchedToSameKey += new EventHandler(t_SwitchedToSameKey);
                    textBoxes.Add(c);
                    keys.Add(c.Key);
                    i++;
                }
            }
        }
Esempio n. 29
0
        public List<Pass.PassData> PaserObj(string objName)
        {
            List<Pass.PassData> datalist = new List<Pass.PassData>();
            Dictionary<string, Material> matDic = new Dictionary<string,Material>();

            foreach (string line in System.IO.File.ReadAllLines(objName))
            {
                if (line.StartsWith("mtllib"))
                {
                    string matLibName = line.Substring(7);
                    matDic = parseMat("media/" + matLibName);
                }
                else if (line.StartsWith("vt"))
                {
                    string[] tempAry = line.Split(new char[1] { ' ' });
                    tempAry = Array.FindAll<string>(tempAry, x =>
                        {
                            float temp;
                            return float.TryParse(x, out temp);
                        });
                    SlimDX.Vector2 uv = new SlimDX.Vector2();
                    uv.X = System.Convert.ToSingle(tempAry[0]);
                    uv.Y = 1.0f - System.Convert.ToSingle(tempAry[1]);

                    uvList.Add(uv);
                }
                else if (line.StartsWith("vn"))
                {
                    string[] tempAry = line.Split(new char[1] { ' ' });
                    tempAry = Array.FindAll<string>(tempAry, x =>
                        {
                            float temp;
                            return float.TryParse(x, out temp);
                        });
                    SlimDX.Vector4 normal = new SlimDX.Vector4();
                    normal.X = System.Convert.ToSingle(tempAry[0]);
                    normal.Y = System.Convert.ToSingle(tempAry[1]);
                    normal.Z = System.Convert.ToSingle(tempAry[2])-1.0f;

                    normalList.Add(normal);
                }
                else if (line.StartsWith("v"))
                {
                    string[] tempAry = line.Split(new char[1] { ' ' });
                    tempAry = Array.FindAll<string>(tempAry, x =>
                        {
                            float temp;
                            return float.TryParse(x, out temp);
                        });
                    SlimDX.Vector4 pos = new SlimDX.Vector4();
                    pos.X = System.Convert.ToSingle(tempAry[0]);
                    pos.Y = System.Convert.ToSingle(tempAry[1]);
                    pos.Z = System.Convert.ToSingle(tempAry[2])*(-1.0f);
                    pos.W = 1.0f;

                    posList.Add(pos);
                }
            }

            List<Vertex> vertexList = new List<Vertex>();
            List<int[]> triangleIndexList = new List<int[]>();
            Material m = null;
            Pass.PassData data = null;

            Dictionary<string, int> cache = new Dictionary<string, int>();

            int dataCount = 0;
            foreach (string line in System.IO.File.ReadAllLines(objName))
            {
                if (line.StartsWith("usemtl"))
                {
                    if (data != null)
                    {
                        data.triangleIndexs = triangleIndexList;
                        data.vertexs = vertexList.ToArray();
                        data.materail = m;
                        datalist.Add(data);
                        dataCount++;
                        System.Console.WriteLine(dataCount);
                    }
                    data = new Pass.PassData();
                    string[] tempAry = line.Split(new char[1] { ' ' });
                    string matName = tempAry[1];
                    m = matDic[matName];
                    vertexList = new List<Vertex>();
                    triangleIndexList = new List<int[]>();

                    cache.Clear();
                }
                else if (line.StartsWith("f"))
                {
                    string[] tempAry = line.Split(new char[1] { ' ' });

                    int[] indexs = new int[3];

                    for (int i=3; i>=1; i--)
                    {
                        string s = tempAry[i];
                        if (string.IsNullOrWhiteSpace(s) || string.IsNullOrEmpty(s))
                            continue;

                        string[] IndexAry = s.Split(new char[1] { '/' });
                        if (IndexAry.Length == 1)
                        {
                            int posIndex = Convert.ToInt32(IndexAry[0]) - 1;
                            string cacheString = "pos" + posIndex.ToString();
                            if (cache.ContainsKey(cacheString))
                            {
                                int index = cache[cacheString];
                                indexs[i] = index;
                            }
                            else
                            {
                                Vertex newVertex = new Vertex();
                                newVertex.pos = posList[posIndex];
                                vertexList.Add(newVertex);
                                indexs[i] = vertexList.Count - 1;
                                cache[cacheString] = vertexList.Count - 1;
                            }
                            //triangleIndexList.Add(indexs);
                        }
                        else if (IndexAry.Length == 2)
                        {
                            int posIndex = Convert.ToInt32(IndexAry[0]) - 1;
                            int uvIndex = Convert.ToInt32(IndexAry[1]) - 1;
                            string cacheString = "pos" + posIndex.ToString() + "uv" + uvIndex.ToString();
                            if (cache.ContainsKey(cacheString))
                            {
                                int index = cache[cacheString];
                                indexs[i] = index;
                            }
                            else
                            {
                                Vertex newVertex = new Vertex();
                                newVertex.pos = posList[posIndex];
                                newVertex.uv = uvList[uvIndex];
                                vertexList.Add(newVertex);
                                indexs[i] = vertexList.Count - 1;
                                cache[cacheString] = vertexList.Count - 1;
                            }
                            //triangleIndexList.Add(indexs);
                        }
                        else if (IndexAry.Length == 3)
                        {
                            int posIndex = Convert.ToInt32(IndexAry[0]) - 1;
                            int uvIndex = Convert.ToInt32(IndexAry[1]) - 1;
                            int normalIndex = Convert.ToInt32(IndexAry[2]) - 1;
                            string cacheString = "pos" + posIndex.ToString() + "uv" + uvIndex.ToString() + "normal"+normalIndex.ToString();
                            if (cache.ContainsKey(cacheString))
                            {
                                int index = cache[cacheString];
                                indexs[i-1] = index;
                            }
                            else
                            {
                                Vertex newVertex = new Vertex();
                                newVertex.pos = posList[posIndex];
                                newVertex.uv = uvList[uvIndex];
                                newVertex.normal = normalList[normalIndex];
                                vertexList.Add(newVertex);
                                indexs[i-1] = vertexList.Count - 1;
                                cache[cacheString] = vertexList.Count - 1;
                            }
                        }
                    }
                    int index1 = indexs[0];
                    int index2 = indexs[1];
                    int index3 = indexs[2];

                    indexs[0] = index3;
                    indexs[1] = index2;
                    indexs[2] = index1;
                    triangleIndexList.Add(indexs);
                }
            }

            if (data != null)
            {
                data.triangleIndexs = triangleIndexList;
                data.vertexs = vertexList.ToArray();
                data.materail = m;
                datalist.Add(data);
            }

            return datalist;
        }
 public ProgramConfigurationInformationControl()
 {
     Size = new SlimDX.Vector2(400, 0);
     Common.ProgramConfigurationInformation.WarningsChanged +=
         new Action(() => Invalidate());
 }