Esempio n. 1
0
        /// <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;
            }
        }