Beispiel #1
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)
        {
            GeometryBase Geom    = default(GeometryBase);
            string       InfoKey = null;

            if (!DA.GetData(0, ref Geom))
            {
                return;
            }
            if (!DA.GetData(1, ref InfoKey))
            {
                return;
            }
            //此处务必对几何体进行拷贝,否则将会影响到前面的几何体
            GeometryBase TempGeom = Geom.Duplicate();

            try
            {
                if (TempGeom.UserDictionary.ContainsKey(InfoKey))
                {
                    TempGeom.UserDictionary.Remove(InfoKey);
                    DA.SetData(0, TempGeom);
                }
                else
                {
                    throw new Exception("在几何体中未找到Key值为:" + InfoKey + " 的字段");
                }
            }catch (Exception ex)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, ex.Message);
            }
        }
Beispiel #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)
        {
            OpenvrWrapper temp = null;

            if (!DA.GetData("Vive", ref temp))
            {
                return;
            }
            var list = temp.TrackedDevices.IndexesByClasses["HMD"];

            if (list.Count == 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No HMD deteceted");
                return;
            }
            int index = temp.TrackedDevices.IndexesByClasses["HMD"][0];

            CurrenTrackedDevice = temp.TrackedDevices.AllDevices[index];
            this.Message        = "HMD";
            CurrenTrackedDevice.ConvertPose();
            XyPlane = Plane.WorldXY;
            XyPlane.Transform(CurrenTrackedDevice.CorrectedMatrix4X4);
            if (!Paused)
            {
                OldPlane     = XyPlane;
                OldTransform = CurrenTrackedDevice.CorrectedMatrix4X4;
            }

            var newHMD = HMD.Duplicate();

            newHMD.Transform(OldTransform);
            DA.SetData("HMD", newHMD);
            DA.SetData("Plane", OldPlane);
            DA.SetData("Matrix", OldTransform);
        }
Beispiel #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)
        {
            GeometryBase Geom    = default(GeometryBase);
            string       InfoKey = default(string);
            //特别注意
            dynamic InfoValue = default(dynamic);

            if (!DA.GetData(0, ref Geom))
            {
                return;
            }
            if (!DA.GetData(1, ref InfoKey))
            {
                return;
            }
            if (!DA.GetData(2, ref InfoValue))
            {
                return;
            }
            //这句代码至关重要
            GeometryBase TempGeom = Geom.Duplicate();

            if ((TempGeom is Rhino.Geometry.Point))
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "目前尚不支持Point的户自定义数据写入");
                return;
            }
            TempGeom.UserDictionary.Set(InfoKey, InfoValue.Value);
            DA.SetData(0, TempGeom);
        }
        /// <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)
        {
            OpenvrWrapper temp  = null;
            int           index = 0;

            if (!DA.GetData("Vive", ref temp))
            {
                return;
            }
            DA.GetData("Index", ref index);
            var list = temp.TrackedDevices.IndexesByClasses["Tracker"];

            if (list.Count == 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No Tracker deteceted");
                this.Message = "";
                return;
            }
            if (index > list.Count - 1)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Index exceeds the trackers detected");
                this.Message = "";
                return;
            }

            int globaleindex = temp.TrackedDevices.IndexesByClasses["Tracker"][index];

            CurrenTrackedDevice = temp.TrackedDevices.AllDevices[globaleindex];
            this.Message        = "Tracker" + index;
            CurrenTrackedDevice.ConvertPose();
            CurrenTrackedDevice.GetTrackerCorrectedMatrix4X4();
            XyPlane = Plane.WorldXY;
            XyPlane.Transform(CurrenTrackedDevice.CorrectedMatrix4X4);
            if (!Paused)
            {
                OldPlane     = XyPlane;
                OldTransform = CurrenTrackedDevice.CorrectedMatrix4X4;
            }

            var newtracker = tracker.Duplicate();

            newtracker.Transform(OldTransform);
            DA.SetData("Tracker", newtracker);
            DA.SetData("Plane", OldPlane);
            DA.SetData("Matrix", OldTransform);
        }
        /// <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)
        {
            OpenvrWrapper temp = null;

            if (!DA.GetData("Vive", ref temp))
            {
                return;
            }
            var list = temp.TrackedDevices.IndexesByClasses["Controller"];

            if (list.Count == 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No Controller deteceted");
                return;
            }
            if (list.Count == 1)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "There's only one Controller, please use Controller1");
                return;
            }
            int index = temp.TrackedDevices.IndexesByClasses["Controller"][1];

            CurrenTrackedDevice = temp.TrackedDevices.AllDevices[index];
            this.Message        = "Controller2";
            CurrenTrackedDevice.ConvertPose();
            XyPlane = Plane.WorldXY;
            XyPlane.Transform(CurrenTrackedDevice.CorrectedMatrix4X4);
            if (!Paused)
            {
                OldPlane     = XyPlane;
                OldTransform = CurrenTrackedDevice.CorrectedMatrix4X4;
            }

            var newcontroller = controller.Duplicate();

            newcontroller.Transform(OldTransform);
            DA.SetData("Controller", newcontroller);
            DA.SetData("Plane", OldPlane);
            DA.SetData("Matrix", OldTransform);

            CurrenTrackedDevice.GetControllerTriggerState();
            DA.SetDataList("TriggerState", CurrenTrackedDevice.TriggerStates);
            DA.SetDataList("TouchPadState", CurrenTrackedDevice.TouchPadStates);
        }