refactor: use python built in dataclass to improve our raw data structs.

This commit is contained in:
2026-03-20 14:50:05 +08:00
parent 77e4dcdb69
commit eb8984c341
8 changed files with 123 additions and 237 deletions

View File

@@ -1,14 +1,12 @@
import bpy import bpy
import typing import typing
from dataclasses import dataclass
from dataclasses import field as datafield
from . import UTIL_functions from . import UTIL_functions
@dataclass
class RawBallanceMapInfo(): class RawBallanceMapInfo():
cSectorCount: typing.ClassVar[int] = 1 mSectorCount: int = datafield(default=1)
mSectorCount: int
def __init__(self, **kwargs):
self.mSectorCount = kwargs.get("mSectorCount", RawBallanceMapInfo.cSectorCount)
def regulate(self): def regulate(self):
self.mSectorCount = UTIL_functions.clamp_int(self.mSectorCount, 1, 999) self.mSectorCount = UTIL_functions.clamp_int(self.mSectorCount, 1, 999)

View File

@@ -1,21 +1,19 @@
import bpy import bpy
import os, typing import os, typing
from dataclasses import dataclass
from dataclasses import field as datafield
from . import UTIL_naming_convention from . import UTIL_naming_convention
@dataclass
class RawPreferences(): class RawPreferences():
cBallanceTextureFolder: typing.ClassVar[str] = "" mBallanceTextureFolder: str = datafield(default="")
cNoComponentCollection: typing.ClassVar[str] = "" mNoComponentCollection: str = datafield(default="")
mBallanceTextureFolder: str
mNoComponentCollection: str
def __init__(self, **kwargs):
self.mBallanceTextureFolder = kwargs.get("mBallanceTextureFolder", "")
self.mNoComponentCollection = kwargs.get("mNoComponentCollection", "")
def has_valid_blc_tex_folder(self) -> bool: def has_valid_blc_tex_folder(self) -> bool:
return os.path.isdir(self.mBallanceTextureFolder) return os.path.isdir(self.mBallanceTextureFolder)
DEFAULT_RAW_PREFERENCES = RawPreferences()
class BBPPreferences(bpy.types.AddonPreferences): class BBPPreferences(bpy.types.AddonPreferences):
bl_idname = __package__ bl_idname = __package__
@@ -23,14 +21,14 @@ class BBPPreferences(bpy.types.AddonPreferences):
name = "Ballance Texture Folder", name = "Ballance Texture Folder",
description = "The path to folder which will be used by this plugin to get external Ballance texture.", description = "The path to folder which will be used by this plugin to get external Ballance texture.",
subtype = 'DIR_PATH', subtype = 'DIR_PATH',
default = RawPreferences.cBallanceTextureFolder, default = DEFAULT_RAW_PREFERENCES.mBallanceTextureFolder,
translation_context = 'BBPPreferences/property' translation_context = 'BBPPreferences/property'
) # type: ignore ) # type: ignore
no_component_collection: bpy.props.StringProperty( no_component_collection: bpy.props.StringProperty(
name = "No Component Collection", name = "No Component Collection",
description = "When importing, it is the name of collection where objects store will not be saved as component. When exporting, all forced no component objects will be stored in this name represented collection", description = "When importing, it is the name of collection where objects store will not be saved as component. When exporting, all forced no component objects will be stored in this name represented collection",
default = RawPreferences.cNoComponentCollection, default = DEFAULT_RAW_PREFERENCES.mNoComponentCollection,
translation_context = 'BBPPreferences/property' translation_context = 'BBPPreferences/property'
) # type: ignore ) # type: ignore

View File

@@ -1,43 +1,21 @@
import bpy import bpy
import typing, math, enum import typing, math, enum
from dataclasses import dataclass
from dataclasses import field as datafield
from . import UTIL_functions, UTIL_virtools_types from . import UTIL_functions, UTIL_virtools_types
@dataclass
class RawVirtoolsCamera(): class RawVirtoolsCamera():
# Class Member
mProjectionType: UTIL_virtools_types.CK_CAMERA_PROJECTION mProjectionType: UTIL_virtools_types.CK_CAMERA_PROJECTION = datafield(default=UTIL_virtools_types.CK_CAMERA_PROJECTION.CK_PERSPECTIVEPROJECTION)
mOrthographicZoom: float mOrthographicZoom: float = datafield(default=1.0)
mFrontPlane: float mFrontPlane: float = datafield(default=1.0)
mBackPlane: float mBackPlane: float = datafield(default=4000.0)
mFov: float mFov: float = datafield(default=0.5)
mAspectRatio: tuple[int, int] mAspectRatio: tuple[int, int] = datafield(default_factory=lambda: (4, 3))
# Class member default value
cDefaultProjectionType: typing.ClassVar[UTIL_virtools_types.CK_CAMERA_PROJECTION] = UTIL_virtools_types.CK_CAMERA_PROJECTION.CK_PERSPECTIVEPROJECTION
cDefaultOrthographicZoom: typing.ClassVar[float] = 1.0
cDefaultFrontPlane: typing.ClassVar[float] = 1.0
cDefaultBackPlane: typing.ClassVar[float] = 4000.0
cDefaultFov: typing.ClassVar[float] = 0.5
cDefaultAspectRatio: typing.ClassVar[tuple[int, int]] = (4, 3)
def __init__(self, **kwargs):
# assign default value for each component
self.mProjectionType = kwargs.get("mProjectionType", RawVirtoolsCamera.cDefaultProjectionType)
self.mOrthographicZoom = kwargs.get("mOrthographicZoom", RawVirtoolsCamera.cDefaultOrthographicZoom)
self.mFrontPlane = kwargs.get("mFrontPlane", RawVirtoolsCamera.cDefaultFrontPlane)
self.mBackPlane = kwargs.get("mBackPlane", RawVirtoolsCamera.cDefaultBackPlane)
self.mFov = kwargs.get("mFov", RawVirtoolsCamera.cDefaultFov)
self.mAspectRatio = kwargs.get("mAspectRatio", RawVirtoolsCamera.cDefaultAspectRatio)
def regulate(self) -> None: def regulate(self) -> None:
# everything should be positive # everything should be positive
@@ -52,6 +30,8 @@ class RawVirtoolsCamera():
h = max(1, h) h = max(1, h)
self.mAspectRatio = (w, h) self.mAspectRatio = (w, h)
DEFAULT_RAW_VIRTOOLS_CAMERA = RawVirtoolsCamera()
#region Blender Enum Prop Helper #region Blender Enum Prop Helper
_g_Helper_CK_CAMERA_PROJECTION = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.CK_CAMERA_PROJECTION) _g_Helper_CK_CAMERA_PROJECTION = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.CK_CAMERA_PROJECTION)
@@ -63,7 +43,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
name = "Type", name = "Type",
description = "The type of this camera.", description = "The type of this camera.",
items = _g_Helper_CK_CAMERA_PROJECTION.generate_items(), items = _g_Helper_CK_CAMERA_PROJECTION.generate_items(),
default = _g_Helper_CK_CAMERA_PROJECTION.to_selection(RawVirtoolsCamera.cDefaultProjectionType), default = _g_Helper_CK_CAMERA_PROJECTION.to_selection(DEFAULT_RAW_VIRTOOLS_CAMERA.mProjectionType),
translation_context = 'BBP_PG_virtools_camera/property' translation_context = 'BBP_PG_virtools_camera/property'
) # type: ignore ) # type: ignore
@@ -74,7 +54,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
soft_min = 0.0, soft_min = 0.0,
soft_max = 0.5, soft_max = 0.5,
step = 5, step = 5,
default = RawVirtoolsCamera.cDefaultOrthographicZoom, default = DEFAULT_RAW_VIRTOOLS_CAMERA.mOrthographicZoom,
translation_context = 'BBP_PG_virtools_camera/property' translation_context = 'BBP_PG_virtools_camera/property'
) # type: ignore ) # type: ignore
@@ -85,7 +65,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
soft_min = 0.0, soft_min = 0.0,
soft_max = 5000.0, soft_max = 5000.0,
step = 100, step = 100,
default = RawVirtoolsCamera.cDefaultFrontPlane, default = DEFAULT_RAW_VIRTOOLS_CAMERA.mFrontPlane,
translation_context = 'BBP_PG_virtools_camera/property' translation_context = 'BBP_PG_virtools_camera/property'
) # type: ignore ) # type: ignore
@@ -96,7 +76,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
soft_min = 0.0, soft_min = 0.0,
soft_max = 5000.0, soft_max = 5000.0,
step = 100, step = 100,
default = RawVirtoolsCamera.cDefaultBackPlane, default = DEFAULT_RAW_VIRTOOLS_CAMERA.mBackPlane,
translation_context = 'BBP_PG_virtools_camera/property' translation_context = 'BBP_PG_virtools_camera/property'
) # type: ignore ) # type: ignore
@@ -108,7 +88,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
max = math.radians(180.0), max = math.radians(180.0),
step = 100, step = 100,
precision = 100, precision = 100,
default = RawVirtoolsCamera.cDefaultFov, default = DEFAULT_RAW_VIRTOOLS_CAMERA.mFov,
translation_context = 'BBP_PG_virtools_camera/property' translation_context = 'BBP_PG_virtools_camera/property'
) # type: ignore ) # type: ignore
@@ -119,7 +99,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
soft_min = 1, soft_min = 1,
soft_max = 40, soft_max = 40,
step = 1, step = 1,
default = RawVirtoolsCamera.cDefaultAspectRatio[0], default = DEFAULT_RAW_VIRTOOLS_CAMERA.mAspectRatio[0],
translation_context = 'BBP_PG_virtools_camera/property' translation_context = 'BBP_PG_virtools_camera/property'
) # type: ignore ) # type: ignore
@@ -130,7 +110,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
soft_min = 1, soft_min = 1,
soft_max = 40, soft_max = 40,
step = 1, step = 1,
default = RawVirtoolsCamera.cDefaultAspectRatio[1], default = DEFAULT_RAW_VIRTOOLS_CAMERA.mAspectRatio[1],
translation_context = 'BBP_PG_virtools_camera/property' translation_context = 'BBP_PG_virtools_camera/property'
) # type: ignore ) # type: ignore

