示例#1
0
 def CreateComponent(self, name, state):
     component = PointLightClientComponent()
     renderObject = trinity.Tr2InteriorLightSource()
     component.renderObject = renderObject
     graphicWrappers.Wrap(renderObject)
     component.originalPrimaryLighting = bool(state['primaryLighting'])
     component.performanceLevel = state['performanceLevel']
     renderObject.SetColor((state['red'], state['green'], state['blue']))
     renderObject.SetRadius(state['radius'])
     renderObject.SetFalloff(state['falloff'])
     renderObject.shadowImportance = state['shadowImportance']
     renderObject.primaryLighting = bool(state['primaryLighting'])
     renderObject.affectTransparentObjects = bool(state['affectTransparentObjects'])
     renderObject.shadowResolution = int(state['shadowResolution'])
     renderObject.shadowCasterTypes = int(state['shadowCasterTypes'])
     renderObject.projectedTexturePath = state['projectedTexturePath'].encode()
     renderObject.importanceScale = state['importanceScale']
     renderObject.importanceBias = state['importanceBias']
     renderObject.enableShadowLOD = bool(state['enableShadowLOD'])
     renderObject.specularIntensity = float(state.get('specularIntensity', '1'))
     renderObject.useKelvinColor = bool(state['useKelvinColor'])
     customMaterialResPath = state.get('customMaterialPath', '')
     if customMaterialResPath != '':
         renderObject.customMaterial = trinity.Load(customMaterialResPath)
     renderObject.useKelvinColor = bool(state['useKelvinColor'])
     if renderObject.useKelvinColor:
         renderObject.kelvinColor.temperature = state['temperature']
         renderObject.kelvinColor.tint = state['tint']
         renderObject.kelvinColor.whiteBalance = int(state['whiteBalance'])
     component.originalShadowCasterTypes = renderObject.shadowCasterTypes
     component.renderObject.name = self.GetName(state['_spawnID'])
     return component
示例#2
0
def CreateScene3d(tex):
    scene = trinity.Tr2InteriorScene()
    room = trinity.Load(
        'res:/Graphics/Interior/Unique/Test/Test1/Test1WodInteriorStatic.red')
    cell = trinity.Tr2InteriorCell()
    scene.cells.append(cell)
    room.rotation = (0.0, -0.44663557410240173, 0.0, 0.8947159647941589)
    scene.sunDirection = (0.4367, -0.3684, 0.8207)
    scene.shadowCubeMap.enabled = True
    lightSource = trinity.Tr2InteriorLightSource()
    lightSource.radius = 12.0
    lightSource.falloff = 0.6
    lightSource.position = (1.308, 1.7335, 1.4637)
    lightSource.color = (306.0 / 255.0, 238.79999999999998 / 255.0,
                         212.4 / 255.0)
    scene.AddLightSource(lightSource)
    lightSource = trinity.Tr2InteriorLightSource()
    lightSource.radius = 12.0
    lightSource.falloff = 0.6
    lightSource.position = (1.7305, 2.0731, -1.7867)
    lightSource.color = (266.4 / 255.0, 279.59999999999997 / 255.0,
                         306.0 / 255.0)
    scene.AddLightSource(lightSource)
    lightSource = trinity.Tr2InteriorLightSource()
    lightSource.radius = 12.0
    lightSource.falloff = 0.6
    lightSource.position = (-1.7793, 1.016, 0.1315)
    lightSource.color = (115.19999999999999 / 255.0, 147.6 / 255.0,
                         222.0 / 255.0)
    scene.AddLightSource(lightSource)
    scene.sunDiffuseColor = (44.0 / 255.0, 35.0 / 255.0, 35.0 / 255.0, 1.0)
    scene.ambientColor = (0.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0)
    screen = trinity.Tr2InteriorPlaceable()
    screen.placeableResPath = 'res:/Graphics/Placeable/UI/SimpleQuad/SimpleQuad.red'
    texParams = screen.placeableRes.Find('trinity.TriTexture2DParameter')
    diffuseMap = None
    for each in texParams:
        if each.name == 'DiffuseMap':
            diffuseMap = each
            break

    if diffuseMap:
        diffuseMap.SetResource(tex)
    screen.translation = (1, 2, 0)
    screen.rotation = geo2.QuaternionRotationSetYawPitchRoll(-0.6, 0.3, 0.1)
    scene.AddDynamic(screen)
    return (scene, screen)
