Beispiel #1
0
        public static MonoGameDeviceContent <MonoGameModelTemplate> CreateDeviceModel(GraphicsDevice device, Schema2.ModelRoot srcModel, LoaderContext context = null)
        {
            if (context == null)
            {
                context = new BasicEffectsLoaderContext(device);
            }

            context.Reset();

            var templates = srcModel.LogicalScenes
                            .Select(item => SceneTemplate.Create(item, true))
                            .ToArray();

            var srcMeshes = templates
                            .SelectMany(item => item.LogicalMeshIds)
                            .Distinct()
                            .Select(idx => srcModel.LogicalMeshes[idx]);

            foreach (var srcMesh in srcMeshes)
            {
                context._WriteMesh(srcMesh);
            }

            var dstMeshes = context.CreateRuntimeModels();

            var mdl = new MonoGameModelTemplate(templates, srcModel.DefaultScene.LogicalIndex, dstMeshes);

            return(new MonoGameDeviceContent <MonoGameModelTemplate>(mdl, context.Disposables.ToArray()));
        }
Beispiel #2
0
        public static MonoGameDeviceContent <MonoGameModelTemplate> LoadDeviceModel(GraphicsDevice device, string filePath, LoaderContext context = null)
        {
            var model = Schema2.ModelRoot.Load(filePath, Validation.ValidationMode.TryFix);

            return(CreateDeviceModel(device, model, context));
        }