-
Notifications
You must be signed in to change notification settings - Fork 120
add the test of cube export and import #317
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
Open
coco875
wants to merge
4
commits into
Fast-64:main
Choose a base branch
from
coco875:gh-actions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: Linux test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "*" ] | ||
| pull_request: | ||
| branches: [ "master" ] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt install blender | ||
| - name: Build | ||
| run: | | ||
| blender -b --python test\test_cube_export.py | ||
| blender -b --python test\test_cube_import.py | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| extern Lights1 cube_f3dlite_material_lights; | ||
| extern Vtx cube_Cube_mesh_vtx_0[24]; | ||
| extern Gfx cube_Cube_mesh_tri_0[]; | ||
| extern Gfx mat_cube_f3dlite_material[]; | ||
| extern Gfx cube_Cube_mesh[]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| Lights1 cube_f3dlite_material_lights = gdSPDefLights1( | ||
| 0x7F, 0x7F, 0x7F, | ||
| 0xFF, 0xFF, 0xFF, 0x49, 0x49, 0x49); | ||
|
|
||
| Vtx cube_Cube_mesh_vtx_0[24] = { | ||
| {{ {-50, -50, 50}, 0, {368, 1008}, {129, 0, 0, 255} }}, | ||
| {{ {-50, 50, 50}, 0, {624, 1008}, {129, 0, 0, 255} }}, | ||
| {{ {-50, 50, -50}, 0, {624, 752}, {129, 0, 0, 255} }}, | ||
| {{ {-50, -50, -50}, 0, {368, 752}, {129, 0, 0, 255} }}, | ||
| {{ {-50, -50, -50}, 0, {368, 752}, {0, 0, 129, 255} }}, | ||
| {{ {-50, 50, -50}, 0, {624, 752}, {0, 0, 129, 255} }}, | ||
| {{ {50, 50, -50}, 0, {624, 496}, {0, 0, 129, 255} }}, | ||
| {{ {50, -50, -50}, 0, {368, 496}, {0, 0, 129, 255} }}, | ||
| {{ {50, -50, -50}, 0, {368, 496}, {127, 0, 0, 255} }}, | ||
| {{ {50, 50, -50}, 0, {624, 496}, {127, 0, 0, 255} }}, | ||
| {{ {50, 50, 50}, 0, {624, 240}, {127, 0, 0, 255} }}, | ||
| {{ {50, -50, 50}, 0, {368, 240}, {127, 0, 0, 255} }}, | ||
| {{ {50, -50, 50}, 0, {368, 240}, {0, 0, 127, 255} }}, | ||
| {{ {50, 50, 50}, 0, {624, 240}, {0, 0, 127, 255} }}, | ||
| {{ {-50, 50, 50}, 0, {624, -16}, {0, 0, 127, 255} }}, | ||
| {{ {-50, -50, 50}, 0, {368, -16}, {0, 0, 127, 255} }}, | ||
| {{ {-50, -50, -50}, 0, {112, 496}, {0, 129, 0, 255} }}, | ||
| {{ {50, -50, -50}, 0, {368, 496}, {0, 129, 0, 255} }}, | ||
| {{ {50, -50, 50}, 0, {368, 240}, {0, 129, 0, 255} }}, | ||
| {{ {-50, -50, 50}, 0, {112, 240}, {0, 129, 0, 255} }}, | ||
| {{ {50, 50, -50}, 0, {624, 496}, {0, 127, 0, 255} }}, | ||
| {{ {-50, 50, -50}, 0, {880, 496}, {0, 127, 0, 255} }}, | ||
| {{ {-50, 50, 50}, 0, {880, 240}, {0, 127, 0, 255} }}, | ||
| {{ {50, 50, 50}, 0, {624, 240}, {0, 127, 0, 255} }}, | ||
| }; | ||
|
|
||
| Gfx cube_Cube_mesh_tri_0[] = { | ||
| gsSPVertex(cube_Cube_mesh_vtx_0 + 0, 16, 0), | ||
| gsSP1Triangle(0, 1, 2, 0), | ||
| gsSP1Triangle(0, 2, 3, 0), | ||
| gsSP1Triangle(4, 5, 6, 0), | ||
| gsSP1Triangle(4, 6, 7, 0), | ||
| gsSP1Triangle(8, 9, 10, 0), | ||
| gsSP1Triangle(8, 10, 11, 0), | ||
| gsSP1Triangle(12, 13, 14, 0), | ||
| gsSP1Triangle(12, 14, 15, 0), | ||
| gsSPVertex(cube_Cube_mesh_vtx_0 + 16, 8, 0), | ||
| gsSP1Triangle(0, 1, 2, 0), | ||
| gsSP1Triangle(0, 2, 3, 0), | ||
| gsSP1Triangle(4, 5, 6, 0), | ||
| gsSP1Triangle(4, 6, 7, 0), | ||
| gsSPEndDisplayList(), | ||
| }; | ||
|
|
||
| Gfx mat_cube_f3dlite_material[] = { | ||
| gsDPPipeSync(), | ||
| gsDPSetCombineLERP(0, 0, 0, SHADE, 0, 0, 0, ENVIRONMENT, 0, 0, 0, SHADE, 0, 0, 0, ENVIRONMENT), | ||
| gsSPTexture(65535, 65535, 0, 0, 1), | ||
| gsSPSetLights1(cube_f3dlite_material_lights), | ||
| gsSPEndDisplayList(), | ||
| }; | ||
|
|
||
| Gfx cube_Cube_mesh[] = { | ||
| gsSPDisplayList(mat_cube_f3dlite_material), | ||
| gsSPDisplayList(cube_Cube_mesh_tri_0), | ||
| gsDPPipeSync(), | ||
| gsSPSetGeometryMode(G_LIGHTING), | ||
| gsSPClearGeometryMode(G_TEXTURE_GEN), | ||
| gsDPSetCombineLERP(0, 0, 0, SHADE, 0, 0, 0, ENVIRONMENT, 0, 0, 0, SHADE, 0, 0, 0, ENVIRONMENT), | ||
| gsSPTexture(65535, 65535, 0, 0, 0), | ||
| gsSPEndDisplayList(), | ||
| }; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import math | ||
| import bpy | ||
| from os.path import dirname, abspath | ||
| import sys | ||
| import mathutils | ||
|
|
||
| sys.path.append(dirname(dirname(dirname(abspath(__file__))))) | ||
| from fast64 import register | ||
|
|
||
| sys.path.append(dirname(dirname(abspath(__file__)))) | ||
| from fast64_internal.utility import PluginError, applyRotation | ||
| from fast64_internal.f3d.f3d_gbi import DLFormat | ||
| from fast64_internal.f3d.f3d_material import createF3DMat, getDefaultMaterialPreset | ||
| from fast64_internal.f3d.f3d_writer import exportF3DtoC, getWriteMethodFromEnum | ||
|
|
||
| register() | ||
|
|
||
|
|
||
| def purge_orphans(): | ||
| if bpy.app.version >= (3, 0, 0): | ||
| bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=True, do_recursive=True) | ||
| else: | ||
| # call purge_orphans() recursively until there are no more orphan data blocks to purge | ||
| result = bpy.ops.outliner.orphans_purge() | ||
| if result.pop() != "CANCELLED": | ||
| purge_orphans() | ||
|
|
||
|
|
||
| def clean_scene(): | ||
| """ | ||
| Removing all of the objects, collection, materials, particles, | ||
| textures, images, curves, meshes, actions, nodes, and worlds from the scene | ||
| """ | ||
| if bpy.context.active_object and bpy.context.active_object.mode == "EDIT": | ||
| bpy.ops.object.editmode_toggle() | ||
|
|
||
| for obj in bpy.data.objects: | ||
| obj.hide_set(False) | ||
| obj.hide_select = False | ||
| obj.hide_viewport = False | ||
|
|
||
| bpy.ops.object.select_all(action="SELECT") | ||
| bpy.ops.object.delete() | ||
|
|
||
| collection_names = [col.name for col in bpy.data.collections] | ||
| for name in collection_names: | ||
| bpy.data.collections.remove(bpy.data.collections[name]) | ||
|
|
||
| # in the case when you modify the world shader | ||
| world_names = [world.name for world in bpy.data.worlds] | ||
| for name in world_names: | ||
| bpy.data.worlds.remove(bpy.data.worlds[name]) | ||
| # create a new world data block | ||
| bpy.ops.world.new() | ||
| bpy.context.scene.world = bpy.data.worlds["World"] | ||
|
|
||
| purge_orphans() | ||
|
|
||
|
|
||
| clean_scene() | ||
|
|
||
| bpy.ops.mesh.primitive_cube_add(size=1, location=(0, 0, 0)) | ||
|
|
||
| bpy.ops.object.select_all(action="SELECT") | ||
|
|
||
| if bpy.context.mode != "OBJECT": | ||
| bpy.ops.object.mode_set(mode="OBJECT") | ||
|
|
||
| allObjs = bpy.context.selected_objects | ||
| if len(allObjs) == 0: | ||
| raise PluginError("No objects selected.") | ||
| obj = bpy.context.selected_objects[0] | ||
| if obj.type != "MESH": | ||
| raise PluginError("Object is not a mesh.") | ||
|
|
||
| preset = getDefaultMaterialPreset("Shaded Solid") | ||
| createF3DMat(obj, preset) | ||
|
|
||
| scaleValue = bpy.context.scene.blenderF3DScale | ||
| finalTransform = mathutils.Matrix.Diagonal(mathutils.Vector((scaleValue, scaleValue, scaleValue))).to_4x4() | ||
| applyRotation([obj], math.radians(90), "X") | ||
|
|
||
| exportPath = bpy.path.abspath(bpy.context.scene.DLExportPath) | ||
| dlFormat = DLFormat.Static if bpy.context.scene.DLExportisStatic else DLFormat.Dynamic | ||
| texDir = bpy.context.scene.DLTexDir | ||
| savePNG = bpy.context.scene.saveTextures | ||
| separateTexDef = bpy.context.scene.DLSeparateTextureDef | ||
| DLName = "cube" | ||
| matWriteMethod = getWriteMethodFromEnum(bpy.context.scene.matWriteMethod) | ||
|
|
||
| exportF3DtoC( | ||
| exportPath, | ||
| obj, | ||
| dlFormat, | ||
| finalTransform, | ||
| texDir, | ||
| savePNG, | ||
| separateTexDef, | ||
| DLName, | ||
| matWriteMethod, | ||
| ) | ||
|
|
||
| applyRotation([obj], math.radians(-90), "X") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import math | ||
| import bpy | ||
| from os.path import dirname, abspath | ||
| import sys | ||
|
|
||
| sys.path.append(dirname(dirname(dirname(abspath(__file__))))) | ||
| from fast64 import register | ||
|
|
||
| sys.path.append(dirname(dirname(abspath(__file__)))) | ||
| from fast64_internal.f3d.f3d_gbi import get_F3D_GBI | ||
| from fast64_internal.f3d.f3d_material import createF3DMat | ||
| from fast64_internal.f3d.f3d_parser import F3DContext, getImportData, importMeshC | ||
|
|
||
| register() | ||
|
|
||
|
|
||
| def purge_orphans(): | ||
| if bpy.app.version >= (3, 0, 0): | ||
| bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=True, do_recursive=True) | ||
| else: | ||
| # call purge_orphans() recursively until there are no more orphan data blocks to purge | ||
| result = bpy.ops.outliner.orphans_purge() | ||
| if result.pop() != "CANCELLED": | ||
| purge_orphans() | ||
|
|
||
|
|
||
| def clean_scene(): | ||
| """ | ||
| Removing all of the objects, collection, materials, particles, | ||
| textures, images, curves, meshes, actions, nodes, and worlds from the scene | ||
| """ | ||
| if bpy.context.active_object and bpy.context.active_object.mode == "EDIT": | ||
| bpy.ops.object.editmode_toggle() | ||
|
|
||
| for obj in bpy.data.objects: | ||
| obj.hide_set(False) | ||
| obj.hide_select = False | ||
| obj.hide_viewport = False | ||
|
|
||
| bpy.ops.object.select_all(action="SELECT") | ||
| bpy.ops.object.delete() | ||
|
|
||
| collection_names = [col.name for col in bpy.data.collections] | ||
| for name in collection_names: | ||
| bpy.data.collections.remove(bpy.data.collections[name]) | ||
|
|
||
| # in the case when you modify the world shader | ||
| world_names = [world.name for world in bpy.data.worlds] | ||
| for name in world_names: | ||
| bpy.data.worlds.remove(bpy.data.worlds[name]) | ||
| # create a new world data block | ||
| bpy.ops.world.new() | ||
| bpy.context.scene.world = bpy.data.worlds["World"] | ||
|
|
||
| purge_orphans() | ||
|
|
||
|
|
||
| clean_scene() | ||
|
|
||
| obj = None | ||
| if bpy.context.mode != "OBJECT": | ||
| bpy.ops.object.mode_set(mode="OBJECT") | ||
|
|
||
| name = "cube_Cube_mesh" | ||
| importPath = "./cube/model.inc.c" | ||
| basePath = bpy.path.abspath(bpy.context.scene.DLImportBasePath) | ||
| scaleValue = bpy.context.scene.blenderF3DScale | ||
|
|
||
| removeDoubles = bpy.context.scene.DLRemoveDoubles | ||
| importNormals = bpy.context.scene.DLImportNormals | ||
| drawLayer = bpy.context.scene.DLImportDrawLayer | ||
|
|
||
| data = getImportData([importPath]) | ||
|
|
||
| importMeshC( | ||
| data, | ||
| name, | ||
| scaleValue, | ||
| removeDoubles, | ||
| importNormals, | ||
| drawLayer, | ||
| F3DContext(get_F3D_GBI(), basePath, createF3DMat(None)), | ||
| ) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.