Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the possibility to import course from the decomp of mk64 #316

Merged
merged 51 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
a67236b
start add mk64 course importer
coco875 Feb 29, 2024
43c25b6
add the possibility to import course
coco875 Feb 29, 2024
ebe1688
remove unmodified function
coco875 Feb 29, 2024
758632c
Update panels.py
coco875 Feb 29, 2024
c41cbf2
reformat by using black
coco875 Feb 29, 2024
fe59e90
Update fast64_internal/mk64/__init__.py
coco875 Feb 29, 2024
230cd6f
Update fast64_internal/mk64/f3d_course_parser.py
coco875 Feb 29, 2024
a8eac6a
create MK64F3DContext class
coco875 Feb 29, 2024
6a3a2c1
Merge branch 'mk64' of https://github.com/coco875/fast64 into mk64
coco875 Feb 29, 2024
dfb910b
ok add a mk64/README.md and add getVertexDataStart as a method of F3D…
coco875 Feb 29, 2024
6002ab7
Merge remote-tracking branch 'upstream/main' into mk64
coco875 Feb 29, 2024
955e8e1
Update fast64_internal/mk64/__init__.py
coco875 Feb 29, 2024
0ebed47
add upgrade_changed_props
coco875 Feb 29, 2024
21630a1
Merge branch 'mk64' of https://github.com/coco875/fast64 into mk64
coco875 Feb 29, 2024
ee38f20
fix poll
coco875 Feb 29, 2024
bd0cea7
fix a bug and a error
coco875 Feb 29, 2024
6d0c13b
remove poll from MK64_ImportCourseDLPanel
coco875 Feb 29, 2024
4e77d46
add the options to enable render mode for course
coco875 Mar 2, 2024
a590c15
fix too short argument not be parse
coco875 Mar 4, 2024
b3b916e
change MK64_Properties
coco875 Mar 7, 2024
bd93561
Update f3d_parser.py
coco875 Mar 7, 2024
0e77021
update file who are rename in mk64
coco875 Apr 4, 2024
3d41cb6
Merge branch 'main' into mk64
coco875 Jun 20, 2024
97a0123
reformat with black
coco875 Jun 20, 2024
b4fedd2
fix an import
coco875 Jun 20, 2024
f24435e
Update fast64_internal/mk64/__init__.py
coco875 Jun 20, 2024
a4372f3
Update fast64_internal/mk64/f3d_course_parser.py
coco875 Jun 20, 2024
97230eb
Update fast64_internal/mk64/__init__.py
coco875 Jun 20, 2024
3df043d
Update fast64_internal/mk64/__init__.py
coco875 Jun 20, 2024
8b7e2dd
sort import
coco875 Jun 20, 2024
3d4722a
Update README.md
coco875 Jun 20, 2024
685da73
Update README.md
coco875 Jun 20, 2024
6fdf8d4
Update __init__.py
coco875 Jun 20, 2024
9abb003
Merge remote-tracking branch 'upstream/main' into mk64
coco875 Jul 29, 2024
5f520f8
Update __init__.py
coco875 Jul 29, 2024
fcc6d1a
add properties to mk64
coco875 Jul 29, 2024
f1119c0
rename properties field
coco875 Jul 29, 2024
bd80fb1
remove drawLayer
coco875 Jul 29, 2024
df47e6d
Update __init__.py
coco875 Jul 30, 2024
7541dba
fix enum of game problem
coco875 Jul 30, 2024
e73a86d
Update fast64_internal/mk64/f3d/properties.py
coco875 Jul 30, 2024
5e2964c
move MK64_ImportCourseDL to operators file
coco875 Jul 30, 2024
30f9030
format black
coco875 Jul 30, 2024
2a08f97
forget an import
coco875 Jul 30, 2024
edc0e7b
forget another import
coco875 Jul 30, 2024
77ac333
make some snake_case move panels and scale
coco875 Aug 1, 2024
6930776
fix black
coco875 Aug 1, 2024
f323083
fix snakke_case
coco875 Aug 1, 2024
76a5c64
rename to mk64_model_classes
coco875 Aug 1, 2024
f7d9d4d
Update operators.py
coco875 Aug 1, 2024
5684b13
forget a snake_case
coco875 Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from .fast64_internal.oot.props_panel_main import OOT_ObjectProperties
from .fast64_internal.utility_anim import utility_anim_register, utility_anim_unregister, ArmatureApplyWithMeshOperator

