当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.NodeContent类代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Content.Pipeline.Graphics.NodeContent的典型用法代码示例。如果您正苦于以下问题:C# NodeContent类的具体用法?C# NodeContent怎么用?C# NodeContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NodeContent类属于Microsoft.Xna.Framework.Content.Pipeline.Graphics命名空间,在下文中一共展示了NodeContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StoreEffectTechniqueInMeshName

        /// <summary>
        /// Stores the current selected technique and if the texture uses alpha
        /// into the mesh name for each mesh part.
        /// </summary>
        private void StoreEffectTechniqueInMeshName(
			NodeContent input, ContentProcessorContext context)
        {
            MeshContent mesh = input as MeshContent;
            if (mesh != null)
            {
                foreach (GeometryContent geom in mesh.Geometry)
                {
                    EffectMaterialContent effectMaterial = geom.Material as EffectMaterialContent;
                    if (effectMaterial != null)
                    {
                        if (effectMaterial.OpaqueData.ContainsKey("technique"))
                        {
                            // Store technique here! (OpaqueData["technique"] is an int32)
                            input.Name = input.Name + effectMaterial.OpaqueData["technique"];
                        } // if
                    } // if
                } // foreach
            } // if

            // Go through all childs
            foreach (NodeContent child in input.Children)
            {
                StoreEffectTechniqueInMeshName(child, context);
            } // foreach
        }
开发者ID:kiichi7,项目名称:SpeedyRacerContentAndSourceCode,代码行数:30,代码来源:XnaGraphicEngineModelProcessor.cs

示例2: Process

        public override ModelContent Process(NodeContent input, ContentProcessorContext context)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            //we always want to generate tangent frames, as we use tangent space normal mapping
            GenerateTangentFrames = true;

            //merge transforms
            MeshHelper.TransformScene(input, input.Transform);
            input.Transform = Matrix.Identity;

            if (!_isSkinned)
                MergeTransforms(input);

            ModelContent model = base.Process(input, context);
            //gather some information that will be useful in run time
            MeshMetadata metadata = new MeshMetadata();
            BoundingBox aabb = new BoundingBox();
            metadata.BoundingBox = ComputeBoundingBox(input, ref aabb, metadata);

            //assign it to our Tag
            model.Tag = metadata;
            return model;
        }
开发者ID:justshiv,项目名称:LightSavers,代码行数:26,代码来源:LightPrePassProcessor.cs

示例3: Process

 public override ModelContent Process(NodeContent input, ContentProcessorContext context)
 {
     model = base.Process(input, context);
     AnimationClips clips = ProcessAnimations(model, input, context);
     model.Tag = clips;
     return model;
 }
开发者ID:Kingofhearts102,项目名称:PrisonSteps,代码行数:7,代码来源:AnimationProcessor.cs

示例4: Process

 /// <summary>
 /// The main Process method converts an intermediate format content pipeline
 /// NodeContent tree to a ModelContent object with embedded animation data.
 /// </summary>
 public override ModelContent Process(NodeContent input, ContentProcessorContext context)
 {
     SkinningData skinningData = SkinningHelpers.GetSkinningData(input, context, SkinnedEffect.MaxBones);
     ModelContent model = base.Process(input, context);
     model.Tag = skinningData;
     return model;
 }
开发者ID:tykz,项目名称:xna-morijobi-win,代码行数:11,代码来源:GpuSkinnedModelProcessor.cs

示例5: Import

        public override TImport Import(string filename, ContentImporterContext context)
        {
            _context = context;

            // _animfiles will contain list of new temp anim files.
            _animfiles = new List<string>();

            // Decouple header and animation data.
            ExtractAnimations(filename);

            // Process master file (this will also process the first animation)
            _master = base.Import(filename, context);

            // Process the remaining animations.
            foreach (string file in _animfiles) {
                TImport anim = base.Import(file, context);

                // Append animation to master NodeContent.
                AppendAnimation(_master, anim);
            }

            // Delete the temporary animation files.
            DeleteTempFiles();

            return _master;
        }
开发者ID:dsmo7206,项目名称:Lemma,代码行数:26,代码来源:SkinnedModelImporter.cs

