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
<PackageReference Include="MauryDev.KoGaMa.ModelAPI" Version="1.0.5" />
<PackageVersion Include="MauryDev.KoGaMa.ModelAPI" Version="1.0.5" />
<PackageReference Include="MauryDev.KoGaMa.ModelAPI" />
paket add MauryDev.KoGaMa.ModelAPI --version 1.0.5
#r "nuget: MauryDev.KoGaMa.ModelAPI, 1.0.5"
#:package MauryDev.KoGaMa.ModelAPI@1.0.5
#addin nuget:?package=MauryDev.KoGaMa.ModelAPI&version=1.0.5
#tool nuget:?package=MauryDev.KoGaMa.ModelAPI&version=1.0.5
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:
ModelInfoacts 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
PositionConvertertranslates compressed bytes intoVector3and vice versa, utilizing a $5 \times 5 \times 5$ grid system. - Optimized Data Structure: Use of
IntVector(based onshort) to reduce the memory footprint in models containing thousands of cubes. - Serialization Interface: A generic
ISerializerfor 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)andGetCubesByMaterial(id). - Bounding Box: Automatically calculates the minimum and maximum limits of the model via the
GetBoundingBox()method. - Manipulation: Support for
AddCube,RemoveCube, andClear.
2. Cube (The Basic Unit)
Represents an individual block with the following properties:
Position: Grid location viaIntVector.Materials: An array of 6 bytes (one for each face defined in theFaceenum).Corners: An array of 8 bytes that define vertex deformations.- Tip: Use
Cube.IdentityByteCornersto reset a cube to its default state.
- Tip: Use
GetCornersVectors(): Converts corner bytes into actualVector3values 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 | Versions 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. |
-
.NETStandard 2.0
- System.Numerics.Vectors (>= 4.6.1)
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.