示例#1
0
    def _GetCell(self, cellName):
        for cell in self.cells:
            if cell.name == cellName:
                return cell

        cell = trinity.Tr2InteriorCell()
        cell.name = cellName
        cell.shProbeResPath = INTERIOR_RES_PATH + str(
            self.id) + '_' + cellName + '.shp'
        cell.reflectionMapPath = INTERIOR_REFMAP_PATH + 'Cube_%s_%s.dds' % (
            self.id, cellName)
        self.cells.append(cell)
        self._SortCells()
        self._LoadUVData(cellName)
        return cell
    def _GetCell(self, cellName):
        """
        Finds and returns a cell by a specified name and if it can't will add it before returning
        """
        for cell in self.cells:
            if cell.name == cellName:
                return cell

        cell = trinity.Tr2InteriorCell()
        cell.name = cellName
        cell.shProbeResPath = INTERIOR_RES_PATH + str(self.id) + '_' + cellName + '.shp'
        cell.reflectionMapPath = INTERIOR_REFMAP_PATH + 'Cube_%s_%s.dds' % (self.id, cellName)
        self.cells.append(cell)
        self._SortCells()
        self._LoadUVData(cellName)
        return cell
示例#3
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)
示例#4
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
示例#5
0
    def _GetCell(self, cellName):
        for cell in self.cells:
            if cell.name == cellName:
                return cell

        cell = trinity.Tr2InteriorCell()
        cell.name = cellName
        cell.shProbeResPath = INTERIOR_RES_PATH + str(
            self.id) + '_' + cellName + '.shp'
        cell.reflectionMapPath = INTERIOR_REFMAP_PATH + 'Cube_%s_%s.dds' % (
            self.id, cellName)
        cell.irradianceTexturePath = '%s%s_%s_rad.dds' % (INTERIOR_RES_PATH,
                                                          self.id, cell.name)
        cell.directionalIrradianceTexturePath = '%s%s_%s_dir_rad.dds' % (
            INTERIOR_RES_PATH, self.id, cell.name)
        self.cells.append(cell)
        self._LoadUVData(cellName)
        return cell