View File

@@ -1,54 +1,26 @@
import bpy import bpy
import typing, math import typing, math
from dataclasses import dataclass
from dataclasses import field as datafield
from . import UTIL_functions, UTIL_virtools_types from . import UTIL_functions, UTIL_virtools_types
# Raw Data # Raw Data
@dataclass
class RawVirtoolsLight(): class RawVirtoolsLight():
# Class member
mType: UTIL_virtools_types.VXLIGHT_TYPE mType: UTIL_virtools_types.VXLIGHT_TYPE = datafield(default=UTIL_virtools_types.VXLIGHT_TYPE.VX_LIGHTPOINT)
mColor: UTIL_virtools_types.VxColor mColor: UTIL_virtools_types.VxColor = datafield(default_factory=lambda: UTIL_virtools_types.VxColor(1.0, 1.0, 1.0, 1.0))
mConstantAttenuation: float mConstantAttenuation: float = datafield(default=1.0)
mLinearAttenuation: float mLinearAttenuation: float = datafield(default=0.0)
mQuadraticAttenuation: float mQuadraticAttenuation: float = datafield(default=0.0)
mRange: float mRange: float = datafield(default=100.0)
mHotSpot: float mHotSpot: float = datafield(default=math.radians(40))
mFalloff: float mFalloff: float = datafield(default=math.radians(45))
mFalloffShape: float mFalloffShape: float = datafield(default=1.0)
# Class member default value
cDefaultType: typing.ClassVar[UTIL_virtools_types.VXLIGHT_TYPE] = UTIL_virtools_types.VXLIGHT_TYPE.VX_LIGHTPOINT
cDefaultColor: typing.ClassVar[UTIL_virtools_types.VxColor] = UTIL_virtools_types.VxColor(1.0, 1.0, 1.0, 1.0)
cDefaultConstantAttenuation: typing.ClassVar[float] = 1.0
cDefaultLinearAttenuation: typing.ClassVar[float] = 0.0
cDefaultQuadraticAttenuation: typing.ClassVar[float] = 0.0
cDefaultRange: typing.ClassVar[float] = 100.0
cDefaultHotSpot: typing.ClassVar[float] = math.radians(40)
cDefaultFalloff: typing.ClassVar[float] = math.radians(45)
cDefaultFalloffShape: typing.ClassVar[float] = 1.0
def __init__(self, **kwargs):
# assign default value for each component
self.mType = kwargs.get('mType', RawVirtoolsLight.cDefaultType)
self.mColor = kwargs.get('mColor', RawVirtoolsLight.cDefaultColor).clone()
self.mConstantAttenuation = kwargs.get('mConstantAttenuation', RawVirtoolsLight.cDefaultConstantAttenuation)
self.mLinearAttenuation = kwargs.get('mLinearAttenuation', RawVirtoolsLight.cDefaultLinearAttenuation)
self.mQuadraticAttenuation = kwargs.get('mQuadraticAttenuation', RawVirtoolsLight.cDefaultQuadraticAttenuation)
self.mRange = kwargs.get('mRange', RawVirtoolsLight.cDefaultRange)
self.mHotSpot = kwargs.get('mHotSpot', RawVirtoolsLight.cDefaultHotSpot)
self.mFalloff = kwargs.get('mFalloff', RawVirtoolsLight.cDefaultFalloff)
self.mFalloffShape = kwargs.get('mFalloffShape', RawVirtoolsLight.cDefaultFalloffShape)
def regulate(self) -> None: def regulate(self) -> None:
# regulate color and reset its alpha value # regulate color and reset its alpha value
@@ -70,6 +42,8 @@ class RawVirtoolsLight():
if self.mFalloff < self.mHotSpot: if self.mFalloff < self.mHotSpot:
self.mFalloff = self.mHotSpot self.mFalloff = self.mHotSpot
DEFAULT_RAW_VIRTOOLS_LIGHT = RawVirtoolsLight()
# Blender Property Group # Blender Property Group
_g_Helper_VXLIGHT_TYPE = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.VXLIGHT_TYPE) _g_Helper_VXLIGHT_TYPE = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.VXLIGHT_TYPE)
@@ -79,7 +53,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
name = "Type", name = "Type",
description = "The type of this light", description = "The type of this light",
items = _g_Helper_VXLIGHT_TYPE.generate_items(), items = _g_Helper_VXLIGHT_TYPE.generate_items(),
default = _g_Helper_VXLIGHT_TYPE.to_selection(RawVirtoolsLight.cDefaultType), default = _g_Helper_VXLIGHT_TYPE.to_selection(DEFAULT_RAW_VIRTOOLS_LIGHT.mType),
translation_context = 'BBP_PG_virtools_light/property' translation_context = 'BBP_PG_virtools_light/property'
) # type: ignore ) # type: ignore
@@ -90,7 +64,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 1.0, max = 1.0,
size = 3, size = 3,
default = RawVirtoolsLight.cDefaultColor.to_const_rgb(), default = DEFAULT_RAW_VIRTOOLS_LIGHT.mColor.to_const_rgb(),
translation_context = 'BBP_PG_virtools_light/property' translation_context = 'BBP_PG_virtools_light/property'
) # type: ignore ) # type: ignore
@@ -100,7 +74,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 10.0, max = 10.0,
step = 10, step = 10,
default = RawVirtoolsLight.cDefaultConstantAttenuation, default = DEFAULT_RAW_VIRTOOLS_LIGHT.mConstantAttenuation,
translation_context = 'BBP_PG_virtools_light/property' translation_context = 'BBP_PG_virtools_light/property'
) # type: ignore ) # type: ignore
@@ -110,7 +84,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 10.0, max = 10.0,
step = 10, step = 10,
default = RawVirtoolsLight.cDefaultLinearAttenuation, default = DEFAULT_RAW_VIRTOOLS_LIGHT.mLinearAttenuation,
translation_context = 'BBP_PG_virtools_light/property' translation_context = 'BBP_PG_virtools_light/property'
) # type: ignore ) # type: ignore
@@ -120,7 +94,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 10.0, max = 10.0,
step = 10, step = 10,
default = RawVirtoolsLight.cDefaultQuadraticAttenuation, default = DEFAULT_RAW_VIRTOOLS_LIGHT.mQuadraticAttenuation,
translation_context = 'BBP_PG_virtools_light/property' translation_context = 'BBP_PG_virtools_light/property'
) # type: ignore ) # type: ignore
@@ -130,7 +104,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 200.0, max = 200.0,
step = 100, step = 100,
default = RawVirtoolsLight.cDefaultRange, default = DEFAULT_RAW_VIRTOOLS_LIGHT.mRange,
translation_context = 'BBP_PG_virtools_light/property' translation_context = 'BBP_PG_virtools_light/property'
) # type: ignore ) # type: ignore
@@ -140,7 +114,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = math.radians(180), max = math.radians(180),
subtype = 'ANGLE', subtype = 'ANGLE',
default = RawVirtoolsLight.cDefaultHotSpot, default = DEFAULT_RAW_VIRTOOLS_LIGHT.mHotSpot,
translation_context = 'BBP_PG_virtools_light/property' translation_context = 'BBP_PG_virtools_light/property'
) # type: ignore ) # type: ignore
@@ -150,7 +124,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = math.radians(180), max = math.radians(180),
subtype = 'ANGLE', subtype = 'ANGLE',
default = RawVirtoolsLight.cDefaultFalloff, default = DEFAULT_RAW_VIRTOOLS_LIGHT.mFalloff,
translation_context = 'BBP_PG_virtools_light/property' translation_context = 'BBP_PG_virtools_light/property'
) # type: ignore ) # type: ignore
@@ -160,7 +134,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 10.0, max = 10.0,
step = 10, step = 10,
default = RawVirtoolsLight.cDefaultFalloffShape, default = DEFAULT_RAW_VIRTOOLS_LIGHT.mFalloffShape,
translation_context = 'BBP_PG_virtools_light/property' translation_context = 'BBP_PG_virtools_light/property'
) # type: ignore ) # type: ignore

