예제 #1
0
        void LoadModels()
        {
            /*
             * var build = ResourcesManager.LoadAsset<SceneNode>(@"Assets\Models\School1F\School.pmx");
             * if (build)
             * {
             *  build.Name = "School1F";
             *  CoreEngine.MainScene.AddNode2Root(build);
             *  var serviceData = new ReaderDAE(@"Assets\Models\School1F\School.dae");
             *  meshData = serviceData.GetMeshes();
             *  NavigationMesh.Instalize(meshData[0].vertices, meshData[0].indeces);
             *
             *  /*
             *  //test NavMap draw
             *  Mesh mesh = new Mesh(meshData[0].vertices, meshData[0].indeces);
             *  Materials = new Material[meshData[0].indeces.Length / 3];
             *  var shdrst = new ShaderSettings();
             *  shdrst.Ambient = true;
             *  for (int i = 0; i < Materials.Length; i++)
             *  {
             *      Materials[i] = new MaterialPMX(shdrst, new RenderDirectives());
             *      Materials[i].Offset = i * 3;
             *      Materials[i].Count = 3;
             *  }
             *  MeshDrawer md = new MeshDrawer(mesh, Materials);
             *  Node.AddComponent(md);
             */
            //Load Collision Mesh

            /*
             * Vector3[] verts = new Vector3[meshData[1].vertices.Length];
             * for (int i = 0; i < verts.Length; i++)
             * {
             *  verts[i] = meshData[1].vertices[i].Position;
             * }
             * CoreEngine.pEngine.SetScene(verts, meshData[1].indeces, build.GetTransform.GlobalTransform);
             *
             * }
             */

            //var build = ResourcesManager.LoadAsset<SceneNode>(@"Assets\Models\Home\house.dae");
            //if (build)
            //{
            //  build.Name = "Home";
            // CoreEngine.MainScene.AddNode2Root(build);
            //var serviceData = new ReaderDAE(@"Assets\Models\School1F\School.dae");
            //meshData = serviceData.GetMeshes();
            //NavigationMesh.Instalize(meshData[0].vertices, meshData[0].indeces);

            /*
             * //test NavMap draw
             * Mesh mesh = new Mesh(meshData[0].vertices, meshData[0].indeces);
             * Materials = new Material[meshData[0].indeces.Length / 3];
             * var shdrst = new ShaderSettings();
             * shdrst.Ambient = true;
             * for (int i = 0; i < Materials.Length; i++)
             * {
             *  Materials[i] = new MaterialPMX(shdrst, new RenderDirectives());
             *  Materials[i].Offset = i * 3;
             *  Materials[i].Count = 3;
             * }
             * MeshDrawer md = new MeshDrawer(mesh, Materials);
             * Node.AddComponent(md);
             */
            //Load Collision Mesh

            /*
             * Vector3[] verts = new Vector3[meshData[1].vertices.Length];
             * for (int i = 0; i < verts.Length; i++)
             * {
             *  verts[i] = meshData[1].vertices[i].Position;
             * }
             * CoreEngine.pEngine.SetScene(verts, meshData[1].indeces, build.GetTransform.GlobalTransform);
             */
            //}

            var model1 = ResourcesManager.LoadAsset <ModelPrefab>(@"Assets\Models\Michelle\Seifuku.pmx").CreateNode();

            if (model1)
            {
                model1.Name = "Michelle.Seifuku";
                model1.GetTransform.Position           = Vector3.UnitZ * 0.5f;
                model1.GetTransform.RotationQuaternion = new Quaternion(0, MathF.PI, 0);
                CoreEngine.MainScene.AddNode2Root(model1);
                //var manager = model1.GetComponent<PhysicsManager>();
                model1.AddComponent <NpcAI>();
                cc = model1.AddComponent <NPCNavigationController>();
                //cc.Materials = Materials;

                var anim = model1.GetComponent <Animator>();
                bc = anim.BoneController;

                /*
                 * root.UpdateTransform();
                 * var scale = Matrix4.CreateOrthographic(800,600, -1,1);
                 * var model = rect.GlobalTransform;// * Matrix4.CreateScale(1 / (float)CoreEngine.GetCamera.Width, 1 / (float)CoreEngine.GetCamera.Height, 1);
                 *
                 *
                 * Vector4 pos = model * new Vector4(1, 1, 0, 1);
                 * Console.WriteLine(model);
                 * //pos.X /= 800;
                 * //pos.Y /= 600;
                 * Console.WriteLine(scale * pos);
                 *
                 * Console.WriteLine(new Vector4(800, 300, 0, 1)* Matrix4.CreateTranslation(-400, -300, 0));
                 */
            }

            var build = ResourcesManager.LoadAsset <ModelPrefab>(@"Assets\Models\Home\house.dae").CreateNode();

            if (build)
            {
                build.Name = "Home";
                CoreEngine.MainScene.AddNode2Root(build);

                var serviceData = new ReaderDAE(@"Assets\Models\Home\house_add.dae");
                var meshData    = serviceData.GetMeshes();
                if (meshData.ContainsKey("NavMap"))
                {
                    NavigationMesh.Instalize(meshData["NavMap"].vertices, meshData["NavMap"].indeces);
                }

                if (meshData.ContainsKey("Phys"))
                {
                    Vector3[] verts = new Vector3[meshData["Phys"].vertices.Length];
                    for (int i = 0; i < verts.Length; i++)
                    {
                        verts[i] = meshData["Phys"].vertices[i].Position;
                    }
                    CoreEngine.pEngine.SetScene(verts, meshData["Phys"].indeces, build.GetTransform.GlobalTransform);
                }

                /*
                 * Mesh mesh = new Mesh(meshData[0].vertices, meshData[0].indeces);
                 * Materials = new Material[meshData[0].indeces.Length / 3];
                 * var shdrst = new ShaderSettings();
                 * shdrst.Ambient = true;
                 * for (int i = 0; i < Materials.Length; i++)
                 * {
                 *  Materials[i] = new MaterialPMX(shdrst, new RenderDirectives());
                 *  Materials[i].Offset = i * 3;
                 *  Materials[i].Count = 3;
                 * }
                 * MeshDrawer md = new MeshDrawer(mesh, Materials);
                 * Node.AddComponent(md);
                 */
            }

            /*
             * var model2 = ResourcesManager.LoadAsset<SceneNode>(@"Assets\Models\Hinata\Seifuku.pmx");
             * if (model2)
             * {
             *  model2.Name = "Hinata.Seifuku";
             *  model2.GetTransform.Position = -OpenTK.Vector3.UnitZ * 2;
             *  CoreEngine.MainScene.AddNode2Root(model2);
             *  model2.AddComponent<NpcAI>();
             *  //var src = ResourcesManager.LoadAsset<AudioSource>(@"Assets\Sound\hina.mp3");
             *  //model2.AddComponent(src);
             *  //src.Play();
             * }
             */
            //SceneSaveLoadSystem.Save2File("");

            LoadAssetLocations(@"Assets\Models\Home\house_assets.dae", build);
        }