public void Load(TagFileName tfn) { LoadTagBuffer(tfn); BinaryReader br = new BinaryReader(this.Stream); m_Schi.Read(br); m_Schi.ReadChildData(br); br.Close(); int map_count = m_Schi.ShaderTransparentChicagoValues.Maps.Count; mapTransforms = new Matrix[map_count]; for (int i = 0; i < map_count; i++) { float u_scale = m_Schi.ShaderTransparentChicagoValues.Maps[i].Map.Value; float v_scale = m_Schi.ShaderTransparentChicagoValues.Maps[i].Map2.Value; mapTransforms[i] = new Matrix(); mapTransforms[i].Scale(u_scale, v_scale, 1); } Stage1ColorOp = m_Schi.ShaderTransparentChicagoValues.Maps[0].ColorFunction.Value; Stage1AlphaOp = m_Schi.ShaderTransparentChicagoValues.Maps[0].AlphaFunction.Value; Stage1AlphaReplicate = m_Schi.ShaderTransparentChicagoValues.Maps[0].Flags.GetFlag(2); if (map_count > 1) { Stage2ColorOp = m_Schi.ShaderTransparentChicagoValues.Maps[1].ColorFunction.Value; Stage2AlphaOp = m_Schi.ShaderTransparentChicagoValues.Maps[1].AlphaFunction.Value; Stage2AlphaReplicate = m_Schi.ShaderTransparentChicagoValues.Maps[1].Flags.GetFlag(2); } }
public void Load(TagFileName tfn) { LoadTagBuffer(tfn); BinaryReader br = new BinaryReader(this.Stream); m_Swat.Read(br); m_Swat.ReadChildData(br); br.Close(); tint.Diffuse = Color.LightSkyBlue; rippleTransforms = new Matrix[m_Swat.ShaderTransparentWaterValues.Ripples.Count]; for (int i = 0; i < m_Swat.ShaderTransparentWaterValues.Ripples.Count; i++) { float u_offset = m_Swat.ShaderTransparentWaterValues.Ripples[i].MapOffset.I; float v_offset = m_Swat.ShaderTransparentWaterValues.Ripples[i].MapOffset.K; rippleTransforms[i] = new Matrix(); rippleTransforms[i] = Matrix.Identity; rippleTransforms[i].M31 = u_offset; rippleTransforms[i].M32 = v_offset; rippleTransforms[i].Scale(m_Swat.ShaderTransparentWaterValues.RippleScale.Value, m_Swat.ShaderTransparentWaterValues.RippleScale.Value, 0); } }
public void SaveTagBuffer(TagFileName tfn) { string tag_path = ""; switch (tfn.Source) { case TagSource.Debug: tag_path = tfn.RelativePath; break; case TagSource.LocalProject: tag_path = OptionsManager.ActiveProjectPath + @"Tags\" + tfn.RelativePath; break; default: throw new Exception("Cannot save a tag that isn't local project or debug."); break; } FileStream tagFile = new FileStream(tag_path, FileMode.Create); BinaryWriter tagWriter = new BinaryWriter(tagFile); tagWriter.BaseStream.Position = 0; this.m_PromHeader.Write(ref tagWriter); byte[] temp = this.m_stream.GetBuffer(); tagWriter.Write(temp, 0, this.m_PromHeader.TagSize); tagFile.Close(); }
public void Load(TagFileName tfn) { LoadTagBuffer(tfn); BinaryReader br = new BinaryReader(this.Stream); m_Sgla.Read(br); m_Sgla.ReadChildData(br); br.Close(); }
public void Load(TagFileName tfn) { LoadTagBuffer(tfn); BinaryReader br = new BinaryReader(this.Stream); m_Scex.Read(br); m_Scex.ReadChildData(br); br.Close(); int two_stage_count = m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps.Count; int four_stage_count = m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps.Count; //print out debug info Trace.WriteLine("scex name: " + tfn.RelativePath); Trace.WriteLine("Framebuffer Blend Mode = " + m_Scex.ShaderTransparentChicagoExtendedValues.FramebufferBlendFunction.Value.ToString()); for (int i = 0; i < two_stage_count; i++) { Trace.WriteLine(string.Format("(2): ColorOp[{0}] = {1} AlphaOp = {2} flags = {3:X}", i, m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[i].ColorFunction.Value.ToString(), m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[i].AlphaFunction.Value.ToString(), m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[i].Flags.Value )); } Trace.WriteLine(""); for (int i = 0; i < four_stage_count; i++) { Trace.WriteLine(string.Format("(4): ColorOp[{0}] = {1} AlphaOp = {2} flags = {3:X}", i, m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[i].ColorFunction.Value.ToString(), m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[i].AlphaFunction.Value.ToString(), m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[i].Flags.Value )); } if (two_stage_count != 0) { int map_count = m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps.Count; mapTransforms = new Matrix[map_count]; for (int i = 0; i < map_count; i++) { float u_scale = m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[i].Map.Value; float v_scale = m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[i].Map2.Value; mapTransforms[i] = new Matrix(); //if there is no scaling, then just leave matrix at null if ((Math.Abs(1.0 - u_scale) > 0.001) || (Math.Abs(1.0 - u_scale) > 0.001)) { mapTransforms[i].Scale(u_scale, v_scale, 1); } else { mapTransforms[i] = Matrix.Identity; } } Stage1ColorOp = m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[0].ColorFunction.Value; Stage1AlphaOp = m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[0].AlphaFunction.Value; Stage1AlphaReplicate = m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[0].Flags.GetFlag(2); Stage2ColorOp = m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[1].ColorFunction.Value; Stage2AlphaOp = m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[1].AlphaFunction.Value; Stage2AlphaReplicate = m_Scex.ShaderTransparentChicagoExtendedValues.TwoStageMaps[1].Flags.GetFlag(2); } else { bUseFourStage = true; int map_count = m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps.Count; mapTransforms = new Matrix[map_count]; for (int i = 0; i < map_count; i++) { float u_scale = m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[i].Map.Value; float v_scale = m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[i].Map2.Value; mapTransforms[i] = new Matrix(); //if there is no scaling, then just leave matrix at null if ((Math.Abs(1.0 - u_scale) > 0.001) || (Math.Abs(1.0 - u_scale) > 0.001)) { mapTransforms[i].Scale(u_scale, v_scale, 1); } else { mapTransforms[i] = Matrix.Identity; } } Stage1ColorOp = m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[0].ColorFunction.Value; Stage1AlphaOp = m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[0].AlphaFunction.Value; Stage1AlphaReplicate = m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[0].Flags.GetFlag(2); Stage2ColorOp = m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[1].ColorFunction.Value; Stage2AlphaOp = m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[1].AlphaFunction.Value; Stage2AlphaReplicate = m_Scex.ShaderTransparentChicagoExtendedValues.FourStageMaps[1].Flags.GetFlag(2); } }
public bool LoadTagBuffer(TagFileName tfn) { this.TagFilename = tfn.RelativePath; bool bStatus = true; FileStream tagFile = null; BinaryReader tagReader = null; try { //read file into memory buffer switch (tfn.Source) { case TagSource.Debug: case TagSource.LocalShared: tagFile = new FileStream(tfn.RelativePath, FileMode.Open); tagReader = new BinaryReader(tagFile); m_BufLength = (int)tagReader.BaseStream.Length; m_Buffer = new byte[m_BufLength]; tagReader.BaseStream.Position = 0; m_Buffer = tagReader.ReadBytes(m_BufLength); tagFile.Close(); break; case TagSource.LocalProject: tagFile = new FileStream(OptionsManager.ActiveProjectTagsPath + tfn.RelativePath, FileMode.Open); tagReader = new BinaryReader(tagFile); m_BufLength = (int)tagReader.BaseStream.Length; m_Buffer = new byte[m_BufLength]; tagReader.BaseStream.Position = 0; m_Buffer = tagReader.ReadBytes(m_BufLength); tagFile.Close(); break; case TagSource.Prefab: break; case TagSource.Archive: if ((tfn.Version == MapfileVersion.HALOPC) || (tfn.Version == MapfileVersion.HALOCE)) { m_Buffer = TagLibraryManager.HaloPC.ReadFile(tfn.RelativePath); m_BufLength = m_Buffer.Length; } else if (tfn.Version == MapfileVersion.XHALO1) { //todo: read buffer from archive m_Buffer = TagLibraryManager.HaloXbox.ReadFile(tfn.RelativePath); m_BufLength = m_Buffer.Length; } else if (tfn.Version == MapfileVersion.XHALO2) { m_Buffer = TagLibraryManager.Halo2Xbox.ReadFile(tfn.RelativePath); m_BufLength = m_Buffer.Length; } break; case TagSource.NotFound: Trace.WriteLine("Could not find " + tfn.RelativePath); bStatus = false; break; } if (m_Buffer != null) { // Check for known headers int[] bin = new int[0x10]; for (int x = 0; x < bin.Length; x++) { bin[x] = BitConverter.ToInt32(m_Buffer, x * 4); } m_headerType = TagHeaderType.Unknown; if (bin[0xF] == 0x6D616C62) { m_headerType = TagHeaderType.Blam; } if (bin[0x0] == 0x4d4f5250 /*0x70726F6D*/) { m_headerType = TagHeaderType.Prometheus; } // Create the memory stream, load the header struct if (m_headerType == TagHeaderType.Blam) { // Read the tag and create the memorystream int headerLength = 0x40; m_stream = new MemoryStream(m_Buffer, headerLength, m_Buffer.Length - headerLength); } else if (m_headerType == TagHeaderType.Prometheus) { m_PromHeader.Read(m_Buffer); m_BufLength = m_PromHeader.TagSize; m_stream = new MemoryStream(m_Buffer, TagHeader.PROM_HEADER_SIZE, m_PromHeader.TagSize); // Read the attachment header //m_PromHeader.SeekToAttachStart(ref tagReader); //m_attachmentHeader.Read(ref tagReader); } else { bStatus = false; throw new PrometheusException( "Unsupported tag file format.", true); } } } catch (Exception ex) { throw new PrometheusException( "The specified tag could not be loaded: " + tfn.RelativePath, ex, true); } return(bStatus); }