Model Definitions

Modified on Tue, 01 Jun 2021 at 08:45 PM

A model is a collection of voxel definitions and/or colors inside a 3D volume.


You can define model definitions:

  • at design time or
  • at runtime


Model definitions can be used in:

  • Biomes (eg. trees)
  • Detail generators (like the houses used by the default village spawner)
  • Programmatically using the ModelPlace method.


How does a Model Definition look in your project


A model definition is an ScriptableObject that stores: size of the model, optional offset or shift for the pivot point and a list of voxels.

The image below shows the contents of the CactusTree1 model included with the sample world. The fields of any ModelDefinition are:

  • SizeX/Y/Z: size of the bounding box of the model.
  • Offset X/Y/Z: by default all models are supposed to "sit" on the ground (ie. if you place a model at y position 10, the bottom row will be painted at that position and goes up from there).
  • Bits: a list of voxel elements. Each "bit" contains the index of the voxel in the 3D volume, the voxel definition at that position and a color. The IsEmpty field specifies if that position can clear any existing content when placing a model. For example, if placing a house over a populated place, the interior of the house will be marked as empty. This is done automatically by Voxel Play although you can specify specific bits as empty.
  • Build Duration: duration for placing this model in the scene. This value is stored in the ModelDefinition but it's not used by default. A explicit call to ModelPlace must be done passing the duration as parameter to build the model using duration.



Please check the Model Definition entry in the Programming Topics section for more details.




Creating Model Definitions in the Constructor


The constructor is a tool that let you "paint" your model inside a closed and special area and save the model in your project. Please note that the constructor is in beta and still provides basic editing capabilities. The constructor is only available inside Unity Editor, not in builds.


To access the constructor, select top menu Assets / Create / Voxel Play / Constructor Tools...

You can use the demo scene 1 "Earth demo scene" as a starting point, run it, enter the constructor tool.

Check out this video for an example:



You can use the Constructor to create new trees and add them to the biome collection:




Creating and placing Model Definitions at Runtime


Often you will prefer to place existing models using code. Use the method ModelPlace to place a model into the scene. This method is overloaded to accept different arguments. You can use it to place:

  • An existing Model Definition from your project (eg. created with the Constructor).
  • A 3D array of colors.
  • A 3D array of voxel definitions.
  • A 3D array of voxel definitions and colors.


Please refer to this article to learn how to place a 3D array of voxels into the scene.


ModelPlace can be called to place the model in the same frame of the call or through consecutive frames for a given duration specified in the ModelDefinition object (buildDuration field):









Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article