コード例 #1
0
        void LoadEntityIntoScene(FileInfo modelFile)
        {
            string    path      = modelFile.FullName;
            ModelPack modelPack = caches.GetModel(path);

            foreach (var tex in modelPack.textures)
            {
                caches.PreloadTexture(tex);
            }
            if (modelPack.pmx != null)
            {
                GameObject gameObject = new GameObject();
                gameObject.LoadPmx(modelPack);
                scene.AddGameObject(gameObject);
            }
            else
            {
                GameObject gameObject = new GameObject();
                gameObject.Name = Path.GetFileNameWithoutExtension(path);
                modelPack.LoadMeshComponent(gameObject);
                scene.AddGameObject(gameObject);
            }
            gameDriverContext.RequireRender(false);
        }
コード例 #2
0
ファイル: Coocoo3DScene.cs プロジェクト: sselecirPyM/Coocoo3D
        public void ToScene(Scene currentScene, MainCaches caches)
        {
            foreach (var obj in objects)
            {
                GameObject gameObject = GetGameObject(obj);
                if (obj.type == "mmdModel")
                {
                    string    pmxPath   = obj.path;
                    ModelPack modelPack = caches.GetModel(pmxPath);

                    gameObject.LoadPmx(modelPack);
                    var renderer       = gameObject.GetComponent <MMDRendererComponent>();
                    var animationState = gameObject.GetComponent <AnimationStateComponent>();
                    if (obj.skinning != null)
                    {
                        renderer.skinning = (bool)obj.skinning;
                    }
                    if (obj.enableIK != null)
                    {
                        renderer.enableIK = (bool)obj.enableIK;
                    }
                    if (obj.properties != null)
                    {
                        if (obj.properties.TryGetValue("motion", out string motion))
                        {
                            animationState.motionPath = motion;
                        }
                    }
                    if (obj.materials != null)
                    {
                        Mat2Mat(obj.materials, renderer.Materials);
                    }
                    currentScene.AddGameObject(gameObject);
                }
                else if (obj.type == "model")
                {
                    string    path      = obj.path;
                    ModelPack modelPack = caches.GetModel(path);

                    modelPack.LoadMeshComponent(gameObject);
                    var renderer = gameObject.GetComponent <MeshRendererComponent>();

                    if (obj.materials != null)
                    {
                        Mat2Mat(obj.materials, renderer.Materials);
                    }
                    currentScene.AddGameObject(gameObject);
                }
                else
                {
                    Caprice.Display.UIShowType uiShowType = default;
                    switch (obj.type)
                    {
                    case "lighting":
                        uiShowType = Caprice.Display.UIShowType.Light;
                        break;

                    case "decal":
                        uiShowType = Caprice.Display.UIShowType.Decal;
                        break;

                    case "particle":
                        uiShowType = Caprice.Display.UIShowType.Particle;
                        break;

                    default:
                        continue;
                    }
                    VisualComponent component = new VisualComponent();
                    component.UIShowType = uiShowType;
                    gameObject.AddComponent(component);
                    if (obj.visual != null)
                    {
                        component.material = Mat2Mat(obj.visual.material);
                    }
                    currentScene.AddGameObject(gameObject);
                }
            }
        }