Struct PointDataV2
- Namespace
- VoxelPlayground.Engine
- Assembly
- VoxEngineCore.dll
Represents the data of a single voxel point.
[Serializable]
public struct PointDataV2
Constructors
PointDataV2(PointData)
Constructor from legacy PointData.
public PointDataV2(PointData other)
Parameters
otherPointDataLegacy point data.
PointDataV2(PointDataV2)
Copy constructor.
public PointDataV2(PointDataV2 other)
Parameters
otherPointDataV2Source point data.
Fields
color
The current color in RGB565 format.
[SerializeField]
public ushort color
Field Value
- ushort
HardnessCap_Bullet
Hardness cap for bullet attacks.
public const int HardnessCap_Bullet = 8
Field Value
- int
HardnessCap_Explosion
Hardness cap for explosions.
public const int HardnessCap_Explosion = 10
Field Value
- int
HardnessCap_Fist
Hardness cap for fist attacks.
public const int HardnessCap_Fist = 6
Field Value
- int
HardnessCap_Sword
Hardness cap for sword attacks.
public const int HardnessCap_Sword = 7
Field Value
- int
ID_EMPTY
ID for empty space.
public const uint ID_EMPTY = 0
Field Value
- uint
ID_GLASS
Standard IDs for common materials.
public static readonly uint ID_GLASS
Field Value
- uint
ID_GLOW
Standard IDs for common materials.
public static readonly uint ID_GLOW
Field Value
- uint
ID_METAL
Standard IDs for common materials.
public static readonly uint ID_METAL
Field Value
- uint
ID_SKIN
Standard IDs for common materials.
public static readonly uint ID_SKIN
Field Value
- uint
ID_STONE
Standard IDs for common materials.
public static readonly uint ID_STONE
Field Value
- uint
MAX_HARDNESS
Maximum hardness value.
public const uint MAX_HARDNESS = 15
Field Value
- uint
NORMAL_HARDNESS
Default hardness value.
public const uint NORMAL_HARDNESS = 3
Field Value
- uint
NORMAL_TEMPERATURE
Default temperature value.
public const uint NORMAL_TEMPERATURE = 3
Field Value
- uint
originalColor
The original color in RGB565 format, used for restoration.
[SerializeField]
public ushort originalColor
Field Value
- ushort
properties
Packed properties of the voxel.
[SerializeField]
public uint properties
Field Value
- uint
PROPERTY_MAX_VALUE
Maximum property value (3 bits).
public const uint PROPERTY_MAX_VALUE = 7
Field Value
- uint
PROPERTY_Min_VALUE
Minimum property value.
public const uint PROPERTY_Min_VALUE = 0
Field Value
- uint
Properties
Color
Gets or sets the color of the voxel.
public Color Color { get; set; }
Property Value
ColorRaw
Gets the raw packed color value.
public ushort ColorRaw { get; }
Property Value
- ushort
ID
Gets or sets the material ID.
public uint ID { get; set; }
Property Value
- uint
Value
Gets or sets the normalized value associated with the voxel (e.g. damage level).
public float Value { get; set; }
Property Value
- float
Weights
Gets or sets the weight value (legacy for character body parts).
public uint Weights { get; set; }
Property Value
- uint
Methods
CalcHardness2IntensityMlp(float, float)
Calculates the intensity multiplier based on hardness difference.
public static float CalcHardness2IntensityMlp(float hardnessCap, float selfHardness)
Parameters
hardnessCapfloatThe hardness of the attacker.
selfHardnessfloatThe hardness of the target.
Returns
- float
The intensity multiplier (0-1).
CloneFrom(PointDataV2)
Clones data from another point data.
public void CloneFrom(PointDataV2 other)
Parameters
otherPointDataV2Source point data.
CopyColor(PointDataV2)
Copies color and original color from another point data, and marks for restoration.
public void CopyColor(PointDataV2 otherData)
Parameters
otherDataPointDataV2The source point data.
EmptyPoint()
Creates an empty point data.
public static PointDataV2 EmptyPoint()
Returns
- PointDataV2
Empty point data.
GetColor()
Gets the color of the voxel.
public Color GetColor()
Returns
- Color
The color.
GetHardness()
Gets the hardness of the current voxel.
public uint GetHardness()
Returns
- uint
The hardness value.
GetHardnessAffectSize(float)
Calculates the size affect based on hardness.
public static float GetHardnessAffectSize(float hardness)
Parameters
hardnessfloatThe hardness value.
Returns
- float
The size affect multiplier.
GetHardnessById(uint)
Gets the hardness for a specific material ID.
public uint GetHardnessById(uint id)
Parameters
iduintThe material ID.
Returns
- uint
The hardness value.
GetHardnessNormalize()
Gets the normalized hardness of the current voxel (0-1).
public float GetHardnessNormalize()
Returns
- float
The normalized hardness.
GetNumber(Property)
Gets a numeric property value.
public uint GetNumber(PointDataV2.Property property)
Parameters
propertyPointDataV2.PropertyThe property to get.
Returns
- uint
The value of the property.
GetPropertyValueNormalized(Property)
Gets a normalized property value (0-1).
public float GetPropertyValueNormalized(PointDataV2.Property property)
Parameters
propertyPointDataV2.PropertyThe property to get.
Returns
- float
The normalized value.
GetSize()
Gets the size of the struct in bytes.
public static int GetSize()
Returns
- int
The size in bytes.
InitDefaultValue()
Initializes default property values.
public void InitDefaultValue()
IsSolid()
Checks if the voxel is solid (non-empty).
public bool IsSolid()
Returns
- bool
True if solid.
IsUnyielding()
Checks if the voxel is unyielding (indestructible).
public bool IsUnyielding()
Returns
- bool
True if unyielding.
PackColor(float, float, float, ref ushort)
Packs RGB float values into a ushort RGB565 format.
public static void PackColor(float r, float g, float b, ref ushort value)
Parameters
rfloatRed component (0-1).
gfloatGreen component (0-1).
bfloatBlue component (0-1).
valueushortThe reference to store the packed value.
ProgressivelyRestoreOriginalColor()
Progressively restores the color towards the original color.
public void ProgressivelyRestoreOriginalColor()
RestoreOriginalColor()
Immediately restores the original color.
public void RestoreOriginalColor()
SetColor(float3)
Sets the color of the voxel.
public void SetColor(float3 color)
Parameters
colorfloat3The color as float3.
SetHardnessTable(uint[])
Sets the global hardness table.
public static void SetHardnessTable(uint[] hardness)
Parameters
hardnessuint[]Array of hardness values.
SetNumber(Property, uint)
Sets a numeric property value.
public void SetNumber(PointDataV2.Property property, uint value)
Parameters
propertyPointDataV2.PropertyThe property to set.
valueuintThe value to set.
SetUnyielding(bool)
Sets the unyielding state of the voxel.
public void SetUnyielding(bool yes)
Parameters
yesboolTrue to make unyielding.
StoreOriginalColor()
Stores the current color as the original color for future restoration.
public void StoreOriginalColor()
UnpackColor565ToF3(ushort)
Unpacks a ushort RGB565 value into a float3 RGB vector.
public static float3 UnpackColor565ToF3(ushort packedColor)
Parameters
packedColorushortThe packed color value.
Returns
- float3
The unpacked color as float3.
UnpackIDFromInteger(uint)
Unpacks the ID from the integer property value.
public static uint UnpackIDFromInteger(uint intValue)
Parameters
intValueuintThe integer property value.
Returns
- uint
The unpacked ID.