refactor: use python built in dataclass to improve our raw data structs.
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
import bpy
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field as datafield
|
||||
from . import UTIL_functions
|
||||
|
||||
@dataclass
|
||||
class RawBallanceMapInfo():
|
||||
cSectorCount: typing.ClassVar[int] = 1
|
||||
|
||||
mSectorCount: int
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.mSectorCount = kwargs.get("mSectorCount", RawBallanceMapInfo.cSectorCount)
|
||||
mSectorCount: int = datafield(default=1)
|
||||
|
||||
def regulate(self):
|
||||
self.mSectorCount = UTIL_functions.clamp_int(self.mSectorCount, 1, 999)
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import bpy
|
||||
import os, typing
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field as datafield
|
||||
from . import UTIL_naming_convention
|
||||
|
||||
@dataclass
|
||||
class RawPreferences():
|
||||
cBallanceTextureFolder: typing.ClassVar[str] = ""
|
||||
cNoComponentCollection: typing.ClassVar[str] = ""
|
||||
|
||||
mBallanceTextureFolder: str
|
||||
mNoComponentCollection: str
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.mBallanceTextureFolder = kwargs.get("mBallanceTextureFolder", "")
|
||||
self.mNoComponentCollection = kwargs.get("mNoComponentCollection", "")
|
||||
mBallanceTextureFolder: str = datafield(default="")
|
||||
mNoComponentCollection: str = datafield(default="")
|
||||
|
||||
def has_valid_blc_tex_folder(self) -> bool:
|
||||
return os.path.isdir(self.mBallanceTextureFolder)
|
||||
|
||||
DEFAULT_RAW_PREFERENCES = RawPreferences()
|
||||
|
||||
class BBPPreferences(bpy.types.AddonPreferences):
|
||||
bl_idname = __package__
|
||||
|
||||
@@ -23,14 +21,14 @@ class BBPPreferences(bpy.types.AddonPreferences):
|
||||
name = "Ballance Texture Folder",
|
||||
description = "The path to folder which will be used by this plugin to get external Ballance texture.",
|
||||
subtype = 'DIR_PATH',
|
||||
default = RawPreferences.cBallanceTextureFolder,
|
||||
default = DEFAULT_RAW_PREFERENCES.mBallanceTextureFolder,
|
||||
translation_context = 'BBPPreferences/property'
|
||||
) # type: ignore
|
||||
|
||||
no_component_collection: bpy.props.StringProperty(
|
||||
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",
|
||||
default = RawPreferences.cNoComponentCollection,
|
||||
default = DEFAULT_RAW_PREFERENCES.mNoComponentCollection,
|
||||
translation_context = 'BBPPreferences/property'
|
||||
) # type: ignore
|
||||
|
||||
|
||||
@@ -1,44 +1,22 @@
|
||||
import bpy
|
||||
import typing, math, enum
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field as datafield
|
||||
from . import UTIL_functions, UTIL_virtools_types
|
||||
|
||||
@dataclass
|
||||
class RawVirtoolsCamera():
|
||||
# Class Member
|
||||
|
||||
mProjectionType: UTIL_virtools_types.CK_CAMERA_PROJECTION
|
||||
|
||||
mOrthographicZoom: float
|
||||
|
||||
mFrontPlane: float
|
||||
mBackPlane: float
|
||||
mFov: float
|
||||
|
||||
mAspectRatio: tuple[int, int]
|
||||
|
||||
# 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
|
||||
mProjectionType: UTIL_virtools_types.CK_CAMERA_PROJECTION = datafield(default=UTIL_virtools_types.CK_CAMERA_PROJECTION.CK_PERSPECTIVEPROJECTION)
|
||||
|
||||
cDefaultFrontPlane: typing.ClassVar[float] = 1.0
|
||||
cDefaultBackPlane: typing.ClassVar[float] = 4000.0
|
||||
cDefaultFov: typing.ClassVar[float] = 0.5
|
||||
mOrthographicZoom: float = datafield(default=1.0)
|
||||
|
||||
cDefaultAspectRatio: typing.ClassVar[tuple[int, int]] = (4, 3)
|
||||
mFrontPlane: float = datafield(default=1.0)
|
||||
mBackPlane: float = datafield(default=4000.0)
|
||||
mFov: float = datafield(default=0.5)
|
||||
|
||||
mAspectRatio: tuple[int, int] = datafield(default_factory=lambda: (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:
|
||||
# everything should be positive
|
||||
self.mOrthographicZoom = max(0.0, self.mOrthographicZoom)
|
||||
@@ -52,6 +30,8 @@ class RawVirtoolsCamera():
|
||||
h = max(1, h)
|
||||
self.mAspectRatio = (w, h)
|
||||
|
||||
DEFAULT_RAW_VIRTOOLS_CAMERA = RawVirtoolsCamera()
|
||||
|
||||
#region Blender Enum Prop Helper
|
||||
|
||||
_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",
|
||||
description = "The type of this camera.",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -74,7 +54,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
|
||||
soft_min = 0.0,
|
||||
soft_max = 0.5,
|
||||
step = 5,
|
||||
default = RawVirtoolsCamera.cDefaultOrthographicZoom,
|
||||
default = DEFAULT_RAW_VIRTOOLS_CAMERA.mOrthographicZoom,
|
||||
translation_context = 'BBP_PG_virtools_camera/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -85,7 +65,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
|
||||
soft_min = 0.0,
|
||||
soft_max = 5000.0,
|
||||
step = 100,
|
||||
default = RawVirtoolsCamera.cDefaultFrontPlane,
|
||||
default = DEFAULT_RAW_VIRTOOLS_CAMERA.mFrontPlane,
|
||||
translation_context = 'BBP_PG_virtools_camera/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -96,7 +76,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
|
||||
soft_min = 0.0,
|
||||
soft_max = 5000.0,
|
||||
step = 100,
|
||||
default = RawVirtoolsCamera.cDefaultBackPlane,
|
||||
default = DEFAULT_RAW_VIRTOOLS_CAMERA.mBackPlane,
|
||||
translation_context = 'BBP_PG_virtools_camera/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -108,7 +88,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
|
||||
max = math.radians(180.0),
|
||||
step = 100,
|
||||
precision = 100,
|
||||
default = RawVirtoolsCamera.cDefaultFov,
|
||||
default = DEFAULT_RAW_VIRTOOLS_CAMERA.mFov,
|
||||
translation_context = 'BBP_PG_virtools_camera/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -119,7 +99,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
|
||||
soft_min = 1,
|
||||
soft_max = 40,
|
||||
step = 1,
|
||||
default = RawVirtoolsCamera.cDefaultAspectRatio[0],
|
||||
default = DEFAULT_RAW_VIRTOOLS_CAMERA.mAspectRatio[0],
|
||||
translation_context = 'BBP_PG_virtools_camera/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -130,7 +110,7 @@ class BBP_PG_virtools_camera(bpy.types.PropertyGroup):
|
||||
soft_min = 1,
|
||||
soft_max = 40,
|
||||
step = 1,
|
||||
default = RawVirtoolsCamera.cDefaultAspectRatio[1],
|
||||
default = DEFAULT_RAW_VIRTOOLS_CAMERA.mAspectRatio[1],
|
||||
translation_context = 'BBP_PG_virtools_camera/property'
|
||||
) # type: ignore
|
||||
|
||||
|
||||
@@ -1,54 +1,26 @@
|
||||
import bpy
|
||||
import typing, math
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field as datafield
|
||||
from . import UTIL_functions, UTIL_virtools_types
|
||||
|
||||
# Raw Data
|
||||
|
||||
@dataclass
|
||||
class RawVirtoolsLight():
|
||||
# Class member
|
||||
|
||||
mType: UTIL_virtools_types.VXLIGHT_TYPE = datafield(default=UTIL_virtools_types.VXLIGHT_TYPE.VX_LIGHTPOINT)
|
||||
mColor: UTIL_virtools_types.VxColor = datafield(default_factory=lambda: UTIL_virtools_types.VxColor(1.0, 1.0, 1.0, 1.0))
|
||||
|
||||
mType: UTIL_virtools_types.VXLIGHT_TYPE
|
||||
mColor: UTIL_virtools_types.VxColor
|
||||
mConstantAttenuation: float = datafield(default=1.0)
|
||||
mLinearAttenuation: float = datafield(default=0.0)
|
||||
mQuadraticAttenuation: float = datafield(default=0.0)
|
||||
|
||||
mConstantAttenuation: float
|
||||
mLinearAttenuation: float
|
||||
mQuadraticAttenuation: float
|
||||
mRange: float = datafield(default=100.0)
|
||||
|
||||
mRange: float
|
||||
|
||||
mHotSpot: float
|
||||
mFalloff: float
|
||||
mFalloffShape: float
|
||||
|
||||
# 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)
|
||||
mHotSpot: float = datafield(default=math.radians(40))
|
||||
mFalloff: float = datafield(default=math.radians(45))
|
||||
mFalloffShape: float = datafield(default=1.0)
|
||||
|
||||
def regulate(self) -> None:
|
||||
# regulate color and reset its alpha value
|
||||
@@ -70,6 +42,8 @@ class RawVirtoolsLight():
|
||||
if self.mFalloff < self.mHotSpot:
|
||||
self.mFalloff = self.mHotSpot
|
||||
|
||||
DEFAULT_RAW_VIRTOOLS_LIGHT = RawVirtoolsLight()
|
||||
|
||||
# Blender Property Group
|
||||
|
||||
_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",
|
||||
description = "The type of this light",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -90,7 +64,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = 1.0,
|
||||
size = 3,
|
||||
default = RawVirtoolsLight.cDefaultColor.to_const_rgb(),
|
||||
default = DEFAULT_RAW_VIRTOOLS_LIGHT.mColor.to_const_rgb(),
|
||||
translation_context = 'BBP_PG_virtools_light/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -100,7 +74,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = 10.0,
|
||||
step = 10,
|
||||
default = RawVirtoolsLight.cDefaultConstantAttenuation,
|
||||
default = DEFAULT_RAW_VIRTOOLS_LIGHT.mConstantAttenuation,
|
||||
translation_context = 'BBP_PG_virtools_light/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -110,7 +84,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = 10.0,
|
||||
step = 10,
|
||||
default = RawVirtoolsLight.cDefaultLinearAttenuation,
|
||||
default = DEFAULT_RAW_VIRTOOLS_LIGHT.mLinearAttenuation,
|
||||
translation_context = 'BBP_PG_virtools_light/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -120,7 +94,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = 10.0,
|
||||
step = 10,
|
||||
default = RawVirtoolsLight.cDefaultQuadraticAttenuation,
|
||||
default = DEFAULT_RAW_VIRTOOLS_LIGHT.mQuadraticAttenuation,
|
||||
translation_context = 'BBP_PG_virtools_light/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -130,7 +104,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = 200.0,
|
||||
step = 100,
|
||||
default = RawVirtoolsLight.cDefaultRange,
|
||||
default = DEFAULT_RAW_VIRTOOLS_LIGHT.mRange,
|
||||
translation_context = 'BBP_PG_virtools_light/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -140,7 +114,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = math.radians(180),
|
||||
subtype = 'ANGLE',
|
||||
default = RawVirtoolsLight.cDefaultHotSpot,
|
||||
default = DEFAULT_RAW_VIRTOOLS_LIGHT.mHotSpot,
|
||||
translation_context = 'BBP_PG_virtools_light/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -150,7 +124,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = math.radians(180),
|
||||
subtype = 'ANGLE',
|
||||
default = RawVirtoolsLight.cDefaultFalloff,
|
||||
default = DEFAULT_RAW_VIRTOOLS_LIGHT.mFalloff,
|
||||
translation_context = 'BBP_PG_virtools_light/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -160,7 +134,7 @@ class BBP_PG_virtools_light(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = 10.0,
|
||||
step = 10,
|
||||
default = RawVirtoolsLight.cDefaultFalloffShape,
|
||||
default = DEFAULT_RAW_VIRTOOLS_LIGHT.mFalloffShape,
|
||||
translation_context = 'BBP_PG_virtools_light/property'
|
||||
) # type: ignore
|
||||
|
||||
|
||||
@@ -1,98 +1,41 @@
|
||||
import bpy
|
||||
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 PROP_virtools_texture, PROP_preferences
|
||||
|
||||
@dataclass
|
||||
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
|
||||
mAmbient: UTIL_virtools_types.VxColor
|
||||
mSpecular: UTIL_virtools_types.VxColor
|
||||
mEmissive: UTIL_virtools_types.VxColor
|
||||
mSpecularPower: float
|
||||
mTexture: bpy.types.Image | None = datafield(default=None)
|
||||
mTextureBorderColor: UTIL_virtools_types.VxColor = datafield(default_factory=lambda: UTIL_virtools_types.VxColor(0.0, 0.0, 0.0, 0.0))
|
||||
|
||||
mTexture: bpy.types.Image | None
|
||||
mTextureBorderColor: UTIL_virtools_types.VxColor
|
||||
mTextureBlendMode: UTIL_virtools_types.VXTEXTURE_BLENDMODE = datafield(default=UTIL_virtools_types.VXTEXTURE_BLENDMODE.VXTEXTUREBLEND_MODULATEALPHA)
|
||||
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
|
||||
mTextureMinMode: UTIL_virtools_types.VXTEXTURE_FILTERMODE
|
||||
mTextureMagMode: UTIL_virtools_types.VXTEXTURE_FILTERMODE
|
||||
mTextureAddressMode: UTIL_virtools_types.VXTEXTURE_ADDRESSMODE
|
||||
mSourceBlend: UTIL_virtools_types.VXBLEND_MODE = datafield(default=UTIL_virtools_types.VXBLEND_MODE.VXBLEND_ONE)
|
||||
mDestBlend: UTIL_virtools_types.VXBLEND_MODE = datafield(default=UTIL_virtools_types.VXBLEND_MODE.VXBLEND_ZERO)
|
||||
mFillMode: UTIL_virtools_types.VXFILL_MODE = datafield(default=UTIL_virtools_types.VXFILL_MODE.VXFILL_SOLID)
|
||||
mShadeMode: UTIL_virtools_types.VXSHADE_MODE = datafield(default=UTIL_virtools_types.VXSHADE_MODE.VXSHADE_GOURAUD)
|
||||
|
||||
mSourceBlend: UTIL_virtools_types.VXBLEND_MODE
|
||||
mDestBlend: UTIL_virtools_types.VXBLEND_MODE
|
||||
mFillMode: UTIL_virtools_types.VXFILL_MODE
|
||||
mShadeMode: UTIL_virtools_types.VXSHADE_MODE
|
||||
mEnableAlphaTest: bool = datafield(default=False)
|
||||
mEnableAlphaBlend: bool = datafield(default=False)
|
||||
mEnablePerspectiveCorrection: bool = datafield(default=True)
|
||||
mEnableZWrite: bool = datafield(default=True)
|
||||
mEnableTwoSided: bool = datafield(default=False)
|
||||
|
||||
mEnableAlphaTest: bool
|
||||
mEnableAlphaBlend: bool
|
||||
mEnablePerspectiveCorrection: bool
|
||||
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)
|
||||
mAlphaRef: int = datafield(default=0)
|
||||
mAlphaFunc: UTIL_virtools_types.VXCMPFUNC = datafield(default=UTIL_virtools_types.VXCMPFUNC.VXCMP_ALWAYS)
|
||||
mZFunc: UTIL_virtools_types.VXCMPFUNC = datafield(default=UTIL_virtools_types.VXCMPFUNC.VXCMP_LESSEQUAL)
|
||||
|
||||
def regulate(self) -> None:
|
||||
# regulate colors
|
||||
@@ -112,6 +55,8 @@ class RawVirtoolsMaterial():
|
||||
# specular power
|
||||
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)
|
||||
|
||||
_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,
|
||||
max = 1.0,
|
||||
size = 3,
|
||||
default = RawVirtoolsMaterial.cDefaultAmbient.to_const_rgb(),
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mAmbient.to_const_rgb(),
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -143,7 +88,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = 1.0,
|
||||
size = 4,
|
||||
default = RawVirtoolsMaterial.cDefaultDiffuse.to_const_rgba(),
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mDiffuse.to_const_rgba(),
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -154,7 +99,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = 1.0,
|
||||
size = 3,
|
||||
default = RawVirtoolsMaterial.cDefaultSpecular.to_const_rgb(),
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mSpecular.to_const_rgb(),
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -165,7 +110,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = 1.0,
|
||||
size = 3,
|
||||
default = RawVirtoolsMaterial.cDefaultEmissive.to_const_rgb(),
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEmissive.to_const_rgb(),
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -174,7 +119,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
description = "Specular highlight power",
|
||||
min = 0.0,
|
||||
max = 100.0,
|
||||
default = RawVirtoolsMaterial.cDefaultSpecularPower,
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mSpecularPower,
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -192,7 +137,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
min = 0.0,
|
||||
max = 1.0,
|
||||
size = 4,
|
||||
default = RawVirtoolsMaterial.cDefaultTextureBorderColor.to_const_rgba(),
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mTextureBorderColor.to_const_rgba(),
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -200,7 +145,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
name = "Texture Blend",
|
||||
description = "Texture blend mode",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -208,7 +153,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
name = "Filter Min",
|
||||
description = "Texture filter mode when the texture is minified",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -216,7 +161,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
name = "Filter Mag",
|
||||
description = "Texture filter mode when the texture is magnified",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -224,7 +169,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
name = "Address Mode",
|
||||
description = "The address mode controls how the texture coordinates outside the range 0..1",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -232,7 +177,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
name = "Source Blend",
|
||||
description = "Source blend factor",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -240,7 +185,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
name = "Destination Blend",
|
||||
description = "Destination blend factor",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -248,7 +193,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
name = "Fill Mode",
|
||||
description = "Fill mode",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -256,38 +201,38 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
name = "Shade Mode",
|
||||
description = "Shade mode",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
enable_alpha_test: bpy.props.BoolProperty(
|
||||
name = "Alpha Test",
|
||||
description = "Whether the alpha test is enabled",
|
||||
default = RawVirtoolsMaterial.cDefaultEnableAlphaTest,
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEnableAlphaTest,
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
enable_alpha_blend: bpy.props.BoolProperty(
|
||||
name = "Blend",
|
||||
description = "Whether alpha blending is enabled or not.",
|
||||
default = RawVirtoolsMaterial.cDefaultEnableAlphaBlend,
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEnableAlphaBlend,
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
enable_perspective_correction: bpy.props.BoolProperty(
|
||||
name = "Perspective Correction",
|
||||
description = "Whether texture perspective correction is enabled",
|
||||
default = RawVirtoolsMaterial.cDefaultEnablePerspectiveCorrection,
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEnablePerspectiveCorrection,
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
enable_z_write: bpy.props.BoolProperty(
|
||||
name = "Z-Buffer Write",
|
||||
description = "Whether writing in ZBuffer is enabled.",
|
||||
default = RawVirtoolsMaterial.cDefaultEnableZWrite,
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mEnableZWrite,
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
enable_two_sided: bpy.props.BoolProperty(
|
||||
name = "Both Sided",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -296,7 +241,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
description = "Alpha referential value",
|
||||
min = 0,
|
||||
max = 255,
|
||||
default = RawVirtoolsMaterial.cDefaultAlphaRef,
|
||||
default = DEFAULT_RAW_VIRTOOLS_MATERIAL.mAlphaRef,
|
||||
translation_context = 'BBP_PG_virtools_material/property'
|
||||
) # type: ignore
|
||||
|
||||
@@ -304,7 +249,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
name = "Alpha Test Function",
|
||||
description = "Alpha comparision function",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -312,7 +257,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
name = "Z Compare Function",
|
||||
description = "Z Comparison function",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import bpy
|
||||
import typing, enum
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field as datafield
|
||||
from . import UTIL_functions, UTIL_blender_mesh, UTIL_virtools_types
|
||||
|
||||
# Raw Data
|
||||
|
||||
@dataclass
|
||||
class RawVirtoolsMesh():
|
||||
# Instance Member Declarations
|
||||
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):
|
||||
# assign default value for each component
|
||||
self.mLitMode = kwargs.get('mLitMode', RawVirtoolsMesh.cDefaultLitMode)
|
||||
mLitMode: UTIL_virtools_types.VXMESH_LITMODE = datafield(default=UTIL_virtools_types.VXMESH_LITMODE.VX_LITMESH)
|
||||
|
||||
DEFAULT_RAW_VIRTOOLS_MESH = RawVirtoolsMesh()
|
||||
|
||||
# blender enum prop helper defines
|
||||
_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",
|
||||
description = "Lighting mode of the mesh.",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
import bpy
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field as datafield
|
||||
from . import UTIL_virtools_types, UTIL_functions
|
||||
|
||||
@dataclass
|
||||
class RawVirtoolsTexture():
|
||||
|
||||
# Instance Member Declarations
|
||||
|
||||
mSaveOptions: UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS
|
||||
mVideoFormat: UTIL_virtools_types.VX_PIXELFORMAT
|
||||
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)
|
||||
|
||||
# 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
|
||||
DEFAULT_RAW_VIRTOOLS_TEXTURE = RawVirtoolsTexture()
|
||||
|
||||
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
|
||||
_g_Helper_CK_TEXTURE_SAVEOPTIONS = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS)
|
||||
_g_Helper_VX_PIXELFORMAT = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.VX_PIXELFORMAT)
|
||||
@@ -29,7 +22,7 @@ class BBP_PG_virtools_texture(bpy.types.PropertyGroup):
|
||||
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.",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
@@ -37,7 +30,7 @@ class BBP_PG_virtools_texture(bpy.types.PropertyGroup):
|
||||
name = "Video Format",
|
||||
description = "The desired surface pixel format in video memory.",
|
||||
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'
|
||||
) # type: ignore
|
||||
|
||||
|
||||
@@ -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. "),
|
||||
},
|
||||
CK_CAMERA_PROJECTION: {
|
||||
CK_CAMERA_PROJECTION.CK_PERSPECTIVEPROJECTION.value: EnumDocstring("Perspective projection", ""),
|
||||
CK_CAMERA_PROJECTION.CK_ORTHOGRAPHICPROJECTION.value: EnumDocstring("Orthographic projection", ""),
|
||||
CK_CAMERA_PROJECTION.CK_PERSPECTIVEPROJECTION.value: EnumDocstring("Perspective Projection", ""),
|
||||
CK_CAMERA_PROJECTION.CK_ORTHOGRAPHICPROJECTION.value: EnumDocstring("Orthographic Projection", ""),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user