View File

@@ -1,98 +1,41 @@
import bpy import bpy
import typing, enum, copy, os import typing, enum, copy, os
from dataclasses import dataclass
from dataclasses import field as datafield
from . import UTIL_virtools_types, UTIL_functions, UTIL_ballance_texture, UTIL_file_browser from . import UTIL_virtools_types, UTIL_functions, UTIL_ballance_texture, UTIL_file_browser
from . import PROP_virtools_texture, PROP_preferences from . import PROP_virtools_texture, PROP_preferences
@dataclass
class RawVirtoolsMaterial(): class RawVirtoolsMaterial():
# Instance Member Declarations mDiffuse: UTIL_virtools_types.VxColor = datafield(default_factory=lambda: UTIL_virtools_types.VxColor(0.7, 0.7, 0.7, 1.0))
mAmbient: UTIL_virtools_types.VxColor = datafield(default_factory=lambda: UTIL_virtools_types.VxColor(0.3, 0.3, 0.3, 1.0))
mSpecular: UTIL_virtools_types.VxColor = datafield(default_factory=lambda: UTIL_virtools_types.VxColor(0.5, 0.5, 0.5, 1.0))
mEmissive: UTIL_virtools_types.VxColor = datafield(default_factory=lambda: UTIL_virtools_types.VxColor(0.0, 0.0, 0.0, 1.0))
mSpecularPower: float = datafield(default=0.0)
mDiffuse: UTIL_virtools_types.VxColor mTexture: bpy.types.Image | None = datafield(default=None)
mAmbient: UTIL_virtools_types.VxColor mTextureBorderColor: UTIL_virtools_types.VxColor = datafield(default_factory=lambda: UTIL_virtools_types.VxColor(0.0, 0.0, 0.0, 0.0))
mSpecular: UTIL_virtools_types.VxColor
mEmissive: UTIL_virtools_types.VxColor
mSpecularPower: float
mTexture: bpy.types.Image | None mTextureBlendMode: UTIL_virtools_types.VXTEXTURE_BLENDMODE = datafield(default=UTIL_virtools_types.VXTEXTURE_BLENDMODE.VXTEXTUREBLEND_MODULATEALPHA)
mTextureBorderColor: UTIL_virtools_types.VxColor mTextureMinMode: UTIL_virtools_types.VXTEXTURE_FILTERMODE = datafield(default=UTIL_virtools_types.VXTEXTURE_FILTERMODE.VXTEXTUREFILTER_LINEAR)
mTextureMagMode: UTIL_virtools_types.VXTEXTURE_FILTERMODE = datafield(default=UTIL_virtools_types.VXTEXTURE_FILTERMODE.VXTEXTUREFILTER_LINEAR)
mTextureAddressMode: UTIL_virtools_types.VXTEXTURE_ADDRESSMODE = datafield(default=UTIL_virtools_types.VXTEXTURE_ADDRESSMODE.VXTEXTURE_ADDRESSWRAP)
mTextureBlendMode: UTIL_virtools_types.VXTEXTURE_BLENDMODE mSourceBlend: UTIL_virtools_types.VXBLEND_MODE = datafield(default=UTIL_virtools_types.VXBLEND_MODE.VXBLEND_ONE)
mTextureMinMode: UTIL_virtools_types.VXTEXTURE_FILTERMODE mDestBlend: UTIL_virtools_types.VXBLEND_MODE = datafield(default=UTIL_virtools_types.VXBLEND_MODE.VXBLEND_ZERO)
mTextureMagMode: UTIL_virtools_types.VXTEXTURE_FILTERMODE mFillMode: UTIL_virtools_types.VXFILL_MODE = datafield(default=UTIL_virtools_types.VXFILL_MODE.VXFILL_SOLID)
mTextureAddressMode: UTIL_virtools_types.VXTEXTURE_ADDRESSMODE mShadeMode: UTIL_virtools_types.VXSHADE_MODE = datafield(default=UTIL_virtools_types.VXSHADE_MODE.VXSHADE_GOURAUD)
mSourceBlend: UTIL_virtools_types.VXBLEND_MODE mEnableAlphaTest: bool = datafield(default=False)
mDestBlend: UTIL_virtools_types.VXBLEND_MODE mEnableAlphaBlend: bool = datafield(default=False)
mFillMode: UTIL_virtools_types.VXFILL_MODE mEnablePerspectiveCorrection: bool = datafield(default=True)
mShadeMode: UTIL_virtools_types.VXSHADE_MODE mEnableZWrite: bool = datafield(default=True)
mEnableTwoSided: bool = datafield(default=False)
mEnableAlphaTest: bool mAlphaRef: int = datafield(default=0)
mEnableAlphaBlend: bool mAlphaFunc: UTIL_virtools_types.VXCMPFUNC = datafield(default=UTIL_virtools_types.VXCMPFUNC.VXCMP_ALWAYS)
mEnablePerspectiveCorrection: bool mZFunc: UTIL_virtools_types.VXCMPFUNC = datafield(default=UTIL_virtools_types.VXCMPFUNC.VXCMP_LESSEQUAL)
mEnableZWrite: bool
mEnableTwoSided: bool
mAlphaRef: int
mAlphaFunc: UTIL_virtools_types.VXCMPFUNC
mZFunc: UTIL_virtools_types.VXCMPFUNC
# Default Value Declarations
cDefaultDiffuse: typing.ClassVar[UTIL_virtools_types.VxColor] = UTIL_virtools_types.VxColor(0.7, 0.7, 0.7, 1.0)
cDefaultAmbient: typing.ClassVar[UTIL_virtools_types.VxColor] = UTIL_virtools_types.VxColor(0.3, 0.3, 0.3, 1.0)
cDefaultSpecular: typing.ClassVar[UTIL_virtools_types.VxColor] = UTIL_virtools_types.VxColor(0.5, 0.5, 0.5, 1.0)
cDefaultEmissive: typing.ClassVar[UTIL_virtools_types.VxColor] = UTIL_virtools_types.VxColor(0.0, 0.0, 0.0, 1.0)
cDefaultSpecularPower: typing.ClassVar[float] = 0.0
cDefaultTexture: typing.ClassVar[bpy.types.Image | None] = None
cDefaultTextureBorderColor: typing.ClassVar[UTIL_virtools_types.VxColor] = UTIL_virtools_types.VxColor(0.0, 0.0, 0.0, 0.0)
cDefaultTextureBlendMode: typing.ClassVar[UTIL_virtools_types.VXTEXTURE_BLENDMODE]= UTIL_virtools_types.VXTEXTURE_BLENDMODE.VXTEXTUREBLEND_MODULATEALPHA
cDefaultTextureMinMode: typing.ClassVar[UTIL_virtools_types.VXTEXTURE_FILTERMODE] = UTIL_virtools_types.VXTEXTURE_FILTERMODE.VXTEXTUREFILTER_LINEAR
cDefaultTextureMagMode: typing.ClassVar[UTIL_virtools_types.VXTEXTURE_FILTERMODE] = UTIL_virtools_types.VXTEXTURE_FILTERMODE.VXTEXTUREFILTER_LINEAR
cDefaultTextureAddressMode: typing.ClassVar[UTIL_virtools_types.VXTEXTURE_ADDRESSMODE] = UTIL_virtools_types.VXTEXTURE_ADDRESSMODE.VXTEXTURE_ADDRESSWRAP
cDefaultSourceBlend: typing.ClassVar[UTIL_virtools_types.VXBLEND_MODE] = UTIL_virtools_types.VXBLEND_MODE.VXBLEND_ONE
cDefaultDestBlend: typing.ClassVar[UTIL_virtools_types.VXBLEND_MODE] = UTIL_virtools_types.VXBLEND_MODE.VXBLEND_ZERO
cDefaultFillMode: typing.ClassVar[UTIL_virtools_types.VXFILL_MODE] = UTIL_virtools_types.VXFILL_MODE.VXFILL_SOLID
cDefaultShadeMode: typing.ClassVar[UTIL_virtools_types.VXSHADE_MODE] = UTIL_virtools_types.VXSHADE_MODE.VXSHADE_GOURAUD
cDefaultEnableAlphaTest: typing.ClassVar[bool] = False
cDefaultEnableAlphaBlend: typing.ClassVar[bool] = False
cDefaultEnablePerspectiveCorrection: typing.ClassVar[bool] = True
cDefaultEnableZWrite: typing.ClassVar[bool] = True
cDefaultEnableTwoSided: typing.ClassVar[bool] = False
cDefaultAlphaRef: typing.ClassVar[int] = 0
cDefaultAlphaFunc: typing.ClassVar[UTIL_virtools_types.VXCMPFUNC] = UTIL_virtools_types.VXCMPFUNC.VXCMP_ALWAYS
cDefaultZFunc: typing.ClassVar[UTIL_virtools_types.VXCMPFUNC] = UTIL_virtools_types.VXCMPFUNC.VXCMP_LESSEQUAL
def __init__(self, **kwargs):
# assign default value for each component
self.mDiffuse = kwargs.get('mDiffuse', RawVirtoolsMaterial.cDefaultDiffuse).clone()
self.mAmbient = kwargs.get('mAmbient', RawVirtoolsMaterial.cDefaultAmbient).clone()
self.mSpecular = kwargs.get('mSpecular', RawVirtoolsMaterial.cDefaultSpecular).clone()
self.mSpecularPower = kwargs.get('mSpecularPower', RawVirtoolsMaterial.cDefaultSpecularPower)
self.mEmissive = kwargs.get('mEmissive', RawVirtoolsMaterial.cDefaultEmissive).clone()
self.mEnableTwoSided = kwargs.get('mEnableTwoSided', RawVirtoolsMaterial.cDefaultEnableTwoSided)
self.mTexture = kwargs.get('mTexture', RawVirtoolsMaterial.cDefaultTexture)
self.mTextureMinMode = kwargs.get('mTextureMinMode', RawVirtoolsMaterial.cDefaultTextureMinMode)
self.mTextureMagMode = kwargs.get('mTextureMagMode', RawVirtoolsMaterial.cDefaultTextureMagMode)
self.mSourceBlend = kwargs.get('mSourceBlend', RawVirtoolsMaterial.cDefaultSourceBlend)
self.mDestBlend = kwargs.get('mDestBlend', RawVirtoolsMaterial.cDefaultDestBlend)
self.mEnableAlphaBlend = kwargs.get('mEnableAlphaBlend', RawVirtoolsMaterial.cDefaultEnableAlphaBlend)
self.mShadeMode = kwargs.get('mShadeMode', RawVirtoolsMaterial.cDefaultShadeMode)
self.mFillMode = kwargs.get('mFillMode', RawVirtoolsMaterial.cDefaultFillMode)
self.mEnableAlphaTest = kwargs.get('mEnableAlphaTest', RawVirtoolsMaterial.cDefaultEnableAlphaTest)
self.mEnableZWrite = kwargs.get('mEnableZWrite', RawVirtoolsMaterial.cDefaultEnableZWrite)
self.mEnablePerspectiveCorrection = kwargs.get('mEnablePerspectiveCorrection', RawVirtoolsMaterial.cDefaultEnablePerspectiveCorrection)
self.mTextureBlendMode = kwargs.get('mTextureBlendMode', RawVirtoolsMaterial.cDefaultTextureBlendMode)
self.mTextureAddressMode = kwargs.get('mTextureAddressMode', RawVirtoolsMaterial.cDefaultTextureAddressMode)
self.mZFunc = kwargs.get('mZFunc', RawVirtoolsMaterial.cDefaultZFunc)
self.mAlphaFunc = kwargs.get('mAlphaFunc', RawVirtoolsMaterial.cDefaultAlphaFunc)
self.mTextureBorderColor = kwargs.get('mTextureBorderColor', RawVirtoolsMaterial.cDefaultTextureBorderColor).clone()
self.mAlphaRef = kwargs.get('mAlphaRef', RawVirtoolsMaterial.cDefaultAlphaRef)
def regulate(self) -> None: def regulate(self) -> None:
# regulate colors # regulate colors
@@ -112,6 +55,8 @@ class RawVirtoolsMaterial():
# specular power # specular power
self.mSpecularPower = UTIL_functions.clamp_float(self.mSpecularPower, 0.0, 100.0) self.mSpecularPower = UTIL_functions.clamp_float(self.mSpecularPower, 0.0, 100.0)
DEFAULT_RAW_VIRTOOLS_MATERIAL = RawVirtoolsMaterial()
#region Blender Enum Prop Helper (Virtools type specified) #region Blender Enum Prop Helper (Virtools type specified)
_g_Helper_VXTEXTURE_BLENDMODE = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.VXTEXTURE_BLENDMODE) _g_Helper_VXTEXTURE_BLENDMODE = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.VXTEXTURE_BLENDMODE)
@@ -132,7 +77,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 1.0, max = 1.0,
size = 3, size = 3,
default = RawVirtoolsMaterial.cDefaultAmbient.to_const_rgb(), default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mAmbient.to_const_rgb(),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -143,7 +88,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 1.0, max = 1.0,
size = 4, size = 4,
default = RawVirtoolsMaterial.cDefaultDiffuse.to_const_rgba(), default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mDiffuse.to_const_rgba(),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -154,7 +99,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 1.0, max = 1.0,
size = 3, size = 3,
default = RawVirtoolsMaterial.cDefaultSpecular.to_const_rgb(), default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mSpecular.to_const_rgb(),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -165,7 +110,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 1.0, max = 1.0,
size = 3, size = 3,
default = RawVirtoolsMaterial.cDefaultEmissive.to_const_rgb(), default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEmissive.to_const_rgb(),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -174,7 +119,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
description = "Specular highlight power", description = "Specular highlight power",
min = 0.0, min = 0.0,
max = 100.0, max = 100.0,
default = RawVirtoolsMaterial.cDefaultSpecularPower, default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mSpecularPower,
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -192,7 +137,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
min = 0.0, min = 0.0,
max = 1.0, max = 1.0,
size = 4, size = 4,
default = RawVirtoolsMaterial.cDefaultTextureBorderColor.to_const_rgba(), default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mTextureBorderColor.to_const_rgba(),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -200,7 +145,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
name = "Texture Blend", name = "Texture Blend",
description = "Texture blend mode", description = "Texture blend mode",
items = _g_Helper_VXTEXTURE_BLENDMODE.generate_items(), items = _g_Helper_VXTEXTURE_BLENDMODE.generate_items(),
default = _g_Helper_VXTEXTURE_BLENDMODE.to_selection(RawVirtoolsMaterial.cDefaultTextureBlendMode), default = _g_Helper_VXTEXTURE_BLENDMODE.to_selection(DEFAULT_RAW_VIRTOOLS_MATERIAL.mTextureBlendMode),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -208,7 +153,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
name = "Filter Min", name = "Filter Min",
description = "Texture filter mode when the texture is minified", description = "Texture filter mode when the texture is minified",
items = _g_Helper_VXTEXTURE_FILTERMODE.generate_items(), items = _g_Helper_VXTEXTURE_FILTERMODE.generate_items(),
default = _g_Helper_VXTEXTURE_FILTERMODE.to_selection(RawVirtoolsMaterial.cDefaultTextureMinMode), default = _g_Helper_VXTEXTURE_FILTERMODE.to_selection(DEFAULT_RAW_VIRTOOLS_MATERIAL.mTextureMinMode),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -216,7 +161,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
name = "Filter Mag", name = "Filter Mag",
description = "Texture filter mode when the texture is magnified", description = "Texture filter mode when the texture is magnified",
items = _g_Helper_VXTEXTURE_FILTERMODE.generate_items(), items = _g_Helper_VXTEXTURE_FILTERMODE.generate_items(),
default = _g_Helper_VXTEXTURE_FILTERMODE.to_selection(RawVirtoolsMaterial.cDefaultTextureMagMode), default = _g_Helper_VXTEXTURE_FILTERMODE.to_selection(DEFAULT_RAW_VIRTOOLS_MATERIAL.mTextureMagMode),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -224,7 +169,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
name = "Address Mode", name = "Address Mode",
description = "The address mode controls how the texture coordinates outside the range 0..1", description = "The address mode controls how the texture coordinates outside the range 0..1",
items = _g_Helper_VXTEXTURE_ADDRESSMODE.generate_items(), items = _g_Helper_VXTEXTURE_ADDRESSMODE.generate_items(),
default = _g_Helper_VXTEXTURE_ADDRESSMODE.to_selection(RawVirtoolsMaterial.cDefaultTextureAddressMode), default = _g_Helper_VXTEXTURE_ADDRESSMODE.to_selection(DEFAULT_RAW_VIRTOOLS_MATERIAL.mTextureAddressMode),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -232,7 +177,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
name = "Source Blend", name = "Source Blend",
description = "Source blend factor", description = "Source blend factor",
items = _g_Helper_VXBLEND_MODE.generate_items(), items = _g_Helper_VXBLEND_MODE.generate_items(),
default = _g_Helper_VXBLEND_MODE.to_selection(RawVirtoolsMaterial.cDefaultSourceBlend), default = _g_Helper_VXBLEND_MODE.to_selection(DEFAULT_RAW_VIRTOOLS_MATERIAL.mSourceBlend),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -240,7 +185,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
name = "Destination Blend", name = "Destination Blend",
description = "Destination blend factor", description = "Destination blend factor",
items = _g_Helper_VXBLEND_MODE.generate_items(), items = _g_Helper_VXBLEND_MODE.generate_items(),
default = _g_Helper_VXBLEND_MODE.to_selection(RawVirtoolsMaterial.cDefaultDestBlend), default = _g_Helper_VXBLEND_MODE.to_selection(DEFAULT_RAW_VIRTOOLS_MATERIAL.mDestBlend),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -248,7 +193,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
name = "Fill Mode", name = "Fill Mode",
description = "Fill mode", description = "Fill mode",
items = _g_Helper_VXFILL_MODE.generate_items(), items = _g_Helper_VXFILL_MODE.generate_items(),
default = _g_Helper_VXFILL_MODE.to_selection(RawVirtoolsMaterial.cDefaultFillMode), default = _g_Helper_VXFILL_MODE.to_selection(DEFAULT_RAW_VIRTOOLS_MATERIAL.mFillMode),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -256,38 +201,38 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
name = "Shade Mode", name = "Shade Mode",
description = "Shade mode", description = "Shade mode",
items = _g_Helper_VXSHADE_MODE.generate_items(), items = _g_Helper_VXSHADE_MODE.generate_items(),
default = _g_Helper_VXSHADE_MODE.to_selection(RawVirtoolsMaterial.cDefaultShadeMode), default = _g_Helper_VXSHADE_MODE.to_selection(DEFAULT_RAW_VIRTOOLS_MATERIAL.mShadeMode),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
enable_alpha_test: bpy.props.BoolProperty( enable_alpha_test: bpy.props.BoolProperty(
name = "Alpha Test", name = "Alpha Test",
description = "Whether the alpha test is enabled", description = "Whether the alpha test is enabled",
default = RawVirtoolsMaterial.cDefaultEnableAlphaTest, default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEnableAlphaTest,
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
enable_alpha_blend: bpy.props.BoolProperty( enable_alpha_blend: bpy.props.BoolProperty(
name = "Blend", name = "Blend",
description = "Whether alpha blending is enabled or not.", description = "Whether alpha blending is enabled or not.",
default = RawVirtoolsMaterial.cDefaultEnableAlphaBlend, default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEnableAlphaBlend,
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
enable_perspective_correction: bpy.props.BoolProperty( enable_perspective_correction: bpy.props.BoolProperty(
name = "Perspective Correction", name = "Perspective Correction",
description = "Whether texture perspective correction is enabled", description = "Whether texture perspective correction is enabled",
default = RawVirtoolsMaterial.cDefaultEnablePerspectiveCorrection, default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEnablePerspectiveCorrection,
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
enable_z_write: bpy.props.BoolProperty( enable_z_write: bpy.props.BoolProperty(
name = "Z-Buffer Write", name = "Z-Buffer Write",
description = "Whether writing in ZBuffer is enabled.", description = "Whether writing in ZBuffer is enabled.",
default = RawVirtoolsMaterial.cDefaultEnableZWrite, default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEnableZWrite,
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
enable_two_sided: bpy.props.BoolProperty( enable_two_sided: bpy.props.BoolProperty(
name = "Both Sided", name = "Both Sided",
description = "Whether the material is both sided or not", description = "Whether the material is both sided or not",
default = RawVirtoolsMaterial.cDefaultEnableTwoSided, default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEnableTwoSided,
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -296,7 +241,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
description = "Alpha referential value", description = "Alpha referential value",
min = 0, min = 0,
max = 255, max = 255,
default = RawVirtoolsMaterial.cDefaultAlphaRef, default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mAlphaRef,
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -304,7 +249,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
name = "Alpha Test Function", name = "Alpha Test Function",
description = "Alpha comparision function", description = "Alpha comparision function",
items = _g_Helper_VXCMPFUNC.generate_items(), items = _g_Helper_VXCMPFUNC.generate_items(),
default = _g_Helper_VXCMPFUNC.to_selection(RawVirtoolsMaterial.cDefaultAlphaFunc), default = _g_Helper_VXCMPFUNC.to_selection(DEFAULT_RAW_VIRTOOLS_MATERIAL.mAlphaFunc),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore
@@ -312,7 +257,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
name = "Z Compare Function", name = "Z Compare Function",
description = "Z Comparison function", description = "Z Comparison function",
items = _g_Helper_VXCMPFUNC.generate_items(), items = _g_Helper_VXCMPFUNC.generate_items(),
default = _g_Helper_VXCMPFUNC.to_selection(RawVirtoolsMaterial.cDefaultZFunc), default = _g_Helper_VXCMPFUNC.to_selection(DEFAULT_RAW_VIRTOOLS_MATERIAL.mZFunc),
translation_context = 'BBP_PG_virtools_material/property' translation_context = 'BBP_PG_virtools_material/property'
) # type: ignore ) # type: ignore

View File

@@ -1,18 +1,16 @@
import bpy import bpy
import typing, enum import typing, enum
from dataclasses import dataclass
from dataclasses import field as datafield
from . import UTIL_functions, UTIL_blender_mesh, UTIL_virtools_types from . import UTIL_functions, UTIL_blender_mesh, UTIL_virtools_types
# Raw Data # Raw Data
@dataclass
class RawVirtoolsMesh(): class RawVirtoolsMesh():
# Instance Member Declarations mLitMode: UTIL_virtools_types.VXMESH_LITMODE = datafield(default=UTIL_virtools_types.VXMESH_LITMODE.VX_LITMESH)
mLitMode: UTIL_virtools_types.VXMESH_LITMODE
# Default Value Declarations
cDefaultLitMode: typing.ClassVar[UTIL_virtools_types.VXMESH_LITMODE] = UTIL_virtools_types.VXMESH_LITMODE.VX_LITMESH
def __init__(self, **kwargs): DEFAULT_RAW_VIRTOOLS_MESH = RawVirtoolsMesh()
# assign default value for each component
self.mLitMode = kwargs.get('mLitMode', RawVirtoolsMesh.cDefaultLitMode)
# blender enum prop helper defines # blender enum prop helper defines
_g_Helper_VXMESH_LITMODE = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.VXMESH_LITMODE) _g_Helper_VXMESH_LITMODE = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.VXMESH_LITMODE)
@@ -24,7 +22,7 @@ class BBP_PG_virtools_mesh(bpy.types.PropertyGroup):
name = "Lit Mode", name = "Lit Mode",
description = "Lighting mode of the mesh.", description = "Lighting mode of the mesh.",
items = _g_Helper_VXMESH_LITMODE.generate_items(), items = _g_Helper_VXMESH_LITMODE.generate_items(),
default = _g_Helper_VXMESH_LITMODE.to_selection(RawVirtoolsMesh.cDefaultLitMode), default = _g_Helper_VXMESH_LITMODE.to_selection(DEFAULT_RAW_VIRTOOLS_MESH.mLitMode),
translation_context = 'BBP_PG_virtools_mesh/property' translation_context = 'BBP_PG_virtools_mesh/property'
) # type: ignore ) # type: ignore

View File

@@ -1,23 +1,16 @@
import bpy import bpy
import typing import typing
from dataclasses import dataclass
from dataclasses import field as datafield
from . import UTIL_virtools_types, UTIL_functions from . import UTIL_virtools_types, UTIL_functions
@dataclass
class RawVirtoolsTexture(): class RawVirtoolsTexture():
# Instance Member Declarations mSaveOptions: UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS = datafield(default=UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS.CKTEXTURE_RAWDATA)
mVideoFormat: UTIL_virtools_types.VX_PIXELFORMAT = datafield(default=UTIL_virtools_types.VX_PIXELFORMAT._16_ARGB1555)
mSaveOptions: UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS DEFAULT_RAW_VIRTOOLS_TEXTURE = RawVirtoolsTexture()
mVideoFormat: UTIL_virtools_types.VX_PIXELFORMAT
# Default Value Declarations
cDefaultSaveOptions: typing.ClassVar[UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS] = UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS.CKTEXTURE_RAWDATA
cDefaultVideoFormat: typing.ClassVar[UTIL_virtools_types.VX_PIXELFORMAT] = UTIL_virtools_types.VX_PIXELFORMAT._16_ARGB1555
def __init__(self, **kwargs):
# assign default value for each component
self.mSaveOptions = kwargs.get('mSaveOptions', RawVirtoolsTexture.cDefaultSaveOptions)
self.mVideoFormat = kwargs.get('mVideoFormat', RawVirtoolsTexture.cDefaultVideoFormat)
# blender enum prop helper defines # blender enum prop helper defines
_g_Helper_CK_TEXTURE_SAVEOPTIONS = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS) _g_Helper_CK_TEXTURE_SAVEOPTIONS = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS)
@@ -29,7 +22,7 @@ class BBP_PG_virtools_texture(bpy.types.PropertyGroup):
name = "Save Options", name = "Save Options",
description = "When saving a composition textures or sprites can be kept as reference to external files or converted to a given format and saved inside the composition file.", description = "When saving a composition textures or sprites can be kept as reference to external files or converted to a given format and saved inside the composition file.",
items = _g_Helper_CK_TEXTURE_SAVEOPTIONS.generate_items(), items = _g_Helper_CK_TEXTURE_SAVEOPTIONS.generate_items(),
default = _g_Helper_CK_TEXTURE_SAVEOPTIONS.to_selection(RawVirtoolsTexture.cDefaultSaveOptions), default = _g_Helper_CK_TEXTURE_SAVEOPTIONS.to_selection(DEFAULT_RAW_VIRTOOLS_TEXTURE.mSaveOptions),
translation_context = 'BBP_PG_virtools_texture/property' translation_context = 'BBP_PG_virtools_texture/property'
) # type: ignore ) # type: ignore
@@ -37,7 +30,7 @@ class BBP_PG_virtools_texture(bpy.types.PropertyGroup):
name = "Video Format", name = "Video Format",
description = "The desired surface pixel format in video memory.", description = "The desired surface pixel format in video memory.",
items = _g_Helper_VX_PIXELFORMAT.generate_items(), items = _g_Helper_VX_PIXELFORMAT.generate_items(),
default = _g_Helper_VX_PIXELFORMAT.to_selection(RawVirtoolsTexture.cDefaultVideoFormat), default = _g_Helper_VX_PIXELFORMAT.to_selection(DEFAULT_RAW_VIRTOOLS_TEXTURE.mVideoFormat),
translation_context = 'BBP_PG_virtools_texture/property' translation_context = 'BBP_PG_virtools_texture/property'
) # type: ignore ) # type: ignore

View File

@@ -260,8 +260,8 @@ _g_Docstring: dict[type, dict[int, EnumDocstring]] = {
VXMESH_LITMODE.VX_LITMESH.value: EnumDocstring("Lit", "Lighting is done by renderer using normals and face material information. "), VXMESH_LITMODE.VX_LITMESH.value: EnumDocstring("Lit", "Lighting is done by renderer using normals and face material information. "),
}, },
CK_CAMERA_PROJECTION: { CK_CAMERA_PROJECTION: {
CK_CAMERA_PROJECTION.CK_PERSPECTIVEPROJECTION.value: EnumDocstring("Perspective projection", ""), CK_CAMERA_PROJECTION.CK_PERSPECTIVEPROJECTION.value: EnumDocstring("Perspective Projection", ""),
CK_CAMERA_PROJECTION.CK_ORTHOGRAPHICPROJECTION.value: EnumDocstring("Orthographic projection", ""), CK_CAMERA_PROJECTION.CK_ORTHOGRAPHICPROJECTION.value: EnumDocstring("Orthographic Projection", ""),
} }
} }