protected override void OnLoad(EventArgs e) { base.OnLoad(e); WindowBorder = WindowBorder.Fixed; MMW.MainCamera.DebugDraw = true; var t = MMW.MainCamera.GameObject.Transform; t.Position = new Vector3(0.0f, 2.0f, -5.0f); t.Rotate.X = -0.3f; MMW.MainCamera.Near = 0.01f; MMW.MainCamera.Far = 100.0f; //MMW.MainCamera.GameObject.AddComponent<Blur>(20.0f, 2); var importer = new MqoImporter(); //var results = importer.Import(@"../../mqo/brick.mqo"); var results = importer.Import(@"C:\Users\yoship\Downloads\mqo\Old_Station\Old Station\Old_station.mqo", ImportType.Full); foreach (var tex in results[0].Textures) { tex.Load(); } foreach (var mesh in results[0].Meshes) { mesh.Load(); } foreach (var mat in results[0].Materials) { mat.Shader = MMW.GetAsset <Shader>("Test"); } var obj = new GameObject(results[0].Name, Matrix4.Identity, "mqo"); for (var i = 0; i < results[0].Meshes.Length; i++) { var mr = obj.AddComponent <MeshRenderer>(); mr.Mesh = results[0].Meshes[i]; for (var m = 0; m < mr.Mesh.SubMeshCount; m++) { var matIndex = mr.Mesh.GetMaterialIndex(m); mr.SetMaterial(matIndex, results[0].Materials[matIndex], true); } } obj.AddComponent <RotateTest>(); MMW.RegistGameObject(obj); var probj = new GameObject("Property Renderer") { Layer = 31 }; probj.AddComponent <PropertyRenderer>(); MMW.RegistGameObject(probj); }
private void CreateBoneObject(Transform parent, Bone[] children) { foreach (var c in children) { var obj = new GameObject(c.Name, Matrix4.Identity); //obj.Layer = GameObject.LayerUI; obj.Transform.Parent = parent; obj.Transform.WorldTransform = Matrix4.CreateTranslation(c.Position); obj.AddComponent <BoneVisibleTest>(c); if (c.Children != null) { CreateBoneObject(obj.Transform, c.Children); } MMW.RegistGameObject(obj); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); WindowBorder = WindowBorder.Fixed; MMW.MainCamera.DebugDraw = true; var t = MMW.MainCamera.GameObject.Transform; t.Position = new Vector3(1.0f, 2.0f, -20.0f); var rand = new Random(); for (var i = 0; i < 50; i++) { var x = rand.Next(20) - 10; var z = rand.Next(20) - 10; var y = rand.Next(3, 10); var b = new GameObject("Box" + i, Matrix4.CreateTranslation(x, y, z)); b.AddComponent <BoxCollider>(); var r = b.AddComponent <RigidBody>(); b.AddComponent <PhysicsTest>(); MMW.RegistGameObject(b); } { var plane = new GameObject("Plane", Matrix4.CreateTranslation(new Vector3(0.0f, -2.0f, 0.0f))); var planeMesh = Mesh.CreateSimplePlaneMesh(30.0f, 30.0f); var mr = plane.AddComponent <MeshRenderer>(planeMesh); var mat = new Material("Test", MMW.GetAsset <Shader>("Test")); mat.AddParam("diffuse", Color4.Gray); mr.SetMaterial(0, mat, false); plane.AddComponent <PlaneCollider>(30.0f, 30.0f); MMW.RegistGameObject(plane); } var probj = new GameObject("Property Renderer") { Layer = 31 }; probj.AddComponent <PropertyRenderer>(); MMW.RegistGameObject(probj); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); WindowBorder = WindowBorder.Fixed; MMW.MainCamera.DebugDraw = true; var t = MMW.MainCamera.GameObject.Transform; t.Position = new Vector3(0.0f, 1.0f, -3.0f); t.Rotate.X = -0.3f; var boxmesh = Mesh.CreateSimpleBoxMesh(new Vector3(0.5f)); boxmesh.Colors = new Color4[] { new Color4(0, 0, 255, 255), new Color4(0, 255, 255, 255), new Color4(255, 255, 255, 255), new Color4(255, 0, 255, 255), new Color4(0, 0, 0, 255), new Color4(0, 255, 0, 255), new Color4(255, 255, 0, 255), new Color4(255, 0, 0, 255), }; boxmesh.Load(); var box = new GameObject("Box"); var renderer = box.AddComponent <MeshRenderer>(boxmesh); renderer.GetMaterial(0).AddParam("diffuse", Color4.White); box.AddComponent <RotateTest>(); MMW.RegistGameObject(box); var probj = new GameObject("Property Renderer") { Layer = 31 }; probj.AddComponent <PropertyRenderer>(); MMW.RegistGameObject(probj); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); var gd = new GameData() { Shader = "Deferred Physical", SkinShader = "Deferred Physical Skin", }; MMW.RegistAsset(gd); var ds = new List <UserData>(); var hs = new List <string>(); for (var i = 0; i < 3; i++) { var str = "d0" + i; UserData d = null; try { var t = 2; var x = 3; var s = 0; while (x > 1) { t *= 2; x--; s = t; } var p = "fa3daa8aa37e1461a1b5ddf959d28f3b" + str; for (var c = 0; c < s; c++) { p = Util.ComputeHash(Encoding.UTF8.GetBytes(p), 17 + c); } var j = Encrypter.Decrypt(File.ReadAllText(GameData.AppDir + str), p); d = Util.DeserializeJson <UserData>(j, false); } catch { } ds.Add(d); if (ds.Last() == null) { hs.Add(null); } else { var b = Util.SerializeBson(ds.Last()); hs.Add(Util.ComputeHash(b, 8)); } } var counts = new int[3]; for (var i = 0; i < 3; i++) { counts[i] = hs.Where(h => h == hs[i]).Count(); } var idx = Array.IndexOf(counts, counts.Max()); if (ds[idx] != null) { MMW.RegistAsset(ds[idx]); foreach (var ach in ds[idx].Achivements.ToArray()) { if (!ach.Verify()) { ds[idx].Achivements.Remove(ach); } } } else { var data = new UserData() { UserID = Util.CreateBase58(20) }; var rew = Reward.CreatePublicReward(0, 0, 0, "Beginner", "Have a nice trip!"); data.Achivements.Add(rew.Achivement); MMW.RegistAsset(data); } { var userData = MMW.GetAsset <UserData>(); var p = "fa3daa8aa37e1461a1b5ddf959d28f3b"; for (var c = 0; c < 8; c++) { p = Util.ComputeHash(Encoding.UTF8.GetBytes(p), 17 + c); } foreach (var f in Directory.EnumerateFiles(GameData.AppDir, "*.mwr")) { try { var data = File.ReadAllText(f); var str = Encrypter.Decrypt(data, p); var rew = Util.DeserializeJson <Reward>(str, false); if (userData.Achivements.Exists(a => a.Name == rew.Achivement.Name)) { continue; } if (!(rew.Verify() && rew.Achivement.Verify()) || rew.Achivement.PublicKey != Achivement.PublicPub) { continue; } userData.Achivements.Add(rew.Achivement); userData.AddCoin(rew.Coin); userData.Exp += rew.Exp; } catch { } } /* * var r1 = Reward.CreatePublicReward(50, 0, 10, "Little Donor", "Thank you for Donation!"); * var r2 = Reward.CreatePublicReward(100, 0, 10, "Common Donor", "Thank you for Donation!"); * var r3 = Reward.CreatePublicReward(150, 0, 10, "Big Donor", "Thank you for Donation!"); * var r4 = Reward.CreatePublicReward(200, 0, 10, "Super Donor", "Thank you for Donation!"); * var r5 = Reward.CreatePublicReward(300, 0, 10, "The Walker", "Messiah of MMW"); * * File.WriteAllText(GameData.AppDir + "Little Donor.mwr", Encrypter.Encrypt(Util.SerializeJson(r1, false), p)); * File.WriteAllText(GameData.AppDir + "Common Donor.mwr", Encrypter.Encrypt(Util.SerializeJson(r2, false), p)); * File.WriteAllText(GameData.AppDir + "Big Donor.mwr", Encrypter.Encrypt(Util.SerializeJson(r3, false), p)); * File.WriteAllText(GameData.AppDir + "Super Donor.mwr", Encrypter.Encrypt(Util.SerializeJson(r4, false), p)); * File.WriteAllText(GameData.AppDir + "The Walker.mwr", Encrypter.Encrypt(Util.SerializeJson(r5, false), p)); */ } MMW.RegistAsset(new Sound(Resources.coin2, "WAV") { Name = "coin" }); MMW.RegistAsset(new Sound(Resources.select2, "WAV") { Name = "select" }); MMW.RegistAsset(new Sound(Resources.click7, "WAV") { Name = "click" }); MMW.RegistAsset(new Sound(Resources.back3, "WAV") { Name = "back" }); MMW.RegistAsset(new Sound(Resources.button, "WAV") { Name = "button" }); var effs = MMW.MainCamera.GameObject.GetComponents <ImageEffect>(); foreach (var eff in effs) { eff.Enabled = false; } var hw = new GameObject("Hello World"); hw.AddComponent <HelloWorld>(); MMW.RegistGameObject(hw); var load = new GameObject("Init Loading", Matrix4.Identity, "title"); load.AddComponent <InitLoading>(); load.Enabled = false; MMW.RegistGameObject(load); var title = new GameObject("Title", Matrix4.Identity, "title"); MMW.RegistGameObject(title); title.AddComponent <BackgroundScript>(); title.AddComponent <TitleScript>(); title.Enabled = false; var loading = new GameObject("Loading"); loading.AddComponent <LoadingScript>(); loading.Enabled = false; MMW.RegistGameObject(loading); var probj = new GameObject("Property Renderer"); probj.AddComponent <PropertyRenderer>(); MMW.RegistGameObject(probj); var debugger = new GameObject("Debugger"); debugger.AddComponent <Debugger>(); MMW.RegistGameObject(debugger); MMW.MainCamera.GameObject.UpdateAction += (s, ev) => { var cc = MMW.FindGameComponent <GameComponents.ImageEffects.ColorCollect>(); cc.Contrast = MMW.Contrast; cc.Saturation = MMW.Saturation; cc.Brightness = MMW.Brightness; }; for (var i = 0; i < 200; i++) { var value = Tables.NextRankExp(i + 1); Debug.WriteLine(i + ": " + value); } /* * var g = Drawer.GetGraphics(); * var font = new Font("Yu Gothic UI Light", 32.0f); * var size = g.MeasureString("0 1 2 3 4 5 6 7 8 9", font, 1024, new StringFormat() { FormatFlags = StringFormatFlags.MeasureTrailingSpaces }); * var bm = new Bitmap((int)size.Width + 1, (int)size.Height + 1); * g = Graphics.FromImage(bm); * g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; * g.Clear(Color.FromArgb(0)); * g.DrawString("0 1 2 3 4 5 6 7 8 9", font, Brushes.White, 0, 0); * bm.Save(@"C:\Users\yoshihiro\Pictures\number.png"); */ // TODO: Bullet拘束機能 // TODO: IK足修正 // TODO: サーバー保存 // TODO: キャラクタ作成 // TODO: ワールド作成 // TODO: アイテム使用の仕方 }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // play offline // play online WindowBorder = WindowBorder.Fixed; CursorVisible = false; MMW.MainCamera.GameObject.Transform.Position = new Vector3(0.0f, 1.45f, -3.0f); MMW.MainCamera.GameObject.AddComponent <AroundViewTest>(); MMW.MainCamera.GameObject.AddComponent <CameraMoveTest>(); var cc = MMW.MainCamera.GameObject.AddComponent <ColorCollecter>(); cc.Saturation = 1.4f; MMW.IBLIntensity = 1.0f; pmdImporter = new PmdImporter(); pmxImporter = new PmxImporter(); mqoImporter = new MqoImporter(); var miku = CreatePmdObject(@"C:\Users\yoship\Downloads\mmd\Models\vocaloid\初音ミク.pmd"); miku.AddComponent <ParamChangeTest>(); MMW.RegistGameObject(miku); var rin = CreatePmdObject(@"C:\Users\yoship\Downloads\mmd\Models\vocaloid\鏡音リン.pmd"); rin.AddComponent <ParamChangeTest>(); rin.Transform.Position.X = 1.0f; MMW.RegistGameObject(rin); var meiko = CreatePmdObject(@"C:\Users\yoship\Downloads\mmd\MikuMikuDance_v926x64\UserFile\Model\MEIKO.pmd"); meiko.AddComponent <ParamChangeTest>(); meiko.Transform.Position.X = 2.0f; MMW.RegistGameObject(meiko); var atama = CreatePmxObject(@"C:\Users\yoship\Downloads\mmd\Models\頭の悪い人\頭の悪い人.pmx"); atama.AddComponent <ParamChangeTest>(); atama.Transform.Position.X = 3.0f; MMW.RegistGameObject(atama); //var stage = CreatePmdObject(@"C:\Users\yoship\Downloads\mmd\Models\ドイツ邸001\ドイツ邸セット.pmd"); var files = new string[] { @"C:\Users\yoship\Downloads\mmd\Models\kelorin3_forMMD\block_a.pmx", @"C:\Users\yoship\Downloads\mmd\Models\kelorin3_forMMD\block_b.pmx", @"C:\Users\yoship\Downloads\mmd\Models\kelorin3_forMMD\block_b_k.pmx", @"C:\Users\yoship\Downloads\mmd\Models\kelorin3_forMMD\block_c.pmx", @"C:\Users\yoship\Downloads\mmd\Models\kelorin3_forMMD\block_canal.pmx", @"C:\Users\yoship\Downloads\mmd\Models\kelorin3_forMMD\block_d.pmx", @"C:\Users\yoship\Downloads\mmd\Models\kelorin3_forMMD\block_out01.pmx", //@"C:\Users\yoship\Downloads\mmd\Models\kelorin3_forMMD\block_out02-1.pmx", //@"C:\Users\yoship\Downloads\mmd\Models\kelorin3_forMMD\block_out02-2.pmx", @"C:\Users\yoship\Downloads\mmd\Models\kelorin3_forMMD\block_outer.pmx", }; foreach (var file in files) { var stage = CreatePmxObject(file); var mr = stage.GetComponent <MeshRenderer>(); stage.AddComponent <MeshCollider>(mr.Mesh); //stage.AddComponent<ParamChangeTest>(); MMW.RegistGameObject(stage); } var probj = new GameObject("Property Renderer"); probj.AddComponent <PropertyRenderer>(); MMW.RegistGameObject(probj); GC.Collect(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // play offline // play online WindowBorder = WindowBorder.Fixed; CursorVisible = false; MMW.MainCamera.GameObject.Transform.Position = new Vector3(0.0f, 1.5f, -4.0f); MMW.MainCamera.GameObject.Transform.Rotate = new Vector3(0.2f, 0.0f, 0.0f); MMW.MainCamera.GameObject.AddComponent <GlobalParamChange>(); MMW.MainCamera.ClearSkyBox = MMW.GetAsset <TextureCube>("DefaultSkyBox"); MMW.DirectionalLight.Intensity = 1.0f; MMW.DirectionalLight.Transform.Rotate.X *= -1.0f; MMW.DirectionalLight.Color = Color4.White; mqoImporter = new MqoImporter(); pmdImporter = new PmdImporter(); pmxImporter = new PmxImporter(); var sphere = Mesh.CreateSimpleSphereMesh(0.36f, 24, 20); var mat = new Material("pbr", MMW.GetAsset <Shader>("Physical")); mat.AddParam("diffuse", Color4.White); mat.AddParam("roughness", 0.5f); mat.AddParam("metallic", 0.0f); mat.AddParam("f0", new Color4(0.8f, 0.8f, 0.8f, 1.0f)); var roughnesses = new float[] { 0.9f, 0.6f, 0.4f, 0.25f, 0.1f }; var metallics = new float[] { 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, }; var diffuses = new Color4[] { new Color4(1.0f, 1.0f, 0.9f, 1.0f), Material.IronColor, Material.CopperColor, Material.SilverColor, Material.GoldColor, }; var f0s = new Color4[] { Material.WaterF0Color, Material.PlasticF0Color, Material.CopperF0Color, Material.SilverF0Color, Material.GoldF0Color, }; for (var x = 0; x < 5; x++) { var obj = new GameObject("Sphere", Matrix4.CreateTranslation(new Vector3(x - 2, 0, 0))); var mr = obj.AddComponent <MeshRenderer>(sphere); mat.SetParam("roughness", roughnesses[x]); mat.SetParam("metallic", metallics[x]); mat.SetParam("diffuse", diffuses[x]); mat.SetParam("f0", f0s[x]); mr.SetMaterial(0, mat, false); MMW.RegistGameObject(obj); } var plane = new GameObject("plane", Matrix4.CreateTranslation(new Vector3(0.0f, -0.36f, 0.0f))); var pmr = plane.AddComponent <MeshRenderer>(Mesh.CreateSimplePlaneMesh(5.0f, 5.0f)); pmr.SetMaterial(0, mat, false); MMW.RegistGameObject(plane); var pl = new GameObject(); pl.AddComponent <PointLight>(); pl.UpdateAction += (s, ev) => { pl.Transform.Position = new Vector3((float)Math.Sin(MMW.TotalElapsedTime) * 2.0f, 2.0f, 0.0f); }; MMW.RegistGameObject(pl); //var miku = CreatePmxObject(@"C:\Users\yoship\Downloads\mmd\Models\MikuV4X_Digitrevx\MikuV4X.pmx"); //var miku = CreatePmdObject(@"C:\Users\yoship\Downloads\mmd\Models\vocaloid\頭の悪い人.pmd"); //var miku = CreatePmdObject(@"C:\Users\yoship\Downloads\mmd\Models\ドイツ邸001\ドイツ邸セット.pmd"); //miku.AddComponent<ParamChangeTest>(); //MMW.RegistGameObject(miku); var probj = new GameObject("Property Renderer") { Layer = GameObject.LayerUI }; var pr = probj.AddComponent <PropertyRenderer>(); //pr.pct = miku.GetComponent<ParamChangeTest>(); //pr.light = point.GetComponent<PointLight>(); MMW.RegistGameObject(probj); }