/// <summary> /// Initialise the side tree view to show the scene. /// </summary> private void InitFillTreeFromWorldSingleEntity() { this.treeView_entity_info.Nodes.Clear(); // make root node and build whole tree var root_nd = new SceneTreeNode("root"); // make entity tree var ent_one = new EntityTreeNode(_world._enttity_one.Name); ent_one.DrawMeshBounds = new BoundingBoxGroup(_world._enttity_one._extra_geometry._mesh_id2box.Values); // make entity mesh MeshTreeNode ent_mesh_nodes = MakeMeshTree(_world._enttity_one, _world._enttity_one._node); // make entity armature ArmatureTreeNode ent_arma_nodes = MakeArmatureTree(_world._enttity_one, _world._enttity_one._armature); root_nd.Nodes.Add(ent_one); ent_one.Nodes.Add(ent_mesh_nodes); ent_one.Nodes.Add(ent_arma_nodes); ent_arma_nodes.BackColor = Color.LightBlue; ent_mesh_nodes.BackColor = Color.LightGreen; ent_one.BackColor = Color.Gold; // attach and refresh this.treeView_entity_info.Nodes.Add(root_nd); // show the entity node // ent_one.EnsureVisible(); this.treeView_entity_info.ExpandAll(); ent_arma_nodes.EnsureVisible(); this.treeView_entity_info.Invalidate(); }
private MeshTreeNode MakeMeshTree(Entity ent, Node nd) { var current = new MeshTreeNode(nd.Name); var child_boxes = new List <MeshBounds>(); if (nd.MeshCount > 1) { foreach (int mesh_id in nd.MeshIndices) { MeshBounds aabb = ent._extra_geometry._mesh_id2box[mesh_id]; string mesh_name = _world._cur_scene._inner.Meshes[mesh_id].Name; var mesh_view_nd = new MeshTreeNode(mesh_name); var list = new List <MeshBounds>() { aabb }; mesh_view_nd.DrawData = new BoundingBoxGroup(list); child_boxes.Add(aabb); current.Nodes.Add(mesh_view_nd); } // get a bounding box that covers all of the meshes assigned to this node current.DrawData = new BoundingBoxGroup(child_boxes); } else { // Place the bounding box of mesh as self bounding box MeshBounds aabb = ent._extra_geometry._mesh_id2box[nd.MeshIndices[0]]; var list = new List <MeshBounds>() { aabb }; current.DrawData = new BoundingBoxGroup(list); } foreach (var child_nd in nd.Children) { var treeview_child = MakeMeshTree(ent, child_nd); current.Nodes.Add(treeview_child); } return(current); }