Ejemplo n.º 1
0
        //CAMERA

        public void SetCamera(wCameraStandard WindCamera, double Extents)
        {
            Cam = WindCamera;
            if (Cam.IsDefault)
            {
                Ortho = new OrthographicCamera(Cam.Location.ToPoint3D(), Cam.Direction.ToVector3D(), Cam.Up.ToVector3D(), Extents);
                ViewPort.Orthographic             = true;
                ViewPort.Camera                   = Ortho;
                ViewPort.Camera.NearPlaneDistance = -Extents;
            }
            else
            {
                if (Cam.LensLength <= 0)
                {
                    Ortho = new OrthographicCamera(Cam.Location.ToPoint3D(), Cam.Direction.ToVector3D(), Cam.Up.ToVector3D(), Cam.Distance);
                    ViewPort.Orthographic             = true;
                    ViewPort.Camera                   = Ortho;
                    ViewPort.Camera.NearPlaneDistance = -Extents;
                }
                else
                {
                    Perspective           = new PerspectiveCamera(Cam.Location.ToPoint3D(), Cam.Direction.ToVector3D(), Cam.Up.ToVector3D(), Cam.LensLength);
                    ViewPort.Orthographic = false;
                    ViewPort.Camera       = Perspective;
                }
            }
            SceneDiagonal = Extents;
        }
Ejemplo n.º 2
0
        /// <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)
        {
            Point3d C = new Point3d(0, 0, 0);
            double  P = 45;
            double  T = -45;
            double  D = 100;
            double  L = 50;

            if (!DA.GetData(0, ref C))
            {
                return;
            }
            if (!DA.GetData(1, ref P))
            {
                return;
            }
            if (!DA.GetData(2, ref T))
            {
                return;
            }
            if (!DA.GetData(3, ref D))
            {
                return;
            }
            if (!DA.GetData(4, ref L))
            {
                return;
            }

            wCamera Cam = new wCameraStandard(new wPoint(C.X, C.Y, C.Z), Math.PI / 2 + (P / 180.0) * Math.PI, (T / 180.0) * Math.PI, D, L);

            DA.SetData(0, Cam);
        }
Ejemplo n.º 3
0
        /// <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)
        {
            Point3d  P = new Point3d(100, 100, 100);
            Point3d  T = new Point3d(0, 0, 0);
            Vector3d Z = new Vector3d(0, 0, 1);
            double   L = 0;

            if (!DA.GetData(0, ref P))
            {
                return;
            }
            if (!DA.GetData(1, ref T))
            {
                return;
            }
            if (!DA.GetData(2, ref Z))
            {
                return;
            }
            if (!DA.GetData(3, ref L))
            {
                return;
            }

            wCamera Cam = new wCameraStandard(new wPoint(P.X, P.Y, P.Z), new wPoint(T.X, T.Y, T.Z), new wVector(Z.X, Z.Y, Z.Z), L);

            DA.SetData(0, Cam);
        }
Ejemplo n.º 4
0
        private void CameraModeB(Object sender, EventArgs e)
        {
            InitialCamera = new wCameraStandard(90, 90, 1.0, 0, true);

            Params.Input[3].ClearData();
            Params.Input[3].AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, InitialCamera);

            CameraMode = 9;
            this.ExpireSolution(true);
        }
Ejemplo n.º 5
0
        /// <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 pPointCloudViewer(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      = (pPointCloudViewer)Element.ParrotControl;
                }
            }
            else
            {
                pCtrl.SetProperties();
                Elements.Add(C, WindObject);
            }

            //Set Unique Control Properties

            List <Point3d> P = new List <Point3d>();
            List <Color>   X = new List <Color>();
            List <double>  R = new List <double>();
            IGH_Goo        U = null;


            if (Params.Input[3].VolatileDataCount < 1)
            {
                Params.Input[3].ClearData();
                Params.Input[3].AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, InitialCamera);
            }

            if (!DA.GetDataList(0, P))
            {
                return;
            }
            if (!DA.GetDataList(1, X))
            {
                return;
            }
            if (!DA.GetDataList(2, R))
            {
                return;
            }
            if (!DA.GetData(3, ref U))
            {
                return;
            }

            wCameraStandard V = new wCameraStandard();

            U.CastTo(out V);


            for (int i = (X.Count - 1); i < P.Count; i++)
            {
                X.Add(X[X.Count - 1]);
            }

            for (int i = (R.Count - 1); i < P.Count; i++)
            {
                R.Add(R[R.Count - 1]);
            }

            pCtrl.ClearScene();

            for (int i = 0; i < P.Count; i++)
            {
                pCtrl.AddPoint(new wPoint(P[i].X, P[i].Y, P[i].Z), new wColor(X[i]), R[i]);
            }

            BoundingBox Bbox = new BoundingBox(P);

            pCtrl.SetCamera(V, Bbox.Diagonal.Length);

            pCtrl.SetNavigation(HasNavigation);
            pCtrl.SetGizmo(HasGizmo);
            pCtrl.SetCoordinateSystem(HasCoordinates);

            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);
        }
Ejemplo n.º 6
0
        /// <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 pViewport(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      = (pViewport)Element.ParrotControl;
                }
            }
            else
            {
                Elements.Add(C, WindObject);
            }

            //Set Unique Control Properties
            string  Text            = "GH_HACK";
            int     DisplayIndex    = 0;
            int     ProjectionIndex = 0;
            wCamera Cam             = new wCameraStandard();

            if (!DA.GetData(0, ref Text))
            {
                return;
            }
            if (!DA.GetData(1, ref DisplayIndex))
            {
                return;
            }
            if (!DA.GetData(2, ref ProjectionIndex))
            {
                return;
            }
            if (!DA.GetData(3, ref Cam))
            {
                return;
            }

            pCtrl.SetProperties(Text);

            if (ZoomExtent)
            {
                pCtrl.ZoomExtents();
                ZoomExtent = false;
            }

            if (ZoomSelect)
            {
                pCtrl.ZoomSelected();
                ZoomSelect = false;
            }

            pCtrl.SetGridAxis(HasGrid, HasAxis, HasGizmo);
            pCtrl.SetCameraProjection((pViewport.CameraProjection)ProjectionIndex, Cam.LensLength);
            pCtrl.SetCameraPosition(Cam.Location, Cam.Target, Cam.Up);
            //pCtrl.SetViewPort(Rhino.RhinoDoc.ActiveDoc.Views.ToList()[0].ActiveViewport);
            pCtrl.SetViewShading(Rhino.Display.DisplayModeDescription.GetDisplayModes()[0]);

            pCtrl.BuildView();


            //Set Parrot Element and Wind Object properties
            if (!Active)
            {
                Element = new pElement(pCtrl.Element, pCtrl, pCtrl.Type);
            }

            Element.Control     = pCtrl;
            WindObject          = new wObject(Element, "Parrot", Element.Type);
            WindObject.GUID     = this.InstanceGuid;
            WindObject.Instance = C;

            Elements[this.RunCount] = WindObject;

            DA.SetData(0, WindObject);
        }