Voxel struct

Modified on Sun, 29 Aug 2021 at 02:15 AM

The Voxel struct defines any voxel in Voxel Play inside a chunk. It's defined as a partial structure so additional fields can be declared in another file that uses the same struct declaration.


Each voxel exposes the following fields:


public partial struct Voxel {


    public byte hasContent; // 0=empty, 1 = has contents, 2 = is a hole (temporarily used by cave generators)

    public bool isEmpty { get; } // convenient property that returns true if this voxel is empty


    public short typeIndex; // index to the array of voxel definitions in Voxel Play

    public VoxelDefinition type; // returns the voxel definition for this voxel


    public byte opaque; // 0 = this voxel let light pass through, 15 = fully opaque

    public byte light; // 0-15 amount of Sun light passing through this voxel.

    public byte torchLight; // 0-15 amount of torch light passing through this voxel.


    public byte red, green, blue; // if tinting option is enabled, these fields contains the RGB tint color

    public Color32 color { get; set; } // convenient method to retrieve/set tint color

    public bool isColored { get; } // returns true if the voxel is not pure white (default tint color)


    public int GetWaterLevel(); // returns the amount of water (0-15)

    public bool hasWater { get; }; // convenient property that returns true if this voxel contains water


    public int GetTextureRotation(); // returns the voxel rotation (1=90º, 2=180º, 3=270º)

    public float GetTextureRotationDegrees(); // same but returns the degrees (0, 90, 180, 270)


    ...

    (other internal-use only methods omitted for clarity)

}


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