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


C# GraphicFactory.GetModel方法代码示例

本文整理汇总了C#中GraphicFactory.GetModel方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicFactory.GetModel方法的具体用法?C# GraphicFactory.GetModel怎么用?C# GraphicFactory.GetModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicFactory的用法示例。


在下文中一共展示了GraphicFactory.GetModel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadModel

 protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformation)
 {
     model = factory.GetModel(this.Name, isInternal, forceFromDisk);
     ModelBuilderHelper.Extract(factory,out BatchInformations, out TextureInformation,model,_diffuseName,_bumpName,_specularName,_glowName,isInternal);            
     
     BoundingSphere sphere = new BoundingSphere();
     foreach (var item in model.Meshes)
     {
         sphere = BoundingSphere.CreateMerged(sphere, item.BoundingSphere);
     }
     modelRadius = sphere.Radius;         
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:12,代码来源:SimpleModel.cs

示例2: Load


//.........这里部分代码省略.........
                {
                    String name = SerializerHelper.DeserializeAttributeBaseType<String>("name", node);
                    Vector3 pos = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    DummyInfo di = new DummyInfo();
                    di.Name = name;
                    di.Position = pos;
                    elements.DummyInfo.Add(di);
                }
            }

            ///////PROCCESS LIGHTS /////////////////////
            foreach (var item in spotLights)
            {
                SpotLightInformation si = item.Value;
                targetInfo ti = targets[item.Key + ".Target"];
                SpotLightPE sl = new SpotLightPE(si.pos, Vector3.Normalize(ti.targetPos - si.pos), si.color,si.decay, (ti.targetPos - si.pos).Length() * 10f, (float)Math.Cos(si.angle / 2), si.multiplier);
                sl.CastShadown = si.castShadow;
                sl.Name = si.name;
                elements.LightsInfo.Add(sl);

            }

            ///////PROCCESS CAMERAS/////////////////////
            foreach (var item in cameras)
            {
                CameraInfo ci = item.Value;
                targetInfo ti = targets[item.Key + ".Target"];
                ci.Target = ti.targetPos;
                elements.CameraInfo.Add(ci);
            }


            Model model = factory.GetModel(modelPath + Name);
            modelNames.Add(modelPath + Name);
            Matrix[] m = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(m);

            ////////////EXTRAINDO MESHES
            for (int i = 0; i < model.Meshes.Count; i++)
            {
                String name = model.Meshes[i].Name.Substring(5);
                if (infos.ContainsKey(name))
                {

                    for (int j = 0; j < model.Meshes[i].MeshParts.Count; j++)
                    {
                        XmlModelMeshInfo inf = infos[name];
                        Matrix tr = m[model.Meshes[i].ParentBone.Index];

                        Vector3 scale;
                        Vector3 pos;
                        Quaternion ori;
                        tr.Decompose(out scale, out ori, out pos);

                        ObjectInformation mi = new ObjectInformation();
                        mi.modelName = inf.modelName;
                        mi.meshPartIndex = j;
                        mi.meshIndex = i;
                        mi.position = pos;
                        mi.scale = scale;
                        mi.rotation = ori;
                        
                        ModelBuilderHelper.Extract(m, model.Meshes[i].MeshParts[j], out mi.batchInformation);
                        mi.ellasticity = inf.ellasticity;
                        mi.dinamicfriction = inf.dinamicfriction;
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:67,代码来源:ExtractXmlModelLoader.cs

示例3: ClothModel

        public ClothModel(GraphicFactory factory, PhysxPhysicWorld PhysxPhysicWorld, ClothMeshDescription clothMeshDesc,
            String ModelName,XNA.Vector3 scale,
            String diffuseTextureName = null)
            : base(factory, ModelName, false)
        {
            this._diffuseName = diffuseTextureName;
            Model model = factory.GetModel(ModelName);
            SimpleModel SimpleModel = new Modelo.SimpleModel(factory, ModelName,null,null,null,null,false);

            Vector3[] verts = null;
            Vector2[] tex = null;
            int[] inds = null;
            ExtractData(ref verts, ref inds, ref tex, SimpleModel,scale);
            SimpleModel.CleanUp(factory);

            VerticesNum = verts.Length;
            IndicesNum = inds.Length;

            clothMeshDesc.AllocateVertices<Vector3>(VerticesNum);
            clothMeshDesc.AllocateTriangles<int>(IndicesNum / 3);

            clothMeshDesc.VertexCount = VerticesNum;
            clothMeshDesc.TriangleCount = IndicesNum / 3;            

            BatchInformation = new PloobsEngine.Modelo.BatchInformation(0, VerticesNum, IndicesNum / 3, 0, 0,
                VertexPositionNormalTexture.VertexDeclaration, VertexPositionNormalTexture.VertexDeclaration.VertexStride, PrimitiveType.TriangleList);
            BatchInformation.ModelLocalTransformation = XNA.Matrix.Identity;

            vertexPositionNormalTexture = new VertexPositionNormalTexture[VerticesNum];

            BatchInformation.VertexBuffer = factory.CreateDynamicVertexBuffer(VertexPositionNormalTexture.VertexDeclaration, VerticesNum + (int)(1.2 * VerticesNum), BufferUsage.WriteOnly);
            BatchInformation.IndexBuffer = factory.CreateDynamicIndexBuffer(IndexElementSize.ThirtyTwoBits, IndicesNum + (int)(1.2 * IndicesNum), BufferUsage.WriteOnly);

            BatchInformation.IndexBuffer.SetData<int>(inds);
            clothMeshDesc.VerticesStream.SetData(verts);
            clothMeshDesc.TriangleStream.SetData(inds);


            XNA.Vector3[] pts = new XNA.Vector3[BatchInformation.NumVertices];
            for (int i = 0; i < BatchInformation.NumVertices; i++)
            {
                vertexPositionNormalTexture[i].TextureCoordinate = tex[i].AsXNA();
                vertexPositionNormalTexture[i].Position = verts[i].AsXNA();
                pts[i] = vertexPositionNormalTexture[i].Position;
            }

            modelRadius = Microsoft.Xna.Framework.BoundingSphere.CreateFromPoints(pts).Radius;
            pts = null;


            // We are using 32 bit integers for our indices, so make sure the 16 bit flag is removed.
            // 32 bits are the default, so this isn't technically needed, but it's good to show in a sample
            clothMeshDesc.Flags &= ~MeshFlag.Indices16Bit;
            //clothMeshDesc.Flags |= (MeshFlag)((int)clothMeshDesc.Flags | (int)ClothMeshFlag.Tearable);

            // Write the cooked data to memory
            using (var memoryStream = new MemoryStream())
            {
                Cooking.InitializeCooking();
                Cooking.CookClothMesh(clothMeshDesc, memoryStream);
                Cooking.CloseCooking();

                // Need to reset the position of the stream to the beginning
                memoryStream.Position = 0;

                ClothMesh = PhysxPhysicWorld.Core.CreateClothMesh(memoryStream);
            }


            LoadModel(factory, out BatchInformations, out TextureInformations);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:71,代码来源:ClothModel.cs

示例4: LoadModel

        /// <summary>
        /// Loads the model.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="BatchInformations">The batch informations.</param>
        /// <param name="TextureInformations">The texture informations.</param>
        protected override void LoadModel(GraphicFactory factory, out BatchInformation[][] BatchInformations, out TextureInformation[][] TextureInformations)
        {
            //code not called !!!
            //Here for future usage.

            model = factory.GetModel(this.Name, isInternal);
            ModelBuilderHelper.Extract(model, out BatchInformations);
            
            BoundingSphere sphere = new BoundingSphere();
            foreach (var item in model.Meshes)
            {
                BoundingSphere.CreateMerged(sphere, item.BoundingSphere);
            }
            modelRadius = sphere.Radius;

            TextureInformations = new TextureInformation[1][];
            TextureInformations[0] = new TextureInformation[1];
            TextureInformations[0][0] = new TextureInformation(isInternal, factory);
            TextureInformations[0][0].LoadTexture();
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:26,代码来源:CustomModel.cs

示例5: Extract

 public static void Extract(GraphicFactory factory, out BatchInformation[][] batchInformationS, out TextureInformation[][] textureInformationS, string modelName, String diffuseName = null, String bumpName = null, string specularName = null, String glowName = null, bool isinternal = false)
 {
     Model model = factory.GetModel(modelName, isinternal);
     Extract(factory, out batchInformationS, out textureInformationS, model, diffuseName, bumpName, specularName, glowName, isinternal);
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:5,代码来源:ModelBuilderHelper.cs


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