示例#6
0
    def SetupPickScene(self, doUpdate = True):
        self.pickScene = trinity.Tr2InteriorScene()
        cell = trinity.Tr2InteriorCell()
        cell.isUnbounded = True
        self.pickScene.cells.append(cell)
        if hasattr(self.pickScene, 'updateShadowCubeMap'):
            self.pickScene.updateShadowCubeMap = False
        self.pickAvatarCache = {}
        self.pickAvatar = self.avatar.CopyTo()
        self.pickAvatar.clothMeshes.removeAt(-1)
        foundUpperNude = False
        foundLowerNude = False
        foundHead = False
        torsoClickable = False
        for meshIx in range(len(self.avatar.visualModel.meshes)):
            mesh = self.avatar.visualModel.meshes[meshIx]
            self.pickAvatar.visualModel.meshes[meshIx].SetGeometryRes(mesh.geometry)
            if mesh.name.startswith('topinner'):
                foundUpperNude = True
                if len(mesh.opaqueAreas):
                    torsoClickable |= True
            if mesh.name.startswith('bottominner'):
                foundLowerNude = True
            if mesh.name.startswith('head'):
                foundHead = True

        deleteList = []
        for mesh in self.pickAvatar.visualModel.meshes:
            if mesh.name.startswith('feet') or mesh.name.startswith('hands'):
                deleteList.append(mesh)

        for d in deleteList:
            self.pickAvatar.visualModel.meshes.remove(d)

        self.pickExtraMods = []
        if not foundUpperNude or not torsoClickable:
            deleteList = []
            for mesh in self.pickAvatar.visualModel.meshes:
                if mesh.name.startswith('topinner'):
                    deleteList.append(mesh)

            for d in deleteList:
                self.pickAvatar.visualModel.meshes.remove(d)

            torsoMod = self.factory.CollectBuildData(self.doll.gender, 'topinner/torso_nude')
            self.pickExtraMods.append(torsoMod)
            item = blue.resMan.LoadObject(torsoMod.redfile)
            if item:
                index = 1
                for m in item.meshes:
                    m.name = 'topinner' + str(index)
                    self.pickAvatar.visualModel.meshes.append(m)
                    torsoMod.meshGeometryResPaths[m.name] = m.geometryResPath
                    self.pickAvatarPaths[m.name] = m.geometryResPath
                    index += 1

        index = 1
        for armPart in ['dependants/sleeveslower/standard', 'dependants/sleevesupper/standard']:
            armMod = self.factory.CollectBuildData(self.doll.gender, armPart)
            self.pickExtraMods.append(armMod)
            item = blue.resMan.LoadObject(armMod.redfile)
            if item:
                for m in item.meshes:
                    m.name = 'dependantsnude' + str(index)
                    self.pickAvatar.visualModel.meshes.append(m)
                    armMod.meshGeometryResPaths[m.name] = m.geometryResPath
                    self.pickAvatarPaths[m.name] = m.geometryResPath
                    index += 1

        if not foundLowerNude:
            legMod = self.factory.CollectBuildData(self.doll.gender, 'bottominner/legs_nude')
            self.pickExtraMods.append(legMod)
            item = blue.resMan.LoadObject(legMod.redfile)
            if item:
                index = 1
                for m in item.meshes:
                    m.name = 'bottominner' + str(index)
                    self.pickAvatar.visualModel.meshes.append(m)
                    legMod.meshGeometryResPaths[m.name] = m.geometryResPath
                    self.pickAvatarPaths[m.name] = m.geometryResPath
                    index += 1

        if not foundHead:
            headMod = self.factory.CollectBuildData(self.doll.gender, 'head/head_generic')
            self.pickExtraMods.append(headMod)
            item = blue.resMan.LoadObject(headMod.redfile)
            if item:
                index = 1
                for m in item.meshes:
                    m.name = 'head' + str(index)
                    self.pickAvatar.visualModel.meshes.append(m)
                    headMod.meshGeometryResPaths[m.name] = m.geometryResPath
                    self.pickAvatarPaths[m.name] = m.geometryResPath
                    index += 1

        handMod = self.factory.CollectBuildData(self.doll.gender, 'hands/hands_nude')
        self.pickExtraMods.append(handMod)
        item = blue.resMan.LoadObject(handMod.redfile)
        if item:
            index = 1
            for m in item.meshes:
                m.name = 'hands' + str(index)
                self.pickAvatar.visualModel.meshes.append(m)
                handMod.meshGeometryResPaths[m.name] = m.geometryResPath
                self.pickAvatarPaths[m.name] = m.geometryResPath
                index += 1

        feetMod = self.factory.CollectBuildData(self.doll.gender, 'feet/feet_nude')
        self.pickExtraMods.append(feetMod)
        item = blue.resMan.LoadObject(feetMod.redfile)
        if item:
            index = 1
            for m in item.meshes:
                m.name = 'feet' + str(index)
                self.pickAvatar.visualModel.meshes.append(m)
                feetMod.meshGeometryResPaths[m.name] = m.geometryResPath
                self.pickAvatarPaths[m.name] = m.geometryResPath
                index += 1

        for mesh in self.pickAvatar.visualModel.meshes:
            if len(mesh.decalAreas):
                for decalArea in mesh.decalAreas:
                    mesh.opaqueAreas.append(decalArea)

        self.pickAvatar.animationUpdater = self.avatar.animationUpdater
        self.pickAvatar.worldTransformUpdater = self.avatar.worldTransformUpdater

        def Filter(mesh):
            for f in ['head',
             'topinner',
             'bottominner',
             'hands',
             'feet',
             'dependantsnude']:
                if mesh.name.lower().startswith(f):
                    return True

            return False

        index = 0
        remList = []
        for mesh in self.pickAvatar.visualModel.meshes:
            if not Filter(mesh):
                remList.append(mesh)

        for m in remList:
            self.pickAvatar.visualModel.meshes.remove(m)

        self.pickScene.AddDynamic(self.pickAvatar)
        self.pickScene.RebuildSceneData()
        cameraProj, cameraView = self.GetProjectionAndViewMatrixFunc()
        rj = trinity.CreateRenderJob('ProdPickScene')
        RT = trinity.Tr2RenderTarget(32, 32, 1, trinity.PIXEL_FORMAT.B8G8R8A8_UNORM)
        depth = trinity.Tr2DepthStencil(32, 32, trinity.DEPTH_STENCIL_FORMAT.D24S8)
        rj.PushRenderTarget(RT)
        rj.PushDepthStencil(depth)
        rj.SetStdRndStates(trinity.RM_PICKING)
        rj.SetView(cameraView)
        rj.SetProjection(cameraProj)
        rj.Update(self.pickScene)
        rj.VisibilityQuery()
        rj.RenderScene(self.pickScene)
        rj.PopDepthStencil()
        rj.PopRenderTarget()
        rj.ScheduleOnce()
        trinity.renderJobs.UnscheduleByName('PickSceneUpdate')
        self.updateRenderjob = trinity.CreateRenderJob('PickSceneUpdate')
        self.updateRenderjob.SetView(cameraView)
        self.updateRenderjob.SetProjection(cameraProj)
        self.updateRenderjob.Update(self.pickScene)
        self.updateRenderjob.ScheduleRecurring()
        self.UpdateBlendShapes([], doUpdate=doUpdate)