Пример #1
0
def create_white_box_component(entityId):
    whiteBoxMeshComponentTypeId = get_white_box_component_type()

    whiteBoxMeshComponentOutcome = editor.EditorComponentAPIBus(
        bus.Broadcast, 'AddComponentsOfType', entityId,
        [whiteBoxMeshComponentTypeId])
    whiteBoxMeshComponents = whiteBoxMeshComponentOutcome.GetValue()
    whiteBoxMeshComponent = whiteBoxMeshComponents[0]
    editor.EditorComponentAPIBus(bus.Broadcast, 'EnableComponents',
                                 whiteBoxMeshComponents)

    return whiteBoxMeshComponent
Пример #2
0
def get_white_box_component_type():
    typeIdsList = editor.EditorComponentAPIBus(bus.Broadcast,
                                               'FindComponentTypeIds',
                                               ["White Box"])
    whiteBoxMeshComponentTypeId = typeIdsList[0]

    return whiteBoxMeshComponentTypeId
Пример #3
0
def get_white_box_component_type():
    typeIdsList = editor.EditorComponentAPIBus(
        bus.Broadcast, 'FindComponentTypeIdsByEntityType', ['White Box'],
        EntityType().Game)
    whiteBoxMeshComponentTypeId = typeIdsList[0]

    return whiteBoxMeshComponentTypeId
Пример #4
0
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.
"""

# setup path
import azlmbr.legacy.general as general
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.entity
import azlmbr.object
import azlmbr.math
import azlmbr.whitebox.api as api
from azlmbr.entity import EntityId

# get Component Type for WhiteBoxMesh
typeIdsList = editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeIds', ["White Box"])
whiteBoxMeshComponentTypeId = typeIdsList[0]

# use old White Box entity to hold White Box component if it exists, otherwise use a new one
newEntityId = None
oldEntityId = general.find_editor_entity('WhiteBox')

if oldEntityId.IsValid():
    whiteBoxMeshComponentExists = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', oldEntityId, whiteBoxMeshComponentTypeId)
    if (whiteBoxMeshComponentExists):
        oldwhiteBoxMeshComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', oldEntityId, whiteBoxMeshComponentTypeId)
        editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [oldwhiteBoxMeshComponent.GetValue()])
        newEntityId = oldEntityId
else:
    newEntityId = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', EntityId())
    editor.EditorEntityAPIBus(bus.Event, 'SetName', newEntityId, "WhiteBox")
Пример #5
0
def generate_blast_slice_asset(chunkNameList, request):
    # get list of relative chunk paths
    fbxFilename = get_source_fbx_filename(request)
    assetPaths = convert_to_asset_paths(fbxFilename, request.watchFolder,
                                        chunkNameList)

    outcome = azlmbr.asset.entity.PythonBuilderRequestBus(
        bus.Broadcast, 'CreateEditorEntity', 'BlastData')
    if (outcome.IsSuccess() is False):
        raise_error('could not create an editor entity')
    blastDataEntityId = outcome.GetValue()

    # create a component for the editor entity
    gameType = azlmbr.entity.EntityType().Game
    blastMeshDataTypeIdList = editor.EditorComponentAPIBus(
        bus.Broadcast, 'FindComponentTypeIdsByEntityType',
        ["Blast Slice Storage Component"], gameType)
    componentOutcome = editor.EditorComponentAPIBus(bus.Broadcast,
                                                    'AddComponentOfType',
                                                    blastDataEntityId,
                                                    blastMeshDataTypeIdList[0])
    if (componentOutcome.IsSuccess() is False):
        raise_error(
            'failed to add component (Blast Slice Storage Component) to the blast_slice'
        )

    # build the blast slice using the chunk asset paths
    blastMeshComponentId = componentOutcome.GetValue()[0]
    outcome = editor.EditorComponentAPIBus(bus.Broadcast,
                                           'BuildComponentPropertyTreeEditor',
                                           blastMeshComponentId)
    if (outcome.IsSuccess() is False):
        raise_error(
            f'failed to create Property Tree Editor for component ({blastMeshComponentId})'
        )
    pte = outcome.GetValue()
    pte.set_visible_enforcement(True)
    pte.set_value('Mesh Paths', assetPaths)

    # write out an object stream with the extension of .blast_slice
    basePath, sceneFile = os.path.split(request.sourceFile)
    blastFilename = os.path.splitext(sceneFile)[0] + '.blast_slice'
    blastFilename = os.path.join(basePath, blastFilename)
    blastFilename = blastFilename.replace('\\', '/').lower()
    tempFilename = os.path.join(request.tempDirPath, blastFilename)
    entityList = [blastDataEntityId]
    makeDynamic = False
    outcome = azlmbr.asset.entity.PythonBuilderRequestBus(
        bus.Broadcast, 'WriteSliceFile', tempFilename, entityList, makeDynamic)
    if (outcome.IsSuccess() is False):
        raise_error(
            f'WriteSliceFile failed for blast_slice file ({blastFilename})')

    # return a job product
    blastSliceAsset = azlmbr.blast.BlastSliceAsset()
    subId = binascii.crc32(blastFilename.encode('utf8'))
    product = azlmbr.asset.builder.JobProduct(blastFilename,
                                              blastSliceAsset.GetAssetTypeId(),
                                              subId)
    product.dependenciesHandled = True
    return product