예제 #1
0
        private MagmaModelContent ProcessFileWithSeparateCollisionMesh(
            NodeContent input,
            ContentProcessorContext context,
            string collisionMeshFilename
            )
        {
#if DEBUG
            context.Logger.LogImportantMessage("  processing file using a separate collision mesh");
            context.Logger.LogImportantMessage("  using '" + collisionMeshFilename + "' as collision mesh");
#endif

            NodeContent collisionMeshContent = collisionMeshContent = context.BuildAndLoadAsset <NodeContent, NodeContent>(
                new ExternalReference <NodeContent>(collisionMeshFilename), null);

            // calculate bounds because changes are based on the bounding box
            AlignedBox3 boundingBox = CalculateAlignedBox3(input, context, true);

            TransformMeshes(new NodeContent[] { input, collisionMeshContent }, context, ref boundingBox);

            // let the base class process the model
            MagmaModelContent modelContent = BaseProcessing(input, context);

            // add bounding volumes to the model
            modelContent.VolumeCollection = CalculateCollisionVolumes(new NodeContent[] { collisionMeshContent }, context);

            return(modelContent);
        }
예제 #2
0
        private MagmaModelContent BaseProcessing(
            NodeContent input,
            ContentProcessorContext context
            )
        {
            BaseClass baseClass = new BaseClass();

            MagmaModelContent content = new MagmaModelContent();

            content.XnaModel = baseClass.Process(input, context);

            return(content);
        }
예제 #3
0
        private MagmaModelContent ProcessLegacyFile(
            NodeContent input,
            ContentProcessorContext context
            )
        {
            context.Logger.LogWarning(null, input.Identity, "processing legacy file using the graphical mesh as collision mesh");

            // calculate bounds because changes are based on the bounding box
            AlignedBox3 bb = CalculateAlignedBox3(input, context, false);

            TransformMeshes(new NodeContent[] { input }, context, ref bb);

            // let the base class process the model
            MagmaModelContent modelContent = BaseProcessing(input, context);

            // add bounding volumes to the model
            modelContent.VolumeCollection = CalculateCollisionVolumes(new NodeContent[] { input }, context);

            return(modelContent);
        }
예제 #4
0
        private MagmaModelContent ProcessContainerGroup(
            NodeContent input,
            ContentProcessorContext context
            )
        {
#if DEBUG
            context.Logger.LogImportantMessage("  processing one group contained in a model container");
#endif

            // find the child to process!
            NodeContent currentGroupNode = GetChild(input, CurrentGroup);
            Debug.Assert(currentGroupNode != null);
            if (currentGroupNode == null)
            {
                throw new ArgumentException(string.Format("unable to find referenced child ({0})!", CurrentGroup));
            }

            input.Children.Clear();
            input.Children.Add(currentGroupNode);

            // copy the identity
            //currentGroupNode.Identity = input.Identity;

            // calculate bounds because changes are based on the bounding box
            AlignedBox3 bb = CalculateAlignedBox3(input, context, true);

            // transform the graphical mesh and the collision meshes in one step!
            TransformMeshes(new NodeContent[] { input }, context, ref bb);

            // extract all collision meshes
            List <NodeContent> collisionNodes = new List <NodeContent>();
            foreach (NodeContent child in currentGroupNode.Children)
            {
                if (IsCollisionNode(child))
                {
                    collisionNodes.Add(child);
                }
            }
            foreach (NodeContent collisionMesh in collisionNodes)
            {
#if DEBUG
                context.Logger.LogImportantMessage("  using {0} as a collision fragment", collisionMesh.Name);
#endif
                currentGroupNode.Children.Remove(collisionMesh);
            }

            // let the base class process the graphical model
            MagmaModelContent modelContent = BaseProcessing(input, context);

            // now we process our collision meshes...
            // TODO: take all collision meshes not only the first one!
            VolumeCollection collection = new VolumeCollection();

            if (collisionNodes.Count == 0)
            {
                context.Logger.LogWarning(null, input.Identity, "unable to find a collision mesh in group {0}", CurrentGroup);
                modelContent.VolumeCollection = CalculateCollisionVolumes(new NodeContent[] { input }, context);
            }
            else
            {
                NodeContent[] collisionNodesArray = new NodeContent[collisionNodes.Count];
                for (int i = 0; i < collisionNodes.Count; ++i)
                {
                    collisionNodesArray[i] = collisionNodes[i];
                }
                modelContent.VolumeCollection = CalculateCollisionVolumes(collisionNodesArray, context);
            }

            return(modelContent);
        }