/// <summary> /// Initialization /// </summary> public void InitializeBusinessLogic() { ConfigurationHelper.RegisterSettings(Properties.Settings.Default); pointCloudViewModel = new PointcloudViewModel(new SharpDX.Size2(0, 0)); PointCloudView.ViewModel = pointCloudViewModel; PointCloudView.InitializeScene(); DataContext = pointCloudViewModel; // Moving Camera vertically up and turning it to look down PointCloudView.ViewModel.SetCvmPosition(new System.Windows.Media.Media3D.Vector3D(0, 0, groundZ), new System.Windows.Media.Media3D.Vector3D(180, 0, 90)); var planeColor = System.Windows.Media.Color.FromArgb(20, 50, 255, 50).ToColor4(); // Only points from this rectangular area are included and outliers are ignored var scenePlane = PointcloudViewModel.CreatePlane(planeColor, groundD, groundW, new SharpDX.Vector3(0, 0, 1f)); PointCloudView.SceneRoot.Children.Add(scenePlane); // For 3D texts BillboardTextModel3D text = new BillboardTextModel3D(); PointCloudView.SceneRoot.Children.Add(text); labels = new BillboardText3D(); text.Geometry = labels; boundingBoxGroup = new GroupModel3D(); PointCloudView.SceneRoot.Children.Add(boundingBoxGroup); rosControlBase.RosConnected += RosControlBase_RosConnected; rosControlBase.RosDisconnected += RosControlBase_RosDisconnected; rosControlBase.CvmDeviceInfoChaged += RosControlBase_CvmDeviceInfoChaged; }
public DynaShapeDisplay(Solver solver) { this.solver = solver; pointGeometry = new PointGeometry3D { Positions = new Vector3Collection(), Indices = new IntCollection(), Colors = new Color4Collection() }; lineGeometry = new LineGeometry3D() { Positions = new Vector3Collection(), Indices = new IntCollection(), Colors = new Color4Collection() }; billboardText = new BillboardText3D(); DynaShapeViewExtension.DynamoWindow.Dispatcher.Invoke( () => { pointModel = new PointGeometryModel3D { Size = new Size(5, 5), Figure = PointGeometryModel3D.PointFigure.Ellipse, Color = Color.White, }; lineModel = new LineGeometryModel3D { Thickness = 0.5, Color = Color.White, }; billboardTextModel = new BillboardTextModel3D() { }; }, DispatcherPriority.Send); DynaShapeViewExtension.ViewModel.RequestViewRefresh += RequestViewRefreshHandler; DynaShapeViewExtension.DynamoWindow.Closed += (sender, args) => Dispose(); }
private void CreateOrUpdateText(string baseId, Vector3 pt, IRenderPackage rp) { var textId = baseId + TextKey; BillboardTextModel3D bbText; if (Model3DDictionary.ContainsKey(textId)) { bbText = Model3DDictionary[textId] as BillboardTextModel3D; } else { bbText = new BillboardTextModel3D() { Geometry = HelixRenderPackage.InitText3D(), }; Model3DDictionary.Add(textId, bbText); } var geom = bbText.Geometry as BillboardText3D; geom.TextInfo.Add(new TextInfo(HelixRenderPackage.CleanTag(rp.Description), new Vector3(pt.X + 0.025f, pt.Y + 0.025f, pt.Z + 0.025f))); }
/// <summary> /// Use the render packages returned from the visualization manager to update the visuals. /// The visualization event arguments will contain a set of render packages and an id representing /// the associated node. Visualizations for the background preview will return an empty id. /// </summary> /// <param name="e"></param> public void RenderDrawables(VisualizationEventArgs e) { //check the id, if the id is meant for another watch, //then ignore it if (e.Id != _id) { Attach(); NotifyPropertyChanged(""); return; } // Don't render if the user's system is incapable. if (renderingTier == 0) { return; } #if DEBUG renderTimer.Start(); #endif Text = null; var packages = e.Packages.Concat(e.SelectedPackages) .Cast <HelixRenderPackage>().Where(rp => rp.MeshVertexCount % 3 == 0); var text = HelixRenderPackage.InitText3D(); var aggParams = new PackageAggregationParams { Packages = packages, Text = text }; AggregateRenderPackages(aggParams); #if DEBUG renderTimer.Stop(); Debug.WriteLine(string.Format("RENDER: {0} ellapsed for compiling assets for rendering.", renderTimer.Elapsed)); renderTimer.Reset(); renderTimer.Start(); #endif //Helix render the packages in certain order. Here, the BillBoardText has to be rendered //after rendering all the geometry. Otherwise, the Text will not get rendered at the right //position. Also, BillBoardText gets attached only once. It is not removed from the tree everytime. //Instead, only the geometry gets updated every time. Once it is attached (after the geometry), helix // renders the text at the right position. if (Text != null && Text.TextInfo.Any()) { BillboardTextModel3D billboardText3D = new BillboardTextModel3D { Transform = Model1Transform }; if (model3DDictionary != null && !model3DDictionary.ContainsKey("BillBoardText")) { model3DDictionary.Add("BillBoardText", billboardText3D); } var billBoardModel3D = model3DDictionary["BillBoardText"] as BillboardTextModel3D; billBoardModel3D.Geometry = Text; if (!billBoardModel3D.IsAttached) { billBoardModel3D.Attach(View.RenderHost); } } else { if (model3DDictionary != null && model3DDictionary.ContainsKey("BillBoardText")) { var billBoardModel3D = model3DDictionary["BillBoardText"] as BillboardTextModel3D; billBoardModel3D.Geometry = Text; } } //This is required for Dynamo to send property changed notifications to helix. NotifyPropertyChanged(""); }