示例6: Process

        public override ModelContent Process(NodeContent input, ContentProcessorContext context)
        {
            ModelContent model = base.Process(input, context);

            //results will be stored in this collection
            List<Vector3> points = new List<Vector3>();

            //loop throught each mesh at the center of each of its bounding spheres
            foreach (ModelMeshContent mesh in model.Meshes)
            {
                //we will need to transform the center by the meshes parent bone atrix
                //if we don't they will all be at the same position
                Matrix transform;

                if (mesh.ParentBone.Transform != null)
                    transform = mesh.ParentBone.Transform;

                var p = Vector3.Transform(mesh.BoundingSphere.Center, mesh.ParentBone.Transform);

                //using the property above we can make decisions
                if (PreservePointHeight)
                    points.Add(p);
                else
                    points.Add(new Vector3(p.X,0,p.Z));

            }

            //we always store the additional data in the Tag property of the object
            model.Tag = points;

            return model;
        }
开发者ID:TalonTwist,项目名称:3DBraveChess,代码行数:32,代码来源:ContentProcessor1.cs

示例7: Process

        /// <summary>
        /// The main method in charge of processing the content.
        /// </summary>
        public override ModelContent Process(NodeContent input,
                                             ContentProcessorContext context)
        {
            // Chain to the base ModelProcessor class.
            ModelContent model = base.Process(input, context);

            // Look up the input vertex positions.
            FindVertices(input);

            // You can store any type of object in the model Tag property. This
            // sample only uses built-in types such as string, Vector3, BoundingSphere,
            // dictionaries, and arrays, which the content pipeline knows how to
            // serialize by default. We could also attach custom data types here, but
            // then we would have to provide a ContentTypeWriter and ContentTypeReader
            // implementation to tell the pipeline how to serialize our custom type.
            //
            // We are setting our model Tag to a dictionary that maps strings to
            // objects, and then storing two different kinds of custom data into that
            // dictionary. This is a useful pattern because it allows processors to
            // combine many different kinds of information inside the single Tag value.

            Dictionary<string, object> tagData = new Dictionary<string, object>();

            model.Tag = tagData;

            // Store vertex information in the tag data, as an array of Vector3.
            tagData.Add("Vertices", vertices.ToArray());

            // Also store a custom bounding sphere.
            tagData.Add("BoundingSphere", BoundingSphere.CreateFromPoints(vertices));

            return model;
        }
开发者ID:nguoihocnghe,项目名称:chessbreaklaw,代码行数:36,代码来源:ChessBreakLawProcessor.cs

示例8: CalculateBoundingBox

        public void CalculateBoundingBox(NodeContent node)
        {
            MeshContent mesh = node as MeshContent;

            if (mesh != null)
            {
                // calculating max and min points coordinates
                foreach (Vector3 vertex in mesh.Positions)
                {
                    if (vertex.X < minPoint.X) minPoint.X = vertex.X;
                    if (vertex.Y < minPoint.Y) minPoint.Y = vertex.Y;
                    if (vertex.Z < minPoint.Z) minPoint.Z = vertex.Z;

                    if (vertex.X > maxPoint.X) maxPoint.X = vertex.X;
                    if (vertex.Y > maxPoint.Y) maxPoint.Y = vertex.Y;
                    if (vertex.Z > maxPoint.Z) maxPoint.Z = vertex.Z;
                }
            }

            else
            {
                // calling the function recursively for all the children nodes
                foreach (NodeContent childNode in node.Children)
                {
                    this.CalculateBoundingBox(childNode);
                }
            }
        }
开发者ID:propheel,项目名称:Projects,代码行数:28,代码来源:BoundingBoxContentProcessor.cs

示例9: Process

        public override ModelContent Process(NodeContent input, ContentProcessorContext context)
        {
            ValidateMesh(input, context, null);
            BoneContent skeleton = MeshHelper.FindSkeleton(input);
            if (skeleton == null)
                throw new InvalidContentException("Input skeleton not found.");
            //Bakes everything
            FlattenTransforms(input, skeleton);
            //Read bind pse and skeleton hierarchy data.
            IList<BoneContent> bones = MeshHelper.FlattenSkeleton(skeleton);

            if (bones.Count > SkinnedEffect.MaxBones)
            {
                throw new InvalidContentException(string.Format("Skeleton has {0} bones, but the max is {1}.", bones.Count, SkinnedEffect.MaxBones));
            }
            List<Matrix> bindPose = new List<Matrix>();
            List<Matrix> inverseBindPose = new List<Matrix>();
            List<int> skeletonHierarchy = new List<int>();
            Dictionary<string, int> boneIndices = new Dictionary<string, int>();

            foreach (BoneContent bone in bones)
            {
                bindPose.Add(bone.Transform);
                inverseBindPose.Add(Matrix.Invert(bone.AbsoluteTransform));
                skeletonHierarchy.Add(bones.IndexOf(bone.Parent as BoneContent));
                boneIndices.Add(bone.Name, boneIndices.Count);
            }
            ModelContent model = base.Process(input, context);
            model.Tag = new SkinningDataStorage(bindPose, inverseBindPose, skeletonHierarchy, boneIndices);
            return model;
        }