from .fast64_internal.mk64 import MK64_Properties, mk64_register, mk64_unregister

from .fast64_internal.f3d.f3d_material import mat_register, mat_unregister
from .fast64_internal.f3d.f3d_render_engine import render_engine_register, render_engine_unregister
from .fast64_internal.f3d.f3d_writer import f3d_writer_register, f3d_writer_unregister
Expand Down Expand Up @@ -51,6 +53,7 @@
gameEditorEnum = (
("SM64", "SM64", "Super Mario 64"),
("OOT", "OOT", "Ocarina Of Time"),
("MK64", "MK64", "Mario Kart 64"),
)


Expand Down Expand Up @@ -260,6 +263,7 @@ class Fast64_Properties(bpy.types.PropertyGroup):

sm64: bpy.props.PointerProperty(type=SM64_Properties, name="SM64 Properties")
oot: bpy.props.PointerProperty(type=OOT_Properties, name="OOT Properties")
mk64: bpy.props.PointerProperty(type=MK64_Properties, name="MK64 Properties")
settings: bpy.props.PointerProperty(type=Fast64Settings_Properties, name="Fast64 Settings")
renderSettings: bpy.props.PointerProperty(type=Fast64RenderSettings_Properties, name="Fast64 Render Settings")

Expand Down Expand Up @@ -408,6 +412,8 @@ def gameEditorUpdate(self, context):
self.f3d_type = "F3D"
elif self.gameEditorMode == "OOT":
self.f3d_type = "F3DEX2/LX2"
elif self.gameEditorMode == "MK64":
self.f3d_type = "F3DEX/LX"


# called on add-on enabling
Expand Down Expand Up @@ -437,6 +443,7 @@ def register():
bsdf_conv_register()
sm64_register(True)
oot_register(True)
mk64_register(True)

for cls in classes:
register_class(cls)
Expand Down Expand Up @@ -483,6 +490,7 @@ def unregister():
f3d_parser_unregister()
sm64_unregister(True)
oot_unregister(True)
mk64_unregister(True)
mat_unregister()
bsdf_conv_unregister()
bsdf_conv_panel_unregsiter()
Expand Down
144 changes: 144 additions & 0 deletions fast64_internal/mk64/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import bpy
from bpy_types import PropertyGroup
coco875 marked this conversation as resolved.
Show resolved Hide resolved
from ..f3d.f3d_gbi import get_F3D_GBI
from ..f3d.f3d_material import createF3DMat
from ..f3d.f3d_parser import getImportData, importMeshC
from ..panels import MK64_Panel
from ..utility import prop_split
from bpy.utils import register_class, unregister_class
from ..utility import raisePluginError
from .f3d_course_parser import MK64F3DContext, parseCourseVtx


class MK64_Properties(PropertyGroup):
"""Global MK64 Scene Properties found under scene.fast64.mk64"""

version: bpy.props.IntProperty(name="MK64_Properties Version", default=0)
coco875 marked this conversation as resolved.
Show resolved Hide resolved


class MK64_ImportCourseDL(bpy.types.Operator):
coco875 marked this conversation as resolved.
Show resolved Hide resolved
# set bl_ properties
bl_idname = "object.fast64_mk64_course_import_dl"
coco875 marked this conversation as resolved.
Show resolved Hide resolved
bl_label = "Import Course DL"
bl_options = {"REGISTER", "UNDO", "PRESET"}

