You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
"""
|
|
Copyright (c) Contributors to the Open 3D Engine Project.
|
|
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
|
|
SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
"""
|
|
import azlmbr.scene as sceneApi
|
|
from scene_api import scene_data as sceneData
|
|
import uuid
|
|
|
|
def update_manifest(scene):
|
|
graph = sceneData.SceneGraph(scene.graph)
|
|
rootNode = graph.get_root()
|
|
kidNode = graph.get_node_child(rootNode)
|
|
chunkNameList = []
|
|
|
|
siblingNode = graph.get_node_child(kidNode)
|
|
while siblingNode.IsValid():
|
|
chunkGraphName = sceneData.SceneGraphName(graph.get_node_name(siblingNode))
|
|
chunkName = chunkGraphName.get_name()
|
|
chunkNameList.append(chunkName)
|
|
siblingNode = graph.get_node_sibling(siblingNode)
|
|
|
|
sceneManifest = sceneData.SceneManifest()
|
|
|
|
for activeMeshIndex in range(len(chunkNameList)):
|
|
chunkName = chunkNameList[activeMeshIndex]
|
|
meshGroup = sceneManifest.add_mesh_group(chunkName)
|
|
meshGroup['id'] = '{' + str(uuid.uuid5(uuid.NAMESPACE_DNS, scene.sourceFilename + chunkName)) + '}'
|
|
sceneManifest.mesh_group_add_comment(meshGroup, 'auto generated by test_chunks_builder')
|
|
sceneManifest.mesh_group_set_origin(meshGroup, None, 0, 0, 0, 1.0)
|
|
for meshIndex in range(len(chunkNameList)):
|
|
if (activeMeshIndex == meshIndex):
|
|
sceneManifest.mesh_group_select_node(meshGroup, chunkNameList[meshIndex])
|
|
else:
|
|
sceneManifest.mesh_group_unselect_node(meshGroup, chunkNameList[meshIndex])
|
|
|
|
return sceneManifest.export()
|
|
|
|
mySceneJobHandler = None
|
|
|
|
def on_update_manifest(args):
|
|
scene = args[0]
|
|
result = update_manifest(scene)
|
|
global mySceneJobHandler
|
|
mySceneJobHandler.disconnect()
|
|
mySceneJobHandler = None
|
|
return result
|
|
|
|
def main():
|
|
global mySceneJobHandler
|
|
mySceneJobHandler = sceneApi.ScriptBuildingNotificationBusHandler()
|
|
mySceneJobHandler.connect()
|
|
mySceneJobHandler.add_callback('OnUpdateManifest', on_update_manifest)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|