mirror of
https://github.com/red031000/nitrog3d.git
synced 2025-06-18 13:15:35 -04:00
command 0x2A: TexImageParam
This commit is contained in:
parent
6e3a3e9011
commit
9b1787c162
@ -1,4 +1,4 @@
|
||||
from .utils import error, read32, np_fixed_to_float, fixed_to_float, to_rgb, vec10_to_vec, PolygonMode, CullMode
|
||||
from .utils import error, read32, np_fixed_to_float, fixed_to_float, to_rgb, vec10_to_vec, PolygonMode, CullMode, TexturePalette0Mode, TextureFlip, TextureRepeat, TextureTSize, TextureSSize, TextureConversionMode, TextureFormat
|
||||
from enum import IntEnum
|
||||
import numpy as np
|
||||
|
||||
@ -137,6 +137,12 @@ def parse_dl_command(data, offset, commandData, report_func):
|
||||
polyAttr = DLCommandPolygonAttr()
|
||||
polyAttr.parse(attributes)
|
||||
commands.append(polyAttr)
|
||||
elif command == 0x2A:
|
||||
attributes = read32(data, offset)
|
||||
offset += 4
|
||||
texImageParam = DLCommandTexImageParam()
|
||||
texImageParam.parse(attributes)
|
||||
commands.append(texImageParam)
|
||||
#todo more commands
|
||||
return commands, offset
|
||||
|
||||
@ -305,3 +311,39 @@ class DLCommandPolygonAttr(DLCommand):
|
||||
self.depthTest = (attributes >> 14) & 0x1 != 0
|
||||
|
||||
self.fog = (attributes >> 15) & 0x1 != 0
|
||||
|
||||
class DLCommandTexImageParam(DLCommand):
|
||||
def __init__(self):
|
||||
super().__init__(0x2A)
|
||||
self.texturePalette0Mode = TexturePalette0Mode.USE
|
||||
self.textureFlip = TextureFlip.NONE
|
||||
self.textureRepeat = TextureRepeat.NONE
|
||||
self.textureTSize = TextureTSize.T8
|
||||
self.textureSSize = TextureSSize.S8
|
||||
self.textureConversionMode = TextureConversionMode.NONE
|
||||
self.textureFormat = TextureFormat.NONE
|
||||
self.textureAddress = 0
|
||||
|
||||
def parse(self, attributes):
|
||||
texturePalette0Mode = (attributes >> 29) & 0x1
|
||||
self.texturePalette0Mode = TexturePalette0Mode(texturePalette0Mode)
|
||||
|
||||
textureFlip = (attributes >> 18) & 0x3
|
||||
self.textureFlip = TextureFlip(textureFlip)
|
||||
|
||||
textureRepeat = (attributes >> 16) & 0x3
|
||||
self.textureRepeat = TextureRepeat(textureRepeat)
|
||||
|
||||
textureTSize = (attributes >> 23) & 0x7
|
||||
self.textureTSize = TextureTSize(textureTSize)
|
||||
|
||||
textureSSize = (attributes >> 20) & 0x7
|
||||
self.textureSSize = TextureSSize(textureSSize)
|
||||
|
||||
textureConversionMode = (attributes >> 30) & 0x3
|
||||
self.textureConversionMode = TextureConversionMode(textureConversionMode)
|
||||
|
||||
textureFormat = (attributes >> 26) & 0x7
|
||||
self.textureFormat = TextureFormat(textureFormat)
|
||||
|
||||
self.textureAddress = attributes & 0xFFFF
|
||||
|
@ -1,6 +1,6 @@
|
||||
from enum import IntEnum, IntFlag
|
||||
from os.path import isfile
|
||||
from .utils import read8, read16, read32, read_str, log, debug, parse_dictionary, fixed_to_float, to_rgb, PolygonMode, CullMode
|
||||
from .utils import read8, read16, read32, read_str, log, debug, parse_dictionary, fixed_to_float, to_rgb, PolygonMode, CullMode, TexturePalette0Mode, TextureFlip, TextureRepeat, TextureTSize, TextureSSize, TextureConversionMode, TextureFormat
|
||||
from .g3_commands import parse_dl
|
||||
import numpy as np
|
||||
|
||||
@ -198,58 +198,6 @@ class NSBMDMaterialPolygonAttributes():
|
||||
self.fog = (attributes >> 15) & 0x1 != 0
|
||||
log('Fog: %s' % self.fog, report_func)
|
||||
|
||||
class TextureFormat(IntEnum):
|
||||
NONE = 0
|
||||
A3I5 = 1
|
||||
PLTT4 = 2
|
||||
PLTT16 = 3
|
||||
PLTT256 = 4
|
||||
COMP4X4 = 5
|
||||
A5I3 = 6
|
||||
DIRECT = 7
|
||||
|
||||
class TextureConversionMode(IntEnum):
|
||||
NONE = 0
|
||||
TEXCOORD = 1
|
||||
NORMAL = 2
|
||||
VERTEX = 3
|
||||
|
||||
class TextureSSize(IntEnum):
|
||||
S8 = 0
|
||||
S16 = 1
|
||||
S32 = 2
|
||||
S64 = 3
|
||||
S128 = 4
|
||||
S256 = 5
|
||||
S512 = 6
|
||||
S1024 = 7
|
||||
|
||||
class TextureTSize(IntEnum):
|
||||
T8 = 0
|
||||
T16 = 1
|
||||
T32 = 2
|
||||
T64 = 3
|
||||
T128 = 4
|
||||
T256 = 5
|
||||
T512 = 6
|
||||
T1024 = 7
|
||||
|
||||
class TextureRepeat(IntEnum):
|
||||
NONE = 0
|
||||
S = 1
|
||||
T = 2
|
||||
ST = 3
|
||||
|
||||
class TextureFlip(IntEnum):
|
||||
NONE = 0
|
||||
S = 1
|
||||
T = 2
|
||||
ST = 3
|
||||
|
||||
class TexturePalette0Mode(IntEnum):
|
||||
USE = 0
|
||||
TRANSPARENT = 1
|
||||
|
||||
class NSBMDMaterialTextureImageParameters():
|
||||
def __init__(self):
|
||||
self.address = 0
|
||||
|
52
utils.py
52
utils.py
@ -77,3 +77,55 @@ class CullMode(IntEnum):
|
||||
FRONT = 1
|
||||
BACK = 2
|
||||
BOTH = 3
|
||||
|
||||
class TexturePalette0Mode(IntEnum):
|
||||
USE = 0
|
||||
TRANSPARENT = 1
|
||||
|
||||
class TextureFlip(IntEnum):
|
||||
NONE = 0
|
||||
S = 1
|
||||
T = 2
|
||||
ST = 3
|
||||
|
||||
class TextureRepeat(IntEnum):
|
||||
NONE = 0
|
||||
S = 1
|
||||
T = 2
|
||||
ST = 3
|
||||
|
||||
class TextureTSize(IntEnum):
|
||||
T8 = 0
|
||||
T16 = 1
|
||||
T32 = 2
|
||||
T64 = 3
|
||||
T128 = 4
|
||||
T256 = 5
|
||||
T512 = 6
|
||||
T1024 = 7
|
||||
|
||||
class TextureSSize(IntEnum):
|
||||
S8 = 0
|
||||
S16 = 1
|
||||
S32 = 2
|
||||
S64 = 3
|
||||
S128 = 4
|
||||
S256 = 5
|
||||
S512 = 6
|
||||
S1024 = 7
|
||||
|
||||
class TextureConversionMode(IntEnum):
|
||||
NONE = 0
|
||||
TEXCOORD = 1
|
||||
NORMAL = 2
|
||||
VERTEX = 3
|
||||
|
||||
class TextureFormat(IntEnum):
|
||||
NONE = 0
|
||||
A3I5 = 1
|
||||
PLTT4 = 2
|
||||
PLTT16 = 3
|
||||
PLTT256 = 4
|
||||
COMP4X4 = 5
|
||||
A5I3 = 6
|
||||
DIRECT = 7
|
||||
|
Loading…
Reference in New Issue
Block a user