// Constructor /// <summary> /// Initializes a new instance of the <see cref="Hatwell.GameLibrary.Rendering.Viewport"/> class. /// <param name="viewport">A reference to the <see cref="Microsoft.DirectX.Direct3D.Viewport"/> class.</param> /// </summary> public Viewport(D3DViewport viewport) { this = new Viewport(); X = viewport.X; Y = viewport.Y; Width = viewport.Width; Height = viewport.Height; }
// Constructor /// <summary> /// Initializes a new instance of the <see cref="Hatwell.GameLibrary.Rendering.Viewport"/> class. /// <param name="viewport">A reference to the <see cref="Microsoft.DirectX.Direct3D.Viewport"/> class.</param> /// </summary> public Viewport(D3DViewport viewport) { this = new Viewport(); X = viewport.X; Y = viewport.Y; Width = viewport.Width; Height = viewport.Height; }
private void readViewOptions(XmlNode node) { foreach (XmlNode child in node.ChildNodes) { if ("View".Equals(child.Name)) { int id = int.Parse(readAttribute(child, "ID", "5")); Canguro.View.GraphicView view = Canguro.View.GraphicViewManager.Instance.GetView(id); if (view != null) { int options = int.Parse(readAttribute(child, "OptionsShown", "0")); string rot = readAttribute(child, "Rotation"); string trans = readAttribute(child, "Translation"); string scale = readAttribute(child, "Scale"); string scaleFac = readAttribute(child, "ScaleFac", "1"); string[] vp = readAttribute(child, "Viewport").Split(",".ToCharArray()); float vpScale = 1; if (vp.Length >= 6) { Microsoft.DirectX.Direct3D.Viewport vPort = new Microsoft.DirectX.Direct3D.Viewport(); vPort.X = int.Parse(vp[0]); vPort.Width = int.Parse(vp[1]); vPort.Y = int.Parse(vp[2]); vPort.Height = int.Parse(vp[3]); vPort.MinZ = float.Parse(vp[4]); vPort.MaxZ = float.Parse(vp[5]); Microsoft.DirectX.Direct3D.Viewport current = view.Viewport; vpScale = (float)current.Width / (float)vPort.Width; vpScale = (vpScale > (float)current.Height / (float)vPort.Height) ? (float)current.Height / (float)vPort.Height : vpScale; } view.ArcBallCtrl.RotationMatrix = GetAsMatrix(rot); view.ArcBallCtrl.TranslationMatrix = GetAsMatrix(trans); // view.ArcBallCtrl.Scaling = GetAsMatrix(scale); view.ArcBallCtrl.ZoomAbsolute(Convert.ToSingle(scaleFac) * vpScale); // view.ArcBallCtrl.ScalingFac = Convert.ToSingle(scaleFac) * vpScale; view.ViewMatrix = view.ArcBallCtrl.ViewMatrix; view.ModelRenderer.RenderOptions.OptionsShown = (Canguro.View.Renderer.RenderOptions.ShowOptions)options; } } } }