private void WandOben(int x, int z) { int oldIndex = vertexListWaende.Count; vertexListWaende.Add(new VertexPositionTexture(new Vector3(x * step, 0, z * step + step), new Vector2(0, 0))); vertexListWaende.Add(new VertexPositionTexture(new Vector3(x * step, height, z * step + step), new Vector2(0, 1))); vertexListWaende.Add(new VertexPositionTexture(new Vector3(x * step + step, 0, z * step + step), new Vector2(1, 0))); vertexListWaende.Add(new VertexPositionTexture(new Vector3(x * step + step, height, z * step + step), new Vector2(1, 1))); List <Vector3> templist = new List <Vector3>(); for (int i = oldIndex; i < vertexListWaende.Count; i++) { templist.Add(vertexListWaende[i].Position); } BoundingBoxes.Add(BoundingBox.CreateFromPoints(templist)); //Console.WriteLine(BoundingBox.CreateFromPoints(templist).Min + " - " + BoundingBox.CreateFromPoints(templist).Max); indexListWaende.Add(Convert.ToInt16(oldIndex)); indexListWaende.Add(Convert.ToInt16(oldIndex + 3)); indexListWaende.Add(Convert.ToInt16(oldIndex + 1)); indexListWaende.Add(Convert.ToInt16(oldIndex)); indexListWaende.Add(Convert.ToInt16(oldIndex + 2)); indexListWaende.Add(Convert.ToInt16(oldIndex + 3)); }
internal Mesh(BinaryReaderEx br, FLVERHeader header) { Dynamic = br.ReadBoolean(); br.AssertByte(0); br.AssertByte(0); br.AssertByte(0); MaterialIndex = br.ReadInt32(); br.AssertInt32(0); br.AssertInt32(0); DefaultBoneIndex = br.ReadInt32(); int boneCount = br.ReadInt32(); int boundingBoxOffset = br.ReadInt32(); int boneOffset = br.ReadInt32(); int faceSetCount = br.ReadInt32(); int faceSetOffset = br.ReadInt32(); int vertexBufferCount = br.AssertInt32(1, 2, 3); int vertexBufferOffset = br.ReadInt32(); if (boundingBoxOffset != 0) { br.StepIn(boundingBoxOffset); { BoundingBox = new BoundingBoxes(br, header); } br.StepOut(); } BoneIndices = new List <int>(br.GetInt32s(boneOffset, boneCount)); faceSetIndices = br.GetInt32s(faceSetOffset, faceSetCount); vertexBufferIndices = br.GetInt32s(vertexBufferOffset, vertexBufferCount); }
/// <summary> /// Determines whether the specified <see cref="GeoJSONObject" />, is equal to this instance. /// </summary> /// <param name="other">The <see cref="GeoJSONObject" /> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="GeoJSONObject" /> is equal to this instance; otherwise, <c>false</c>. /// </returns> protected virtual bool Equals(GeoJSONObject other) { if (Type != other.Type) { return(false); } if (!Equals(CRS, other.CRS)) { return(false); } if (BoundingBoxes == null && other.BoundingBoxes == null) { return(true); } if ((BoundingBoxes != null && other.BoundingBoxes == null) || (BoundingBoxes == null && other.BoundingBoxes != null)) { return(false); } return(BoundingBoxes.SequenceEqual(other.BoundingBoxes, DoubleComparer)); }
/// <summary> /// Returns true if ResponseTimeMapBoundingBoxesResult instances are equal /// </summary> /// <param name="other">Instance of ResponseTimeMapBoundingBoxesResult to be compared</param> /// <returns>Boolean</returns> public bool Equals(ResponseTimeMapBoundingBoxesResult other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( SearchId == other.SearchId || SearchId != null && SearchId.Equals(other.SearchId) ) && ( BoundingBoxes == other.BoundingBoxes || BoundingBoxes != null && other.BoundingBoxes != null && BoundingBoxes.SequenceEqual(other.BoundingBoxes) ) && ( Properties == other.Properties || Properties != null && Properties.Equals(other.Properties) )); }
public void MouseUp(Point point) { if (IsMouseDown) { var rect = new Rect(mouseDownLocation, point); BoundingBoxes.Add(new BoundingBox(rect, SelectedClass)); } IsMouseDown = false; }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() { unchecked { var hashCode = (BoundingBoxes != null ? BoundingBoxes.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CRS != null ? CRS.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)Type; return(hashCode); } }
private void ExDrawGhostRect() { if (IsPlay && IsLeftMouseDown) { IsLeftMouseDown = false; GhostRect = new Rect(); var rect = new Rect(mouseDownLocation, new Point(PanelX, PanelY)); BoundingBoxes.Add(new BoundingBox(rect, "New")); } else if (IsPlay && !IsLeftMouseDown) { IsLeftMouseDown = true; mouseDownLocation = new Point(PanelX, PanelY); } }
private void ExObjectDetect() { this.MediaService.Capture(); var configurationDetector = new ConfigurationDetector(); var config = configurationDetector.Detect(); using (var yoloWrapper = new YoloWrapper(config)) { var items = yoloWrapper.Detect(@"C:\Users\csy18\OneDrive\바탕 화면\RomanticLabel\RomanticLabel\cap.png"); foreach (var item in items) { var rect = new Rect(item.X, item.Y, item.Width, item.Height); BoundingBoxes.Add(new BoundingBox(rect, item.Type)); } } }
// Create a canvas containging the image as well as the bounding boxes defined by the filetable id private static Canvas CreateCanvasWithBoundingBoxesAndImage(Image image, double height, int margin, long fileTableID) { Canvas canvas = new Canvas { Width = image.Source.Width, Height = height, Background = Brushes.Gray }; Canvas.SetLeft(image, 0); Canvas.SetTop(image, 0); canvas.Children.Add(image); BoundingBoxes boundingBoxes = Util.GlobalReferences.MainWindow.GetBoundingBoxesForCurrentFile(fileTableID); boundingBoxes.DrawBoundingBoxesInCanvas(canvas, image.Source.Width, image.Source.Height, margin); return(canvas); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (SearchId != null) { hashCode = hashCode * 59 + SearchId.GetHashCode(); } if (BoundingBoxes != null) { hashCode = hashCode * 59 + BoundingBoxes.GetHashCode(); } if (Properties != null) { hashCode = hashCode * 59 + Properties.GetHashCode(); } return(hashCode); } }
public render_model(CacheBase Cache, int Address) { cache = Cache; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Name = Cache.Strings.GetItemByID(Reader.ReadInt16()); //Flags = new Bitmask(Reader.ReadInt32()); #region BoundingBox Block Reader.SeekTo(Address + 20); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { BoundingBoxes.Add(new BoundingBox(Cache, iOffset + 56 * i)); } #endregion #region Regions Block Reader.SeekTo(Address + 28); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Regions.Add(new Region(Cache, iOffset + 16 * i)); } #endregion #region ModelParts Block Reader.SeekTo(Address + 36); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new ModelSection(Cache, iOffset + 92 * i) { FacesIndex = i, VertsIndex = i, NodeIndex = 255 }); } Reader.SeekTo(Address + 72); #endregion #region Nodes Block iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Nodes.Add(new Node(Cache, iOffset + 96 * i)); } #endregion #region MarkerGroups Block Reader.SeekTo(Address + 88); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { MarkerGroups.Add(new MarkerGroup(Cache, iOffset + 12 * i)); } #endregion #region Shaders Block Reader.SeekTo(Address + 96); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Shaders.Add(new Shader(Cache, iOffset + 32 * i)); } #endregion }
public static void Main(string[] args) { var fonts = new FontCollection(); FontFamily font = fonts.Install(@"Fonts\SixLaborsSampleAB.ttf"); FontFamily fontWoff = fonts.Install(@"Fonts\SixLaborsSampleAB.woff"); FontFamily carter = fonts.Install(@"Fonts\CarterOne.ttf"); FontFamily wendy_One = fonts.Install(@"Fonts\WendyOne-Regular.ttf"); FontFamily colorEmoji = fonts.Install(@"Fonts\Twemoji Mozilla.ttf"); FontFamily font2 = fonts.Install(@"Fonts\OpenSans-Regular.ttf"); FontFamily emojiFont = SystemFonts.Find("Segoe UI Emoji"); FontFamily uiFont = SystemFonts.Find("Segoe UI"); RenderTextProcessorWithAlignment(emojiFont, "😀A😀", pointSize: 20, fallbackFonts: new[] { colorEmoji }); RenderTextProcessorWithAlignment(uiFont, "this\nis\na\ntest", pointSize: 20, fallbackFonts: new[] { font2 }); RenderTextProcessorWithAlignment(uiFont, "first\n\n\n\nlast", pointSize: 20, fallbackFonts: new[] { font2 }); // fallback font tests RenderTextProcessor(colorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(colorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(colorEmoji, "😀", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(emojiFont, "😀", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(font2, string.Empty, pointSize: 72, fallbackFonts: new[] { emojiFont }); RenderText(font2, "😀 Hello World! 😀", pointSize: 72, fallbackFonts: new[] { emojiFont }); //// general RenderText(font, "abc", 72); RenderText(font, "ABd", 72); RenderText(fontWoff, "abe", 72); RenderText(fontWoff, "ABf", 72); RenderText(font2, "ov", 72); RenderText(font2, "a\ta", 72); RenderText(font2, "aa\ta", 72); RenderText(font2, "aaa\ta", 72); RenderText(font2, "aaaa\ta", 72); RenderText(font2, "aaaaa\ta", 72); RenderText(font2, "aaaaaa\ta", 72); RenderText(font2, "Hello\nWorld", 72); RenderText(carter, "Hello\0World", 72); RenderText(wendy_One, "Hello\0World", 72); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\t\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 0 }, "Zero\tTab"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 0 }, "Zero\tTab"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "One\tTab"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 6 }, "\tTab Then Words"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "Tab Then Words"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "Words Then Tab\t"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, " Spaces Then Words"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "Words Then Spaces "); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "\naaaabbbbccccddddeeee\n\t\t\t3 tabs\n\t\t\t\t\t5 tabs"); RenderText(new Font(SystemFonts.Find("Arial"), 20f, FontStyle.Regular), "á é à ó ú ç ã õ", 200, 50); RenderText(new Font(SystemFonts.Find("Arial"), 10f, FontStyle.Regular), "PGEP0JK867", 200, 50); RenderText(new RendererOptions(SystemFonts.CreateFont("consolas", 72)) { TabWidth = 4 }, "xxxxxxxxxxxxxxxx\n\txxxx\txxxx\n\t\txxxxxxxx\n\t\t\txxxx"); BoundingBoxes.Generate("a b c y q G H T", SystemFonts.CreateFont("arial", 40f)); TextAlignment.Generate(SystemFonts.CreateFont("arial", 50f)); TextAlignmentWrapped.Generate(SystemFonts.CreateFont("arial", 50f)); var sb = new StringBuilder(); for (char c = 'a'; c <= 'z'; c++) { sb.Append(c); } for (char c = 'A'; c <= 'Z'; c++) { sb.Append(c); } for (char c = '0'; c <= '9'; c++) { sb.Append(c); } string text = sb.ToString(); foreach (FontFamily f in fonts.Families) { RenderText(f, text, 72); } FontFamily simsum = SystemFonts.Find("SimSun"); RenderText(simsum, "这是一段长度超出设定的æ�¢è¡Œå®½åº¦çš„文本,但是没有在设定的宽度处æ�¢è¡Œã€‚这段文本用于演示问题。希望å�¯ä»¥ä¿®å¤�。如果有需è¦�å�¯ä»¥è�”系我。", 16); FontFamily arial = SystemFonts.Find("Arial"); RenderText(arial, "ìÃîï", 72); }
public static void Main(string[] args) { var fonts = new FontCollection(); var woffFonts = new FontCollection(); FontFamily font = fonts.Add(@"Fonts\SixLaborsSampleAB.ttf"); FontFamily fontWoff = woffFonts.Add(@"Fonts\SixLaborsSampleAB.woff"); FontFamily fontWoff2 = woffFonts.Add(@"Fonts\OpenSans-Regular.woff2"); FontFamily carter = fonts.Add(@"Fonts\CarterOne.ttf"); FontFamily wendyOne = fonts.Add(@"Fonts\WendyOne-Regular.ttf"); FontFamily whitneyBook = fonts.Add(@"Fonts\whitney-book.ttf"); FontFamily colorEmoji = fonts.Add(@"Fonts\Twemoji Mozilla.ttf"); FontFamily font2 = fonts.Add(@"Fonts\OpenSans-Regular.ttf"); FontFamily sunflower = fonts.Add(@"Fonts\Sunflower-Medium.ttf"); #if OS_WINDOWS FontFamily emojiFont = SystemFonts.Get("Segoe UI Emoji"); FontFamily uiFont = SystemFonts.Get("Segoe UI"); FontFamily arabicFont = SystemFonts.Get("Dubai"); FontFamily tahoma = SystemFonts.Get("Tahoma"); RenderText(font2, "\uFB01", pointSize: 11.25F); RenderText(fontWoff2, "\uFB01", pointSize: 11.25F); RenderText(tahoma, "p", pointSize: 11.25F); RenderText(tahoma, "Lorem ipsum dolor sit amet", pointSize: 11.25F); return; RenderText(uiFont, "Soft\u00ADHyphen", pointSize: 72); FontFamily bugzilla = fonts.Add(@"Fonts\me_quran_volt_newmet.ttf"); RenderText(uiFont, "Soft\u00ADHyphen", pointSize: 72); RenderText(bugzilla, "بِسْمِ ٱللَّهِ ٱلرَّحْمَٟنِ ٱلرَّحِيمِ", pointSize: 72); RenderText(uiFont, "first\n\n\n\nl", pointSize: 20, fallbackFonts: new[] { font2 }); RenderText(uiFont, "first\n\n\n\nlast", pointSize: 20, fallbackFonts: new[] { font2 }); RenderText(uiFont, "Testing", pointSize: 20); RenderText(emojiFont, "👩🏽🚒a", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(arabicFont, "English اَلْعَرَبِيَّةُ English", pointSize: 20); RenderText(arabicFont, "English English", pointSize: 20); RenderText(arabicFont, "اَلْعَرَبِيَّةُ اَلْعَرَبِيَّةُ", pointSize: 20); RenderText(arabicFont, "اَلْعَرَبِيَّةُ", pointSize: 20); RenderText(arabicFont, "SS ص", pointSize: 20); RenderText(arabicFont, "S ص", pointSize: 20); RenderText(arabicFont, "English اَلْعَرَبِيَّةُ", pointSize: 20); RenderTextProcessorWithAlignment(emojiFont, "😀A😀", pointSize: 20, fallbackFonts: new[] { colorEmoji }); RenderTextProcessorWithAlignment(uiFont, "this\nis\na\ntest", pointSize: 20, fallbackFonts: new[] { font2 }); RenderTextProcessorWithAlignment(uiFont, "first\n\n\n\nlast", pointSize: 20, fallbackFonts: new[] { font2 }); RenderText(emojiFont, "😀", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(font2, string.Empty, pointSize: 72, fallbackFonts: new[] { emojiFont }); RenderText(font2, "😀 Hello World! 😀", pointSize: 72, fallbackFonts: new[] { emojiFont }); #endif // fallback font tests RenderTextProcessor(colorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(colorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(colorEmoji, "😀", pointSize: 72, fallbackFonts: new[] { font2 }); //// general RenderText(font, "abc", 72); RenderText(font, "ABd", 72); RenderText(fontWoff, "abe", 72); RenderText(fontWoff, "ABf", 72); RenderText(fontWoff2, "woff2", 72); RenderText(font2, "ov", 72); RenderText(font2, "a\ta", 72); RenderText(font2, "aa\ta", 72); RenderText(font2, "aaa\ta", 72); RenderText(font2, "aaaa\ta", 72); RenderText(font2, "aaaaa\ta", 72); RenderText(font2, "aaaaaa\ta", 72); RenderText(font2, "Hello\nWorld", 72); RenderText(carter, "Hello\0World", 72); RenderText(wendyOne, "Hello\0World", 72); RenderText(whitneyBook, "Hello\0World", 72); RenderText(sunflower, "í", 30); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\tx"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\tx"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\t\tx"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\t\t\tx"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 0 }, "Zero\tTab"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 0 }, "Zero\tTab"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 1 }, "One\tTab"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 6 }, "\tTab Then Words"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 1 }, "Tab Then Words"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 1 }, "Words Then Tab\t"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 1 }, " Spaces Then Words"); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 1 }, "Words Then Spaces "); RenderText(new TextOptions(new Font(font2, 72)) { TabWidth = 1 }, "\naaaabbbbccccddddeeee\n\t\t\t3 tabs\n\t\t\t\t\t5 tabs"); #if OS_WINDOWS RenderText(new Font(SystemFonts.Get("Arial"), 20f, FontStyle.Regular), "á é í ó ú ç ã õ", 200, 50); RenderText(new Font(SystemFonts.Get("Arial"), 10f, FontStyle.Regular), "PGEP0JK867", 200, 50); RenderText(new TextOptions(SystemFonts.CreateFont("consolas", 72)) { TabWidth = 4 }, "xxxxxxxxxxxxxxxx\n\txxxx\txxxx\n\t\txxxxxxxx\n\t\t\txxxx"); BoundingBoxes.Generate("a b c y q G H T", SystemFonts.CreateFont("arial", 40f)); TextAlignmentSample.Generate(SystemFonts.CreateFont("arial", 50f)); TextAlignmentWrapped.Generate(SystemFonts.CreateFont("arial", 50f)); FontFamily simsum = SystemFonts.Get("SimSun"); RenderText(simsum, "这是一段长度超出设定的换行宽度的文本,但是没有在设定的宽度处换行。这段文本用于演示问题。希望可以修复。如果有需要可以联系我。", 16); FontFamily jhengHei = SystemFonts.Get("Microsoft JhengHei"); RenderText(jhengHei, " ,;:!¥()?{}-=+\|~!@#%&", 16); FontFamily arial = SystemFonts.Get("Arial"); RenderText(arial, "ìíîï", 72); #endif var sb = new StringBuilder(); for (char c = 'a'; c <= 'z'; c++) { sb.Append(c); } for (char c = 'A'; c <= 'Z'; c++) { sb.Append(c); } for (char c = '0'; c <= '9'; c++) { sb.Append(c); } string text = sb.ToString(); foreach (FontFamily f in fonts.Families) { RenderText(f, text, 72); } }
/// <summary> /// Reads the model data for specified item and converts it into a .obj file /// </summary> /// <param name="itemID">The item ID</param> /// <param name="raceID">The currently selected races ID</param> /// <param name="part">items equipment slot</param> /// <param name="parentNode">Equipment slot name</param> /// <param name="childNode">Item Name</param> public Read3D(string itemID, string raceID, string part, string parentNode, string childNode) { string modelFolder, modelFile; modelFolder = "chara/equipment/e" + itemID + "/model"; modelFile = "c" + raceID + "e" + itemID + "_" + part + ".mdl"; FindOffset fo = new FindOffset(modelFile); string offset = fo.getFileOffset(); int loc = ((int.Parse(offset, NumberStyles.HexNumber) / 8) & 0x000f) / 2; using (BinaryReader br = new BinaryReader(File.OpenRead(Properties.Settings.Default.DefaultDir + "/040000.win32.dat" + loc))) { int initialOffset = int.Parse(offset, NumberStyles.HexNumber); if (loc == 1) { initialOffset = initialOffset - 16; } else if (loc == 2) { initialOffset = initialOffset - 32; } else if (loc == 3) { initialOffset = initialOffset - 48; } List <byte> byteList = new List <byte>(); br.BaseStream.Seek(initialOffset, SeekOrigin.Begin); int headerLength = br.ReadInt32(); int type = br.ReadInt32(); int decompressedSize = br.ReadInt32(); br.ReadBytes(8); int parts = br.ReadInt16(); int endOfHeader = initialOffset + headerLength; int partCount = 0; byteList.AddRange(new byte[68]); br.BaseStream.Seek(initialOffset + 24, SeekOrigin.Begin); int[] chunkUncompSizes = new int[11]; int[] chunkLengths = new int[11]; int[] chunkOffsets = new int[11]; int[] chunkBlockStart = new int[11]; int[] chunkNumBlocks = new int[11]; for (int f = 0; f < 11; f++) { chunkUncompSizes[f] = br.ReadInt32(); } for (int f = 0; f < 11; f++) { chunkLengths[f] = br.ReadInt32(); } for (int f = 0; f < 11; f++) { chunkOffsets[f] = br.ReadInt32(); } for (int f = 0; f < 11; f++) { chunkBlockStart[f] = br.ReadInt16(); } int totalBlocks = 0; for (int f = 0; f < 11; f++) { chunkNumBlocks[f] = br.ReadInt16(); totalBlocks += chunkNumBlocks[f]; } meshCount = br.ReadInt16(); materialCount = br.ReadInt16(); br.ReadBytes(4); int[] blockSizes = new int[totalBlocks]; for (int f = 0; f < totalBlocks; f++) { blockSizes[f] = br.ReadInt16(); } br.BaseStream.Seek(initialOffset + headerLength + chunkOffsets[0], SeekOrigin.Begin); for (int i = 0; i < blockSizes.Length; i++) { int lastPos = (int)br.BaseStream.Position; br.ReadBytes(8); int partCompressedSize = br.ReadInt32(); int partDecompressedSize = br.ReadInt32(); if (partCompressedSize == 32000) { byte[] forlist = br.ReadBytes(partDecompressedSize); byteList.AddRange(forlist); } else { byte[] forlist = br.ReadBytes(partCompressedSize); byte[] partDecompressedBytes = new byte[partDecompressedSize]; using (MemoryStream ms = new MemoryStream(forlist)) { using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress)) { int count = ds.Read(partDecompressedBytes, 0x00, partDecompressedSize); } } byteList.AddRange(partDecompressedBytes); } br.BaseStream.Seek(lastPos + blockSizes[i], SeekOrigin.Begin); } decompBytes = byteList.ToArray(); } using (BinaryReader br = new BinaryReader(new MemoryStream(decompBytes))) { Model model = new Model(meshCount, materialCount); for (int x = 0; x < 3; x++) { List <MeshInfo> mInfo = new List <MeshInfo>(); for (int i = 0; i < meshCount / 3; i++) { mInfo.Clear(); br.BaseStream.Seek((x * 136) + 68, SeekOrigin.Begin); int dataArrayNum = br.ReadByte(); while (dataArrayNum != 255) { MeshInfo meshInfo = new MeshInfo(dataArrayNum, br.ReadByte(), br.ReadByte(), br.ReadByte()); mInfo.Add(meshInfo); br.ReadBytes(4); dataArrayNum = br.ReadByte(); } model.Quality[x].meshInfoDict.Add(i, mInfo.ToArray()); } } br.BaseStream.Seek(136 * meshCount + 68, SeekOrigin.Begin); model.numStrings = br.ReadInt32(); model.stringBlockSize = br.ReadInt32(); br.ReadBytes(model.stringBlockSize); br.ReadBytes(4); model.numTotalMeshes = br.ReadInt16(); model.numAtrStrings = br.ReadInt16(); model.numParts = br.ReadInt16(); model.numMaterialStrings = br.ReadInt16(); model.numBoneStrings = br.ReadInt16(); model.numBoneLists = br.ReadInt16(); model.unk1 = br.ReadInt16(); model.unk2 = br.ReadInt16(); model.unk3 = br.ReadInt16(); model.unk4 = br.ReadInt16(); model.unk5 = br.ReadInt16(); model.unk6 = br.ReadInt16(); br.ReadBytes(10); model.unk7 = br.ReadInt16(); br.ReadBytes(16); br.ReadBytes(32 * model.unk5); for (int i = 0; i < 3; i++) { model.Quality[i].meshOffset = br.ReadInt16(); model.Quality[i].numMeshes = br.ReadInt16(); br.ReadBytes(40); model.Quality[i].vertDataSize = br.ReadInt32(); model.Quality[i].indexDataSize = br.ReadInt32(); model.Quality[i].vertOffset = br.ReadInt32(); model.Quality[i].indexOffset = br.ReadInt32(); } for (int x = 0; x < 3; x++) { for (int i = 0; i < meshCount / 3; i++) { Mesh m = new Mesh(); m.numVerts = br.ReadInt32(); m.numIndex = br.ReadInt32(); m.materialNumber = br.ReadInt16(); m.partTableOffset = br.ReadInt16(); m.partTableCount = br.ReadInt16(); m.boneListIndex = br.ReadInt16(); m.indexDataOffset = br.ReadInt32(); for (int j = 0; j < 3; j++) { m.vertexDataOffsets[j] = br.ReadInt32(); } for (int k = 0; k < 3; k++) { m.vertexSizes[k] = br.ReadByte(); } m.numBuffers = br.ReadByte(); model.Quality[x].mesh[i] = m; } } br.ReadBytes(model.numAtrStrings * 4); br.ReadBytes(model.unk6 * 20); model.setMeshParts(); for (int i = 0; i < model.numParts; i++) { MeshPart mp = new MeshPart(); mp.indexOffset = br.ReadInt32(); mp.indexCount = br.ReadInt32(); mp.attributes = br.ReadInt32(); mp.boneReferenceOffset = br.ReadInt16(); mp.boneReferenceCount = br.ReadInt16(); model.meshPart[i] = mp; } //something with attribute masks br.ReadBytes(model.unk7 * 12); br.ReadBytes(model.numMaterialStrings * 4); br.ReadBytes(model.numBoneStrings * 4); model.setBoneList(); for (int i = 0; i < model.numBoneLists; i++) { BoneList bl = new BoneList(); for (int j = 0; j < 64; j++) { bl.boneList[j] = br.ReadInt16(); } bl.boneCount = br.ReadInt32(); model.boneList[i] = bl; } br.ReadBytes(model.unk1 * 16); br.ReadBytes(model.unk2 * 12); br.ReadBytes(model.unk3 * 4); model.boneIndexSize = br.ReadInt32(); model.setBoneIndicies(); for (int i = 0; i < model.boneIndexSize / 2; i++) { model.boneIndicies[i] = br.ReadInt16(); } int padding = br.ReadByte(); br.ReadBytes(padding); for (int i = 0; i < model.bb.Length; i++) { BoundingBoxes bb = new BoundingBoxes(); for (int j = 0; j < 4; j++) { bb.pointA[j] = br.ReadSingle(); } for (int k = 0; k < 4; k++) { bb.pointB[k] = br.ReadSingle(); } model.bb[i] = bb; } for (int i = 0; i < 3; i++) { for (int j = 0; j < model.Quality[i].numMeshes; j++) { Mesh m = model.Quality[i].mesh[j]; m.setMeshData(); for (int k = 0; k < m.numBuffers; k++) { br.BaseStream.Seek(model.Quality[i].vertOffset + m.vertexDataOffsets[k], SeekOrigin.Begin); MeshData md = new MeshData(); md.meshData = br.ReadBytes(m.vertexSizes[k] * m.numVerts); m.meshData[k] = md; } br.BaseStream.Seek(model.Quality[i].indexOffset + (m.indexDataOffset * 2), SeekOrigin.Begin); m.indexData = br.ReadBytes(2 * m.numIndex); } } List <string> objBytes = new List <string>(); int vertexs = 0, coordinates = 0, normals = 0; for (int i = 0; i < model.Quality[0].numMeshes; i++) { objBytes.Clear(); Mesh m = model.Quality[0].mesh[i]; MeshInfo[] mi = model.Quality[0].meshInfoDict[i]; int c = 0; foreach (var a in mi) { if (a.useType == 0) { vertexs = c; } else if (a.useType == 3) { normals = c; } else if (a.useType == 4) { coordinates = c; } c++; } using (BinaryReader br1 = new BinaryReader(new MemoryStream(m.meshData[mi[vertexs].dataArrayNum].meshData))) { for (int j = 0; j < m.numVerts; j++) { int offset1 = j * m.vertexSizes[mi[vertexs].dataArrayNum] + mi[vertexs].offset; br1.BaseStream.Seek(offset1, SeekOrigin.Begin); if (mi[vertexs].dataType == 13 || mi[vertexs].dataType == 14) { float f1, f2, f3; Half h1 = Half.ToHalf((ushort)br1.ReadInt16()); Half h2 = Half.ToHalf((ushort)br1.ReadInt16()); Half h3 = Half.ToHalf((ushort)br1.ReadInt16()); f1 = HalfHelper.HalfToSingle(h1); f2 = HalfHelper.HalfToSingle(h2); f3 = HalfHelper.HalfToSingle(h3); objBytes.Add("v " + f1.ToString() + " " + f2.ToString() + " " + f3.ToString() + " "); } else if (mi[vertexs].dataType == 2) { float f1, f2, f3; f1 = br1.ReadSingle(); f2 = br1.ReadSingle(); f3 = br1.ReadSingle(); objBytes.Add("v " + f1.ToString() + " " + f2.ToString() + " " + f3.ToString() + " "); } } } using (BinaryReader br1 = new BinaryReader(new MemoryStream(m.meshData[mi[coordinates].dataArrayNum].meshData))) { for (int j = 0; j < m.numVerts; j++) { int offset1 = j * m.vertexSizes[mi[coordinates].dataArrayNum] + mi[coordinates].offset; br1.BaseStream.Seek(offset1, SeekOrigin.Begin); Half a1 = Half.ToHalf((ushort)br1.ReadInt16()); Half b1 = Half.ToHalf((ushort)br1.ReadInt16()); float a = HalfHelper.HalfToSingle(a1); float b = (HalfHelper.HalfToSingle(b1)); objBytes.Add("vt " + a.ToString() + " " + b.ToString() + " "); } } using (BinaryReader br1 = new BinaryReader(new MemoryStream(m.meshData[mi[normals].dataArrayNum].meshData))) { for (int j = 0; j < m.numVerts; j++) { br1.BaseStream.Seek(j * m.vertexSizes[mi[normals].dataArrayNum] + mi[normals].offset, SeekOrigin.Begin); Half h1 = Half.ToHalf((ushort)br1.ReadInt16()); Half h2 = Half.ToHalf((ushort)br1.ReadInt16()); Half h3 = Half.ToHalf((ushort)br1.ReadInt16()); objBytes.Add("vn " + HalfHelper.HalfToSingle(h1).ToString() + " " + HalfHelper.HalfToSingle(h2).ToString() + " " + HalfHelper.HalfToSingle(h3).ToString() + " "); } } using (BinaryReader br1 = new BinaryReader(new MemoryStream(m.indexData))) { for (int j = 0; j < m.numIndex; j += 3) { int a1 = br1.ReadInt16() + 1; int b1 = br1.ReadInt16() + 1; int c1 = br1.ReadInt16() + 1; objBytes.Add("f " + a1 + "/" + a1 + "/" + a1 + " " + b1 + "/" + b1 + "/" + b1 + " " + c1 + "/" + c1 + "/" + c1 + " "); } } Directory.CreateDirectory(Properties.Settings.Default.SaveDir + "/" + parentNode + "/" + childNode); File.WriteAllLines(Properties.Settings.Default.SaveDir + "/" + parentNode + "/" + childNode + "/Mesh_" + i + ".obj", objBytes.ToArray()); } } }
public scenario_structure_bsp(CacheBase Cache, int Address) { cache = Cache; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); #region sldt/lbsp ID //lbsp's sections address will be used instead of the one in sbsp int sectionAddress = 0; int sectionCount = 0; foreach (var item in Cache.IndexItems) { if (item.ClassCode == "scnr") { Reader.SeekTo(item.Offset + 76); int cnt = Reader.ReadInt32(); int ptr = Reader.ReadInt32() - Cache.Magic; int bspIndex = 0; for (int i = 0; i < cnt; i++) { Reader.SeekTo(ptr + 172 * i + 12); if (Cache.IndexItems.GetItemByID(Reader.ReadInt32()).Offset == Address) { bspIndex = i; break; } } Reader.SeekTo(item.Offset + 1844 + 12); int sldtID = Reader.ReadInt32(); int sldtAddress = Cache.IndexItems.GetItemByID(sldtID).Offset; Reader.SeekTo(sldtAddress + 4); cnt = Reader.ReadInt32(); ptr = Reader.ReadInt32() - Cache.Magic; Reader.SeekTo(ptr + 32 * bspIndex + 12); int lbspID = Reader.ReadInt32(); int lbspAddress = Cache.IndexItems.GetItemByID(lbspID).Offset; Reader.SeekTo(lbspAddress + 124); sectionCount = Reader.ReadInt32(); sectionAddress = Reader.ReadInt32() - Cache.Magic; Reader.SeekTo(lbspAddress + 268); geomRawID = Reader.ReadInt32(); break; } } #endregion Reader.SeekTo(Address + 236); XBounds = new RealBounds(Reader.ReadSingle(), Reader.ReadSingle()); YBounds = new RealBounds(Reader.ReadSingle(), Reader.ReadSingle()); ZBounds = new RealBounds(Reader.ReadSingle(), Reader.ReadSingle()); #region Clusters Block Reader.SeekTo(Address + 308); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Clusters.Add(new Cluster(Cache, iOffset + 140 * i)); } #endregion #region Shaders Block Reader.SeekTo(Address + 320); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Shaders.Add(new ReachRetail.render_model.Shader(Cache, iOffset + 44 * i)); } #endregion #region GeometryInstances Block Reader.SeekTo(Address + 608); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { GeomInstances.Add(new InstancedGeometry(Cache, iOffset + 4 * i)); } #region Load Fixup Data Reader.SeekTo(Address + 1298); int id = Reader.ReadUInt16(); var entry = Cache.zone.RawEntries[id]; var er = new EndianReader(new MemoryStream(Cache.zone.FixupData), EndianFormat.BigEndian); int addr = entry.Fixups[entry.Fixups.Count - 10].Offset; for (int i = 0; i < GeomInstances.Count; i++) { er.SeekTo(entry.FixupOffset + addr + 156 * i); var geom = GeomInstances[i]; geom.TransformScale = er.ReadSingle(); geom.TransformMatrix.m11 = er.ReadSingle(); geom.TransformMatrix.m12 = er.ReadSingle(); geom.TransformMatrix.m13 = er.ReadSingle(); geom.TransformMatrix.m21 = er.ReadSingle(); geom.TransformMatrix.m22 = er.ReadSingle(); geom.TransformMatrix.m23 = er.ReadSingle(); geom.TransformMatrix.m31 = er.ReadSingle(); geom.TransformMatrix.m32 = er.ReadSingle(); geom.TransformMatrix.m33 = er.ReadSingle(); geom.TransformMatrix.m41 = er.ReadSingle(); geom.TransformMatrix.m42 = er.ReadSingle(); geom.TransformMatrix.m43 = er.ReadSingle(); er.ReadUInt16(); er.ReadUInt16(); er.ReadUInt16(); geom.SectionIndex = er.ReadUInt16(); } er.Close(); er.Dispose(); #endregion #endregion Reader.SeekTo(Address + 796); RawID1 = Reader.ReadInt32(); Reader.SeekTo(Address + 976); RawID2 = Reader.ReadInt32(); #region ModelParts Block Reader.SeekTo(Address + 1100); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; if (sectionAddress == -Cache.Magic) { sectionAddress = iOffset; //null address in lbsp } for (int i = 0; i < iCount; i++) { ModelSections.Add(new ReachRetail.render_model.ModelSection(Cache, sectionAddress + 92 * i)); } #endregion #region Bounding Boxes Block Reader.SeekTo(Address + 1112); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { BoundingBoxes.Add(new ReachRetail.render_model.BoundingBox(Cache, iOffset + 52 * i)); } #endregion Reader.SeekTo(Address + 1244); RawID3 = Reader.ReadInt32(); }
public scenario_structure_bsp(CacheBase Cache, int Address) { cache = Cache; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); #region sldt ID //sldt's sections address will be used instead of the one in sbsp int sectionAddress = 0; foreach (var item in Cache.IndexItems) { if (item.ClassCode == "scnr") { Reader.SeekTo(item.Offset + 20); int cnt = Reader.ReadInt32(); int ptr = Reader.ReadInt32() - Cache.Magic; int bspIndex = 0; for (int i = 0; i < cnt; i++) { Reader.SeekTo(ptr + 108 * i + 12); if (Cache.IndexItems.GetItemByID(Reader.ReadInt32()).Offset == Address) { bspIndex = i; break; } } Reader.SeekTo(item.Offset + 1776 + 12); int sldtID = Reader.ReadInt32(); int sldtAddress = Cache.IndexItems.GetItemByID(sldtID).Offset; Reader.SeekTo(sldtAddress + 4); cnt = Reader.ReadInt32(); ptr = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < cnt; i++) { Reader.SeekTo(ptr + 436 * i + 2); if (Reader.ReadInt16() != bspIndex) { continue; } Reader.SeekTo(ptr + 436 * i + 312); sectionAddress = Reader.ReadInt32() - Cache.Magic; Reader.SeekTo(ptr + 436 * i + 428); geomRawID = Reader.ReadInt32(); } break; } } #endregion Reader.SeekTo(Address + 60); XBounds = new RealBounds(Reader.ReadSingle(), Reader.ReadSingle()); YBounds = new RealBounds(Reader.ReadSingle(), Reader.ReadSingle()); ZBounds = new RealBounds(Reader.ReadSingle(), Reader.ReadSingle()); #region Clusters Block Reader.SeekTo(Address + 180); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Clusters.Add(new Cluster(Cache, iOffset + 220 * i)); } #endregion #region Shaders Block Reader.SeekTo(Address + 192); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Shaders.Add(new Halo3Beta.render_model.Shader(Cache, iOffset + 36 * i)); } #endregion #region GeometryInstances Block Reader.SeekTo(Address + 432); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { GeomInstances.Add(new InstancedGeometry(Cache, iOffset + 120 * i)); } #endregion Reader.SeekTo(Address + 580); RawID1 = Reader.ReadInt32(); #region ModelSections Block Reader.SeekTo(Address + 740); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new Halo3Beta.render_model.ModelSection(Cache, sectionAddress + 76 * i)); } #endregion #region Bounding Boxes Block Reader.SeekTo(Address + 752); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { BoundingBoxes.Add(new Halo3Beta.render_model.BoundingBox(Cache, iOffset + 44 * i)); } #endregion Reader.SeekTo(Address + 860); RawID2 = Reader.ReadInt32(); Reader.SeekTo(Address + 892); RawID3 = Reader.ReadInt32(); }
public static void Main(string[] args) { FontCollection fonts = new FontCollection(); FontFamily font = fonts.Install(@"..\..\tests\SixLabors.Fonts.Tests\Fonts\SixLaborsSampleAB.ttf"); FontFamily fontWoff = fonts.Install(@"..\..\tests\SixLabors.Fonts.Tests\Fonts\SixLaborsSampleAB.woff"); FontFamily font2 = fonts.Install(@"..\..\tests\SixLabors.Fonts.Tests\Fonts\OpenSans-Regular.ttf"); FontFamily carter = fonts.Install(@"..\..\tests\SixLabors.Fonts.Tests\Fonts\Carter_One\CarterOne.ttf"); FontFamily Wendy_One = fonts.Install(@"..\..\tests\SixLabors.Fonts.Tests\Fonts\Wendy_One\WendyOne-Regular.ttf"); RenderText(font, "abc", 72); RenderText(font, "ABd", 72); RenderText(fontWoff, "abe", 72); RenderText(fontWoff, "ABf", 72); RenderText(font2, "ov", 72); RenderText(font2, "a\ta", 72); RenderText(font2, "aa\ta", 72); RenderText(font2, "aaa\ta", 72); RenderText(font2, "aaaa\ta", 72); RenderText(font2, "aaaaa\ta", 72); RenderText(font2, "aaaaaa\ta", 72); RenderText(font2, "Hello\nWorld", 72); RenderText(carter, "Hello\0World", 72); RenderText(Wendy_One, "Hello\0World", 72); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\t\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 0 }, "Zero\tTab"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 0 }, "Zero\tTab"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "One\tTab"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 6 }, "\tTab Then Words"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "Tab Then Words"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "Words Then Tab\t"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, " Spaces Then Words"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "Words Then Spaces "); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "\naaaabbbbccccddddeeee\n\t\t\t3 tabs\n\t\t\t\t\t5 tabs"); RenderText(new Font(SystemFonts.Find("Arial"), 20f, FontStyle.Regular), "á é í ó ú ç ã õ", 200, 50); RenderText(new Font(SystemFonts.Find("Arial"), 10f, FontStyle.Regular), "PGEP0JK867", 200, 50); RenderText(new RendererOptions(SystemFonts.CreateFont("consolas", 72)) { TabWidth = 4 }, "xxxxxxxxxxxxxxxx\n\txxxx\txxxx\n\t\txxxxxxxx\n\t\t\txxxx"); BoundingBoxes.Generate("a b c y q G H T", SystemFonts.CreateFont("arial", 40f)); TextAlignment.Generate(SystemFonts.CreateFont("arial", 50f)); TextAlignmentWrapped.Generate(SystemFonts.CreateFont("arial", 50f)); StringBuilder sb = new StringBuilder(); for (char c = 'a'; c <= 'z'; c++) { sb.Append(c); } for (char c = 'A'; c <= 'Z'; c++) { sb.Append(c); } for (char c = '0'; c <= '9'; c++) { sb.Append(c); } string text = sb.ToString(); foreach (FontFamily f in fonts.Families) { RenderText(f, text, 72); } }
public render_model(CacheBase Cache, int Address) { cache = Cache; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Name = Cache.Strings.GetItemByID(Reader.ReadInt32()); Flags = new Bitmask(Reader.ReadInt32()); #region Regions Block Reader.SeekTo(Address + 12); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Regions.Add(new Region(Cache, iOffset + 16 * i)); } #endregion Reader.SeekTo(Address + 28); InstancedGeometryIndex = Reader.ReadInt32(); #region Instanced Geometry Block Reader.SeekTo(Address + 32); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { GeomInstances.Add(new InstancedGeometry(Cache, iOffset + 60 * i)); } #endregion #region Nodes Block Reader.SeekTo(Address + 48); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Nodes.Add(new Node(Cache, iOffset + 96 * i)); } #endregion #region MarkerGroups Block Reader.SeekTo(Address + 60); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { MarkerGroups.Add(new MarkerGroup(Cache, iOffset + 16 * i)); } #endregion #region Shaders Block Reader.SeekTo(Address + 72); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Shaders.Add(new Shader(Cache, iOffset + 44 * i)); } #endregion #region ModelSections Block Reader.SeekTo(Address + 104); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new ModelSection(Cache, iOffset + 92 * i)); } #endregion #region BoundingBox Block Reader.SeekTo(Address + 116); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { BoundingBoxes.Add(new BoundingBox(Cache, iOffset + 52 * i)); } #endregion #region NodeMapGroup Block Reader.SeekTo(Address + 176); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { NodeIndexGroups.Add(new NodeIndexGroup(Cache, iOffset + 12 * i)); } #endregion Reader.SeekTo(Address + 236); RawID = Reader.ReadInt32(); }
public scenario_structure_bsp(CacheBase Cache, int Address) { cache = Cache; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); #region sldt/lbsp ID //lbsp's sections address will be used instead of the one in sbsp int sectCount = 0, sectionAddress = 0, bbCount = 0, bbAddr = 0; foreach (var item in Cache.IndexItems) { if (item.ClassCode == "scnr") { Reader.SeekTo(item.Offset + 160); int cnt = Reader.ReadInt32(); int ptr = Reader.ReadInt32() - Cache.Magic; int bspIndex = 0; for (int i = 0; i < cnt; i++) { Reader.SeekTo(ptr + 336 * i + 12); if (Cache.IndexItems.GetItemByID(Reader.ReadInt32()).Offset == Address) { bspIndex = i; break; } } Reader.SeekTo(item.Offset + 1896 + 12); int sldtID = Reader.ReadInt32(); int sldtAddress = Cache.IndexItems.GetItemByID(sldtID).Offset; Reader.SeekTo(sldtAddress + 4); cnt = Reader.ReadInt32(); ptr = Reader.ReadInt32() - Cache.Magic; Reader.SeekTo(ptr + 32 * bspIndex + 12); int lbspID = Reader.ReadInt32(); int lbspAddress = Cache.IndexItems.GetItemByID(lbspID).Offset; Reader.SeekTo(lbspAddress + 320); //320, 512, 692 sectCount = Reader.ReadInt32(); sectionAddress = Reader.ReadInt32() - Cache.Magic; Reader.SeekTo(lbspAddress + 344); //344, 536, 716 bbCount = Reader.ReadInt32(); bbAddr = Reader.ReadInt32() - Cache.Magic; Reader.SeekTo(lbspAddress + 464); //464, 656, 836 geomRawID = Reader.ReadInt32(); break; } } #endregion Reader.SeekTo(Address + 268); XBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); YBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); ZBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); #region Clusters Block Reader.SeekTo(Address + 340); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < 1; i++) { Clusters.Add(new Cluster(Cache, iOffset + 140 * i)); } #endregion #region Shaders Block Reader.SeekTo(Address + 352); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Shaders.Add(new Halo4Retail.render_model.Shader(Cache, iOffset + 44 * i)); } #endregion #region GeometryInstances Block Reader.SeekTo(Address + 640); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { GeomInstances.Add(new InstancedGeometry(Cache, iOffset + 4 * i)); } #region Load Fixup Data Reader.SeekTo(Address + 1364); int id = Reader.ReadInt32(); var entry = Cache.zone.RawEntries[id & 0xFFFF]; var er = new EndianReader(new MemoryStream(Cache.GetRawFromID(id)), EndianFormat.Big); int addr = entry.Fixups[entry.Fixups.Count - 10].Offset; for (int i = 0; i < GeomInstances.Count; i++) { er.SeekTo(addr + 148 * i); var geom = GeomInstances[i]; geom.TransformScale = er.ReadSingle(); geom.TransformMatrix = Matrix4x3.Read(er); er.ReadUInt16(); er.ReadUInt16(); er.ReadInt32(); er.ReadUInt16(); geom.SectionIndex = er.ReadUInt16(); } er.Close(); er.Dispose(); #endregion #endregion Reader.SeekTo(Address + 844); RawID1 = Reader.ReadInt32(); Reader.SeekTo(Address + 1048); RawID2 = Reader.ReadInt32(); #region ModelSections Block Reader.SeekTo(Address + 1144); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; if (sectionAddress == -Cache.Magic) { sectionAddress = iOffset; //null address in lbsp } for (int i = 0; i < sectCount; i++) { ModelSections.Add(new Halo4Retail.render_model.ModelSection(Cache, sectionAddress + 112 * i)); } #endregion #region Bounding Boxes Block Reader.SeekTo(Address + 1168); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < bbCount; i++) { BoundingBoxes.Add(new Halo4Retail.render_model.BoundingBox(Cache, bbAddr + 52 * i)); } #endregion Reader.SeekTo(Address + 1288); RawID3 = Reader.ReadInt32(); }
// Update - Runs every frame public void Update(double dt) { Particle[] allParticles = bodyManager.particles.ToArray(); // Setup particle values for this Update foreach (Particle p in bodyManager.particles) { p.timeLeft = dt; // Update acceleration from particle forces foreach (IForce force in p.ExternalForces) { force.ApplyOn(allParticles); } } // Update acceleration from world forces foreach (IForce force in worldForces) { force.ApplyOn(allParticles); } // Apply acceleration - Update velocity based on current particle positions foreach (Particle p in allParticles) { // Apply acceleration - updates velocity based on acceleration and time step p.ApplyAcceleration(dt); p.Acceleration = new Vector(0, 0); } if (RigidbodyCollisions) { // Organize bodies to avoid unnecessary calculations IOrginization organization = new BoundingBoxes(bodyManager.bodies); //IOrginization organization = new SpatialGrid(bodyManager.bodies, 10); var organizedBodies = organization.Organize(); // Handle particle particle collisions foreach (List <Rigidbody> nearBodies in organizedBodies) { if (nearBodies.Count > 1) { new Collision(nearBodies[0], nearBodies[1], dt).Resolve(); } } } // Handle particle wall collisions // Move each particle for its remaining timeLeft // Make sure each particle is in bounds foreach (Particle p in bodyManager.particles) { foreach (Wall wall in new Wall[] { BottomWall, LeftWall, RightWall, TopWall }) { if (new Collision(p, wall).Resolve()) { break; } } if (p.timeLeft != 0) { p.SimMove(p.timeLeft); } // Check if particle is out of bounds - if so -> place in bounds if (p.Y > ContainerSize.Y - p.radius) { p.Move(0, ContainerSize.Y - p.radius - p.Y); } if (p.X > ContainerSize.X - p.radius) { p.Move(ContainerSize.X - p.radius - p.X, 0); } } }
/// <summary> /// Create a new geometry given filename /// </summary> /// <param name="fileName"> filepath to the 3D model file </param> public Geometry(string fileName, bool enableRigging = false) { RiggingEnabled = enableRigging; sourceFileName = fileName; //Create new importer. importer = new AssimpContext(); //import the file scene = importer.ImportFile(fileName, PostProcessSteps.CalculateTangentSpace | PostProcessSteps.Triangulate | PostProcessSteps.JoinIdenticalVertices | PostProcessSteps.SortByPrimitiveType | PostProcessSteps.GenerateUVCoords | PostProcessSteps.FlipUVs | PostProcessSteps.LimitBoneWeights | PostProcessSteps.ValidateDataStructure); //make sure scene not null if (scene == null) { throw new FileNotFoundException(); } //loop through sizes and count them. allMeshes = new List <ClientMesh>(scene.MeshCount); //loop through and store sizes for (int idx = 0; idx < scene.MeshCount; idx++) { ClientMesh mesh = new ClientMesh(); allMeshes.Add(mesh); mesh.CountVertices = scene.Meshes[idx].VertexCount; mesh.vertSize = scene.Meshes[idx].VertexCount * Vector3.SizeInBytes; mesh.normSize = scene.Meshes[idx].Normals.Count * Vector3.SizeInBytes; mesh.faceSize = scene.Meshes[idx].FaceCount * scene.Meshes[idx].Faces[0].IndexCount * sizeof(int); if (scene.Meshes[idx].HasTextureCoords(0)) { mesh.texSize = scene.Meshes[idx].TextureCoordinateChannels[0].Count * Vector3.SizeInBytes; } } diffuseTextureSRV = new Dictionary <string, ShaderResourceView>(); // do all the processing that rigging is required to have if (enableRigging) { _allBones = new List <ClientBone>(); _allBoneMappings = new Dictionary <string, int>(); _allBoneLookup = new Dictionary <string, ClientBone>(); // set the animation related lookup tables AnimationIndices = new Dictionary <string, int>(); _animationNodes = new List <Dictionary <string, ClientAnimationNode> >(scene.AnimationCount); for (int i = 0; i < scene.AnimationCount; i++) { AnimationIndices[scene.Animations[i].Name] = i; _animationNodes.Add(new Dictionary <string, ClientAnimationNode>()); for (int j = 0; j < scene.Animations[i].NodeAnimationChannelCount; j++) { NodeAnimationChannel ch = scene.Animations[i].NodeAnimationChannels[j]; ClientAnimationNode myNode = new ClientAnimationNode(ch.NodeName); _animationNodes[i][ch.NodeName] = myNode; myNode.Translations = new List <Vector3>(); myNode.TranslationTime = new List <double>(); myNode.Rotations = new List <Quaternion>(); myNode.RotationTime = new List <double>(); myNode.Scalings = new List <Vector3>(); myNode.ScalingTime = new List <double>(); // copy over all the necessary information in the animation channels for (int k = 0; k < ch.PositionKeyCount; k++) { myNode.Translations.Add(ch.PositionKeys[k].Value.ToVector3()); myNode.TranslationTime.Add(ch.PositionKeys[k].Time); } for (int k = 0; k < ch.RotationKeyCount; k++) { myNode.Rotations.Add(ch.RotationKeys[k].Value.ToQuaternion()); myNode.RotationTime.Add(ch.RotationKeys[k].Time); } for (int k = 0; k < ch.ScalingKeyCount; k++) { myNode.Scalings.Add(ch.ScalingKeys[k].Value.ToVector3()); myNode.ScalingTime.Add(ch.ScalingKeys[k].Time); } } } // create and store the big scene tree _rootBone = CreateBoneTree(scene.RootNode, null); // set each bone offset foreach (var sceneMesh in scene.Meshes) { foreach (var rawBone in sceneMesh.Bones) { ClientBone found; if (!_allBoneLookup.TryGetValue(rawBone.Name, out found)) { Console.WriteLine("Cannot find bone: " + rawBone.Name); continue; } found.BoneOffset = rawBone.OffsetMatrix.ToMatrix(); _allBones.Add(found); _allBoneMappings[found.BoneName] = _allBones.IndexOf(found); } } // for bones not inside the meshes...? jasdkl;fja;lskdjkfl foreach (var boneName in _allBoneLookup.Keys.Where(b => _allBones.All(b1 => b1.BoneName != b) && b.StartsWith("Bone"))) { _allBoneLookup[boneName].BoneOffset = _allBoneLookup[boneName].Parent.BoneOffset.Clone(); _allBones.Add(_allBoneLookup[boneName]); _allBoneMappings[boneName] = _allBones.IndexOf(_allBoneLookup[boneName]); } // load the bone weights for (int idx = 0; idx < scene.MeshCount; idx++) { LoadBoneWeights(scene.Meshes[idx], allMeshes[idx]); } //_boneTransformStream = new DataStream(MAX_BONES_PER_GEO * sizeof(float) * 16, true, true); _boneTransformList = new List <Matrix>(MAX_BONES_PER_GEO); for (int i = 0; i < MAX_BONES_PER_GEO; i++) { _boneTransformList.Add(Matrix.Identity); } } // main loading loop; copy cover the scene content into the datastreams and then to the buffers for (int idx = 0; idx < scene.MeshCount; idx++) { ClientMesh mesh = allMeshes[idx]; //create new datastreams. mesh.Vertices = new DataStream(mesh.vertSize, true, true); mesh.Normals = new DataStream(mesh.normSize, true, true); mesh.Faces = new DataStream(mesh.faceSize, true, true); // create a new material mesh.Materials = new ClientMaterial(); //min and max bounds var min = new Vector3(float.MaxValue); var max = new Vector3(float.MinValue); // copy the buffers scene.Meshes[idx].Vertices.ForEach(vertex => { mesh.Vertices.Write(vertex.ToVector3()); //keep track of min and max for obj boundaries. min = Vector3.Minimize(min, vertex.ToVector3()); max = Vector3.Maximize(max, vertex.ToVector3()); }); BoundingBoxes.Add(new BoundingBox(min, max)); scene.Meshes[idx].Normals.ForEach(normal => { mesh.Normals.Write(normal.ToVector3()); }); scene.Meshes[idx].Faces.ForEach(face => { mesh.Faces.WriteRange(face.Indices.ToArray()); }); // check if the mesh has texture coordinates if (scene.Meshes[idx].HasTextureCoords(0)) { mesh.TexCoords = new DataStream(mesh.texSize, true, true); scene.Meshes[idx].TextureCoordinateChannels[0].ForEach(texture => { mesh.TexCoords.Write(texture); }); mesh.TexCoords.Position = 0; } // Parse material properties ApplyMaterial(scene.Materials[scene.Meshes[idx].MaterialIndex], mesh.Materials); // reset datastream positions mesh.Vertices.Position = 0; mesh.Normals.Position = 0; mesh.Faces.Position = 0; //create vertex vbo and faces ebo. mesh.VBOPositions = new Buffer(GraphicsRenderer.Device, mesh.Vertices, mesh.vertSize, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); mesh.VBONormals = new Buffer(GraphicsRenderer.Device, mesh.Normals, mesh.normSize, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); if (scene.Meshes[idx].HasTextureCoords(0)) { mesh.VBOTexCoords = new Buffer(GraphicsRenderer.Device, mesh.TexCoords, mesh.texSize, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); } // buffer creation flags var ibd = new BufferDescription( mesh.faceSize, ResourceUsage.Immutable, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); mesh.EBO = new Buffer(GraphicsRenderer.Device, mesh.Faces, ibd); } _inverseGlobalTransform = Matrix.Invert(scene.RootNode.Transform.ToMatrix()); }
/** Returns true if the bounding box attachment contains the line segment. */ public bool IntersectsSegment(BoundingBoxAttachment attachment, float x1, float y1, float x2, float y2) { int index = BoundingBoxes.IndexOf(attachment); return(index == -1 ? false : IntersectsSegment(index, x1, y1, x2, y2)); }
/** Returns true if the bounding box attachment contains the point. The bounding box must be in the SkeletonBounds. */ public bool containsPoint(BoundingBoxAttachment attachment, float x, float y) { int index = BoundingBoxes.IndexOf(attachment); return(index == -1 ? false : ContainsPoint(index, x, y)); }
public gbxmodel(CacheBase Cache, int Address) { cache = Cache; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Name = "gbxmodel"; Flags = new Bitmask(Reader.ReadInt16()); Reader.SeekTo(Address + 0x30); uScale = Reader.ReadSingle(); vScale = Reader.ReadSingle(); #region MarkerGroups Block Reader.SeekTo(Address + 0xAC); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { MarkerGroups.Add(new MarkerGroup(Cache, iOffset + 64 * i)); } #endregion #region Nodes Block Reader.SeekTo(Address + 0xB8); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Nodes.Add(new Node(Cache, iOffset + 156 * i)); } #endregion #region Regions Block Reader.SeekTo(Address + 0xC4); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Regions.Add(new Region(Cache, iOffset + 76 * i)); } #endregion #region ModelParts Block Reader.SeekTo(Address + 0xD0); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new ModelSection(Cache, iOffset + 48 * i) { FacesIndex = i, VertsIndex = i, NodeIndex = 255 }); } #endregion #region Shaders Block Reader.SeekTo(Address + 0xDC); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Shaders.Add(new Shader(Cache, iOffset + 32 * i)); } #endregion #region BoundingBox Block BoundingBoxes.Add(new BoundingBox()); #endregion }
// Show the image / video file for the specified row, but only if its different from what is currently being displayed. private void FileShow(int fileIndex, bool isInSliderNavigation, bool forceUpdate) { // If there is no image set open, or if there is no image to show, then show an image indicating the empty image set. if (this.IsFileDatabaseAvailable() == false || this.DataHandler.FileDatabase.CountAllCurrentlySelectedFiles < 1) { this.MarkableCanvas.SetNewImage(Constant.ImageValues.NoFilesAvailable.Value, null); this.markersOnCurrentFile = null; this.MarkableCanvas_UpdateMarkers(); this.MarkableCanvas.SwitchToImageView(); // We could invalidate the cache here, but it will be reset anyways when images are loaded. if (this.DataHandler != null) { this.DataHandler.IsProgrammaticControlUpdate = false; } // We also need to do a bit of cleanup of UI elements that make no sense when there are no images to show. this.QuickPasteWindowHide(); return; } // If we are already showing the desired file, and if we are not forcing an update, // then abort as there is no need to redisplay the image. if (this.DataHandler.ImageCache.CurrentRow == fileIndex && forceUpdate == false) { return; } this.DataEntryControls.AutocompletionUpdateWithCurrentRowValues(); // for the bitmap caching logic below to work this should be the only place where code in TimelapseWindow moves the image enumerator if (this.DataHandler.ImageCache.TryMoveToFile(fileIndex, forceUpdate, out bool newFileToDisplay) == false) { if (this.DataHandler != null) { this.DataHandler.IsProgrammaticControlUpdate = false; } // We used to throw a new exception, but lets see what happens if we just return instead. // i.e., lets just abort. // throw new Exception(String.Format("in FileShow: possible problem with fileIndex value is {0}, where its not a valid row index in the image table.", fileIndex)); System.Diagnostics.Debug.Print(String.Format("in FileShow: possible problem with fileIndex (value is {0}, where its not a valid row index in the image table.", fileIndex)); return; } // Reset the ThumbnailGrid to the current image // SAULXX: COULD SET FOLDER PATH AND FILEDATABASE ON LOAD, BUT MAY BE BETTER TO JUST KEEP ON DOING IT HERE // SAULXX: Note that this used to be before the above if statement. Not sure if it would be a problem having it here (in case of failur) this.MarkableCanvas.ThumbnailGrid.FolderPath = this.FolderPath; this.MarkableCanvas.ThumbnailGrid.FileTableStartIndex = fileIndex; this.MarkableCanvas.ThumbnailGrid.FileTable = this.DataHandler.FileDatabase.FileTable; // Update each control with the data for the now current image // This is always done as it's assumed either the image changed or that a control refresh is required due to database changes // the call to TryMoveToImage() above refreshes the data stored under this.dataHandler.ImageCache.Current. this.DataHandler.IsProgrammaticControlUpdate = true; foreach (KeyValuePair <string, DataEntryControl> control in this.DataEntryControls.ControlsByDataLabel) { // update value string controlType = this.DataHandler.FileDatabase.FileTableColumnsByDataLabel[control.Key].ControlType; control.Value.SetContentAndTooltip(this.DataHandler.ImageCache.Current.GetValueDisplayString(control.Value.DataLabel)); // for note controls, update the autocomplete list if an edit occurred if (controlType == Constant.Control.Note) { DataEntryNote noteControl = (DataEntryNote)control.Value; if (noteControl.ContentChanged) { noteControl.ContentChanged = false; } } } this.DataHandler.IsProgrammaticControlUpdate = false; // update the status bar to show which image we are on out of the total displayed under the current selection // the total is always refreshed as it's not known if FileShow() is being called due to a change in the selection this.StatusBar.SetCurrentFile(fileIndex + 1); // Add one because indexes are 0-based this.StatusBar.SetCount(this.DataHandler.FileDatabase.CountAllCurrentlySelectedFiles); this.StatusBar.ClearMessage(); this.FileNavigatorSlider.Value = fileIndex + 1; // Get the bounding boxes and markers (if any) for the current image; BoundingBoxes bboxes = this.GetBoundingBoxesForCurrentFile(this.DataHandler.ImageCache.Current.ID); this.markersOnCurrentFile = this.DataHandler.FileDatabase.MarkersGetMarkersForCurrentFile(this.DataHandler.ImageCache.Current.ID); List <Marker> displayMarkers = this.GetDisplayMarkers(); // Display new file if the file changed // This avoids unnecessary image reloads and refreshes in cases where FileShow() is just being called to refresh controls if (newFileToDisplay) { if (this.DataHandler.ImageCache.Current.IsVideo) { this.MarkableCanvas.SetNewVideo(this.DataHandler.ImageCache.Current.GetFileInfo(this.DataHandler.FileDatabase.FolderPath), displayMarkers); this.EnableImageManipulationMenus(false); } else { this.MarkableCanvas.SetNewImage(this.DataHandler.ImageCache.GetCurrentImage, displayMarkers); // Draw markers for this file this.MarkableCanvas_UpdateMarkers(); this.MarkableCanvas.BoundingBoxes = bboxes; this.EnableImageManipulationMenus(true); } } else if (this.IsDisplayingSingleImage()) { if (this.DataHandler.ImageCache.Current.IsVideo) { this.MarkableCanvas.SwitchToVideoView(); } else { this.MarkableCanvas.SwitchToImageView(); this.MarkableCanvas_UpdateMarkers(); } } this.DataGridSelectionsTimer_Reset(); // Set the file player status if (this.DataHandler.ImageCache.CurrentRow == 0) { this.FilePlayer.BackwardsControlsEnabled(false); } else { this.FilePlayer.BackwardsControlsEnabled(true); } if (this.DataHandler.ImageCache.CurrentRow == this.DataHandler.FileDatabase.CountAllCurrentlySelectedFiles - 1) { this.FilePlayer.ForwardsControlsEnabled(false); } else { this.FilePlayer.ForwardsControlsEnabled(true); } // Refresh the Magnifier if needed if (this.IsDisplayingSingleImage()) { if (this.DataHandler.ImageCache.Current.IsVideo) { this.MarkableCanvas.SetMagnifiersAccordingToCurrentState(false, true); } else { this.MarkableCanvas.SetMagnifiersAccordingToCurrentState(true, false); } } // Refresh the CopyPreviousButton and its Previews as needed this.CopyPreviousValuesSetEnableStatePreviewsAndGlowsAsNeeded(); // Refresh the QuickPasteEntry previews if needed if (this.IsDisplayingSingleImage() && this.quickPasteWindow != null) { this.quickPasteWindow.RefreshQuickPasteWindowPreviewAsNeeded(); } // Refresh the markable canvas if needed this.MarkableCanvas.RefreshIfMultipleImagesAreDisplayed(isInSliderNavigation); // Display the episode and duplicate text as needed this.DisplayEpisodeTextInImageIfWarranted(fileIndex); this.DuplicateDisplayIndicatorInImageIfWarranted(); }
public Polygon GetPolygon(BoundingBoxAttachment attachment) { int index = BoundingBoxes.IndexOf(attachment); return(index == -1 ? null : Polygons.Items[index]); }
public scenario_structure_bsp(CacheBase Cache, int Address) { cache = Cache; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); #region sldt/lbsp ID //lbsp's sections address will be used instead of the one in sbsp int sectionAddress = 0; foreach (var item in Cache.IndexItems) { if (item.ClassCode == "scnr") { Reader.SeekTo(item.Offset + 68); int cnt = Reader.ReadInt32(); int ptr = Reader.ReadInt32() - Cache.Magic; int bspIndex = 0; for (int i = 0; i < cnt; i++) { Reader.SeekTo(ptr + 168 * i + 12); if (Cache.IndexItems.GetItemByID(Reader.ReadInt32()).Offset == Address) { bspIndex = i; break; } } Reader.SeekTo(item.Offset + 1828 + 12); int sldtID = Reader.ReadInt32(); var sldt = Cache.IndexItems.GetItemByID(sldtID); int sldtAddress = Cache.IndexItems.GetItemByID(sldtID).Offset; Reader.SeekTo(sldtAddress + 4); cnt = Reader.ReadInt32(); ptr = Reader.ReadInt32() - Cache.Magic; Reader.SeekTo(ptr + 32 * bspIndex + 12); int lbspID = Reader.ReadInt32(); var lbsp = Cache.IndexItems.GetItemByID(lbspID); int lbspAddress = Cache.IndexItems.GetItemByID(lbspID).Offset; Reader.SeekTo(lbspAddress + 116); sectionAddress = Reader.ReadInt32() - Cache.Magic; Reader.SeekTo(lbspAddress + 244); geomRawID = Reader.ReadInt32(); break; } } #endregion Reader.SeekTo(Address + 236); XBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); YBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); ZBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); #region Clusters Block Reader.SeekTo(Address + 308); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Clusters.Add(new Cluster(Cache, iOffset + 288 * i)); } #endregion #region Shaders Block Reader.SeekTo(Address + 320); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Shaders.Add(new ReachBeta.render_model.Shader(Cache, iOffset + 44 * i)); } #endregion #region GeometryInstances Block Reader.SeekTo(Address + 620); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { GeomInstances.Add(new InstancedGeometry(Cache, iOffset + 168 * i)); } #endregion Reader.SeekTo(Address + 796); RawID1 = Reader.ReadInt32(); Reader.SeekTo(Address + 976); RawID2 = Reader.ReadInt32(); #region ModelParts Block Reader.SeekTo(Address + 1112); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new ReachBeta.render_model.ModelSection(Cache, sectionAddress + 92 * i)); } #endregion #region Bounding Boxes Block Reader.SeekTo(Address + 1124); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { BoundingBoxes.Add(new ReachBeta.render_model.BoundingBox(Cache, iOffset + 52 * i)); } #endregion Reader.SeekTo(Address + 1244); RawID3 = Reader.ReadInt32(); }
public static void Main(string[] args) { var fonts = new FontCollection(); FontFamily font = fonts.Install(@"Fonts\SixLaborsSampleAB.ttf"); FontFamily fontWoff = fonts.Install(@"Fonts\SixLaborsSampleAB.woff"); FontFamily carter = fonts.Install(@"Fonts\CarterOne.ttf"); FontFamily Wendy_One = fonts.Install(@"Fonts\WendyOne-Regular.ttf"); FontFamily ColorEmoji = fonts.Install(@"Fonts\Twemoji Mozilla.ttf"); FontFamily font2 = fonts.Install(@"Fonts\OpenSans-Regular.ttf"); var emojiFont = SystemFonts.Find("Segoe UI Emoji"); // fallback font tests RenderTextProcessor(ColorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(ColorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(ColorEmoji, "😀", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(emojiFont, "😀", pointSize: 72, fallbackFonts: new[] { font2 }); RenderText(font2, "", pointSize: 72, fallbackFonts: new[] { emojiFont }); RenderText(font2, "😀 Hello World! 😀", pointSize: 72, fallbackFonts: new[] { emojiFont }); //// general RenderText(font, "abc", 72); RenderText(font, "ABd", 72); RenderText(fontWoff, "abe", 72); RenderText(fontWoff, "ABf", 72); RenderText(font2, "ov", 72); RenderText(font2, "a\ta", 72); RenderText(font2, "aa\ta", 72); RenderText(font2, "aaa\ta", 72); RenderText(font2, "aaaa\ta", 72); RenderText(font2, "aaaaa\ta", 72); RenderText(font2, "aaaaaa\ta", 72); RenderText(font2, "Hello\nWorld", 72); RenderText(carter, "Hello\0World", 72); RenderText(Wendy_One, "Hello\0World", 72); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 4 }, "\t\t\t\t\tx"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 0 }, "Zero\tTab"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 0 }, "Zero\tTab"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "One\tTab"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 6 }, "\tTab Then Words"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "Tab Then Words"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "Words Then Tab\t"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, " Spaces Then Words"); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "Words Then Spaces "); RenderText(new RendererOptions(new Font(font2, 72)) { TabWidth = 1 }, "\naaaabbbbccccddddeeee\n\t\t\t3 tabs\n\t\t\t\t\t5 tabs"); RenderText(new Font(SystemFonts.Find("Arial"), 20f, FontStyle.Regular), "á é à ó ú ç ã õ", 200, 50); RenderText(new Font(SystemFonts.Find("Arial"), 10f, FontStyle.Regular), "PGEP0JK867", 200, 50); RenderText(new RendererOptions(SystemFonts.CreateFont("consolas", 72)) { TabWidth = 4 }, "xxxxxxxxxxxxxxxx\n\txxxx\txxxx\n\t\txxxxxxxx\n\t\t\txxxx"); BoundingBoxes.Generate("a b c y q G H T", SystemFonts.CreateFont("arial", 40f)); TextAlignment.Generate(SystemFonts.CreateFont("arial", 50f)); TextAlignmentWrapped.Generate(SystemFonts.CreateFont("arial", 50f)); var sb = new StringBuilder(); for (char c = 'a'; c <= 'z'; c++) { sb.Append(c); } for (char c = 'A'; c <= 'Z'; c++) { sb.Append(c); } for (char c = '0'; c <= '9'; c++) { sb.Append(c); } string text = sb.ToString(); foreach (FontFamily f in fonts.Families) { RenderText(f, text, 72); } }
public Polygon GetPolygon(BoundingBoxAttachment attachment) { int num = BoundingBoxes.IndexOf(attachment); return((num != -1) ? Polygons.Items[num] : null); }