MauryDev.KoGaMa.ModelAPI 1.0.5

dotnet add package MauryDev.KoGaMa.ModelAPI --version 1.0.5
                    
NuGet\Install-Package MauryDev.KoGaMa.ModelAPI -Version 1.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MauryDev.KoGaMa.ModelAPI" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MauryDev.KoGaMa.ModelAPI" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="MauryDev.KoGaMa.ModelAPI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MauryDev.KoGaMa.ModelAPI --version 1.0.5
                    
#r "nuget: MauryDev.KoGaMa.ModelAPI, 1.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MauryDev.KoGaMa.ModelAPI@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MauryDev.KoGaMa.ModelAPI&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=MauryDev.KoGaMa.ModelAPI&version=1.0.5
                    
Install as a Cake Tool

KoGaMa Model API

The KoGaMa Model API is a lightweight library, developed in .NET Standard 2.0, designed for the manipulation, processing, and serialization of KoGaMa 3D model data. It abstracts the complexity of representing blocks (voxels) that feature vertex deformations, per-face materials, and compressed coordinates.

🚀 Features

  • Cube Representation: Complete block modeling, including global position, individual materials for each face, and vertex offsets (corners).
  • Model Management: ModelInfo acts as a manager, allowing you to add, remove, and search for cubes by position/material, as well as calculate the model's Bounding Box.
  • Bidirectional Coordinate Conversion: The PositionConverter translates compressed bytes into Vector3 and vice versa, utilizing a $5 \times 5 \times 5$ grid system.
  • Optimized Data Structure: Use of IntVector (based on short) to reduce the memory footprint in models containing thousands of cubes.
  • Serialization Interface: A generic ISerializer for implementing persistence in Binary, JSON, or custom formats.
  • Maximum Compatibility: Target .NET Standard 2.0 (compatible with Unity, .NET Framework, and .NET Core/5+).

🛠 Technical Architecture

1. ModelInfo (The Model Manager)

More than just a container, this is the central class for model manipulation:

  • Search and Filtering: Methods such as FindCubeAt(position) and GetCubesByMaterial(id).
  • Bounding Box: Automatically calculates the minimum and maximum limits of the model via the GetBoundingBox() method.
  • Manipulation: Support for AddCube, RemoveCube, and Clear.

2. Cube (The Basic Unit)

Represents an individual block with the following properties:

  • Position: Grid location via IntVector.
  • Materials: An array of 6 bytes (one for each face defined in the Face enum).
  • Corners: An array of 8 bytes that define vertex deformations.
    • Tip: Use Cube.IdentityByteCorners to reset a cube to its default state.
  • GetCornersVectors(): Converts corner bytes into actual Vector3 values for rendering.

3. PositionConverter (The Mathematical Core)

Maps a single byte (0-124) to a Vector3 based on a 5-level grid:

  • Reference values: {-0.5f, -0.25f, 0f, 0.25f, 0.5f}.
  • Calculation:
    • $X = index / 25$
    • $Y = (index \pmod{25}) / 5$
    • $Z = index \pmod 5$

4. IntVector

An optimized struct for integer coordinates, avoiding the overhead of float when unnecessary and providing access via an indexer (vector[0] for X, etc.).


💻 Usage Examples

Creating and Managing a Model

using MauryDev.KoGaMa.ModelAPI.Model;
using MauryDev.KoGaMa.ModelAPI.Models;

var model = new ModelInfo();

// Creating a cube at position (0, 1, 0)
var cube = new Cube(new IntVector(0, 1, 0)) 
{
    Materials = new byte[] { 1, 1, 1, 1, 1, 1 } 
};

model.AddCube(cube);

// Checking if a cube exists at a certain position
if (model.HasCubeAt(new IntVector(0, 1, 0))) 
{
    var foundCube = model.FindCubeAt(new IntVector(0, 1, 0));
}

// Getting the model's Bounding Box
var (min, max) = model.GetBoundingBox();
Console.WriteLine($"Model expands from {min} to {max}");

Working with Vertices (Corners)

var cube = new Cube(new IntVector(0, 0, 0));
cube.Corners = Cube.IdentityByteCorners; // Sets default corners

// Gets the actual positions of the 8 vertices for rendering
System.Numerics.Vector3[] vertices = cube.GetCornersVectors();

foreach (var v in vertices)
{
    Console.WriteLine($"Vertex: {v}");
}

Manual Coordinate Conversion

using MauryDev.KoGaMa.ModelAPI.Utils;

// From Byte to Vector3
byte byteVal = 124; 
System.Numerics.Vector3 vec = PositionConverter.GetVectorFromByte(byteVal);

// From Vector3 to Byte
byte backToByte = PositionConverter.GetByteFromVector(vec);

📦 Installation

Add the reference to the compiled DLL to your project or include the source files.

Dependencies:

  • System.Numerics.Vectors (v4.6.1+)

📐 Coordinate Table (5x5x5 Grid)

Index Float Value
0 -0.5f
1 -0.25f
2 0f
3 0.25f
4 0.5f

👤 Author

  • MauryDev

📄 License

This project is under the MIT license. See the LICENSE file for more details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on MauryDev.KoGaMa.ModelAPI:

Package Downloads
MauryDev.KoGaMa.AvatarAPI

avatar api kogama core

MauryDev.KoGaMa.ModelAPI.KoGaMaTools

ModelAPI KoGaMa Tools

MauryDev.KoGaMa.GameAPI

Package Description

MauryDev.KoGaMa.ModelAPI.KogamaStudio

ModelAPI KoGaMa Studio

MauryDev.KoGaMa.ModelAPI.Official

ModelAPI ModelAPI Official

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 257 6/28/2026
1.0.4 366 6/21/2026
1.0.3 275 6/21/2026
1.0.2 233 6/21/2026
1.0.1 329 6/19/2026
1.0.0 170 6/17/2026