public CoordinateSystemModel3D() { var builder = new MeshBuilder(true, false, false); builder.AddArrow(Vector3.Zero, new Vector3(10, 0, 0), 1, 2, 10); builder.AddArrow(Vector3.Zero, new Vector3(0, 10, 0), 1, 2, 10); builder.AddArrow(Vector3.Zero, new Vector3(0, 0, 10), 1, 2, 10); var mesh = builder.ToMesh(); this.Material = PhongMaterials.White; axisBillboards[0] = new BillboardTextModel3D() { IsHitTestVisible = false }; axisBillboards[1] = new BillboardTextModel3D() { IsHitTestVisible = false }; axisBillboards[2] = new BillboardTextModel3D() { IsHitTestVisible = false }; UpdateAxisColor(mesh, 0, AxisXColor.ToColor4()); UpdateAxisColor(mesh, 1, AxisYColor.ToColor4()); UpdateAxisColor(mesh, 2, AxisZColor.ToColor4()); Geometry = mesh; CullMode = CullMode.Back; }
/// <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(""); }
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))); }