public Bulle(string textFilename, int textIndex) { if (bulle == null) { bulle = new DAE("Content\\Effects\\Visual\\Bulle\\bulle.dae"); bulle.Parse(); VertexPositionColorTexture[] replace = new VertexPositionColorTexture[bulle.VertexBufferColor.Length * 2]; Array.Copy(bulle.VertexBufferColor, 0, replace, 0, bulle.VertexBufferColor.Length); Array.Copy(bulle.VertexBufferColor, 0, replace, bulle.VertexBufferColor.Length, bulle.VertexBufferColor.Length); for (int i = 0; i < bulle.VertexBufferColor.Length; i++) { replace[i].TextureCoordinate.Y += 0.25f; } /*bulle.VertexBufferColor = new VertexPositionColorTexture[bulle.VertexBufferColor.Length * 2]; * Array.Copy(replace, 0, bulle.VertexBufferColor, 0, bulle.VertexBufferColor.Length);*/ bulle.VertexBufferColor = replace; bulle.MeshesOffsets[0][1] *= 2; bulle.vBuffer = new VertexBuffer(Program.game.graphics.GraphicsDevice, typeof(VertexPositionColorTexture), bulle.VertexBufferColor.Length, BufferUsage.None); } this.TextFileName = textFilename; this.SetText(textFilename, textIndex); this.NextText(); /*this.Color = BulleColor.Red; * this.Type= BulleType.Information;*/ /*this.Width = SpeechWidth; * this.Height = SpeechHeight;*/ this.displayType = DisplayType.None; }
public static void LoadKeyblade(string modelName, string movesetName, ref Model target) { Model keyblade = null; if (File.Exists(@"Content\Models\" + modelName + @"\" + modelName + ".dae")) { keyblade = new DAE(@"Content\Models\" + modelName + @"\" + modelName + ".dae"); keyblade.Parse(); MainGame.ResourceFiles.Add(keyblade); keyblade.Render = true; keyblade.Opacity = 0; keyblade.DestOpacity = 0; } if (keyblade != null && Directory.Exists(@"Content\Models\" + movesetName + @"\MSET")) { BinaryMoveset keybladeMset = new BinaryMoveset(@"Content\Models\" + movesetName + @"\MSET"); keybladeMset.Links.Add(keyblade); keybladeMset.Master = (target.Links[0] as Moveset); keybladeMset.Parse(); MainGame.ResourceFiles.Add(keybladeMset); keybladeMset.Render = true; keybladeMset.PlayingIndex = keybladeMset.idle_; keyblade.Links.Add(keybladeMset); keyblade.Master = target; target.Keyblade = keyblade; } }
public void Parse() { this.ResourceIndex = Array.IndexOf(Resource.ResourceIndices, this.FileName.Split('.')[0] + "."); this.IsSky = this.Name.Contains("SKY"); FileStream fs = new FileStream(this.FileName, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader reader = new BinaryReader(fs); this.ModelType = (MDType)reader.ReadSByte(); this.NoCull = reader.ReadSByte() < 0; this.ZIndex = (int)reader.ReadSByte(); reader.ReadSByte(); int textureCount = reader.ReadInt32(); if (this.ModelType == MDType.Map) { for (int i = 0; i < 10; i++) { if (File.Exists(Path.GetDirectoryName(this.FileName) + @"\SKY\" + this.Name + "-SKY" + i + ".dae")) { string fname = Path.GetDirectoryName(this.FileName) + @"\SKY\" + this.Name + "-SKY" + i + ".dae"; Model model = new DAE(Path.GetDirectoryName(this.FileName) + @"\SKY\" + this.Name + "-SKY" + i + ".dae"); model.Parse(); BinaryMoveset bm = null; if (Directory.Exists(Path.GetDirectoryName(fname) + "\\" + Path.GetFileNameWithoutExtension(fname))) { bm = new BinaryMoveset(Path.GetDirectoryName(fname) + "\\" + Path.GetFileNameWithoutExtension(fname)); bm.Links.Add(model); bm.Parse(); bm.PlayingIndex = 0; bm.Render = true; model.Links.Add(bm); } this.SuppMsets.Add(bm); this.Supp.Add(model); } } } if (Directory.Exists(Path.GetDirectoryName(this.FileName) + @"\OBJECTS")) { string[] files = Directory.GetFiles(Path.GetDirectoryName(this.FileName) + @"\OBJECTS", "*.dae"); for (int i = 0; i < files.Length; i++) { Model dae = new DAE(files[i]) { Render = true, ModelType = files[i].Contains("-sp") ? MDType.Specular : MDType.Sky }; dae.Parse(); //(dae as DAE).ExportBin(); BinaryMoveset bm = null; if (Directory.Exists(Path.GetDirectoryName(files[i]) + "\\" + Path.GetFileNameWithoutExtension(files[i]))) { bm = new BinaryMoveset(Path.GetDirectoryName(files[i]) + "\\" + Path.GetFileNameWithoutExtension(files[i])); bm.Links.Add(dae); bm.Parse(); bm.PlayingIndex = 0; bm.ObjectMsetRender = bm.Name.Contains("-mdl-"); bm.Render = true; dae.Links.Add(bm); } this.SuppMsets.Add(bm); this.Supp.Add(dae); } } this.FogStart = reader.ReadInt16() * 10f; this.FogEnd = reader.ReadInt16() * 10f; this.FogColor = (new Microsoft.Xna.Framework.Color(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte())).ToVector3(); reader.Close(); fs.Close(); if (sunbeamList == null) { sunbeamList = File.ReadAllLines("Content\\Effects\\Visual\\Sun\\sunpositions.txt"); } for (int i = 0; i < sunbeamList.Length; i++) { string[] spli = sunbeamList[i].Split('|'); if (spli[0] == this.Name) { spli = spli[1].Split(';'); this.sunbeam = new SunBeam { From = new Vector3(MainGame.SingleParse(spli[0]), MainGame.SingleParse(spli[1]), MainGame.SingleParse(spli[2])) }; this.sunbeam.coll = new Collision("Content\\Effects\\Visual\\Sun\\" + this.Name + ".obj"); } } for (int i = 0; i < this.Supp.Count; i++) { for (int j = i + 1; j < this.Supp.Count; j++) { if (this.Supp[j].ZIndex < this.Supp[i].ZIndex) { var curr = this.Supp[j]; this.Supp.RemoveAt(j); this.Supp.Insert(0, curr); var currM = this.SuppMsets[j]; this.SuppMsets.RemoveAt(j); this.SuppMsets.Insert(0, currM); } } } base.Parse(); }
public Scene(string fname) { this.Commands = new List <SceneCommand>(0); this.Instructions = new List <object>(0); this.StartFrames = new List <int>(0); string[] content = File.ReadAllLines(@"Content\Scenes\" + fname + ".txt"); string[] spli1, spli2; for (int i = 0; i < content.Length; i++) { spli1 = content[i].Split('|'); spli2 = spli1[2].Split(';'); int startFrame = int.Parse(spli1[0]); switch (spli1[1]) { case "Goto": if (startFrame > this.MaxFrame) { this.MaxFrame = startFrame; } Model mdl_ = null; for (int r = 0; r < MainGame.ResourceFiles.Count; r++) { if (MainGame.ResourceFiles[r].Name == spli2[0]) { mdl_ = MainGame.ResourceFiles[r] as Model; break; } } Vector3 dest = new Vector3(MainGame.SingleParse(spli2[1]), MainGame.SingleParse(spli2[2]), MainGame.SingleParse(spli2[3])); this.Instructions.Add(new GotoDest(mdl_, dest)); this.Commands.Add(SceneCommand.Goto); break; case "SetBGMVolume": if (startFrame > this.MaxFrame) { this.MaxFrame = startFrame; } this.Instructions.Add(new int[] { int.Parse(spli1[2]), int.Parse(spli1[3]) }); this.Commands.Add(SceneCommand.SetBGMVolume); break; case "ContactCollison": if (startFrame > this.MaxFrame) { this.MaxFrame = startFrame; } this.Instructions.Add(Boolean.Parse(spli2[0])); this.Commands.Add(SceneCommand.ContactCollison); break; case "SetCamera": if (startFrame > this.MaxFrame) { this.MaxFrame = startFrame; } Vector3[] insts = new Vector3[spli2.Length / 3]; for (int n = 0; n < spli2.Length; n++) { float val = Single.NaN; Single.TryParse(spli2[n], out val); if (n % 3 == 0) { insts[n / 3].X = val; } if (n % 3 == 1) { insts[n / 3].Y = val; } if (n % 3 == 2) { insts[n / 3].Z = val; } } this.Instructions.Add(insts); this.Commands.Add(SceneCommand.SetCamera); break; case "Gameplay": if (startFrame > this.MaxFrame) { this.MaxFrame = startFrame; } this.Instructions.Add(null); this.Commands.Add(SceneCommand.Gameplay); break; case "PlayAnim": Animation anm = new Animation(); for (int n = 0; n < spli2.Length; n += 6) { spli2[n + 0] = spli2[n + 0].Replace("player", Program.game.Player.Name); spli2[n + 1] = spli2[n + 1].Replace("player", Program.game.Player.Name); Model mdl = null; BinaryMoveset mset = null; for (int r = 0; r < MainGame.ResourceFiles.Count; r++) { if (MainGame.ResourceFiles[r].Name == spli2[n + 0]) { mdl = MainGame.ResourceFiles[r] as Model; break; } } if (mdl == null) { for (int r = 0; r < Program.game.Map.Supp.Count; r++) { if (Program.game.Map.Supp[r].Name == spli2[n + 0]) { mdl = Program.game.Map.Supp[r] as Model; break; } } } if (mdl == null) { mdl = new DAE(@"Content\Models\" + spli2[n + 0] + @"\" + spli2[n + 0] + ".dae"); mdl.Parse(); MainGame.ResourceFiles.Add(mdl); mdl.Render = false; } mdl.Cutscene = true; int index = -1; if (mdl.Links.Count > 0) { (mdl.Links[0] as BinaryMoveset).PlayingIndex = -1; } if (int.TryParse(spli2[n + 1], out index)) { if (mdl.Links.Count == 0) { mset = new BinaryMoveset(mdl.FileName.Replace(mdl.Name + ".dae", @"\MSET")); mset.Links.Add(mdl); mset.Parse(); MainGame.ResourceFiles.Add(mset); mdl.Links.Add(mset); } else { mset = (mdl.Links[0] as BinaryMoveset); } } else { string name = Path.GetFileNameWithoutExtension(@"Content\Scenes\ANB\" + spli2[n + 1]); for (int r = 0; r < MainGame.ResourceFiles.Count; r++) { if (MainGame.ResourceFiles[r].Name == name) { mset = MainGame.ResourceFiles[r] as BinaryMoveset; } } if (mset == null) { mset = new BinaryMoveset(@"Content\Scenes\ANB\" + spli2[n + 1]); MainGame.ResourceFiles.Add(mset); } index = 0; } mset.Render = true; if (mset.Links.Count == 0) { mset.Links.Add(mdl); } mset.Skeleton = mdl.Skeleton; if (mdl.Links.Count > 0) { mset.Voices = (mdl.Links[0] as Moveset).Voices; } //mset.Parse(); Vector3 startPos = Vector3.Zero; startPos.X = MainGame.SingleParse(spli2[n + 2]); startPos.Y = MainGame.SingleParse(spli2[n + 3]); startPos.Z = MainGame.SingleParse(spli2[n + 4]); float rot = MainGame.SingleParse(spli2[n + 5]); anm.Append(mdl, mset, index, startPos, rot); if (startFrame + mset.MaxTick > this.MaxFrame) { this.MaxFrame = startFrame + mset.MaxTick; } } this.Instructions.Add(anm); this.Commands.Add(SceneCommand.PlayAnim); break; } this.StartFrames.Add(startFrame); } }
public PAX(string filename) { /*FileStream fs = new FileStream(@"D:\Desktop\KHDebug\KHDebug\bin\DesktopGL\AnyCPU\Debug\Content\Effects\Visual\SavePoint\p0\MSET\move_001.frames", FileMode.Create); * BinaryWriter wr = new BinaryWriter(fs); * * for (int i=0;i<500;i++) * { * * float v1 = (float)(Math.Sin((i/250f)*Math.PI)+1)/2f; * float v2 = 1- v1; * * wr.Write((ushort)11); * wr.Write((ushort)0); * wr.Write(1.000f * v1 + 0.745f * v2); * * wr.Write((ushort)12); * wr.Write((ushort)0); * wr.Write(0.999f * v1 + 1.000f * v2); * * wr.Write((ushort)13); * wr.Write((ushort)0); * wr.Write(0.745f * v1 + 0.982f * v2); * * wr.Write((ushort)11); * wr.Write((ushort)2); * wr.Write(1.000f * v1 + 0.745f * v2); * * wr.Write((ushort)12); * wr.Write((ushort)2); * wr.Write(0.999f * v1 + 1.000f * v2); * * wr.Write((ushort)13); * wr.Write((ushort)2); * wr.Write(0.745f * v1 + 0.982f * v2); * * * if ((i >= 43 && i < 63)|| * (i >= 168 && i < 188)|| * (i >= 294 && i < 314)|| * (i >= 420 && i < 440)) * { * wr.Write((ushort)10); * wr.Write((ushort)1); * if (i >= 420) * wr.Write(1f- ((i - 420) / 20f)); * else if (i >= 294) * wr.Write(1f - ((i - 294) / 20f)); * else if (i >= 168) * wr.Write(1f - ((i - 168) / 20f)); * else * wr.Write(1f - ((i - 43) / 20f)); * } * else * * if (i < 43 || * (i >= 126 && i < 168) || * (i >= 251 && i < 294) || * (i >= 377 && i < 420)) * { * wr.Write((ushort)10); * wr.Write((ushort)1); * wr.Write(1f); * } * else * { * wr.Write((ushort)10); * wr.Write((ushort)1); * wr.Write(0f); * } * * * if (i < 10) * { * wr.Write((ushort)10); * wr.Write((ushort)0); * wr.Write((i / 9f)); * * wr.Write((ushort)10); * wr.Write((ushort)2); * wr.Write(i / 9f); * * wr.Write((ushort)10); * wr.Write((ushort)3); * wr.Write(i / 9f); * } * * wr.Write(-1); * } * * wr.Close(); * fs.Close();*/ /*FileStream fs = new FileStream(@"Content\Effects\Visual\FakeHUD\MSET\move_002.frames", FileMode.OpenOrCreate); * BinaryWriter wr = new BinaryWriter(fs); * for (int i = 0; i < 1; i++) * { * wr.Write((ushort)14); * wr.Write((ushort)0); * wr.Write(0f); * * wr.Write(-1); * } * * wr.Close(); * fs.Close(); * fs.Close();*/ if (File.Exists(filename.Replace(".dae", ".info"))) { string[] input = File.ReadAllLines(filename.Replace(".dae", ".info")); switch (input[0]) { case "None": this.DType = DrawType.None; break; case "ToScreen2D": this.DType = DrawType.ToScreen2D; break; case "FullScreen": this.DType = DrawType.FullScreen; break; case "YawPitchX": this.DType = DrawType.YawPitchX; break; case "YawPitchY": this.DType = DrawType.YawPitchY; break; case "YawPitchAll": this.DType = DrawType.YawPitchAll; break; case "YawX": this.DType = DrawType.YawX; break; case "YawY": this.DType = DrawType.YawY; break; case "YawAll": this.DType = DrawType.YawAll; break; case "PitchX": this.DType = DrawType.PitchX; break; case "PitchY": this.DType = DrawType.PitchY; break; case "PitchAll": this.DType = DrawType.PitchAll; break; } if (input[1] == "CullNone") { this.Cull = false; } if (input[2] == "DepthNone") { this.Depth = false; } } daeFile = new DAE(filename); daeFile.Parse(); RecreateVertexBuffer(true); //daeFile.ModelType = Model.MDType.Sky; //daeFile.Location = new Vector3(0, 0, 0); if (Directory.Exists(filename.Replace(Path.GetFileName(filename), "MSET"))) { moveFile = new BinaryMoveset(filename.Replace(Path.GetFileName(filename), "MSET")); moveFile.Links.Add(daeFile); moveFile.Parse(); moveFile.PlayingIndex = 0; moveFile.InterpolateAnimation = false; daeFile.Links.Add(moveFile); string[] frameFiles = Directory.GetFiles(filename.Replace(Path.GetFileName(filename), "MSET"), "*.frames"); Array.Sort(frameFiles); Frames = new byte[frameFiles.Length][]; FramesIndices = new List <int> [frameFiles.Length]; for (int i = 0; i < Frames.Length; i++) { Frames[i] = File.ReadAllBytes(frameFiles[i]); FramesIndices[i] = new List <int>(0); FramesIndices[i].Add(0); for (int j = 0; j < Frames[i].Length - 4; j += 4) { int read = BitConverter.ToInt32(Frames[i], j); if (read == -1) { FramesIndices[i].Add(j + 4); } } } } }
public static void LoadCharacter(string modelName, string movsesetName, ref Model target) { Model model = null; if (File.Exists(@"Content\Models\" + modelName + @"\" + modelName + ".dae")) { for (int i = 0; i < MainGame.ResourceFiles.Count; i++) { if (MainGame.ResourceFiles[i] is Model && MainGame.ResourceFiles[i].Name == modelName) { model = MainGame.ResourceFiles[i] as Model; break; } } if (model == null) { model = new DAE(@"Content\Models\" + modelName + @"\" + modelName + ".dae"); model.Parse(); MainGame.ResourceFiles.Add(model); } model.Render = true; target = model; model.Opacity = 0; } if (model != null && Directory.Exists(@"Content\Models\" + movsesetName + @"\MSET")) { BinaryMoveset mset = null; for (int i = 0; i < MainGame.ResourceFiles.Count; i++) { if (MainGame.ResourceFiles[i] is BinaryMoveset && MainGame.ResourceFiles[i].Name == movsesetName) { mset = MainGame.ResourceFiles[i] as BinaryMoveset; break; } } if (mset == null) { mset = new BinaryMoveset(@"Content\Models\" + movsesetName + @"\MSET"); mset.Links.Add(model); mset.Parse(); MainGame.ResourceFiles.Add(mset); if (Directory.Exists(@"Content\Models\" + movsesetName + @"\P_EX100_MSET")) { var mset2 = new BinaryMoveset(@"Content\Models\" + movsesetName + @"\P_EX100_MSET"); mset2.Links.Add(Program.game.Player); mset2.Links.Add(mset); mset2.Parse(); mset.Links.Add(mset2); mset2.Render = true; mset2.PlayingIndex = mset2.idle_; } } mset.Render = true; mset.PlayingIndex = mset.idle_; if (model.Links.Count == 0) { model.Links.Insert(0, mset); } } }