public void AddNode(int oid, ObjectNode objNode) { NameNode nameNode = new NameNode(); // nameNode.nameBar = (StaticText)WindowManager.Instance.CreateWindow( // "WindowsLook.WLStaticText", "Window/LabelText-" + oid); // nameNode.nameBar.Font = font; // nameNode.nameBar.Text = "Name: " + objNode.Name; // nameNode.nameBar.HorizontalFormat = HorizontalTextFormat.Center; // nameNode.nameBar.VerticalFormat = VerticalTextFormat.Top; // nameNode.nameBar.SetTextColor(new Color(1, 0, 0, 0)); // nameNode.nameBar.MetricsMode = MetricsMode.Absolute; // float chromeHeight = // nameNode.nameBar.UnclippedPixelRect.Height - nameNode.nameBar.UnclippedInnerRect.Height; // Logger.Log(0, "chromeHeight: {0} Line Spacing: {1}", chromeHeight, font.LineSpacing); // nameNode.nameBar.Size = new Size(60, chromeHeight + font.LineSpacing + 5); // FIXME (why do i need +5) nameDictionary[oid] = nameNode; // window.AddChild(nameNode.nameBar); // nameNode.nameBar.MetricsMode = MetricsMode.Relative; // Console.WriteLine("Adding node for: " + objNode.Name); NameWidget widget = new NameWidget(objNode.SceneNode, objNode.Name); widget.Initialize(); // Object will be clipped to this size widget.MetricsMode = MetricsMode.Relative; widget.Size = new Size(1.0f, 1.0f); widget.Position = new Point(0.0f, 0.0f); widget.Text = objNode.Name; widget.HorizontalFormat = HorizontalTextFormat.Center; widget.VerticalFormat = VerticalTextFormat.Centered; widget.Visible = true; window.AddChild(widget); }
/// <summary> /// Inform the name manager about an object node for which the name /// should be displayed. /// </summary> /// <param name="oid">the object id of the node (used as the key for lookups)</param> /// <param name="objNode">the object node whose name should be displayed</param> public void AddNode(long oid, ObjectNode objNode) { NameNode widgetNode = new NameNode(oid); Node attachNode = null; WidgetSceneObject attachObj = new WidgetSceneObject(); attachObj.WidgetNode = widgetNode; AttachmentPoint ap = objNode.GetAttachmentPoint("name-disabled"); if (ap == null) { // Default to a bit larger than the height of the bounding box float objectHeight = objNode.Entity.BoundingBox.Size.y * 1.02f; ap = new AttachmentPoint("name-disabled", null, Quaternion.Identity, Vector3.UnitY * objectHeight); } attachNode = objNode.AttachLocalObject(ap, attachObj); if (attachNode == null) { widgetNode.NodeVisible = true; widgetNode.Node = objNode.SceneNode; } else { // The node visible will be set by the attachObj widgetNode.Node = attachNode; } // FIXME //widgetNode.Widget.Text = objNode.Name; //widgetNode.Widget.Font = font; window.AddChild(widgetNode.Widget); widgetNode.Widget.Initialize(); widgetNode.SetFont(font); widgetNode.SetText(objNode.Name); lock (nameDictionary) { nameDictionary[oid] = widgetNode; } }