private static void AddMorphTarget(DRSceneNodeContent sceneNode, MeshContent morphTarget) { var meshNode = sceneNode as DRMeshNodeContent; if (meshNode == null) { string message = String.Format( CultureInfo.InvariantCulture, "Morph target \"{0}\" needs to be a child of the base mesh.", morphTarget.Name); throw new InvalidContentException(message, morphTarget.Identity); } if (meshNode.InputMorphTargets == null) { meshNode.InputMorphTargets = new List <MeshContent>(); } meshNode.InputMorphTargets.Add(morphTarget); }
public int Compare(DRSceneNodeContent x, DRSceneNodeContent y) { if (x.LodDistance < y.LodDistance) { return(-1); } if (x.LodDistance > y.LodDistance) { return(+1); } if (x.LodLevel < y.LodLevel) { return(-1); } if (x.LodLevel > y.LodLevel) { return(+1); } return(0); }
private static DRSceneNodeContent BuildSceneGraph(NodeContent node, DRSceneNodeContent parent) { CheckForCyclicReferences(node); DRSceneNodeContent sceneNode; if (node is BoneContent) { // ----- BoneContent // Bones do not show up in the scene graph. sceneNode = null; } else if (node is MeshContent) { // ----- MeshContent var mesh = (MeshContent)node; string morphTargetName; if (ContentHelper.IsMorphTarget(mesh, out morphTargetName)) { // ----- Morph Targets // Morph targets are stored in the parent mesh, they do not show up in // the scene graph. Children of morph targets are ignored! mesh.Name = morphTargetName; AddMorphTarget(parent, mesh); sceneNode = null; } else if (ContentHelper.IsOccluder(mesh)) { // ----- OccluderNode sceneNode = new DROccluderNodeContent { InputMesh = mesh }; } else { // ----- MeshNode sceneNode = new DRMeshNodeContent { InputMesh = mesh }; } } else { // ----- Empty/unsupported node sceneNode = new DRSceneNodeContent(); } if (sceneNode != null) { sceneNode.Name = node.Name; Pose pose; Vector3 scale; DecomposeTransform(node, out pose, out scale); sceneNode.PoseLocal = pose; sceneNode.ScaleLocal = scale; if (node.Children.Count > 0) { // Process children. sceneNode.Children = new List <DRSceneNodeContent>(); // Recursively add children. foreach (var childNode in node.Children) { var childSceneNode = BuildSceneGraph(childNode, sceneNode); if (childSceneNode != null) { childSceneNode.Parent = sceneNode; sceneNode.Children.Add(childSceneNode); } } } } return(sceneNode); }