-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from Baldrax/dev
Dev
- Loading branch information
Showing
13 changed files
with
148 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions
1
scripts/data/nodes/TaleSpire_Object_Set_object_sets_contents.net
This file contains 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 @@ | ||
gAAAAABj4_yUxXHdsPpf5auK85sD9qxzQ43rfPulPMtt3kO6nUzsWGtlZLXH7NFaPqt6ssiepAphRihOVjSPei0PYI50tBSs1l_DIh_ak4AudzVIE6N3pNfKMK3bnNpBBLDKY29WaLzrnDWPxZxSbbMZm0z3nKgMSbPLclaqpCw99ZQdXZn2EtxUa_S5PAC5rzZpHTko-nSXU78AARkWERDVtYifBl7OjcOOdk2eZj_AfO4mdhXAODYxA1PkblazkbLobvtbR7WiqwP5VKPUPxzNx7gc2n7mYray6qOPYimNRO52LbDtmV8XdiqsBvS8Xmsb0B9U11SYtct5KdDbB3_20qWMomBVUTMGzIuUDEBC6zVd_4bDTusQ7LeVPsvPRjEV0ieVJf-taEI-kF9JqR3OF4pdjhbhpxWQFvaevlvGtKol_bkAPdh0MOoW1n_BroWeuEenEdCxgyQ-rk3RyPy2NWTKeBVYAuATzls4mPkXAHGXWOmLfkd8g8tGHjXsd_JazoidgDrWGPpz7G1ohmqtX38vKAloCcJ-_lanyyHNazrxEsW7DEgIdrat1UIEpcRsLdxSAKdgrHAFDIdfk4N5pS0ud4DvZyKSv6V9yqO0yrNJGVwBIut2zLk6BRa21lepf4RuajsxzCuvLpsfPTFiQiX0hmsqxqslXiY52cRKW5O6jF1M9pI0LUxJAe_vLr7CT3M9l4ULZT6tBYv_P4oaQXEIAm3CyHHlQwe6AWSga6Ar3e3h4mKYV1EeLlJrUtwEeiCFKZVXFD0yGcuX-ddspdcrDRcjpjodLG3iSxeg7XPl_8HXtMDiRFEiL6CBzJIahuRttDfAPKPHyCIvwCWeuVpUx5tcNa-0sFCXRNGtSbsg5K5P06A23c8S8c5NVUQ3dTc91k-HDLQnevWnjIgswU9XGjqnFDO93-Rxgl_ymQmqwe5tMCLJwRg968dYknIUhHcprQzYXl15E_gxrkZFlM9DXtV50lqj2zsTPN2R2Zh3_mJNY076GXG9-szp7R_J_Kbr4SNsBmq5tNWqDM_XkyMKjXcBTg== |
This file contains 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
This file contains 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,93 @@ | ||
# Most of the code in here is a duplicate of what is in OBJ_TaleSpire_Terrain as the features are being moved. | ||
# Once this node is complete the redundant functions will be removed. | ||
import json | ||
import htg.utils | ||
import talespire.encode as ts_encode | ||
import hou | ||
|
||
|
||
def set_slab_range(node=None): | ||
si1_parm = node.parm('slabindex1') | ||
si2_parm = node.parm('slabindex2') | ||
slabs_node = hou.node(node.path()+'/NUM_SLABS') | ||
num_points = len(slabs_node.geometry().points()) | ||
si1_parm.set(1) | ||
si2_parm.deleteAllKeyframes() | ||
si2_parm.set(num_points) | ||
|
||
|
||
def copy_slab_from_node(node=None): | ||
json_data = get_js(node) | ||
slab = ts_encode.encode(json_data) | ||
htg.utils.copy_to_clipboard(slab.strip("b'`")) | ||
|
||
|
||
def get_js(geonode=None): | ||
geo = geonode.geometry() | ||
uuid_data = {} | ||
for point in geo.points(): | ||
uuid = point.attribValue('ts_uuid') | ||
x = point.attribValue('ts_x') | ||
y = point.attribValue('ts_y') | ||
z = point.attribValue('ts_z') | ||
degree = point.attribValue('ts_degree') | ||
if uuid not in uuid_data: | ||
uuid_data[uuid] = [] | ||
uuid_data[uuid].append({'x': x, 'y': y, 'z': z, 'degree': degree}) | ||
|
||
data = {'unique_asset_count': len(uuid_data.keys()), 'asset_data': []} | ||
for auuid in uuid_data.keys(): | ||
asset_data = { | ||
'uuid': auuid, | ||
'instance_count': len(uuid_data[auuid]), | ||
'instances': uuid_data[auuid] | ||
} | ||
data['asset_data'].append(asset_data) | ||
|
||
json_dump = json.dumps(data) | ||
return data | ||
|
||
|
||
def get_slab_with_pos(node=None): | ||
offset_node = hou.node(node.path() + '/First_Tile') | ||
geo = offset_node.geometry() | ||
point = geo.point(0) | ||
try: | ||
pos = tuple(point.position()) | ||
json_data = get_js(node) | ||
slab = ts_encode.encode(json_data) | ||
out = { | ||
"position": {"x": pos[0], "y": pos[1], "z": -pos[2]}, | ||
"code": slab.strip("b'`") | ||
} | ||
except AttributeError: | ||
out = None | ||
|
||
return out | ||
|
||
|
||
def encode_slabs(node=None): | ||
num_assets = 1 # Disabled while developing | ||
do_export = True | ||
if num_assets >= 1000000: | ||
button_result = hou.ui.displayMessage('Warning: This map contains more that 1 Million assets.\n' | ||
'TaleSpire will likely crash.\n' | ||
'Are you sure you want to do this?', | ||
buttons=('OK', 'Cancel')) | ||
if button_result != 0: | ||
do_export = False | ||
|
||
if do_export: | ||
grid_node = hou.node(node.path() + '/SLAB_GRID') | ||
num_slabs = len(grid_node.geometry().prims()) | ||
slab_index_parm = node.parm('slabindex1') | ||
og_index = slab_index_parm.eval() | ||
|
||
slab_json = [] | ||
for i in range(1, num_slabs + 1): | ||
slab_index_parm.set(i) | ||
slab_pos = get_slab_with_pos(node) | ||
if slab_pos is not None: | ||
slab_json.append(slab_pos) | ||
htg.utils.copy_to_clipboard(json.dumps(slab_json)) | ||
slab_index_parm.set(og_index) |
This file contains 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,29 @@ | ||
import hou | ||
import htg.utils | ||
import htg.nodes.common as ts_common | ||
|
||
|
||
def refresh_objects(node=None): | ||
cook_paths = ['/object_set_points'] | ||
|
||
for cook_path in cook_paths: | ||
cook_node = hou.node(node.path()+cook_path) | ||
cook_node.cook(force=True) | ||
|
||
|
||
def edit_objects(node=None): | ||
dest_node = hou.node(node.path() + '/object_sets') | ||
htg.utils.set_network(node, dest_node) | ||
|
||
|
||
def load_default_networks(node=None): | ||
networks = { | ||
'object_sets': 'TaleSpire_Object_Set_object_sets_contents.net' | ||
} | ||
ts_common.load_networks(node, networks) | ||
|
||
|
||
def save_object_sets_network(node=None): | ||
file_name = 'TaleSpire_Object_Set_object_sets_contents.net' | ||
net_node = hou.node(node.path() + '/object_sets') | ||
ts_common.save_network(net_node, file_name, mode='node') |