// Initialize _model. private void BuildSceneGraph() { var root = BuildSceneGraph(_input, null); if (root == null) { // Just for safety. (Should not occur in practice.) throw new InvalidOperationException("Invalid root node."); } _model = new DRModelNodeContent(); // In most cases the root node is an empty node, which can be ignored. if (root.GetType() == typeof(DRSceneNodeContent) && root.PoseLocal == Pose.Identity && root.ScaleLocal == Vector3F.One && root.UserData == null) { // Throw away root, only use children. if (root.Children != null) { _model.Children = root.Children; foreach (var child in _model.Children) { child.Parent = _model; } } } else { _model.Children = new List <DRSceneNodeContent> { root }; root.Parent = _model; } // Go through scene graph and update PoseWorld from the root to the leaves. _model.PoseWorld = _model.PoseLocal; foreach (var node in _model.GetDescendants()) { node.PoseWorld = node.Parent.PoseWorld * node.PoseLocal; } }
// Initialize _model. private void BuildSceneGraph() { var root = BuildSceneGraph(_input, null); if (root == null) { // Just for safety. (Should not occur in practice.) throw new InvalidOperationException("Invalid root node."); } _model = new DRModelNodeContent(); // In most cases the root node is an empty node, which can be ignored. if (root.GetType() == typeof(DRSceneNodeContent) && root.PoseLocal == Pose.Identity && root.ScaleLocal == Vector3F.One && root.UserData == null) { // Throw away root, only use children. if (root.Children != null) { _model.Children = root.Children; foreach (var child in _model.Children) child.Parent = _model; } } else { _model.Children = new List<DRSceneNodeContent> { root }; root.Parent = _model; } // Go through scene graph and update PoseWorld from the root to the leaves. _model.PoseWorld = _model.PoseLocal; foreach (var node in _model.GetDescendants()) node.PoseWorld = node.Parent.PoseWorld * node.PoseLocal; }