开发者ID:DuxClarus,项目名称:Uat-Portfolio,代码行数:31,代码来源:SkinnedModelProcessor.cs

示例10: Process

 public override ModelContent Process(NodeContent input, 
                                      ContentProcessorContext context)
 {
     // Break up the mesh to separate triangles.
     NodeContent processedNode = ProcessMesh(input);
     return base.Process(processedNode, context);
 }
开发者ID:kmatzen,项目名称:EECS-494-Final-Project,代码行数:7,代码来源:ShatterProcessor.cs

示例11: Process

        /// <summary> 
        /// The main Process method converts an intermediate format content pipeline
        /// NodeContent tree to a ModelConte nt object with embedded animation data.
        /// </summary>
        public override ModelContent Process(NodeContent input, ContentProcessorContext context)
        {
            ValidateMesh(input, context, null);

            List<int> boneHierarchy = new List<int>();

            // Chain to the base ModelProcessor class so it can convert the model data.
            ModelContent model = base.Process(input, context);

            // Add each of the bones
            foreach (ModelBoneContent bone in model.Bones)
            {
                boneHierarchy.Add(model.Bones.IndexOf(bone.Parent as ModelBoneContent));
            }

            // Animation clips inside the object (mesh)
            Dictionary<string, ModelAnimationClip> animationClips = new Dictionary<string, ModelAnimationClip>();

            // Animation clips at the root of the object
            Dictionary<string, ModelAnimationClip> rootClips = new Dictionary<string, ModelAnimationClip>();

            // Process the animations
            ProcessAnimations(input, model, animationClips, rootClips);

            // Store the data for the model
            model.Tag = new ModelData(animationClips, rootClips, null, null, boneHierarchy);

            return model;
        }
开发者ID:richsta,项目名称:3D-Game-Pandemonium,代码行数:33,代码来源:AnimatedModelProcessor.cs

示例12: FindVertices

        /// <summary>
        /// Helper for extracting a list of all the vertex positions in a model.
        /// </summary>
        void FindVertices(NodeContent node)
        {
            // Is this node a mesh?
            MeshContent mesh = node as MeshContent;

            if (mesh != null)
            {
                // Look up the absolute transform of the mesh.
                //Matrix absoluteTransform = mesh.AbsoluteTransform;

                // Loop over all the pieces of geometry in the mesh.
                foreach (GeometryContent geometry in mesh.Geometry)
                {
                    // Loop over all the indices in this piece of geometry.
                    // Every group of three indices represents one triangle.
                    foreach (int index in geometry.Indices)
                    {
                        // Look up the position of this vertex.
                        Vector3 vertex = geometry.Vertices.Positions[index];

                        // Transform from local into world space.
                        //vertex = Vector3.Transform(vertex, absoluteTransform);

                        // Store this vertex.
                        vertices.Add(vertex);
                    }
                }
            }

            // Recursively scan over the children of this node.
            foreach (NodeContent child in node.Children)
            {
                FindVertices(child);
            }
        }
开发者ID:sp-alex-osou,项目名称:Shaders,代码行数:38,代码来源:TrianglePickingProcessor.cs

示例13: AddVerticesToList

        private List<Triangle> AddVerticesToList(NodeContent node, List<Triangle> triangleList)
        {
            MeshContent mesh = node as MeshContent;
            if (mesh != null)
            {
                Matrix abstransform = mesh.AbsoluteTransform;

                foreach (GeometryContent geo in mesh.Geometry)
                {
                    int triangles = geo.Indices.Count / 3;
                    for (int currentTriangle = 0; currentTriangle < triangles; ++currentTriangle)
                    {
                        int index0 = geo.Indices[currentTriangle * 3 + 0];
                        int index1 = geo.Indices[currentTriangle * 3 + 1];
                        int index2 = geo.Indices[currentTriangle * 3 + 2];

                        Vector3 v0 = geo.Vertices.Positions[index0];
                        Vector3 v1 = geo.Vertices.Positions[index1];
                        Vector3 v2 = geo.Vertices.Positions[index2];

                        Vector3 transv0 = Vector3.Transform(v0, abstransform);
                        Vector3 transv1 = Vector3.Transform(v1, abstransform);
                        Vector3 transv2 = Vector3.Transform(v2, abstransform);

                        Triangle newTriangle = new Triangle(transv0, transv1, transv2);
                        triangleList.Add(newTriangle);
                    }
                }
            }

            foreach (NodeContent child in node.Children)
                triangleList = AddVerticesToList(child, triangleList);

            return triangleList;
        }
