Skip to content

Commit

Permalink
Merge branch 'posetools'
Browse files Browse the repository at this point in the history
  • Loading branch information
Menithal committed May 22, 2020
2 parents c6dc3f1 + 008f20d commit 033a93d
Show file tree
Hide file tree
Showing 14 changed files with 1,062 additions and 107 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This plugin now will focus on supporting as many platforms as possible.
Currently Supports

- HiFi and Forks
- VRC
- VRC (NeosVR by Proxy)
- Tower Unite

## 2.0 works only with 2.81 or later, use older version for 2.80.
Expand Down Expand Up @@ -98,9 +98,9 @@ If Entity is not Child of another entity, no Join is done. Only Children are mer
Note that Boolean operations work differently, and some may not keep the UV Unwrapping correctly in some situations. Use at your own risk


### VRChat Tools (WIP)
### VRChat / Neos Tools (WIP)

Work in progress module to try to stream line some "gotchas" when converting avatars to VRC without the duplicate operator additions from CATS (creating operators for Tools that are already in Blender, which create abit of clutter during operator searches)
Work in progress module to try to stream line some "gotchas" when converting avatars to VRC without the duplicate operator additions from CATS (creating operators for Tools that are already in Blender, which create abit of clutter during operator searches). Also by proxy supports NeosVR, which automatically binds the visemes when fbx export is used.

- A new Panel on the `3D View`'s right tool set is added, labled `MVT: VRC Tools`
- Armature Tools
Expand All @@ -121,9 +121,14 @@ Work in progress module to try to stream line some "gotchas" when converting ava

# Changelog:

### 2.1.0
- Added Hotfix #29 and #28 Relating to Hifi FBX and the FBX changes in 2.8
- Added some Rigging tools: still in work.

### 2.0.1
- Added some sculpting tools to quickly add 0.05 and reduce 0.05 resolution prior to remesh
- Moved UI components around for more easier maintenance.
- Moved compartmentalized components around for more easier maintenance in the future.
- README improvements

