[SM64] Import Cleanup (#164)

* cleanup part 1

* removed sm64_enum_parser as it's unused

* more import cleanup

* applied black on modified files

* ``copy.copy`` -> ``copy``
This commit is contained in:
Yanis42
2022-11-21 13:06:48 +01:00
committed by GitHub
parent c7b1d8066f
commit d7f88e8e2d
18 changed files with 783 additions and 280 deletions
+135 -59
View File
@@ -1,22 +1,100 @@
from .sm64_f3d_writer import *
from .sm64_geolayout_writer import *
from .sm64_geolayout_parser import *
from .sm64_level_parser import *
from .sm64_constants import *
from .sm64_rom_tweaks import *
from .sm64_anim import *
from .sm64_geolayout_bone import *
from .sm64_collision import *
from .sm64_camera import *
from .sm64_objects import *
from .sm64_level_writer import *
from .sm64_spline import *
from .sm64_f3d_parser import *
import bpy
from bpy.types import Operator, PropertyGroup, Scene
from bpy.props import BoolProperty, StringProperty, EnumProperty, IntProperty, FloatProperty
from bpy.utils import register_class, unregister_class
from bpy.path import abspath
from ..panels import SM64_Panel, sm64GoalTypeEnum, sm64GoalImport
from ..render_settings import on_update_render_settings
from .sm64_level_parser import parseLevelAtPointer
from .sm64_constants import level_enums, level_pointers, defaultExtendSegment4
from ..utility import (
prop_split,
checkExpanded,
decodeSegmentedAddr,
encodeSegmentedAddr,
raisePluginError,
enumExportType,
enumCompressionFormat,
)
from .sm64_collision import (
sm64_col_panel_register,
sm64_col_panel_unregister,
sm64_col_register,
sm64_col_unregister,
)
from .sm64_geolayout_bone import (
sm64_bone_panel_register,
sm64_bone_panel_unregister,
sm64_bone_register,
sm64_bone_unregister,
)
from .sm64_camera import (
sm64_cam_panel_register,
sm64_cam_panel_unregister,
sm64_cam_register,
sm64_cam_unregister,
)
from .sm64_objects import (
sm64_obj_panel_register,
sm64_obj_panel_unregister,
sm64_obj_register,
sm64_obj_unregister,
)
from .sm64_geolayout_parser import (
sm64_geo_parser_panel_register,
sm64_geo_parser_panel_unregister,
sm64_geo_parser_register,
sm64_geo_parser_unregister,
)
from .sm64_geolayout_writer import (
sm64_geo_writer_panel_register,
sm64_geo_writer_panel_unregister,
sm64_geo_writer_register,
sm64_geo_writer_unregister,
)
from .sm64_level_writer import (
sm64_level_panel_register,
sm64_level_panel_unregister,
sm64_level_register,
sm64_level_unregister,
)
from .sm64_spline import (
sm64_spline_panel_register,
sm64_spline_panel_unregister,
sm64_spline_register,
sm64_spline_unregister,
)
from .sm64_f3d_parser import (
sm64_dl_parser_panel_register,
sm64_dl_parser_panel_unregister,
sm64_dl_parser_register,
sm64_dl_parser_unregister,
)
from .sm64_f3d_writer import (
sm64_dl_writer_panel_register,
sm64_dl_writer_panel_unregister,
sm64_dl_writer_register,
sm64_dl_writer_unregister,
)
from .sm64_anim import (
sm64_anim_panel_register,
sm64_anim_panel_unregister,
sm64_anim_register,
sm64_anim_unregister,
)
import bpy
from bpy.utils import register_class, unregister_class
enumRefreshVer = [
("Refresh 3", "Refresh 3", "Refresh 3"),
@@ -32,21 +110,21 @@ enumRefreshVer = [
]
class SM64_AddrConv(bpy.types.Operator):
class SM64_AddrConv(Operator):
# set bl_ properties
bl_idname = "object.addr_conv"
bl_label = "Convert Address"
bl_options = {"REGISTER", "UNDO", "PRESET"}
segToVirt: bpy.props.BoolProperty()
segToVirt: BoolProperty()
def execute(self, context):
romfileSrc = None
try:
address = int(context.scene.convertibleAddr, 16)
importRom = context.scene.importRom
romfileSrc = open(bpy.path.abspath(importRom), "rb")
checkExpanded(bpy.path.abspath(importRom))
romfileSrc = open(abspath(importRom), "rb")
checkExpanded(abspath(importRom))
levelParsed = parseLevelAtPointer(romfileSrc, level_pointers[context.scene.levelConvert])
segmentData = levelParsed.segmentData
if self.segToVirt:
@@ -133,35 +211,35 @@ def get_legacy_export_type():
return "C"
class SM64_Properties(bpy.types.PropertyGroup):
class SM64_Properties(PropertyGroup):
"""Global SM64 Scene Properties found under scene.fast64.sm64"""
version: bpy.props.IntProperty(name="SM64_Properties Version", default=0)
version: IntProperty(name="SM64_Properties Version", default=0)
cur_version = 1 # version after property migration
# UI Selection
showImportingMenus: bpy.props.BoolProperty(name="Show Importing Menus", default=False)
exportType: bpy.props.EnumProperty(items=enumExportType, name="Export Type", default="C")
goal: bpy.props.EnumProperty(items=sm64GoalTypeEnum, name="Export Goal", default="All")
showImportingMenus: BoolProperty(name="Show Importing Menus", default=False)
exportType: EnumProperty(items=enumExportType, name="Export Type", default="C")
goal: EnumProperty(items=sm64GoalTypeEnum, name="Export Goal", default="All")
# TODO: Utilize these across all exports
# C exporting
# useCustomExportLocation = bpy.props.BoolProperty(name = 'Use Custom Export Path')
# customExportPath: bpy.props.StringProperty(name = 'Custom Export Path', subtype = 'FILE_PATH')
# exportLocation: bpy.props.EnumProperty(items = enumExportHeaderType, name = 'Export Location', default = 'Actor')
# useSelectedObjectName = bpy.props.BoolProperty(name = 'Use Name From Selected Object', default=False)
# exportName: bpy.props.StringProperty(name='Name', default='mario')
# exportGeolayoutName: bpy.props.StringProperty(name='Name', default='mario_geo')
# useCustomExportLocation = BoolProperty(name = 'Use Custom Export Path')
# customExportPath: StringProperty(name = 'Custom Export Path', subtype = 'FILE_PATH')
# exportLocation: EnumProperty(items = enumExportHeaderType, name = 'Export Location', default = 'Actor')
# useSelectedObjectName = BoolProperty(name = 'Use Name From Selected Object', default=False)
# exportName: StringProperty(name='Name', default='mario')
# exportGeolayoutName: StringProperty(name='Name', default='mario_geo')
# Actor exports
# exportGroup: bpy.props.StringProperty(name='Group', default='group0')
# exportGroup: StringProperty(name='Group', default='group0')
# Level exports
# exportLevelName: bpy.props.StringProperty(name = 'Level', default = 'bob')
# exportLevelOption: bpy.props.EnumProperty(items = enumLevelNames, name = 'Level', default = 'bob')
# exportLevelName: StringProperty(name = 'Level', default = 'bob')
# exportLevelOption: EnumProperty(items = enumLevelNames, name = 'Level', default = 'bob')
# Insertable Binary
# exportInsertableBinaryPath: bpy.props.StringProperty(name = 'Filepath', subtype = 'FILE_PATH')
# exportInsertableBinaryPath: StringProperty(name = 'Filepath', subtype = 'FILE_PATH')
@staticmethod
def upgrade_changed_props():
@@ -235,10 +313,10 @@ def sm64_register(registerPanels):
if registerPanels:
sm64_panel_register()
bpy.types.Scene.importRom = bpy.props.StringProperty(name="Import ROM", subtype="FILE_PATH")
bpy.types.Scene.exportRom = bpy.props.StringProperty(name="Export ROM", subtype="FILE_PATH")
bpy.types.Scene.outputRom = bpy.props.StringProperty(name="Output ROM", subtype="FILE_PATH")
bpy.types.Scene.extendBank4 = bpy.props.BoolProperty(
Scene.importRom = StringProperty(name="Import ROM", subtype="FILE_PATH")
Scene.exportRom = StringProperty(name="Export ROM", subtype="FILE_PATH")
Scene.outputRom = StringProperty(name="Output ROM", subtype="FILE_PATH")
Scene.extendBank4 = BoolProperty(
name="Extend Bank 4 on Export?",
default=True,
description="Sets bank 4 range to ("
@@ -247,19 +325,17 @@ def sm64_register(registerPanels):
+ hex(defaultExtendSegment4[1])
+ ") and copies data from old bank",
)
bpy.types.Scene.convertibleAddr = bpy.props.StringProperty(name="Address")
bpy.types.Scene.levelConvert = bpy.props.EnumProperty(items=level_enums, name="Level", default="IC")
bpy.types.Scene.refreshVer = bpy.props.EnumProperty(items=enumRefreshVer, name="Refresh", default="Refresh 13")
bpy.types.Scene.disableScroll = bpy.props.BoolProperty(name="Disable Scrolling Textures")
Scene.convertibleAddr = StringProperty(name="Address")
Scene.levelConvert = EnumProperty(items=level_enums, name="Level", default="IC")
Scene.refreshVer = EnumProperty(items=enumRefreshVer, name="Refresh", default="Refresh 13")
Scene.disableScroll = BoolProperty(name="Disable Scrolling Textures")
bpy.types.Scene.blenderToSM64Scale = bpy.props.FloatProperty(
Scene.blenderToSM64Scale = FloatProperty(
name="Blender To SM64 Scale", default=100, update=on_update_render_settings
)
bpy.types.Scene.decompPath = bpy.props.StringProperty(name="Decomp Folder", subtype="FILE_PATH")
Scene.decompPath = StringProperty(name="Decomp Folder", subtype="FILE_PATH")
bpy.types.Scene.compressionFormat = bpy.props.EnumProperty(
items=enumCompressionFormat, name="Compression", default="mio0"
)
Scene.compressionFormat = EnumProperty(items=enumCompressionFormat, name="Compression", default="mio0")
def sm64_unregister(unregisterPanels):
@@ -281,17 +357,17 @@ def sm64_unregister(unregisterPanels):
if unregisterPanels:
sm64_panel_unregister()
del bpy.types.Scene.importRom
del bpy.types.Scene.exportRom
del bpy.types.Scene.outputRom
del bpy.types.Scene.extendBank4
del Scene.importRom
del Scene.exportRom
del Scene.outputRom
del Scene.extendBank4
del bpy.types.Scene.convertibleAddr
del bpy.types.Scene.levelConvert
del bpy.types.Scene.refreshVer
del Scene.convertibleAddr
del Scene.levelConvert
del Scene.refreshVer
del bpy.types.Scene.disableScroll
del Scene.disableScroll
del bpy.types.Scene.blenderToSM64Scale
del bpy.types.Scene.decompPath
del bpy.types.Scene.compressionFormat
del Scene.blenderToSM64Scale
del Scene.decompPath
del Scene.compressionFormat
+3 -3
View File
@@ -1,4 +1,4 @@
import re
from re import search
refresh_name = 'Refresh 13'
function_map_path = './sm64.us.map'
@@ -17,10 +17,10 @@ def parse_func_map():
if nextLine[:17] == ' ' * 16 + '0':
outfile.write('\t\t"' + nextLine[26:34] + '" : ')
searchName = nextLine[34:]
searchResult = re.search(r'\s*(\S*).*', searchName)
searchResult = search(r'\s*(\S*).*', searchName)
outfile.write('"' + searchResult.group(1) + '",\n')
nextLine = mapfile.readline()
outfile.write("\t}\n")
mapfile.close()
outfile.close()
outfile.close()
+42 -6
View File
@@ -1,13 +1,49 @@
import bpy, mathutils, math, re, os, copy, shutil
from .sm64_constants import *
import bpy, os, copy, shutil, mathutils, math
from bpy.utils import register_class, unregister_class
from ..panels import SM64_Panel, sm64GoalImport
from .sm64_level_parser import parseLevelAtPointer
from .sm64_rom_tweaks import ExtendBank0x04
from .sm64_geolayout_bone import animatableBoneTypes
from math import pi
from bpy.utils import register_class, unregister_class
from ..utility import *
from ..panels import SM64_Panel, sm64GoalImport
from ..utility import (
CData,
PluginError,
ValueFrameData,
raisePluginError,
encodeSegmentedAddr,
decodeSegmentedAddr,
getExportDir,
toAlnum,
writeIfNotFound,
get64bitAlignedAddr,
writeInsertableFile,
getFrameInterval,
findStartBones,
saveTranslationFrame,
saveQuaternionFrame,
removeTrailingFrames,
applyRotation,
getPathAndLevel,
applyBasicTweaks,
checkExpanded,
tempName,
bytesToHex,
prop_split,
customExportWarning,
decompFolderMessage,
makeWriteInfoBox,
writeBoxExportType,
enumExportHeaderType,
)
from .sm64_constants import (
bank0Segment,
insertableBinaryTypes,
level_pointers,
defaultExtendSegment4,
level_enums,
enumLevelNames,
)
sm64_anim_types = {"ROTATE", "TRANSLATE"}
+15 -4
View File
@@ -1,8 +1,19 @@
import bpy, math, mathutils
import bpy, mathutils
from bpy.utils import register_class, unregister_class
from .sm64_geolayout_constants import *
from .sm64_geolayout_classes import *
from ..utility import *
from ..utility import colorTo16bitRGBA, gammaCorrect
from .sm64_geolayout_classes import (
TransformNode,
ScreenAreaNode,
ZBufferNode,
OrthoNode,
BackgroundNode,
FrustumNode,
CameraNode,
StartNode,
RenderObjNode,
FunctionNode,
)
enumBackgroundType = [
("OCEAN_SKY", "Ocean Sky", "Ocean Sky"),
+33 -6
View File
@@ -1,13 +1,40 @@
from .sm64_constants import *
from .sm64_objects import *
import bpy, shutil, os, math, mathutils
from bpy.utils import register_class, unregister_class
from io import BytesIO
from .sm64_constants import level_enums, level_pointers, enumLevelNames, insertableBinaryTypes, defaultExtendSegment4
from .sm64_objects import SM64_Area, start_process_sm64_objects
from .sm64_level_parser import parseLevelAtPointer
from .sm64_rom_tweaks import ExtendBank0x04
import bpy, shutil, os, math
from io import BytesIO
from ..utility import *
from ..panels import SM64_Panel
from ..utility import (
PluginError,
CData,
toAlnum,
raisePluginError,
encodeSegmentedAddr,
get64bitAlignedAddr,
prop_split,
getExportDir,
writeIfNotFound,
deleteIfFound,
duplicateHierarchy,
cleanupDuplicatedObjects,
writeInsertableFile,
applyRotation,
getPathAndLevel,
applyBasicTweaks,
tempName,
checkExpanded,
bytesToHex,
applyRotation,
customExportWarning,
decompFolderMessage,
makeWriteInfoBox,
writeBoxExportType,
enumExportHeaderType,
)
class CollisionVertex:
def __init__(self, position):
@@ -228,7 +255,7 @@ class SM64ObjectPanel(bpy.types.Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
bl_options = {'HIDE_HEADER'}
bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
+29 -15
View File
@@ -1,13 +1,27 @@
import bpy
from ..panels import SM64_Panel, sm64GoalImport
from ..utility import *
from ..f3d.f3d_parser import *
from mathutils import Matrix
from math import radians
from bpy.types import Operator, Scene
from bpy.path import abspath
from bpy.utils import register_class, unregister_class
from bpy.ops import object
from bpy.props import StringProperty, EnumProperty, BoolProperty
from ..panels import SM64_Panel, sm64GoalImport
from ..f3d.f3d_parser import F3DtoBlenderObject
from .sm64_constants import level_enums, level_pointers
from .sm64_level_parser import parseLevelAtPointer
from ..utility import (
PluginError,
applyRotation,
raisePluginError,
decodeSegmentedAddr,
applyRotation,
checkExpanded,
prop_split,
)
class SM64_ImportDL(bpy.types.Operator):
class SM64_ImportDL(Operator):
# set bl_ properties
bl_idname = "object.sm64_import_dl"
bl_label = "Import Display List"
@@ -24,8 +38,8 @@ class SM64_ImportDL(bpy.types.Operator):
raisePluginError(self, e)
return {"CANCELLED"}
try:
checkExpanded(bpy.path.abspath(context.scene.importRom))
romfileSrc = open(bpy.path.abspath(context.scene.importRom), "rb")
checkExpanded(abspath(context.scene.importRom))
romfileSrc = open(abspath(context.scene.importRom), "rb")
levelParsed = parseLevelAtPointer(romfileSrc, level_pointers[context.scene.levelDLImport])
segmentData = levelParsed.segmentData
start = (
@@ -37,7 +51,7 @@ class SM64_ImportDL(bpy.types.Operator):
romfileSrc, start, context.scene, "sm64_mesh", Matrix.Identity(4), segmentData, True
)
applyRotation([readObj], math.radians(-90), "X")
applyRotation([readObj], radians(-90), "X")
romfileSrc.close()
self.report({"INFO"}, "Generic import succeeded.")
@@ -45,7 +59,7 @@ class SM64_ImportDL(bpy.types.Operator):
except Exception as e:
if context.mode != "OBJECT":
bpy.ops.object.mode_set(mode="OBJECT")
object.mode_set(mode="OBJECT")
if romfileSrc is not None:
romfileSrc.close()
raisePluginError(self, e)
@@ -87,15 +101,15 @@ def sm64_dl_parser_register():
for cls in sm64_dl_parser_classes:
register_class(cls)
bpy.types.Scene.DLImportStart = bpy.props.StringProperty(name="Start Address", default="A3BE1C")
bpy.types.Scene.levelDLImport = bpy.props.EnumProperty(items=level_enums, name="Level", default="CG")
bpy.types.Scene.isSegmentedAddrDLImport = bpy.props.BoolProperty(name="Is Segmented Address", default=False)
Scene.DLImportStart = StringProperty(name="Start Address", default="A3BE1C")
Scene.levelDLImport = EnumProperty(items=level_enums, name="Level", default="CG")
Scene.isSegmentedAddrDLImport = BoolProperty(name="Is Segmented Address", default=False)
def sm64_dl_parser_unregister():
for cls in reversed(sm64_dl_parser_classes):
unregister_class(cls)
del bpy.types.Scene.levelDLImport
del bpy.types.Scene.DLImportStart
del bpy.types.Scene.isSegmentedAddrDLImport
del Scene.levelDLImport
del Scene.DLImportStart
del Scene.isSegmentedAddrDLImport
+73 -18
View File
@@ -1,12 +1,69 @@
import shutil, copy, bpy, cProfile, pstats
from ..panels import SM64_Panel
from ..f3d.f3d_writer import *
from ..f3d.f3d_material import *
from ..f3d.f3d_gbi import FMaterial
from .sm64_texscroll import *
from .sm64_utility import *
import shutil, copy, bpy, re, os
from io import BytesIO
from math import ceil, log, radians
from mathutils import Matrix, Vector
from bpy.utils import register_class, unregister_class
from ..panels import SM64_Panel
from ..f3d.f3d_writer import saveTextureIndex, exportF3DCommon
from ..f3d.f3d_material import TextureProperty, tmemUsageUI, all_combiner_uses, ui_procAnim
from .sm64_texscroll import modifyTexScrollFiles, modifyTexScrollHeadersGroup
from .sm64_utility import starSelectWarning
from .sm64_level_parser import parseLevelAtPointer
from .sm64_rom_tweaks import ExtendBank0x04
from ..f3d.f3d_gbi import (
FMaterial,
FModel,
GfxFormatter,
GfxMatWriteMethod,
ScrollMethod,
DLFormat,
SPDisplayList,
GfxList,
GfxListTag,
FTexRect,
DPPipeSync,
DPSetCycleType,
DPSetTexturePersp,
DPSetAlphaCompare,
DPSetBlendColor,
DPSetRenderMode,
SPScisTextureRectangle,
SPTexture,
SPEndDisplayList,
TextureExportSettings,
GFX_SIZE,
)
from ..utility import (
CData,
PluginError,
raisePluginError,
prop_split,
encodeSegmentedAddr,
applyRotation,
toAlnum,
checkIfPathExists,
writeIfNotFound,
overwriteData,
getExportDir,
writeMaterialFiles,
writeMaterialHeaders,
get64bitAlignedAddr,
writeInsertableFile,
getPathAndLevel,
applyBasicTweaks,
checkExpanded,
tempName,
getAddressFromRAMAddress,
bytesToHex,
customExportWarning,
decompFolderMessage,
makeWriteInfoBox,
writeBoxExportType,
enumExportHeaderType,
)
from .sm64_constants import (
level_enums,
enumLevelNames,
@@ -15,8 +72,6 @@ from .sm64_constants import (
bank0Segment,
insertableBinaryTypes,
)
from .sm64_level_parser import parseLevelAtPointer
from .sm64_rom_tweaks import ExtendBank0x04
enumHUDExportLocation = [
@@ -277,12 +332,12 @@ def exportTexRectCommon(texProp, f3dType, isHWv1, name, convertTextureData):
texProp.S.low = 0
texProp.S.high = texProp.tex.size[0] - 1
texProp.S.mask = math.ceil(math.log(texProp.tex.size[0], 2) - 0.001)
texProp.S.mask = ceil(log(texProp.tex.size[0], 2) - 0.001)
texProp.S.shift = 0
texProp.T.low = 0
texProp.T.high = texProp.tex.size[1] - 1
texProp.T.mask = math.ceil(math.log(texProp.tex.size[1], 2) - 0.001)
texProp.T.mask = ceil(log(texProp.tex.size[1], 2) - 0.001)
texProp.T.shift = 0
fTexRect = FTexRect(f3dType, isHWv1, toAlnum(name), GfxMatWriteMethod.WriteDifferingAndRevert)
@@ -572,20 +627,20 @@ class SM64_ExportDL(bpy.types.Operator):
# T, R, S = obj.matrix_world.decompose()
# objTransform = R.to_matrix().to_4x4() @ \
# mathutils.Matrix.Diagonal(S).to_4x4()
# Matrix.Diagonal(S).to_4x4()
# finalTransform = (blenderToSM64Rotation * \
# (bpy.context.scene.blenderToSM64Scale)).to_4x4()
# finalTransform = mathutils.Matrix.Identity(4)
# finalTransform = Matrix.Identity(4)
scaleValue = bpy.context.scene.blenderToSM64Scale
finalTransform = mathutils.Matrix.Diagonal(mathutils.Vector((scaleValue, scaleValue, scaleValue))).to_4x4()
finalTransform = Matrix.Diagonal(Vector((scaleValue, scaleValue, scaleValue))).to_4x4()
except Exception as e:
raisePluginError(self, e)
return {"CANCELLED"}
try:
applyRotation([obj], math.radians(90), "X")
applyRotation([obj], radians(90), "X")
if context.scene.fast64.sm64.exportType == "C":
exportPath, levelName = getPathAndLevel(
context.scene.DLCustomExport,
@@ -695,13 +750,13 @@ class SM64_ExportDL(bpy.types.Operator):
+ ").",
)
applyRotation([obj], math.radians(-90), "X")
applyRotation([obj], radians(-90), "X")
return {"FINISHED"} # must return a set
except Exception as e:
if context.mode != "OBJECT":
bpy.ops.object.mode_set(mode="OBJECT")
applyRotation([obj], math.radians(-90), "X")
applyRotation([obj], radians(-90), "X")
if context.scene.fast64.sm64.exportType == "Binary":
if romfileOutput is not None:
romfileOutput.close()
+103 -104
View File
@@ -1,8 +1,21 @@
import bpy
from bpy.ops import object
from bpy.types import Bone, Object, Panel, Operator, Armature, Mesh, Material, PropertyGroup
from bpy.utils import register_class, unregister_class
from ..utility import PluginError, prop_split, obj_scale_is_unified
from ..f3d.f3d_material import sm64EnumDrawLayers
from .sm64_geolayout_utility import createBoneGroups, addBoneToGroup
from ..utility import prop_split, PluginError
from ..f3d.f3d_material import *
from bpy.props import (
StringProperty,
IntProperty,
FloatProperty,
BoolProperty,
PointerProperty,
CollectionProperty,
EnumProperty,
FloatVectorProperty,
)
enumBoneType = [
("Switch", "Switch (0x0E)", "Switch"),
@@ -67,7 +80,7 @@ enumMatOverrideOptions = [
]
def drawGeoInfo(panel: bpy.types.Panel, bone: bpy.types.Bone):
def drawGeoInfo(panel: Panel, bone: Bone):
panel.layout.box().label(text="Geolayout Inspector")
if bone is None:
@@ -142,7 +155,7 @@ def drawGeoInfo(panel: bpy.types.Panel, bone: bpy.types.Bone):
layerInfoBox.label(text="'Ignore' bones are on any layer.")
class GeolayoutBonePanel(bpy.types.Panel):
class GeolayoutBonePanel(Panel):
bl_label = "Geolayout Inspector"
bl_idname = "BONE_PT_SM64_Geolayout_Inspector"
bl_space_type = "PROPERTIES"
@@ -158,7 +171,7 @@ class GeolayoutBonePanel(bpy.types.Panel):
drawGeoInfo(self, context.bone)
class GeolayoutArmaturePanel(bpy.types.Panel):
class GeolayoutArmaturePanel(Panel):
bl_label = "Geolayout Armature Inspector"
bl_idname = "OBJECT_PT_SM64_Armature_Geolayout_Inspector"
bl_space_type = "PROPERTIES"
@@ -171,7 +184,7 @@ class GeolayoutArmaturePanel(bpy.types.Panel):
return (
context.scene.gameEditorMode == "SM64"
and context.object is not None
and isinstance(context.object.data, bpy.types.Armature)
and isinstance(context.object.data, Armature)
)
def draw(self, context):
@@ -192,7 +205,7 @@ def drawLayerWarningBox(layout, prop, data):
warningBox.label(text="This is moved to material settings in v4+.")
class GeolayoutObjectPanel(bpy.types.Panel):
class GeolayoutObjectPanel(Panel):
bl_label = "Object Geolayout Inspector"
bl_idname = "OBJECT_PT_SM64_Object_Geolayout_Inspector"
bl_space_type = "PROPERTIES"
@@ -205,7 +218,7 @@ class GeolayoutObjectPanel(bpy.types.Panel):
return (
context.scene.gameEditorMode == "SM64"
and context.object is not None
and isinstance(context.object.data, bpy.types.Mesh)
and isinstance(context.object.data, Mesh)
)
def draw(self, context):
@@ -244,24 +257,20 @@ class GeolayoutObjectPanel(bpy.types.Panel):
# prop_split(col, obj, 'room_num', 'Room')
class MaterialPointerProperty(bpy.types.PropertyGroup):
material: bpy.props.PointerProperty(type=bpy.types.Material)
class MaterialPointerProperty(PropertyGroup):
material: PointerProperty(type=Material)
class SwitchOptionProperty(bpy.types.PropertyGroup):
switchType: bpy.props.EnumProperty(name="Option Type", items=enumSwitchOptions)
optionArmature: bpy.props.PointerProperty(name="Option Armature", type=bpy.types.Object)
materialOverride: bpy.props.PointerProperty(type=bpy.types.Material, name="Material Override")
materialOverrideType: bpy.props.EnumProperty(name="Material Override Type", items=enumMatOverrideOptions)
specificOverrideArray: bpy.props.CollectionProperty(
type=MaterialPointerProperty, name="Specified Materials To Override"
)
specificIgnoreArray: bpy.props.CollectionProperty(
type=MaterialPointerProperty, name="Specified Materials To Ignore"
)
overrideDrawLayer: bpy.props.BoolProperty()
drawLayer: bpy.props.EnumProperty(items=sm64EnumDrawLayers, name="Draw Layer")
expand: bpy.props.BoolProperty()
class SwitchOptionProperty(PropertyGroup):
switchType: EnumProperty(name="Option Type", items=enumSwitchOptions)
optionArmature: PointerProperty(name="Option Armature", type=Object)
materialOverride: PointerProperty(type=Material, name="Material Override")
materialOverrideType: EnumProperty(name="Material Override Type", items=enumMatOverrideOptions)
specificOverrideArray: CollectionProperty(type=MaterialPointerProperty, name="Specified Materials To Override")
specificIgnoreArray: CollectionProperty(type=MaterialPointerProperty, name="Specified Materials To Ignore")
overrideDrawLayer: BoolProperty()
drawLayer: EnumProperty(items=sm64EnumDrawLayers, name="Draw Layer")
expand: BoolProperty()
def drawSwitchOptionProperty(layout, switchOption, index):
@@ -324,12 +333,12 @@ def drawMatArrayProperty(layout, materialPointer, option, index, isSpecific):
removeOp.isSpecific = isSpecific
class AddSwitchOptionMat(bpy.types.Operator):
class AddSwitchOptionMat(Operator):
bl_idname = "bone.add_switch_option_mat"
bl_label = "Add Switch Option Material"
bl_options = {"REGISTER", "UNDO"}
option: bpy.props.IntProperty()
isSpecific: bpy.props.BoolProperty()
option: IntProperty()
isSpecific: BoolProperty()
def execute(self, context):
bone = context.bone
@@ -341,13 +350,13 @@ class AddSwitchOptionMat(bpy.types.Operator):
return {"FINISHED"}
class RemoveSwitchOptionMat(bpy.types.Operator):
class RemoveSwitchOptionMat(Operator):
bl_idname = "bone.remove_switch_option_mat"
bl_label = "Remove Switch Option Material"
bl_options = {"REGISTER", "UNDO"}
option: bpy.props.IntProperty()
index: bpy.props.IntProperty()
isSpecific: bpy.props.BoolProperty()
option: IntProperty()
index: IntProperty()
isSpecific: BoolProperty()
def execute(self, context):
if self.isSpecific:
@@ -358,11 +367,11 @@ class RemoveSwitchOptionMat(bpy.types.Operator):
return {"FINISHED"}
class AddSwitchOption(bpy.types.Operator):
class AddSwitchOption(Operator):
bl_idname = "bone.add_switch_option"
bl_label = "Add Switch Option"
bl_options = {"REGISTER", "UNDO"}
option: bpy.props.IntProperty()
option: IntProperty()
def execute(self, context):
bone = context.bone
@@ -372,11 +381,11 @@ class AddSwitchOption(bpy.types.Operator):
return {"FINISHED"}
class RemoveSwitchOption(bpy.types.Operator):
class RemoveSwitchOption(Operator):
bl_idname = "bone.remove_switch_option"
bl_label = "Remove Switch Option"
bl_options = {"REGISTER", "UNDO"}
option: bpy.props.IntProperty()
option: IntProperty()
def execute(self, context):
context.bone.switch_options.remove(self.option)
@@ -384,12 +393,12 @@ class RemoveSwitchOption(bpy.types.Operator):
return {"FINISHED"}
class MoveSwitchOption(bpy.types.Operator):
class MoveSwitchOption(Operator):
bl_idname = "bone.move_switch_option"
bl_label = "Move Switch Option"
bl_options = {"REGISTER", "UNDO"}
option: bpy.props.IntProperty()
offset: bpy.props.IntProperty()
option: IntProperty()
offset: IntProperty()
def execute(self, context):
bone = context.bone
@@ -399,7 +408,7 @@ class MoveSwitchOption(bpy.types.Operator):
"""
class GeolayoutBoneSidePanel(bpy.types.Panel):
class GeolayoutBoneSidePanel(Panel):
bl_idname = "SM64_Geolayout_Inspector_Side"
bl_label = "SM64 Geolayout Inspector"
bl_space_type = 'VIEW_3D'
@@ -441,17 +450,17 @@ def updateBone(self, context):
createBoneGroups(armatureObj)
if context.bone.geo_cmd not in animatableBoneTypes:
addBoneToGroup(armatureObj, context.bone.name, context.bone.geo_cmd)
bpy.ops.object.mode_set(mode="POSE")
object.mode_set(mode="POSE")
else:
addBoneToGroup(armatureObj, context.bone.name, None)
bpy.ops.object.mode_set(mode="POSE")
object.mode_set(mode="POSE")
class SM64_BoneProperties(bpy.types.PropertyGroup):
version: bpy.props.IntProperty(name="SM64_BoneProperties Version", default=0)
class SM64_BoneProperties(PropertyGroup):
version: IntProperty(name="SM64_BoneProperties Version", default=0)
custom_geo_cmd_macro: bpy.props.StringProperty(name="Geo Command Macro", default="GEO_BONE")
custom_geo_cmd_args: bpy.props.StringProperty(name="Geo Command Args", default="")
custom_geo_cmd_macro: StringProperty(name="Geo Command Macro", default="GEO_BONE")
custom_geo_cmd_args: StringProperty(name="Geo Command Args", default="")
sm64_bone_classes = (
@@ -486,108 +495,98 @@ def sm64_bone_register():
for cls in sm64_bone_classes:
register_class(cls)
bpy.types.Bone.geo_cmd = bpy.props.EnumProperty(
Bone.geo_cmd = EnumProperty(
name="Geolayout Command", items=enumBoneType, default="DisplayListWithOffset", update=updateBone
)
bpy.types.Bone.draw_layer = bpy.props.EnumProperty(name="Draw Layer", items=sm64EnumDrawLayers, default="1")
Bone.draw_layer = EnumProperty(name="Draw Layer", items=sm64EnumDrawLayers, default="1")
# Scale
bpy.types.Bone.geo_scale = bpy.props.FloatProperty(name="Scale", min=2 ** (-16), max=2 ** (16), default=1)
Bone.geo_scale = FloatProperty(name="Scale", min=2 ** (-16), max=2 ** (16), default=1)
# Function, HeldObject, Switch
# 8027795C for HeldObject
bpy.types.Bone.geo_func = bpy.props.StringProperty(
Bone.geo_func = StringProperty(
name="Function", default="", description="Name of function for C, hex address for binary."
)
# Function
bpy.types.Bone.func_param = bpy.props.IntProperty(
name="Function Parameter", min=-(2 ** (15)), max=2 ** (15) - 1, default=0
)
Bone.func_param = IntProperty(name="Function Parameter", min=-(2 ** (15)), max=2 ** (15) - 1, default=0)
# TranslateRotate
bpy.types.Bone.field_layout = bpy.props.EnumProperty(name="Field Layout", items=enumFieldLayout, default="0")
Bone.field_layout = EnumProperty(name="Field Layout", items=enumFieldLayout, default="0")
# Shadow
bpy.types.Bone.shadow_type = bpy.props.EnumProperty(name="Shadow Type", items=enumShadowType, default="1")
Bone.shadow_type = EnumProperty(name="Shadow Type", items=enumShadowType, default="1")
bpy.types.Bone.shadow_solidity = bpy.props.FloatProperty(name="Shadow Alpha", min=0, max=1, default=1)
Bone.shadow_solidity = FloatProperty(name="Shadow Alpha", min=0, max=1, default=1)
bpy.types.Bone.shadow_scale = bpy.props.IntProperty(
name="Shadow Scale", min=-(2 ** (15)), max=2 ** (15) - 1, default=100
)
Bone.shadow_scale = IntProperty(name="Shadow Scale", min=-(2 ** (15)), max=2 ** (15) - 1, default=100)
# bpy.types.Bone.switch_bone = bpy.props.StringProperty(
# Bone.switch_bone = StringProperty(
# name = 'Switch Bone')
# StartRenderArea
bpy.types.Bone.culling_radius = bpy.props.FloatProperty(name="Culling Radius", default=10)
Bone.culling_radius = FloatProperty(name="Culling Radius", default=10)
bpy.types.Bone.switch_options = bpy.props.CollectionProperty(type=SwitchOptionProperty)
Bone.switch_options = CollectionProperty(type=SwitchOptionProperty)
# Static Geolayout
bpy.types.Object.geo_cmd_static = bpy.props.EnumProperty(
name="Geolayout Command", items=enumGeoStaticType, default="Optimal"
)
bpy.types.Object.draw_layer_static = bpy.props.EnumProperty(
name="Draw Layer", items=sm64EnumDrawLayers, default="1"
)
bpy.types.Object.use_render_area = bpy.props.BoolProperty(name="Use Render Area")
bpy.types.Object.culling_radius = bpy.props.FloatProperty(name="Culling Radius", default=10)
Object.geo_cmd_static = EnumProperty(name="Geolayout Command", items=enumGeoStaticType, default="Optimal")
Object.draw_layer_static = EnumProperty(name="Draw Layer", items=sm64EnumDrawLayers, default="1")
Object.use_render_area = BoolProperty(name="Use Render Area")
Object.culling_radius = FloatProperty(name="Culling Radius", default=10)
bpy.types.Object.add_shadow = bpy.props.BoolProperty(name="Add Shadow")
bpy.types.Object.shadow_type = bpy.props.EnumProperty(name="Shadow Type", items=enumShadowType, default="1")
Object.add_shadow = BoolProperty(name="Add Shadow")
Object.shadow_type = EnumProperty(name="Shadow Type", items=enumShadowType, default="1")
bpy.types.Object.shadow_solidity = bpy.props.FloatProperty(name="Shadow Alpha", min=0, max=1, default=1)
Object.shadow_solidity = FloatProperty(name="Shadow Alpha", min=0, max=1, default=1)
bpy.types.Object.shadow_scale = bpy.props.IntProperty(
name="Shadow Scale", min=-(2 ** (15)), max=2 ** (15) - 1, default=100
)
Object.shadow_scale = IntProperty(name="Shadow Scale", min=-(2 ** (15)), max=2 ** (15) - 1, default=100)
bpy.types.Object.add_func = bpy.props.BoolProperty(name="Add Function Node")
Object.add_func = BoolProperty(name="Add Function Node")
bpy.types.Object.use_render_range = bpy.props.BoolProperty(name="Use Render Range (LOD)")
bpy.types.Object.render_range = bpy.props.FloatVectorProperty(name="Render Range", size=2, default=(0, 100))
Object.use_render_range = BoolProperty(name="Use Render Range (LOD)")
Object.render_range = FloatVectorProperty(name="Render Range", size=2, default=(0, 100))
bpy.types.Object.scaleFromGeolayout = bpy.props.BoolProperty(
Object.scaleFromGeolayout = BoolProperty(
name="Scale from Geolayout",
description="If scale is all a single value (e.g. 2, 2, 2), do not apply scale when exporting, and instead use GeoLayout to scale. Can be used to enhance precision by setting scaling values to a value less than 1.",
default=False,
)
# Used during object duplication on export
bpy.types.Object.original_name = bpy.props.StringProperty()
Object.original_name = StringProperty()
def sm64_bone_unregister():
for cls in reversed(sm64_bone_classes):
unregister_class(cls)
del bpy.types.Bone.geo_cmd
del bpy.types.Bone.draw_layer
del bpy.types.Bone.geo_scale
del bpy.types.Bone.geo_func
del bpy.types.Bone.func_param
del bpy.types.Bone.field_layout
del bpy.types.Bone.shadow_type
del bpy.types.Bone.shadow_solidity
del bpy.types.Bone.shadow_scale
del bpy.types.Bone.culling_radius
del bpy.types.Bone.switch_options
del Bone.geo_cmd
del Bone.draw_layer
del Bone.geo_scale
del Bone.geo_func
del Bone.func_param
del Bone.field_layout
del Bone.shadow_type
del Bone.shadow_solidity
del Bone.shadow_scale
del Bone.culling_radius
del Bone.switch_options
del bpy.types.Object.geo_cmd_static
del bpy.types.Object.draw_layer_static
del bpy.types.Object.use_render_area
del bpy.types.Object.culling_radius
del Object.geo_cmd_static
del Object.draw_layer_static
del Object.use_render_area
del Object.culling_radius
del bpy.types.Object.add_shadow
del bpy.types.Object.shadow_type
del bpy.types.Object.shadow_solidity
del bpy.types.Object.shadow_scale
del bpy.types.Object.add_func
del Object.add_shadow
del Object.shadow_type
del Object.shadow_solidity
del Object.shadow_scale
del Object.add_func
del bpy.types.Object.use_render_range
del bpy.types.Object.render_range
del Object.use_render_range
del Object.render_range
del bpy.types.Object.scaleFromGeolayout
del Object.scaleFromGeolayout
+51 -8
View File
@@ -1,9 +1,52 @@
from .sm64_geolayout_constants import *
from .sm64_geolayout_utility import *
from .sm64_constants import *
import bpy
from struct import pack
from copy import copy
from .sm64_function_map import func_map
from ..utility import *
import struct, copy
from ..utility import (
PluginError,
CData,
toAlnum,
encodeSegmentedAddr,
writeVectorToShorts,
convertFloatToShort,
writeEulerVectorToShorts,
writeFloatToShort,
convertEulerFloatToShort,
join_c_args,
radians_to_s16,
geoNodeRotateOrder,
)
from .sm64_geolayout_constants import (
nodeGroupCmds,
GEO_END,
GEO_RETURN,
GEO_NODE_OPEN,
GEO_NODE_CLOSE,
GEO_BRANCH,
GEO_CALL_ASM,
GEO_HELD_OBJECT,
GEO_START,
GEO_SWITCH,
GEO_TRANSLATE_ROTATE,
GEO_TRANSLATE,
GEO_ROTATE,
GEO_BILLBOARD,
GEO_LOAD_DL,
GEO_START_W_SHADOW,
GEO_START_W_RENDERAREA,
GEO_SET_RENDER_RANGE,
GEO_LOAD_DL_W_OFFSET,
GEO_SCALE,
GEO_SET_RENDER_AREA,
GEO_SET_ORTHO,
GEO_SET_CAMERA_FRUSTRUM,
GEO_SET_Z_BUF,
GEO_CAMERA,
GEO_SETUP_OBJ_RENDER,
GEO_SET_BG,
)
drawLayerNames = {
0: "LAYER_FORCE",
@@ -96,7 +139,7 @@ class GeolayoutGraph:
raise PluginError("Circular geolayout dependency." + str(callOrder))
else:
geolayoutList.insert(geolayoutList.index(geolayout), calledGeolayout)
callOrder = copy.copy(callOrder)
callOrder = copy(callOrder)
callOrder.append(calledGeolayout)
self.sortGeolayouts(geolayoutList, calledGeolayout, callOrder)
return geolayoutList
@@ -967,7 +1010,7 @@ class OrthoNode:
def to_binary(self, segmentData):
command = bytearray([GEO_SET_ORTHO, 0x00])
# FIX: This should be f32.
command.extend(bytearray(struct.pack(">f", self.scale)))
command.extend(bytearray(pack(">f", self.scale)))
return command
def to_c(self):
@@ -987,7 +1030,7 @@ class FrustumNode:
def to_binary(self, segmentData):
command = bytearray([GEO_SET_CAMERA_FRUSTRUM, 0x01 if self.useFunc else 0x00])
command.extend(bytearray(struct.pack(">f", self.fov)))
command.extend(bytearray(pack(">f", self.fov)))
command.extend(self.near.to_bytes(2, "big", signed=True)) # Conversion?
command.extend(self.far.to_bytes(2, "big", signed=True)) # Conversion?
+53 -12
View File
@@ -1,17 +1,58 @@
import bpy, mathutils, math, copy
from math import pi
import bpy, mathutils, math, bmesh, copy
from bpy.utils import register_class, unregister_class
from .sm64_level_parser import *
from .sm64_geolayout_bone import enumShadowType
from .sm64_geolayout_constants import *
from .sm64_geolayout_utility import *
from .sm64_constants import *
from ..f3d.f3d_material import createF3DMat, update_preset_manual
from ..f3d.f3d_parser import *
from ..utility import *
from ..f3d.f3d_parser import createBlankMaterial, parseF3DBinary
from ..panels import SM64_Panel, sm64GoalImport
from .sm64_level_parser import parseLevelAtPointer
from .sm64_constants import level_pointers, level_enums
from .sm64_geolayout_bone import enumShadowType
from .sm64_geolayout_constants import getGeoLayoutCmdLength, nodeGroupCmds, GEO_BRANCH_STORE
from ..utility import (
PluginError,
decodeSegmentedAddr,
raisePluginError,
bytesToHexClean,
bitMask,
readVectorFromShorts,
findStartBones,
readEulerVectorFromShorts,
readFloatFromShort,
checkExpanded,
doRotation,
prop_split,
sm64BoneUp,
geoNodeRotateOrder,
)
from .sm64_geolayout_utility import (
createBoneGroups,
createBoneLayerMask,
getBoneGroupIndex,
addBoneToGroup,
boneLayers,
)
from .sm64_geolayout_classes import (
GEO_NODE_CLOSE,
GEO_END,
GEO_BRANCH,
GEO_RETURN,
GEO_NODE_OPEN,
GEO_START,
GEO_SWITCH,
GEO_TRANSLATE_ROTATE,
GEO_TRANSLATE,
GEO_ROTATE,
GEO_LOAD_DL_W_OFFSET,
GEO_BILLBOARD,
GEO_START_W_SHADOW,
GEO_CALL_ASM,
GEO_HELD_OBJECT,
GEO_SCALE,
GEO_START_W_RENDERAREA,
GEO_LOAD_DL,
)
blender_modes = {"OBJECT", "BONE"}
@@ -1,5 +1,5 @@
from ..utility import PluginError
import bpy
from ..utility import PluginError
def getBoneGroupByName(armatureObj, name):
+122 -15
View File
@@ -1,23 +1,130 @@
import bpy, mathutils, math, copy, os, shutil
import bpy, mathutils, math, copy, os, shutil, re
from bpy.utils import register_class, unregister_class
from os.path import basename
from io import BytesIO
from .sm64_objects import InlineGeolayoutObjConfig, inlineGeoLayoutObjects
from .sm64_geolayout_bone import getSwitchOptionBone, animatableBoneTypes
from .sm64_geolayout_constants import *
from .sm64_geolayout_utility import *
from .sm64_constants import *
from .sm64_camera import saveCameraSettingsToGeolayout
from .sm64_geolayout_classes import *
from .sm64_f3d_writer import *
from .sm64_texscroll import *
from .sm64_utility import *
from ..utility import *
from ..operators import ObjectDataExporter
from ..panels import SM64_Panel
from .sm64_objects import InlineGeolayoutObjConfig, inlineGeoLayoutObjects
from .sm64_geolayout_bone import getSwitchOptionBone, animatableBoneTypes
from .sm64_camera import saveCameraSettingsToGeolayout
from .sm64_f3d_writer import SM64Model, SM64GfxFormatter
from .sm64_texscroll import modifyTexScrollFiles, modifyTexScrollHeadersGroup
from .sm64_level_parser import parseLevelAtPointer
from .sm64_rom_tweaks import ExtendBank0x04
from .sm64_utility import starSelectWarning
from ..utility import (
PluginError,
VertexWeightError,
setOrigin,
raisePluginError,
findStartBones,
duplicateHierarchy,
cleanupDuplicatedObjects,
getExportDir,
toAlnum,
writeMaterialFiles,
writeIfNotFound,
get64bitAlignedAddr,
encodeSegmentedAddr,
writeMaterialHeaders,
writeInsertableFile,
bytesToHex,
checkSM64EmptyUsesGeoLayout,
convertEulerFloatToShort,
convertFloatToShort,
checkIsSM64InlineGeoLayout,
checkIsSM64PreInlineGeoLayout,
translate_blender_to_n64,
rotate_quat_blender_to_n64,
get_obj_temp_mesh,
getGroupNameFromIndex,
highlightWeightErrors,
getGroupIndexFromname,
getFMeshName,
checkUniqueBoneNames,
applyRotation,
getPathAndLevel,
applyBasicTweaks,
tempName,
checkExpanded,
getAddressFromRAMAddress,
prop_split,
customExportWarning,
decompFolderMessage,
makeWriteInfoBox,
writeBoxExportType,
enumExportHeaderType,
geoNodeRotateOrder,
)
from ..f3d.f3d_writer import (
TriangleConverterInfo,
LoopConvertInfo,
BufferVertex,
revertMatAndEndDraw,
getInfoDict,
saveStaticModel,
getTexDimensions,
checkForF3dMaterialInFaces,
saveOrGetF3DMaterial,
saveMeshWithLargeTexturesByFaces,
saveMeshByFaces,
isLightingDisabled,
getF3DVert,
isTexturePointSampled,
convertVertexData,
)
from ..f3d.f3d_gbi import (
GfxList,
GfxListTag,
DPSetAlphaCompare,
FModel,
FMesh,
SPVertex,
DPSetEnvColor,
FAreaData,
FFogData,
ScrollMethod,
TextureExportSettings,
DLFormat,
SPEndDisplayList,
SPDisplayList,
)
from .sm64_geolayout_classes import (
DisplayListNode,
TransformNode,
StartNode,
StartRenderAreaNode,
GeolayoutGraph,
JumpNode,
SwitchOverrideNode,
SwitchNode,
TranslateNode,
RotateNode,
TranslateRotateNode,
FunctionNode,
CustomNode,
BillboardNode,
ScaleNode,
RenderRangeNode,
ShadowNode,
DisplayListWithOffsetNode,
CustomAnimatedNode,
HeldObjectNode,
Geolayout,
)
from .sm64_constants import (
insertableBinaryTypes,
bank0Segment,
level_pointers,
defaultExtendSegment4,
level_enums,
enumLevelNames
)
def appendSecondaryGeolayout(geoDirPath, geoName1, geoName2, additionalNode=""):
+41 -6
View File
@@ -1,11 +1,46 @@
import bpy, mathutils, copy
from math import pi
import copy
from .sm64_constants import mainLevelLoadScriptSegment, loadSegmentAddresses
from .sm64_level_constants import *
from .sm64_geolayout_constants import *
from .sm64_constants import *
from ..utility import (
PluginError,
decodeSegmentedAddr,
writeVectorToShorts,
writeFloatToShort,
readVectorFromShorts,
readEulerVectorFromShorts,
writeEulerVectorToShorts,
readFloatFromShort,
readEulerFloatFromShort,
writeEulerFloatToShort,
)
from ..utility import *
from .sm64_level_constants import (
L_END,
L_JUMP,
L_PUSH,
L_POP,
L_NOOP,
L_LOAD_ROM_SEG,
L_LOAD_MIO0_SEG,
L_LOAD_MIO0_TEX,
L_AREA_START,
L_AREA_END,
L_LOAD_POLY_WO_GEO,
L_LOAD_POLY_W_GEO,
L_PLACE_OBJECT,
L_WARP_CONNECT,
L_WARP_PAINTING,
L_WARP_AREA,
L_SET_DEFAULT_MARIO_POS,
L_LOAD_COLLISION,
L_SHOW_DIALOG,
L_SET_DEFAULT_TERRAIN,
L_NOOP2,
L_SET_MUSIC_SCREEN,
L_SET_MUSIC_LEVEL,
L_PLACE_MACRO_OBJECT,
L_JET_STREAM,
)
def parseLevelAtPointer(romfile, pointerAddress):
+37 -10
View File
@@ -1,17 +1,44 @@
import bpy, os, math, re, shutil, mathutils
from collections import defaultdict
from bpy.utils import register_class, unregister_class
import bpy, os, math, re, shutil
from .sm64_constants import *
from .sm64_objects import *
from .sm64_collision import *
from .sm64_geolayout_writer import *
from .sm64_texscroll import *
from .sm64_utility import *
from ..utility import *
from ..panels import SM64_Panel
from ..operators import ObjectDataExporter
from .sm64_constants import cameraTriggerNames, levelIDNames, enumLevelNames
from .sm64_objects import exportAreaCommon, backgroundSegments
from .sm64_collision import exportCollisionCommon
from .sm64_f3d_writer import SM64Model, SM64GfxFormatter
from .sm64_geolayout_writer import setRooms, convertObjectToGeolayout
from .sm64_f3d_writer import modifyTexScrollFiles, modifyTexScrollHeadersGroup
from .sm64_utility import cameraWarning, starSelectWarning
from ..utility import (
PluginError,
writeIfNotFound,
getDataFromFile,
saveDataToFile,
unhideAllAndGetHiddenList,
hideObjsInList,
overwriteData,
selectSingleObject,
deleteIfFound,
applyBasicTweaks,
applyRotation,
prop_split,
toAlnum,
writeMaterialHeaders,
raisePluginError,
customExportWarning,
decompFolderMessage,
makeWriteInfoBox,
writeMaterialFiles,
)
from ..f3d.f3d_gbi import (
ScrollMethod,
TextureExportSettings,
DLFormat,
)
levelDefineArgs = {
"internal name": 0,
+40 -8
View File
@@ -1,14 +1,46 @@
import math, os, bpy, bmesh, mathutils
import math, bpy, mathutils
from bpy.utils import register_class, unregister_class
from io import BytesIO
from .sm64_constants import *
from .sm64_function_map import func_map
from .sm64_spline import *
from .sm64_geolayout_classes import *
from ..utility import *
from ..f3d.f3d_material import sm64EnumDrawLayers
from ..utility import (
PluginError,
CData,
Vector,
toAlnum,
convertRadiansToS16,
checkIdentityRotation,
obj_scale_is_unified,
all_values_equal_x,
checkIsSM64PreInlineGeoLayout,
prop_split,
)
from .sm64_constants import (
levelIDNames,
enumLevelNames,
enumModelIDs,
enumMacrosNames,
enumSpecialsNames,
enumBehaviourPresets,
)
from .sm64_spline import (
assertCurveValid,
convertSplineObject,
)
from .sm64_geolayout_classes import (
DisplayListNode,
JumpNode,
TranslateNode,
RotateNode,
TranslateRotateNode,
FunctionNode,
CustomNode,
BillboardNode,
ScaleNode,
)
enumTerrain = [
("Custom", "Custom", "Custom"),
+3 -3
View File
@@ -1,7 +1,7 @@
from .sm64_constants import *
import bpy
from bpy.utils import register_class, unregister_class
import bpy, bmesh
from ..utility import *
from ..utility import PluginError, CData, toAlnum, prop_split
enumSplineTypes = [
("Trajectory", "Trajectory", "Exports to Trajectory[]. Used for movement"),
+1 -1
View File
@@ -1,5 +1,5 @@
import os, re, bpy
from ..utility import *
from ..utility import PluginError, writeIfNotFound, getDataFromFile, saveDataToFile
from .c_templates.tile_scroll import tile_scroll_c, tile_scroll_h
from .sm64_utility import getMemoryCFilePath
+1 -1
View File
@@ -1,4 +1,4 @@
import bpy, os
import os
def starSelectWarning(operator, fileStatus):
if fileStatus is not None and not fileStatus.starSelectC: