Integrating latest 47acbe8
This commit is contained in:
+119
@@ -0,0 +1,119 @@
|
||||
"""
|
||||
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
its licensors.
|
||||
|
||||
For complete copyright and license terms please see the LICENSE at the root of this
|
||||
distribution (the "License"). All use of this software is governed by the License,
|
||||
or, if provided, by the license below or the license accompanying this file. Do not
|
||||
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
Test case ID : C4044695
|
||||
Test Case Title : Verify that when you add a multiple surface fbx in PxMesh in PhysxCollider,
|
||||
multiple number of Material Slots populate in the Materials Section
|
||||
URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4044695
|
||||
"""
|
||||
|
||||
|
||||
# fmt: off
|
||||
class Tests():
|
||||
create_entity = ("Created test entity", "Failed to create test entity")
|
||||
mesh_added = ("Added Mesh component", "Failed to add Mesh component")
|
||||
physx_collider_added = ("Added PhysX Collider component", "Failed to add PhysX Collider component")
|
||||
shape_is_correct = ("PhysX Collider Shape is correct", "PhysX Collider Shape is not PhysicsAsset")
|
||||
assign_mesh_asset = ("Assigned Mesh asset to Mesh component", "Failed to assign mesh asset to Mesh component")
|
||||
assign_px_mesh_asset = ("Assigned PxMesh asset to Collider component", "Failed to assign PxMesh asset to Collider component")
|
||||
count_mesh_surface = ("Multiple slots show under materials", "Failed to show required surface materials")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def run():
|
||||
"""
|
||||
Summary:
|
||||
Create entity with Mesh and PhysX Collider components and assign a fbx file in both the components.
|
||||
Verify that the fbx is properly fitting the mesh.
|
||||
|
||||
Expected Behavior:
|
||||
1) The fbx is properly fitting the mesh.
|
||||
2) Multiple material slots show up under Materials section in the PhysX Collider component and that
|
||||
they correspond to the number of surfaces as designed in the mesh.
|
||||
|
||||
Test Steps:
|
||||
1) Load the empty level
|
||||
2) Create an entity
|
||||
3) Add Mesh and Physics collider components
|
||||
4) Select the PhysicsAsset shape in the PhysX Collider component
|
||||
5) Assign the fbx file in PhysX Mesh and Mesh component
|
||||
6) Check if multiple material slots show up under Materials section in the PhysX Collider component
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Lumberyard Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Builtins
|
||||
import os
|
||||
|
||||
# Helper Files
|
||||
import ImportPathHelper as imports
|
||||
|
||||
imports.init()
|
||||
from utils import Report
|
||||
from utils import TestHelper as helper
|
||||
from editor_entity_utils import EditorEntity as Entity
|
||||
from asset_utils import Asset
|
||||
|
||||
# Constants
|
||||
PHYSICS_ASSET_INDEX = 7 # Hardcoded enum index value for Shape property
|
||||
SURFACE_TAG_COUNT = 4 # Number of surface tags included in used asset
|
||||
|
||||
# Asset paths
|
||||
STATIC_MESH = os.path.join("assets", "c4044695_physxcollider_addmultiplesurfacefbx", "test.cgf")
|
||||
PHYSX_MESH = os.path.join("assets", "c4044695_physxcollider_addmultiplesurfacefbx", "test.pxmesh")
|
||||
|
||||
helper.init_idle()
|
||||
# 1) Load the empty level
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 2) Create an entity
|
||||
test_entity = Entity.create_editor_entity("test_entity")
|
||||
Report.result(Tests.create_entity, test_entity.id.IsValid())
|
||||
|
||||
# 3) Add Mesh and Physics collider components
|
||||
mesh_component = test_entity.add_component("Mesh")
|
||||
Report.result(Tests.mesh_added, test_entity.has_component("Mesh"))
|
||||
|
||||
collider_component = test_entity.add_component("PhysX Collider")
|
||||
Report.result(Tests.physx_collider_added, test_entity.has_component("PhysX Collider"))
|
||||
|
||||
# 4) Select the PhysicsAsset shape in the PhysX Collider component
|
||||
collider_component.set_component_property_value("Shape Configuration|Shape", PHYSICS_ASSET_INDEX)
|
||||
value_to_test = collider_component.get_component_property_value("Shape Configuration|Shape")
|
||||
Report.result(Tests.shape_is_correct, value_to_test == PHYSICS_ASSET_INDEX)
|
||||
|
||||
# 5) Assign the fbx file in PhysX Mesh and Mesh component
|
||||
px_asset = Asset.find_asset_by_path(PHYSX_MESH)
|
||||
collider_component.set_component_property_value("Shape Configuration|Asset|PhysX Mesh", px_asset.id)
|
||||
px_asset.id = collider_component.get_component_property_value("Shape Configuration|Asset|PhysX Mesh")
|
||||
Report.result(Tests.assign_px_mesh_asset, px_asset.get_path() == PHYSX_MESH.replace(os.sep, "/"))
|
||||
|
||||
mesh_asset = Asset.find_asset_by_path(STATIC_MESH)
|
||||
mesh_component.set_component_property_value("MeshComponentRenderNode|Mesh asset", mesh_asset.id)
|
||||
mesh_asset.id = mesh_component.get_component_property_value("MeshComponentRenderNode|Mesh asset")
|
||||
Report.result(Tests.assign_mesh_asset, mesh_asset.get_path() == STATIC_MESH.replace(os.sep, "/"))
|
||||
|
||||
# 6) Check if multiple material slots show up under Materials section in the PhysX Collider component
|
||||
pte = collider_component.get_property_tree()
|
||||
def get_surface_count():
|
||||
count = pte.get_container_count("Collider Configuration|Physics Material|Mesh Surfaces")
|
||||
return count.GetValue()
|
||||
|
||||
Report.result(
|
||||
Tests.count_mesh_surface, helper.wait_for_condition(lambda: get_surface_count() == SURFACE_TAG_COUNT, 1.0)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
Reference in New Issue
Block a user