### 2.0
- `hifi_tools` is now `metaverse_tools`
Expand Down
5 changes: 4 additions & 1 deletion metaverse_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
bl_info = {
"name": "Metaverse Toolkit Blender Add-on",
"author": "Matti 'Menithal' Lahtinen",
"version": (2, 0, 1),
"version": (2, 2, 2),
"blender": (2, 81, 0),
"location": "File > Import-Export, Materials, Armature",
"description": "Blender tools to allow for easier Content creation various platforms",
Expand Down Expand Up @@ -397,6 +397,8 @@ def menu_func_export(self, context):
self.layout.operator(EXPORT_OT_MVT_TOOLSET_FBX.bl_idname, text="Hifi FBX (.fbx)")
self.layout.operator(EXPORT_OT_MVT_TOOLSET_FST_Writer_Operator.bl_idname,
text="HiFi Avatar FST (.fst)")
# self.layout.operator(EXPORT_OT_MVT_TOOLSET_Export_GLTF_JSON.bl_idname,
# text="HiFi Metaverse Scene JSON / GLTF (.json/.glb/.glm)")
self.layout.operator(EXPORT_OT_MVT_TOOLSET_Export_FBX_JSON.bl_idname,
text="HiFi Metaverse Scene JSON / FBX (.json/.fbx)")

Expand All @@ -423,6 +425,7 @@ def execute(self, context):
classes = (
EXPORT_OT_MVT_TOOLSET_Message_Error_Missing_ATP_Override,
EXPORT_OT_MVT_TOOLSET_IPFS_Feature_Info,
EXPORT_OT_MVT_TOOLSET_Export_GLTF_JSON,
EXPORT_OT_MVT_TOOLSET_Export_FBX_JSON,
EXPORT_OT_MVT_TOOLSET_FBX,
IMPORT_OT_MVT_TOOLSET_Scene_From_JSON,
Expand Down
57 changes: 57 additions & 0 deletions metaverse_tools/files/hifi_json/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,62 @@ def execute(self, context):

return {'FINISHED'}

class EXPORT_OT_MVT_TOOLSET_Export_GLTF_JSON(bpy.types.Operator, ExportHelper):
""" This Operator to show an error that the ATP Override is missing from export
"""
bl_idname = "metaverse_toolset.export_gltb_json"
bl_label = "Export HiFi Scene"
bl_options = {'UNDO'}

filename_ext = ".hifi.json"

directory: StringProperty()
filter_glob: StringProperty(default="*.hifi.json", options={'HIDDEN'})

atp: BoolProperty(default=False, name="Use ATP / Upload to domain",
description="Use ATP instead of Marketplace / upload assets to domain")
use_folder: BoolProperty(default=True, name="Use Folder",
description="Upload Files as a folder instead of individually")

url_override: StringProperty(default="", name="Marketplace / Base Url",
description="Set Marketplace / URL Path here to override")
clone_scene: BoolProperty(default=False, name="Clone Scene prior to export", description="Clones the scene and performs the automated export functions on the clone instead of the original. " +
"WARNING: instancing will not work, and ids will no longer be the same, for future features.")
remove_trailing: BoolProperty(
default=False, name="Remove Trailing .### from names")

def draw(self, context):
layout = self.layout

layout.prop(self, "atp")

if not self.atp:
layout.label(
text="Url Override: Add Marketplace / URL to make sure that the content can be reached.")
layout.prop(self, "url_override")
else:
layout.prop(self, "use_folder")

layout.label(
text="Clone scene: Performs automated actions on a cloned scene instead of the original.")
layout.prop(self, "clone_scene")
layout.prop(self, "remove_trailing")

def execute(self, context):
if not self.filepath:
raise Exception("filepath not set")

if not self.url_override and not self.atp:

bpy.ops.metaverse_toolset_messages.export_missing_atp_override('INVOKE_DEFAULT')
return {'CANCELLED'}
# raise Exception("You must Use ATP or Set the Marketplace / base URL to make sure that the content can be reached after you upload it. ATP currently not supported")

write_file(self, True)

return {'FINISHED'}



class IMPORT_OT_MVT_TOOLSET_Scene_From_JSON(bpy.types.Operator, ImportHelper):
""" Import a metaverse_toolset.json.svo scene into Blender. Works only for Primitives for now.
Expand Down Expand Up @@ -181,6 +237,7 @@ def draw(self, context):

sub.prop(self, "delete_interior_faces")
sub.prop(self, "use_boolean_operation")
sub.prop(self, "use_gltf")

def execute(self, context):
keywords = self.as_keywords(ignore=("filter_glob", "directory"))
Expand Down
44 changes: 31 additions & 13 deletions metaverse_tools/files/hifi_json/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

from metaverse_tools.utils.helpers.extra_math import *

EXPORT_VERSION = 84
EXPORT_VERSION = 85

def center_all(blender_object):
for child in blender_object.children:
Expand Down Expand Up @@ -155,7 +155,7 @@ def set_relative_to_parent(blender_object, json_data):
return json_data


def parse_object(blender_object, path, options):
def parse_object(blender_object, path, options, gltf):
# Store existing rotation mode, just in case.
json_data = None
# Make sure context is quaternion for the models
Expand Down Expand Up @@ -212,10 +212,20 @@ def parse_object(blender_object, path, options):

# TODO: Option to also export via gltf instead of fbx
# TODO: Add Option to not embedtextures / copy paths
file_path = path + reference_name + uid + ".fbx"

print("Writing FBX with path_mode=", file_path)
bpy.ops.metaverse_toolset.export_scene_fbx(filepath=file_path, embed_textures=True, path_mode='COPY', use_selection=True, axis_forward='-Z', axis_up='Y')

#
if gltf:
file_path = path + reference_name + uid
print("Writing GLTF with path_mode=", file_path)
#bpy.ops.metaverse_toolset.export_scene_fbx(filepath=file_path, embed_textures=True, path_mode='COPY', use_selection=True, axis_forward='-Z', axis_up='Y')
# TODO: Add gltf option HERE.
return False

else:
file_path = path + reference_name + uid + ".fbx"
print("Writing FBX with path_mode=", file_path)
bpy.ops.metaverse_toolset.export_scene_fbx(filepath=file_path, embed_textures=True, path_mode='COPY', use_selection=True, axis_forward='-Z', axis_up='Y')

# Restore earlier rotation
# blender_object.dimensions = temp_dimensions
Expand All @@ -230,10 +240,16 @@ def parse_object(blender_object, path, options):
last_folder = path[start:end]
else:
last_folder = ""

model_url = "atp:/"+ last_folder + reference_name + uid + '.fbx'

if gltf:
print("GLTF PLACEHOLDER")
else:
model_url = "atp:/"+ last_folder + reference_name + uid + '.fbx'
else:
model_url = options.url_override + reference_name + uid + '.fbx'
if gltf:
print("GLTF PLACEHOLDER")
else:
model_url = options.url_override + reference_name + uid + '.fbx'


json_data = {
Expand Down Expand Up @@ -385,7 +401,7 @@ def relative_position(parent_object):



def write_file(context):
def write_file(context, gltf=False):
current_scene = bpy.context.scene
read_scene = current_scene

Expand All @@ -407,13 +423,15 @@ def write_file(context):
## Parse the marketplace url
url = ""


## TODO: Remove marketplace hardcode reference
if not context.atp:
url = context.url_override
if "https://highfidelity.com/marketplace/items/" in url:
#if "https://highfidelity.com/marketplace/items/" in url:

marketplace_id = url.replace("https://highfidelity.com/marketplace/items/", "").replace("/edit","").replace("/","")
# marketplace_id = url.replace("https://highfidelity.com/marketplace/items/", "").replace("/edit","").replace("/","")

url = "http://mpassets.highfidelity.com/" + marketplace_id + "-v1/"
# url = "http://mpassets.highfidelity.com/" + marketplace_id + "-v1/"

if not url.endswith('/'):
url = url + "/"
Expand All @@ -424,7 +442,7 @@ def write_file(context):
current_scene_objects = list(read_scene.objects)
for blender_object in current_scene_objects:
print(len(current_scene_objects))
parsed = parse_object(blender_object, path, context)
parsed = parse_object(blender_object, path, context, gltf)

if parsed:
entities.append(parsed)
Expand Down
10 changes: 9 additions & 1 deletion metaverse_tools/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
from . import armature_tools
from . import texture_tools
from . import sculpt_tools
from . import pose_tools
from . import mesh_tools
from .modules import hifi as hifi_ui
from .modules import vrc as vrc_ui
from .modules import tu as tu_ui
Expand Down Expand Up @@ -139,7 +141,7 @@ class TEST_WT_workspace(bpy.types.WorkSpaceTool):
classes = (
OBJECT_PT_MVT_TOOLSET_Assets_Display,
EXPORT_OT_MVT_TOOLSET_IPFS_Assets_Toolset,
SAVE_OT_MVT_TOOLSET_Message_Remind_Save
SAVE_OT_MVT_TOOLSET_Message_Remind_Save,
)


Expand All @@ -150,16 +152,22 @@ class TEST_WT_workspace(bpy.types.WorkSpaceTool):
def register_operators():
module_register()
armature_tools.module_register()
pose_tools.module_register()
texture_tools.module_register()
hifi_ui.module_register()
vrc_ui.module_register()
tu_ui.module_register()
mesh_tools.module_register()
sculpt_tools.module_register()


def unregister_operators():
module_unregister()
armature_tools.module_unregister()
pose_tools.module_unregister()
texture_tools.module_register()
hifi_ui.module_unregister()
vrc_ui.module_unregister()
tu_ui.module_unregister()
mesh_tools.module_unregister()
sculpt_tools.module_unregister()
Loading

0 comments on commit 033a93d

Please sign in to comment.