示例#3
0
def CreateEmptyScene():
    scene = trinity.Tr2InteriorScene()
    cell = trinity.Tr2InteriorCell()
    cell.isUnbounded = True
    scene.cells.append(cell)
    light1 = trinity.Tr2InteriorLightSource()
    light1.radius = 100.0
    light1.position = (0.0, 15.0, 50.0)
    scene.lights.append(light1)
    light2 = trinity.Tr2InteriorLightSource()
    light2.radius = 100.0
    light2.position = (0.0, 15.0, -50.0)
    scene.lights.append(light2)
    light3 = trinity.Tr2InteriorLightSource()
    light3.radius = 100.0
    light3.position = (50.0, 15.0, 0.0)
    scene.lights.append(light3)
    return scene
示例#4
0
 def CreateComponent(self, name, state):
     component = SpotLightClientComponent()
     renderObject = trinity.Tr2InteriorLightSource()
     component.renderObject = renderObject
     graphicWrappers.Wrap(renderObject)
     component.originalPrimaryLighting = bool(state['primaryLighting'])
     component.originalSecondaryLighting = bool(state['secondaryLighting'])
     component.performanceLevel = state['performanceLevel']
     renderObject.SetColor((state['red'], state['green'], state['blue']))
     renderObject.SetRadius(state['radius'])
     renderObject.coneDirection = (state['coneDirectionX'],
                                   state['coneDirectionY'],
                                   state['coneDirectionZ'])
     renderObject.coneAlphaInner = state['coneAlphaInner']
     renderObject.coneAlphaOuter = state['coneAlphaOuter']
     renderObject.SetFalloff(state['falloff'])
     renderObject.shadowImportance = state['shadowImportance']
     renderObject.primaryLighting = bool(state['primaryLighting'])
     renderObject.secondaryLighting = bool(state['secondaryLighting'])
     renderObject.secondaryLightingMultiplier = state[
         'secondaryLightingMultiplier']
     renderObject.affectTransparentObjects = bool(
         state['affectTransparentObjects'])
     renderObject.shadowResolution = int(state['shadowResolution'])
     renderObject.shadowCasterTypes = int(state['shadowCasterTypes'])
     renderObject.projectedTexturePath = state[
         'projectedTexturePath'].encode()
     renderObject.isStatic = bool(state['isStatic'])
     renderObject.importanceScale = state['importanceScale']
     renderObject.importanceBias = state['importanceBias']
     renderObject.enableShadowLOD = bool(state['enableShadowLOD'])
     renderObject.specularIntensity = float(
         state.get('specularIntensity', '1'))
     renderObject.useKelvinColor = bool(state['useKelvinColor'])
     customMaterialResPath = state.get('customMaterialPath', '')
     if customMaterialResPath != '':
         renderObject.customMaterial = trinity.Load(customMaterialResPath)
     if renderObject.useKelvinColor:
         renderObject.kelvinColor.temperature = state['temperature']
         renderObject.kelvinColor.tint = state['tint']
         renderObject.kelvinColor.whiteBalance = int(state['whiteBalance'])
     component.originalShadowCasterTypes = renderObject.shadowCasterTypes
     component.useBoundingBox = bool(state['useBoundingBox'])
     if component.useBoundingBox:
         component.bbPos = util.UnpackStringToTuple(state['bbPos'])
         component.bbRot = util.UnpackStringToTuple(state['bbRot'])
         component.bbScale = util.UnpackStringToTuple(state['bbScale'])
         renderObject.boundingBox = trinity.Tr2InteriorOrientedBoundingBox()
     component.renderObject.name = self.GetName(state['_spawnID'])
     return component