开发者ID:bradleat,项目名称:trafps,代码行数:35,代码来源:TriangleProcessor.cs

示例14: Process

        /// <summary>
        /// The main Process method converts an intermediate format content pipeline
        /// NodeContent tree to a ModelContent object with embedded animation data.
        /// </summary>
        public override ModelContent Process(NodeContent input, ContentProcessorContext context)
        {
            contentPath = Environment.CurrentDirectory;

            using (XmlReader reader = XmlReader.Create(MaterialDataFilePath))
            {
                incomingMaterials = IntermediateSerializer.Deserialize<List<MaterialData>>(reader, null);
            }
            context.AddDependency(Path.Combine(Environment.CurrentDirectory, MaterialDataFilePath));

            // Chain to the base ModelProcessor class so it can convert the model data.
            ModelContent model = base.Process(input, context);

            // Put the material's flags into the ModelMeshPartContent's Tag property.
            foreach (ModelMeshContent mmc in model.Meshes)
            {
                foreach (ModelMeshPartContent mmpc in mmc.MeshParts)
                {
                    MaterialData mat = incomingMaterials.Single(m => m.Name == mmpc.Material.Name);
                    MaterialInfo extraInfo = new MaterialInfo();
                    extraInfo.HandlingFlags = mat.HandlingFlags;
                    extraInfo.RenderState = mat.RenderState;
                    mmpc.Tag = extraInfo;
                }
            }

            return model;
        }
开发者ID:Tengato,项目名称:Mechadrone1,代码行数:32,代码来源:SimpleModelProcessor.cs

示例15: Process

        /// <summary>
        /// The main Process method converts an intermediate format content pipeline
        /// NodeContent tree to a ModelContent object with embedded animation data.
        /// </summary>
        public override ModelContent Process(NodeContent input,
            ContentProcessorContext context)
        {
            ValidateMesh(input, context, null);

            // Find the skeleton.
            BoneContent skeleton = MeshHelper.FindSkeleton(input);

            if (skeleton == null)
                throw new InvalidContentException("Input skeleton not found.");

            // We don't want to have to worry about different parts of the model being
            // in different local coordinate systems, so let's just bake everything.
            FlattenTransforms(input, skeleton);

            // Read the bind pose and skeleton hierarchy data.
            IList<BoneContent> bones = MeshHelper.FlattenSkeleton(skeleton);

            if (bones.Count > SkinnedEffect.MaxBones)
            {
                throw new InvalidContentException(string.Format(
                    "Skeleton has {0} bones, but the maximum supported is {1}.",
                    bones.Count, SkinnedEffect.MaxBones));
            }

            List<Matrix> bindPose = new List<Matrix>();
            List<Matrix> inverseBindPose = new List<Matrix>();
            List<int> skeletonHierarchy = new List<int>();
            #region BaamStudios XnaMixamoImporter Change
            List<string> boneNames = new List<string>();
            #endregion

            foreach (BoneContent bone in bones)
            {
                bindPose.Add(bone.Transform);
                inverseBindPose.Add(Matrix.Invert(bone.AbsoluteTransform));
                skeletonHierarchy.Add(bones.IndexOf(bone.Parent as BoneContent));
                #region BaamStudios XnaMixamoImporter Change
                boneNames.Add(bone.Name);
                #endregion
            }

            // Convert animation data to our runtime format.
            Dictionary<string, AnimationClip> animationClips;
            animationClips = ProcessAnimations(skeleton.Animations, bones);

            // Chain to the base ModelProcessor class so it can convert the model data.
            ModelContent model = base.Process(input, context);

            // Store our custom animation data in the Tag property of the model.
            model.Tag = new SkinningData(animationClips, bindPose,
                                         inverseBindPose, skeletonHierarchy
            #region BaamStudios XnaMixamoImporter Change
                , boneNames
            #endregion
                                         );

            return model;
        }
开发者ID:BaamStudios,项目名称:XnaMixamoImporter,代码行数:63,代码来源:SkinnedModelProcessor.cs


注:本文中的Microsoft.Xna.Framework.Content.Pipeline.Graphics.NodeContent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。