Пример #1
0
        public static NMSModel Read(string fname)
        {
            var model = new NMSModel();

            using (var fs = File.OpenRead(fname))
            {
                using (var handle = new BinaryReader(fs))
                {
                    model.Read(handle);
                }
            }

            return(model);
        }
Пример #2
0
        public bool LoadModel(string FileName)
        {
            if (!File.Exists(FileName))
            {
                return(false);
            }

            Console.WriteLine("Loading {0}...", Path.GetFileNameWithoutExtension(FileName));

            var model = NMSModel.Read(FileName);

            model.PrintStats();

            var Desc = RasterizerStateDescription.Default;

            Desc.CullMode = CullMode.None;

            var entity = CreateCustomMeshModel(
                GraphicsDevice,
                model.ToXenkoVertices(),
                model.Indices.ToArray(),
                PrimitiveType.TriangleList,
                Desc,
                Asset.Load <Material>("Sphere Material"),
                Vector3.Zero,
                Quaternion.Identity,
                false);

            EntityAddQueue.Enqueue(entity);

            Console.WriteLine("OK");

            if (OnModelLoaded != null)
            {
                OnModelLoaded(model, entity, FileName);
            }

            return(true);
        }