Import / Conversion API

advanced scripting

Voxel Play 4 · Scripting / API

Overview

Voxel Play 4 provides static classes for converting Qubicle objects and color data into Unity formats.

QubicleImporter Class

Converts Qubicle binary files into color array representations:

ColorBasedModelDefinition colorModel = QubicleImporter.ImportBinary(stream, System.Text.Encoding.UTF8);

ColorBasedModelDefinition Properties

  • colorModel.name - Object name
  • colorModel.sizeX / sizeY / sizeZ - Dimensions
  • colorModel.offsetX / offsetY / offsetZ - Placement offset
  • colorModel.colors - Linearized color array indexed as: x + z * sizeX + y * sizeX * sizeZ

VoxelPlayConverter Class

Generating GameObjects

GameObject go = VoxelPlayConverter.GenerateVoxelObject(
    colorModel.colors, sizeX, sizeY, sizeZ, offset, scale);

Additional overloads accept textures and normal maps, or a ModelDefinition directly.

When converting a ModelDefinition, a model bit with no microvoxels of its own falls back to the microvoxels declared on its Voxel Definition, so shaped voxels keep their geometry in the generated GameObject instead of becoming cubes. The OBJ exporter applies the same fallback.

Generating Model Definitions

ModelDefinition model = VoxelPlayConverter.GetModelDefinition(
    voxelTemplate, colorModel, ignoreOffset, colorToVoxelMapping);

Color-to-Voxel Mapping

ColorToVoxelMap colorToVoxelMapping = VoxelPlayConverter.GetColorToVoxelMapDefinition(
    colorModel, ignoreTransparency);

This generates mapping entries containing colors and corresponding voxel definitions, allowing custom translations (e.g. white to sand, green to bush).

Was this page helpful?