# Called on demand (i.e. button press, menu item)
# Can also be called from operator search menu (Spacebar)
def execute(self, context):
obj = None
if context.mode != "OBJECT":
bpy.ops.object.mode_set(mode="OBJECT")

try:
name = context.scene.DLImportName
importPath = bpy.path.abspath(context.scene.DLImportPath)
basePath = bpy.path.abspath(context.scene.DLImportBasePath)
Lilaa3 marked this conversation as resolved.
Show resolved Hide resolved
scaleValue = context.scene.blenderF3DScale

removeDoubles = context.scene.DLRemoveDoubles
importNormals = context.scene.DLImportNormals
drawLayer = context.scene.DLImportDrawLayer

paths = [importPath]

if "course_data" in importPath:
paths += [importPath.replace("course_data", "course_displaylists")]

paths += [
importPath.replace("course_data.inc", "course_textures.linkonly").replace(
"course_displaylists.inc", "course_textures.linkonly"
)
]

data = getImportData(paths)

f3d_context = MK64F3DContext(get_F3D_GBI(), basePath, createF3DMat(None))
if "course_displaylists" in importPath or "course_data" in importPath:
vertexPath = importPath.replace("course_displaylists", "course_vertices").replace(
"course_data", "course_vertices"
)
print(vertexPath)
f3d_context.vertexData["0x4000000"] = parseCourseVtx(vertexPath, f3d_context.f3d)

importMeshC(
data,
name,
scaleValue,
removeDoubles,
importNormals,
drawLayer,
f3d_context,
)

self.report({"INFO"}, "Success!")
return {"FINISHED"}

except Exception as e:
if context.mode != "OBJECT":
bpy.ops.object.mode_set(mode="OBJECT")
raisePluginError(self, e)
return {"CANCELLED"} # must return a set


class MK64_ImportCourseDLPanel(MK64_Panel):
bl_idname = "MK64_import_course_DL_panel_settings"
bl_label = "MK64 Import Course DL Panel Settings"
coco875 marked this conversation as resolved.
Show resolved Hide resolved
bl_options = set() # default to open
bl_order = 0 # force to front

@classmethod
def poll(cls, context):
return True
coco875 marked this conversation as resolved.
Show resolved Hide resolved

# called every frame
def draw(self, context):
col = self.layout.column()
col.scale_y = 1.1 # extra padding

col.operator(MK64_ImportCourseDL.bl_idname)
prop_split(col, context.scene, "DLImportName", "Name")
prop_split(col, context.scene, "DLImportPath", "File")
prop_split(col, context.scene, "DLImportBasePath", "Base Path")
prop_split(col, context.scene, "blenderF3DScale", "Scale")
prop_split(col, context.scene, "DLImportDrawLayer", "Draw Layer")
col.prop(context.scene, "DLRemoveDoubles")
col.prop(context.scene, "DLImportNormals")

box = col.box().column()
box.label(text="All data must be contained within file.")
box.label(text="The only exception are pngs converted to inc.c.")

# col.template_list('F3D_UL_ImportDLPathList', '', context.scene,
# 'DLImportOtherFiles', context.scene, 'DLImportOtherFilesIndex')
coco875 marked this conversation as resolved.
Show resolved Hide resolved


mk64_classes = (MK64_Properties,)

mk64_panel_classes = (
MK64_ImportCourseDL,
MK64_ImportCourseDLPanel,
)


def mk64_panel_register():
for cls in mk64_panel_classes:
register_class(cls)


def mk64_panel_unregister():
for cls in mk64_panel_classes:
unregister_class(cls)


def mk64_register(registerPanels):
for cls in mk64_classes:
register_class(cls)
if registerPanels:
mk64_panel_register()


def mk64_unregister(registerPanel):
for cls in reversed(mk64_classes):
unregister_class(cls)
if registerPanel:
mk64_panel_unregister()
Loading