### Read .vox File and Access Data in C# Source: https://github.com/sandrofigo/voxreader/blob/develop/README.md Demonstrates how to read a .vox file using VoxReader and access its models, voxels, palette, and raw chunk data. Ensure the VoxReader library is included in your project. ```csharp using VoxReader; using VoxReader.Interfaces; // Read .vox file IVoxFile voxFile = VoxReader.VoxReader.Read("my_awesome_model.vox"); // Access models of .vox file IModel[] models = voxFile.Models; // Access voxels of first model in the file Voxel[] voxels = models[0].Voxels; // Access properties of a voxel Vector3 position = voxels[0].GlobalPosition; Color color = voxels[0].Color; // Access palette of .vox file IPalette palette = voxFile.Palette; // Access raw data of a chunk byte[] rawData = voxFile.Chunks[0].Content; ``` -------------------------------- ### Accessing Palette Colors and Notes in C# Source: https://context7.com/sandrofigo/voxreader/llms.txt Demonstrates how to access and filter palette colors using their index or associated notes. Requires the VoxReader library. ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); IPalette palette = voxFile.Palette; // Access a specific palette color (note: Colors is 0-indexed; slot 1 in MagicaVoxel = Colors[0]) Color firstColor = palette.Colors[0]; Console.WriteLine(firstColor); // R: 75 G: 75 B: 75 A: 255 // List all palette notes foreach (string note in palette.Notes) { Console.WriteLine(note); // e.g., "Wall", "Floor", "Roof" } // Get all colors tagged with a specific note Color[] wallColors = palette.GetColorsByNote("Wall"); Console.WriteLine($ ``` ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("building.vox"); IPalette palette = voxFile.Palette; Color[] brickColors = palette.GetColorsByNote("Brick"); // Returns up to 8 colors per matched palette row foreach (Color c in brickColors) { Console.WriteLine($" R:{c.R} G:{c.G} B:{c.B} A:{c.A}"); } // Filter scene voxels to only "Brick"-tagged colors HashSet brickSet = new HashSet(brickColors); IModel model = voxFile.Models[0]; Voxel[] brickVoxels = Array.FindAll(model.Voxels, v => brickSet.Contains(v.Color)); Console.WriteLine($"Brick voxels in model: {brickVoxels.Length}"); ``` ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("building.vox"); IPalette palette = voxFile.Palette; int[] roofIndices = palette.GetColorIndicesByNote("Roof"); // Match voxels by palette index HashSet roofSet = new HashSet(roofIndices); Voxel[] roofVoxels = Array.FindAll( voxFile.Models[0].Voxels, v => roofSet.Contains(v.ColorIndex - 1) // ColorIndex is 1-based; palette.Colors is 0-based ); Console.WriteLine($"Roof voxels: {roofVoxels.Length}"); ``` -------------------------------- ### Model Rotation and Transformation with Matrix3 Source: https://context7.com/sandrofigo/voxreader/llms.txt Access global and local model rotations as Matrix3 objects. Matrix3 supports multiplication with other matrices and Vector3 for transforming points. GlobalSize accounts for rotation, potentially swapping axes compared to LocalSize. ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("rotated_scene.vox"); IModel model = voxFile.Models[0]; Matrix3 global = model.GlobalRotation; Matrix3 local = model.LocalRotation; Console.WriteLine($"Global rotation: {global}"); // Output: Global rotation: [(1, 0, 0), (0, 0, -1), (0, 1, 0)] bool isIdentity = global == Matrix3.Identity; Console.WriteLine($"Is unrotated: {isIdentity}"); // Apply rotation to a local vector Vector3 localPoint = new Vector3(5, 0, 3); Vector3 rotated = global * localPoint; Console.WriteLine($"Rotated point: {rotated}"); // GlobalSize accounts for rotation (sides may be swapped vs LocalSize) Console.WriteLine($"LocalSize: {model.LocalSize}"); // X: 10, Y: 20, Z: 10 Console.WriteLine($"GlobalSize: {model.GlobalSize}"); // X: 10, Y: 10, Z: 20 ``` -------------------------------- ### Read .vox file from disk Source: https://context7.com/sandrofigo/voxreader/llms.txt Use this method to parse a .vox file directly from the file system. It returns an IVoxFile object containing all scene data. ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); Console.WriteLine($"File version: {voxFile.VersionNumber}"); // Output: File version: 150 Console.WriteLine($"Number of models: {voxFile.Models.Length}"); // Output: Number of models: 3 Console.WriteLine($"Number of chunks: {voxFile.Chunks.Length}"); // Output: Number of chunks: 12 ``` -------------------------------- ### Accessing Raw Chunk Data in C# Source: https://context7.com/sandrofigo/voxreader/llms.txt Shows how to iterate through all top-level chunks and access specific chunk types or raw byte content. Useful for custom parsing of .vox file structures. ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); // Iterate all top-level chunks foreach (IChunk chunk in voxFile.Chunks) { Console.WriteLine($"Chunk type: {chunk.Type}, Bytes: {chunk.TotalBytes}, Children: {chunk.Children.Length}"); // e.g.: Chunk type: TransformNode, Bytes: 48, Children: 1 } // Get the first chunk of a specific type using the generic accessor IChunk mainChunk = voxFile.Chunks[0]; ITransformNodeChunk transformChunk = mainChunk.GetChild(); // Get ALL chunks of a specific type IChunk[] allTransforms = mainChunk.GetChildren(ChunkType.TransformNode); Console.WriteLine($"Transform nodes: {allTransforms.Length}"); // Read raw bytes for custom parsing byte[] rawPaletteBytes = voxFile.Chunks .FirstOrDefault(c => c.Type == ChunkType.Palette) ?.Content; if (rawPaletteBytes != null) Console.WriteLine($"Raw palette bytes: {rawPaletteBytes.Length}"); // Output: Raw palette bytes: 1024 ``` -------------------------------- ### Access scene models and their properties Source: https://context7.com/sandrofigo/voxreader/llms.txt Iterate through all models in the scene, accessing their names, IDs, copy status, global/local positions, sizes, and rotations. Each model contains an array of its voxels. ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); foreach (IModel model in voxFile.Models) { Console.WriteLine($"Name: {model.Name}"); Console.WriteLine($" Id: {model.Id}, IsCopy: {model.IsCopy}"); Console.WriteLine($" GlobalPosition: {model.GlobalPosition}"); // X: 10, Y: 0, Z: 5 Console.WriteLine($" LocalPosition: {model.LocalPosition}"); // X: 10, Y: 0, Z: 5 Console.WriteLine($" GlobalSize: {model.GlobalSize}"); // X: 10, Y: 10, Z: 20 Console.WriteLine($" LocalSize: {model.LocalSize}"); // X: 10, Y: 20, Z: 10 Console.WriteLine($" GlobalRotation: {model.GlobalRotation}"); // [(1,0,0),(0,0,-1),(0,1,0)] Console.WriteLine($" Voxels: {model.Voxels.Length}"); } ``` -------------------------------- ### IVoxFile.Palette / IPalette Source: https://context7.com/sandrofigo/voxreader/llms.txt Access the 256-color palette stored in the .vox file. This includes IMAP-corrected colors, raw colors, and palette row labels. ```APIDOC ## IVoxFile.Palette / IPalette — Access the color palette Exposes the 256-color palette stored in the `.vox` file. `Colors` returns the IMAP-corrected mapped colors as seen in the MagicaVoxel UI (0-indexed, where index 0 = palette slot 1). `RawColors` gives the raw parsed colors before index mapping. `Notes` gives the palette row labels. ### Accessing Palette Data ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); IPalette palette = voxFile.Palette; // Access a specific palette color (note: Colors is 0-indexed; slot 1 in MagicaVoxel = Colors[0]) Color firstColor = palette.Colors[0]; Console.WriteLine(firstColor); // R: 75 G: 75 B: 75 A: 255 // List all palette notes foreach (string note in palette.Notes) { Console.WriteLine(note); // e.g., "Wall", "Floor", "Roof" } ``` ### Lookup Palette Colors by Note ```csharp // Get all colors tagged with a specific note Color[] wallColors = palette.GetColorsByNote("Wall"); Console.WriteLine($"Wall colors: {wallColors.Length}"); ``` ### Lookup Palette Indices by Note ```csharp // Get palette indices tagged with a specific note int[] wallIndices = palette.GetColorIndicesByNote("Wall"); foreach (int idx in wallIndices) { Console.WriteLine($"Index {idx}: {palette.Colors[idx]}"); } ``` ``` -------------------------------- ### IVoxFile.Models Source: https://context7.com/sandrofigo/voxreader/llms.txt Provides access to all model instances within the parsed .vox file. Each model entry includes its name, ID, copy status, and spatial properties. ```APIDOC ## IVoxFile.Models — Access all models in the scene ### Description Returns an array of `IModel` objects representing every model instance placed in the MagicaVoxel scene, including copies of the same model shape at different positions or rotations. ### Property ```csharp IVoxFile.Models ``` ### Response #### Success Response (IModel[]) - **Models** (IModel[]) - An array of `IModel` objects. - **Name** (string) - The name of the model. - **Id** (int) - The unique identifier of the model. - **IsCopy** (bool) - Indicates if this is a copy of another model. - **GlobalPosition** (Vector3) - The model's position in world space. - **LocalPosition** (Vector3) - The model's position within its parent's coordinate space. - **GlobalSize** (Vector3) - The model's dimensions in world space. - **LocalSize** (Vector3) - The model's dimensions within its parent's coordinate space. - **GlobalRotation** (Matrix3) - The model's rotation in world space. - **Voxels** (Voxel[]) - An array of voxels belonging to this model. ### Request Example ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); foreach (IModel model in voxFile.Models) { Console.WriteLine($"Name: {model.Name}"); Console.WriteLine($" Id: {model.Id}, IsCopy: {model.IsCopy}"); Console.WriteLine($" GlobalPosition: {model.GlobalPosition}"); // X: 10, Y: 0, Z: 5 Console.WriteLine($" LocalPosition: {model.LocalPosition}"); // X: 10, Y: 0, Z: 5 Console.WriteLine($" GlobalSize: {model.GlobalSize}"); // X: 10, Y: 10, Z: 20 Console.WriteLine($" LocalSize: {model.LocalSize}"); // X: 10, Y: 20, Z: 10 Console.WriteLine($" GlobalRotation: {model.GlobalRotation}"); // [(1,0,0),(0,0,-1),(0,1,0)] Console.WriteLine($" Voxels: {model.Voxels.Length}"); } ``` ``` -------------------------------- ### IPalette.GetColorsByNote(string note) Source: https://context7.com/sandrofigo/voxreader/llms.txt Returns all `Color` values from palette rows whose note text matches the provided string. This method returns all colors from every matching row. ```APIDOC ## IPalette.GetColorsByNote(string note) — Lookup palette colors by note label Returns all `Color` values from palette rows whose note text matches the provided string. Palette notes in MagicaVoxel label groups of 8 colors per row; this method returns all colors from every matching row. ### Parameters - **note** (string) - The note label to search for. ### Request Example ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("building.vox"); IPalette palette = voxFile.Palette; Color[] brickColors = palette.GetColorsByNote("Brick"); // Returns up to 8 colors per matched palette row foreach (Color c in brickColors) { Console.WriteLine($" R:{c.R} G:{c.G} B:{c.B} A:{c.A}"); } // Filter scene voxels to only "Brick"-tagged colors HashSet brickSet = new HashSet(brickColors); IModel model = voxFile.Models[0]; Voxel[] brickVoxels = Array.FindAll(model.Voxels, v => brickSet.Contains(v.Color)); Console.WriteLine($"Brick voxels in model: {brickVoxels.Length}"); ``` ``` -------------------------------- ### Access individual voxels and their properties Source: https://context7.com/sandrofigo/voxreader/llms.txt Retrieve the array of voxels for a specific model. Each voxel includes its local and global positions, RGBA color, and the palette index. You can filter voxels based on their properties, such as color. ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); IModel model = voxFile.Models[0]; foreach (Voxel voxel in model.Voxels) { Vector3 local = voxel.LocalPosition; // position within the model bounding box Vector3 global = voxel.GlobalPosition; // position in the world scene Color color = voxel.Color; // RGBA color from the mapped palette int index = voxel.ColorIndex; // 1-based MagicaVoxel palette index Console.WriteLine(voxel.ToString()); // Output: Global Position: [X: 12, Y: 3, Z: 7], Local Position: [X: 2, Y: 3, Z: 7], Color: [R: 255 G: 128 B: 0 A: 255] } // Filter by color Voxel[] redVoxels = Array.FindAll(model.Voxels, v => v.Color.R == 255 && v.Color.G == 0 && v.Color.B == 0); Console.WriteLine($"Red voxels: {redVoxels.Length}"); ``` -------------------------------- ### VoxReader.Read(string filePath) Source: https://context7.com/sandrofigo/voxreader/llms.txt Reads and fully parses a .vox file from the specified file system path. It returns an IVoxFile object containing all scene data. ```APIDOC ## VoxReader.Read(string filePath) — Read a .vox file from disk ### Description Reads and fully parses a `.vox` file at the given file system path. Returns an `IVoxFile` containing all models, the palette, and all raw MAIN-child chunks. ### Method ```csharp VoxReader.VoxReader.Read(string filePath) ``` ### Parameters #### Path Parameters - **filePath** (string) - Required - The file system path to the .vox file. ### Request Example ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); Console.WriteLine($"File version: {voxFile.VersionNumber}"); // Output: File version: 150 Console.WriteLine($"Number of models: {voxFile.Models.Length}"); // Output: Number of models: 3 Console.WriteLine($"Number of chunks: {voxFile.Chunks.Length}"); // Output: Number of chunks: 12 ``` ### Response #### Success Response (IVoxFile) - **VersionNumber** (int) - The version number of the .vox file. - **Models** (IModel[]) - An array of models in the scene. - **Chunks** (Chunk[]) - An array of raw scene chunks. ``` -------------------------------- ### IModel.Voxels Source: https://context7.com/sandrofigo/voxreader/llms.txt Retrieves the array of individual voxels that constitute a model. Each voxel includes its local and global positions, RGBA color, and palette index. ```APIDOC ## IModel.Voxels — Access individual voxels of a model ### Description Returns the array of `Voxel` structs belonging to a model. Each voxel carries its local position (within the model's coordinate space), global position (in world space), RGBA color, and the 1-based MagicaVoxel palette color index. ### Property ```csharp IModel.Voxels ``` ### Response #### Success Response (Voxel[]) - **Voxels** (Voxel[]) - An array of `Voxel` structs. - **LocalPosition** (Vector3) - The voxel's position within the model's bounding box. - **GlobalPosition** (Vector3) - The voxel's position in the world scene. - **Color** (Color) - The RGBA color of the voxel, mapped from the palette. - **ColorIndex** (int) - The 1-based MagicaVoxel palette index for this voxel. ### Request Example ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); IModel model = voxFile.Models[0]; foreach (Voxel voxel in model.Voxels) { Vector3 local = voxel.LocalPosition; // position within the model bounding box Vector3 global = voxel.GlobalPosition; // position in the world scene Color color = voxel.Color; // RGBA color from the mapped palette int index = voxel.ColorIndex; // 1-based MagicaVoxel palette index Console.WriteLine(voxel.ToString()); // Output: Global Position: [X: 12, Y: 3, Z: 7], Local Position: [X: 2, Y: 3, Z: 7], Color: [R: 255 G: 128 B: 0 A: 255] } // Filter by color Voxel[] redVoxels = Array.FindAll(model.Voxels, v => v.Color.R == 255 && v.Color.G == 0 && v.Color.B == 0); Console.WriteLine($"Red voxels: {redVoxels.Length}"); ``` ``` -------------------------------- ### IPalette.GetColorIndicesByNote(string note) Source: https://context7.com/sandrofigo/voxreader/llms.txt Returns the 0-based mapped color indices for all palette rows matching the given note string. These indices can be used to match against `Voxel.ColorIndex`. ```APIDOC ## IPalette.GetColorIndicesByNote(string note) — Lookup palette indices by note label Returns the 0-based mapped color indices (corresponding to `IPalette.Colors`) for all palette rows matching the given note string. Use these indices to match against `Voxel.ColorIndex` (convert: `ColorIndex - 1` for 0-based lookup). ### Parameters - **note** (string) - The note label to search for. ### Request Example ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("building.vox"); IPalette palette = voxFile.Palette; int[] roofIndices = palette.GetColorIndicesByNote("Roof"); // Match voxels by palette index HashSet roofSet = new HashSet(roofIndices); Voxel[] roofVoxels = Array.FindAll( voxFile.Models[0].Voxels, v => roofSet.Contains(v.ColorIndex - 1) // ColorIndex is 1-based; palette.Colors is 0-based ); Console.WriteLine($"Roof voxels: {roofVoxels.Length}"); ``` ``` -------------------------------- ### Model Rotation Source: https://context7.com/sandrofigo/voxreader/llms.txt Access and manipulate model rotation using Matrix3 for both global and local transformations. Matrix3 supports multiplication with other matrices and Vector3 for point transformation. ```APIDOC ## IModel.GlobalRotation / IModel.LocalRotation — Model rotation via Matrix3 Each model exposes its rotation as a `Matrix3` (a 3×3 integer rotation matrix). `GlobalRotation` includes the accumulated rotations of all parent nodes; `LocalRotation` is the rotation relative to the immediate parent. `Matrix3` supports multiplication with other matrices and with `Vector3` for transforming points. ### Usage ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("rotated_scene.vox"); IModel model = voxFile.Models[0]; Matrix3 global = model.GlobalRotation; Matrix3 local = model.LocalRotation; Console.WriteLine($"Global rotation: {global}"); // Output: Global rotation: [(1, 0, 0), (0, 0, -1), (0, 1, 0)] bool isIdentity = global == Matrix3.Identity; Console.WriteLine($"Is unrotated: {isIdentity}"); // Apply rotation to a local vector Vector3 localPoint = new Vector3(5, 0, 3); Vector3 rotated = global * localPoint; Console.WriteLine($"Rotated point: {rotated}"); // GlobalSize accounts for rotation (sides may be swapped vs LocalSize) Console.WriteLine($"LocalSize: {model.LocalSize}"); // X: 10, Y: 20, Z: 10 Console.WriteLine($"GlobalSize: {model.GlobalSize}"); // X: 10, Y: 10, Z: 20 ``` ``` -------------------------------- ### IVoxFile.Chunks / IChunk Source: https://context7.com/sandrofigo/voxreader/llms.txt Access raw chunk data for all top-level chunks within the MAIN chunk. Each chunk provides its type, raw byte content, and child chunks. ```APIDOC ## IVoxFile.Chunks / IChunk — Access raw chunk data `IVoxFile.Chunks` exposes all children of the MAIN chunk as `IChunk` objects. Each chunk provides its `ChunkType`, raw byte `Content`, child chunks, and typed child accessors. This enables custom parsing of any chunk type defined in the MagicaVoxel format specification. ### Iterating Chunks ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); // Iterate all top-level chunks foreach (IChunk chunk in voxFile.Chunks) { Console.WriteLine($"Chunk type: {chunk.Type}, Bytes: {chunk.TotalBytes}, Children: {chunk.Children.Length}"); // e.g.: Chunk type: TransformNode, Bytes: 48, Children: 1 } ``` ### Accessing Typed Child Chunks ```csharp // Get the first chunk of a specific type using the generic accessor IChunk mainChunk = voxFile.Chunks[0]; ITransformNodeChunk transformChunk = mainChunk.GetChild(); // Get ALL chunks of a specific type IChunk[] allTransforms = mainChunk.GetChildren(ChunkType.TransformNode); Console.WriteLine($"Transform nodes: {allTransforms.Length}"); ``` ### Reading Raw Chunk Bytes ```csharp // Read raw bytes for custom parsing byte[] rawPaletteBytes = voxFile.Chunks .FirstOrDefault(c => c.Type == ChunkType.Palette) ?.Content; if (rawPaletteBytes != null) Console.WriteLine($"Raw palette bytes: {rawPaletteBytes.Length}"); // Output: Raw palette bytes: 1024 ``` ``` -------------------------------- ### Read .vox file from byte array Source: https://context7.com/sandrofigo/voxreader/llms.txt Parses a .vox file from an in-memory byte array. This is useful for reading from streams, embedded resources, or network data without direct file system access. ```csharp using VoxReader; using VoxReader.Interfaces; // Load bytes from any source (stream, embedded resource, network, etc.) byte[] data = File.ReadAllBytes("my_scene.vox"); IVoxFile voxFile = VoxReader.VoxReader.Read(data); Console.WriteLine($"Models: {voxFile.Models.Length}"); // Output: Models: 3 ``` -------------------------------- ### VoxReader.Read(byte[] data) Source: https://context7.com/sandrofigo/voxreader/llms.txt Parses a .vox file directly from a byte array. This is useful for reading data from sources other than the file system, such as streams or network responses. ```APIDOC ## VoxReader.Read(byte[] data) — Read a .vox file from a byte array ### Description Parses a `.vox` file from an already-loaded byte array. Useful for reading from streams, embedded resources, or network responses without touching the file system. ### Method ```csharp VoxReader.VoxReader.Read(byte[] data) ``` ### Parameters #### Request Body - **data** (byte[]) - Required - The byte array containing the .vox file data. ### Request Example ```csharp using VoxReader; using VoxReader.Interfaces; // Load bytes from any source (stream, embedded resource, network, etc.) byte[] data = File.ReadAllBytes("my_scene.vox"); IVoxFile voxFile = VoxReader.VoxReader.Read(data); Console.WriteLine($"Models: {voxFile.Models.Length}"); // Output: Models: 3 ``` ### Response #### Success Response (IVoxFile) - **Models** (IModel[]) - An array of models in the scene. ``` -------------------------------- ### Color Type Source: https://context7.com/sandrofigo/voxreader/llms.txt `Color` is an immutable struct representing RGBA colors with byte components (R, G, B, A). It supports equality comparison and is used for palette and voxel colors. ```APIDOC ## Color — RGBA color type `Color` is an immutable struct with `byte` components `R`, `G`, `B`, `A`. It supports equality comparison and is used for all palette and voxel color values. ### Usage ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); Color c = voxFile.Palette.Colors[0]; Console.WriteLine($"R:{c.R} G:{c.G} B:{c.B} A:{c.A}"); // Output: R:75 G:75 B:75 A:255 // Convert to normalized float for use with graphics APIs float r = c.R / 255f; float g = c.G / 255f; float b = c.B / 255f; float a = c.A / 255f; // Compare colors Color orange = voxFile.Models[0].Voxels[0].Color; bool isTransparent = orange.A == 0; bool isSameColor = orange == new Color(); // use Equals for value comparison ``` ``` -------------------------------- ### Vector3 Operations for 3D Coordinates Source: https://context7.com/sandrofigo/voxreader/llms.txt Vector3 is a struct for 3D integer coordinates (X, Y, Z) used for positions and sizes. It supports arithmetic operators and component-wise absolute value via ToAbsolute(). ```csharp using VoxReader; Vector3 a = new Vector3(3, -5, 2); Vector3 b = new Vector3(1, 2, 0); Vector3 sum = a + b; // X: 4, Y: -3, Z: 2 Vector3 diff = a - b; // X: 2, Y: -7, Z: 2 Vector3 scaled = a * 2; // X: 6, Y: -10, Z: 4 Vector3 abs = a.ToAbsolute(); // X: 3, Y: 5, Z: 2 Console.WriteLine($"Sum: {sum}"); Console.WriteLine($"Absolute: {abs}"); bool equal = a == new Vector3(3, -5, 2); // true Console.WriteLine($"Equal: {equal}"); ``` -------------------------------- ### Color RGBA Type and Usage Source: https://context7.com/sandrofigo/voxreader/llms.txt The Color struct represents RGBA colors with byte components (R, G, B, A). It supports equality comparison and can be converted to normalized floats for graphics APIs. Check the Alpha component for transparency. ```csharp using VoxReader; using VoxReader.Interfaces; IVoxFile voxFile = VoxReader.VoxReader.Read("my_scene.vox"); Color c = voxFile.Palette.Colors[0]; Console.WriteLine($"R:{c.R} G:{c.G} B:{c.B} A:{c.A}"); // Output: R:75 G:75 B:75 A:255 // Convert to normalized float for use with graphics APIs float r = c.R / 255f; float g = c.G / 255f; float b = c.B / 255f; float a = c.A / 255f; // Compare colors Color orange = voxFile.Models[0].Voxels[0].Color; bool isTransparent = orange.A == 0; bool isSameColor = orange == new Color(); // use Equals for value comparison ``` -------------------------------- ### Vector3 Type Source: https://context7.com/sandrofigo/voxreader/llms.txt `Vector3` is a struct representing 3D integer coordinates (X, Y, Z) used for positions and sizes. It supports arithmetic operators and equality comparison. ```APIDOC ## Vector3 — 3D integer coordinate type `Vector3` is a struct with integer `X`, `Y`, `Z` components used for all positions and sizes. It supports arithmetic operators (`+`, `-`, `*`, `/`), equality comparison, and `ToAbsolute()` for component-wise absolute value. ### Usage ```csharp using VoxReader; Vector3 a = new Vector3(3, -5, 2); Vector3 b = new Vector3(1, 2, 0); Vector3 sum = a + b; // X: 4, Y: -3, Z: 2 Vector3 diff = a - b; // X: 2, Y: -7, Z: 2 Vector3 scaled = a * 2; // X: 6, Y: -10, Z: 4 Vector3 abs = a.ToAbsolute(); // X: 3, Y: 5, Z: 2 Console.WriteLine($"Sum: {sum}"); Console.WriteLine($"Absolute: {abs}"); bool equal = a == new Vector3(3, -5, 2); // true Console.WriteLine($"Equal: {equal}"); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.