Procedural Prefabs: Python documentation cleanup (#6136)

* Auto LOD script setup

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Working auto LODs

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Correctly selected LODs and added default prefab

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Cleanup code

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Cleanup code

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add missing legal header, move name cleanup to scene_helpers, add documentation

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add PhysX mesh group support.

Updated example script to show usage

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add a physics collider component

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Update DefaultOrValue call

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Document remaining methods in scene_data.py

Add enums where appropriate
Add type hints and default values

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Remove unused import

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Convert docstring to numpy style

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix return types

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Remove empty returns

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add docs on enums

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
This commit is contained in:
amzn-mike
2021-12-09 14:53:35 -06:00
committed by GitHub
parent c63b4eb905
commit 5e5bb27219
3 changed files with 474 additions and 200 deletions
@@ -14,30 +14,44 @@ from scene_api.scene_data import SceneGraphName
def log_exception_traceback():
"""
Outputs an exception stacktrace.
"""
"""Outputs an exception stacktrace."""
data = traceback.format_exc()
logger = logging.getLogger('python')
logger.error(data)
def sanitize_name_for_disk(name: str):
"""
Removes illegal filename characters from a string.
def sanitize_name_for_disk(name: str) -> str:
"""Removes illegal filename characters from a string.
Parameters
----------
name :
String to clean.
Returns
-------
str
Name with illegal characters removed.
:param name: String to clean.
:return: Name with illegal characters removed.
"""
return "".join(char for char in name if char not in "|<>:\"/?*\\")
def get_mesh_node_names(scene_graph: sceneData.SceneGraph) -> Tuple[List[SceneGraphName], List[str]]:
"""
Returns a tuple of all the mesh nodes as well as all the node paths
"""Returns a tuple of all the mesh nodes as well as all the node paths
Parameters
----------
scene_graph :
Scene graph to search
Returns
-------
Tuple[List[SceneGraphName], List[str]]
Tuple of [Mesh Nodes, All Node Paths]
:param scene_graph: Scene graph to search
:return: Tuple of [Mesh Nodes, All Node Paths]
"""
import azlmbr.scene as sceneApi
import azlmbr.scene.graph
@@ -8,7 +8,7 @@
import azlmbr.bus
import azlmbr.math
from scene_api.scene_data import PrimitiveShape, DecompositionMode
from scene_api.scene_data import PrimitiveShape, DecompositionMode, ColorChannel, TangentSpaceSource, TangentSpaceMethod
from scene_helpers import *
@@ -71,6 +71,7 @@ def add_physx_meshes(scene_manifest: sceneData.SceneManifest, source_file_name:
triangle = scene_manifest.add_physx_triangle_mesh_group(source_file_name + "_triangle", False, True, True, True, True, True)
scene_manifest.physx_mesh_group_add_selected_unselected_nodes(triangle, [first_mesh], all_except_first_mesh)
def update_manifest(scene):
import uuid, os
import azlmbr.scene.graph
@@ -114,10 +115,11 @@ def update_manifest(scene):
if node != mesh_path:
scene_manifest.mesh_group_unselect_node(mesh_group, node)
scene_manifest.mesh_group_add_cloth_rule(mesh_group, mesh_path, "Col0", 1, "Col0", 2, "Col0", 2, 3)
scene_manifest.mesh_group_add_cloth_rule(mesh_group, mesh_path, "Col0", ColorChannel.GREEN, "Col0",
ColorChannel.BLUE, "Col0", ColorChannel.BLUE, ColorChannel.ALPHA)
scene_manifest.mesh_group_add_advanced_mesh_rule(mesh_group, True, False, True, "Col0")
scene_manifest.mesh_group_add_skin_rule(mesh_group, 3, 0.002)
scene_manifest.mesh_group_add_tangent_rule(mesh_group, 1, 0)
scene_manifest.mesh_group_add_tangent_rule(mesh_group, TangentSpaceSource.MIKKT_GENERATION, TangentSpaceMethod.TSPACE_BASIC)
# Create an editor entity
entity_id = azlmbr.entity.EntityUtilityBus(azlmbr.bus.Broadcast, "CreateEditorReadyEntity", mesh_group_name)