/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { int Index = 0; double D = 0; double L = 0; if (!DA.GetData(0, ref Index)) { return; } if (!DA.GetData(1, ref D)) { return; } if (!DA.GetData(2, ref L)) { return; } SelectedCamera = CameraSet[Index]; SelectedCamera.SetLength(D); SelectedCamera.LensLength = L; DA.SetData(0, SelectedCamera); UpdateMessage(); }
//CAMERA public void SetCamera(wCamera WindCamera) { Cam = WindCamera; Point3D P = Cam.Location.ToPoint3D(); P = new Point3D(P.X, P.Y, P.Z); if (Cam.LensLength <= 0) { Ortho = new OrthographicCamera(P, Cam.Direction.ToVector3D(), Cam.Up.ToVector3D(), Cam.Distance); ViewPort.Orthographic = true; ViewPort.Camera = Ortho; ViewPort.Camera.NearPlaneDistance = double.NegativeInfinity; } else { Perspective = new PerspectiveCamera(P, Cam.Direction.ToVector3D(), Cam.Up.ToVector3D(), Cam.LensLength); ViewPort.Orthographic = false; ViewPort.Camera = Perspective; } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string ID = this.Attributes.InstanceGuid.ToString(); string name = new GUIDtoAlpha(Convert.ToString(ID + Convert.ToString(this.RunCount)), false).Text; int C = this.RunCount; wObject WindObject = new wObject(); pElement Element = new pElement(); bool Active = Elements.ContainsKey(C); var pCtrl = new pMeshViewer(name); if (Elements.ContainsKey(C)) { Active = true; } //Check if control already exists if (Active) { if (Elements[C] != null) { WindObject = Elements[C]; Element = (pElement)WindObject.Element; pCtrl = (pMeshViewer)Element.ParrotControl; } } else { pCtrl.SetProperties(); Elements.Add(C, WindObject); } //Set Unique Control Properties List <IGH_Goo> X = new List <IGH_Goo>(); List <IGH_Goo> Y = new List <IGH_Goo>(); IGH_Goo U = null; if (Params.Input[1].VolatileDataCount < 1) { UpdateLightInput(1); } //if (Params.Input[2].VolatileDataCount < 1) { UpdateCameraInput(2); } if (!DA.GetDataList(0, X)) { return; } if (!DA.GetDataList(1, Y)) { return; } if (!DA.GetData(2, ref U)) { return; } wCamera V = new wCamera(); U.CastTo(out V); List <wMesh> Meshes = new List <wMesh>(); foreach (IGH_Goo Obj in X) { wMesh M = new wMesh(); Obj.CastTo(out M); Meshes.Add(M); } pCtrl.SetMeshes(Meshes); List <wLight> Lights = new List <wLight>(); foreach (IGH_Goo Obj in Y) { wLight L = new wLight(); Obj.CastTo(out L); Lights.Add(L); } pCtrl.SetLights(Lights); pCtrl.BuildScene(); pCtrl.SetCamera(V); pCtrl.SetNavigation(HasNavigation); pCtrl.SetGizmo(HasGizmo); pCtrl.SetCoordinateSystem(HasCoordinates); //if (V.IsPreset) { pCtrl.ZoomExtents(1.0); } if (ZoomExtents) { pCtrl.ZoomExtents(1.0); ZoomExtents = false; } //Set Parrot Element and Wind Object properties if (!Active) { Element = new pElement(pCtrl.Element, pCtrl, pCtrl.Type); } WindObject = new wObject(Element, "Parrot", Element.Type); WindObject.GUID = this.InstanceGuid; WindObject.Instance = C; Elements[this.RunCount] = WindObject; DA.SetData(0, WindObject); }