Example #1
0
    def cap_scenes():
        import hs, os.path, UserData

        _path = os.path.abspath(os.path.join(UserData.Create("cap"), 'sister'))
        if not os.path.exists(_path): os.makedirs(_path)

        hs.move_camera(pos=(0.0, 0.8, 0.0),
                       dir=(0.0, 0.0, -2.3),
                       angle=(21.9, 169.7, 0.0),
                       fov=23.0)
        # begin females
        hsfem = hs.HSFemale.create_female('[GX]Sister', attach=True)
        hsfem.load_animation('h/anim/female/00.unity3d', 'ha_f_02')
        hsfem.move(pos=(0.0, 0.1, -0.6), rot=(7.4, 3.2, 356.0))
        hsfem.chara.SetActiveTop(True)
        hsfem.chara.ChangeBlinkFlag(False)
        hsfem.chara.ChangeEyesPtn(28, True)
        hsfem.chara.ChangeMouthPtn(16, True)
        hsfem.chara.ChangeLookNeckPtn(1)
        hsfem.chara.ChangeLookEyesPtn(1)
        hsfem.set_clothes_state_all(2)
        # begin items
        item = hs.HSItem.create_item('Bathtub (Yellow)')
        item.move(pos=(0.0, 0.0, 0.0), rot=(0.0, 0.0, 0.0))
        yield os.path.join(_path, 'dailybath (3).png')

        yield None
Example #2
0
def play_actions(hsfem, rootname, moodmap, clothset):
    import os, time
    import hs
    import UserData, YS_Assist
    from collections import OrderedDict as od
    from UnityEngine import Time

    if hsfem == None:
        hsfem = hs.get_first_active_female()
    elif isinstance(hsfem, str):
        hsfem = create_female(hsfem)
    if not isinstance(hsfem, hs.HSFemale):
        yield None

    hsfem.reset()

    _path = os.path.abspath(os.path.join(UserData.Create("cap"), rootname))

    aplayer = None
    for cloth, clothes in clothset.iteritems():
        for k, v in clothes.iteritems():
            if k == 'clothes':
                hsfem.apply_clothes(v)
                hsfem.enable_clothes(0)
            elif k == 'state':
                hsfem.enable_clothes(v)
            elif k == 'acc':
                hsfem.enable_accessories(v)

        for mood, states in moodmap.iteritems():
            _subdir = os.path.join(_path, mood)
            if not os.path.exists(_subdir): os.makedirs(_subdir)
            fname = os.path.join(_subdir, cloth + ".png")

            # speed up time so captures dont miss
            oldTimeScale = Time.timeScale
            Time.timeScale = 5.0
            try:
                for k, v in states.iteritems():
                    if k == 'persona':
                        if not aplayer or aplayer.personality != v:
                            aplayer = hsfem.load_personality(v)
                    elif k == 'action':
                        if aplayer: aplayer.play(v)
                    elif k == 'mood':
                        hsfem.set_mood(v)
            finally:
                Time.timeScale = oldTimeScale

            yield fname

    yield None
Example #3
0
def capture_noblock(_path='', _alpha=True, autofit=True):
    import System
    import Manager
    from System import *
    from System.IO import *
    from UnityEngine import *
    from UnityEngine import Object as Object
    from UnityEngine import Time as Time
    width = Screen.width
    height = Screen.height
    tex = Texture2D(
        width, height,
        TextureFormat.RGB24 if not _alpha else TextureFormat.ARGB32, False)
    tex2 = Texture2D(
        width, height,
        TextureFormat.RGB24 if not _alpha else TextureFormat.ARGB32, False)
    if QualitySettings.antiAliasing != 0:
        rt = RenderTexture.GetTemporary(width, height,
                                        0x18 if not _alpha else 0x20,
                                        RenderTextureFormat.Default,
                                        RenderTextureReadWrite.Default,
                                        QualitySettings.antiAliasing)
        rt2 = RenderTexture.GetTemporary(width, height,
                                         0x18 if not _alpha else 0x20,
                                         RenderTextureFormat.Default,
                                         RenderTextureReadWrite.Default,
                                         QualitySettings.antiAliasing)
    else:
        rt = RenderTexture.GetTemporary(width, height,
                                        0x18 if not _alpha else 0x20)
        rt2 = RenderTexture.GetTemporary(width, height,
                                         0x18 if not _alpha else 0x20)
    #RenderCam = Camera.main
    RenderCam = Manager.Studio.Instance.MainCamera
    backRenderTexture = RenderCam.targetTexture
    backRect = RenderCam.rect
    oldBackground = RenderCam.backgroundColor
    oldFlags = RenderCam.clearFlags
    RenderCam.backgroundColor = Color(Single(1), Single(1), Single(1),
                                      Single(1))
    RenderCam.clearFlags = CameraClearFlags.Color
    RenderCam.targetTexture = rt
    RenderCam.Render()
    RenderCam.targetTexture = backRenderTexture
    RenderCam.rect = backRect
    RenderTexture.active = rt
    tex.ReadPixels(Rect(Single(0), Single(0), width, height), 0, 0)
    tex.Apply()
    RenderTexture.active = None
    RenderCam.backgroundColor = Color(Single(0), Single(0), Single(0),
                                      Single(1))
    RenderCam.clearFlags = CameraClearFlags.Color
    RenderCam.targetTexture = rt2
    RenderCam.Render()
    RenderCam.targetTexture = backRenderTexture
    RenderCam.rect = backRect
    RenderTexture.active = rt2
    tex2.ReadPixels(Rect(Single(0), Single(0), width, height), 0, 0)
    tex2.Apply()
    RenderTexture.active = None
    RenderCam.backgroundColor = oldBackground
    RenderCam.clearFlags = oldFlags
    RenderTexture.ReleaseTemporary(rt)
    RenderTexture.ReleaseTemporary(rt2)

    cols1 = tex.GetPixels()
    cols2 = tex2.GetPixels()
    x1, x2 = width, 0
    y1, y2 = height, 0

    for i in xrange(0, cols1.Length - 1):
        c1 = cols1[i]
        c2 = cols2[i]
        a = 1.0
        if c1 != c2:
            a = Single(1) - Math.Max(
                Math.Abs(c1.r - c2.r),
                Math.Max(Math.Abs(c1.g - c2.g), Math.Abs(c1.b - c2.b)))
        else:
            a = Single(
                1) if c1.a < 0.05 else c1.a  # handle bad alpha rendering
        cols1[i] = Color(c1.r, c1.g, c1.b, a)
        if autofit and a > 0.05:
            y = i // width
            x = i - y * width
            if x < x1: x1 = x
            if x > x2: x2 = x
            if y < y1: y1 = y
            if y > y2: y2 = y
    if autofit:

        def irnd(x):
            return x + x % 2

        # add padding then truncate
        padding = 4
        x1, y1 = max(0, irnd(x1 - padding)), max(0, irnd(y1 - padding))
        x2, y2 = min(width, irnd(x2 + padding)), min(height,
                                                     irnd(y2 + padding))
        Object.Destroy(tex)
        w, h = x2 - x1, y2 - y1
        tex = Texture2D(x2 - x1, y2 - y1, TextureFormat.ARGB32, False)
        cols = tex.GetPixels()
        for i in range(x1, x2):
            for j in range(y1, y2):
                cols[(j - y1) * w + (i - x1)] = cols1[j * width + i]
        tex.SetPixels(cols)
        tex.Apply()
    else:
        tex.SetPixels(cols1)
        tex.Apply()
    bytes = tex.EncodeToPNG()
    Object.Destroy(tex)
    tex = None
    if str.Empty == _path:
        import UserData, datetime
        _path = UserData.Create("cap")
        fileName = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')[:-3]
        _path = Path.GetFullPath(Path.Combine(_path, fileName + ".png"))
        Console.WriteLine("Capture: " + _path)
    File.WriteAllBytes(_path, bytes)
    return True
Example #4
0
def play_actions(hsfem=None, rootname='mother'):
    import os, time
    import hs
    import UserData, YS_Assist
    from collections import OrderedDict as od
    from UnityEngine import Time

    if hsfem == None:
        hsfem = hs.get_first_active_female()
    elif isinstance(hsfem, str):
        hsfem = create_female(hsfem)
    if isinstance(hsfem, hs.HSFemale):
        hsfem.reset()

        #All clothes on
        #hsfem.enable_clothes(0)
        #yield True
        _path = os.path.abspath(os.path.join(UserData.Create("cap"), rootname))

        moodmap = {
            'normal': od(persona='Strict', action='Normal Wait',
                         mood='normal'),
            'angry': od(persona='Strict', action='Hate', mood='angry'),
            'sad': od(persona='Strict', action='Hate 2', mood='sad'),
            'happy': od(persona='Strict', action='Lewd', mood='happy'),
            'hypno': od(persona='Withdrawn',
                        action='Normal Wait',
                        mood='hypno'),
            'surprised': od(persona='Boyish', action='Like', mood='surprised'),
        }
        clothset = {
            'bath': od(
                name='Bath Towel',
                acc=0,
            ),
            'casual': od(
                name='G|Mother Casual',
                acc=1,
            ),
            'naked': od(name='G|Mother Casual', acc=0, state=2),
            'swimsuit': od(
                name='G|Orange Swim',
                acc=0,
            ),
            'underwear': od(
                name='G|Black Lace',
                acc=1,
            ),
            'work': od(
                name='G|Mother Work',
                acc=1,
            ),
        }

        aplayer = None
        for cloth, clothes in clothset.iteritems():
            for k, v in clothes.iteritems():
                if k == 'name':
                    hsfem.apply_clothes(v)
                    hsfem.enable_clothes(0)
                elif k == 'state':
                    hsfem.enable_clothes(v)
                elif k == 'acc':
                    hsfem.enable_accessories(v)

            for mood, states in moodmap.iteritems():
                _subdir = os.path.join(_path, mood)
                if not os.path.exists(_subdir): os.makedirs(_subdir)
                fname = os.path.join(_subdir, cloth + ".png")

                oldTimeScale = Time.timeScale
                Time.timeScale = 5.0
                try:
                    for k, v in states.iteritems():
                        if k == 'persona':
                            if not aplayer or aplayer.personality != v:
                                aplayer = hsfem.load_personality(v)
                        elif k == 'action':
                            if aplayer: aplayer.play(v)
                        elif k == 'mood':
                            hsfem.set_mood(v)
                finally:
                    Time.timeScale = oldTimeScale
                print fname
                time.sleep(0.5)
                hs.capture(fname)

                yield True

        # loads related animations by character name

        #for name in aplayer.names:
        #    aplayer.play(name)  # names available in aplayer.names
        #    yield True

        #hsfem.set_mood('angry')
        #hsfem.set_hand_position('l', 'dummy')
        #hsfem.set_hand_position('r', 'goo') #fist

    yield None
Example #5
0
    def cap_scenes():
        import hs, os.path, UserData

        _path = os.path.abspath(os.path.join(UserData.Create("cap"), 'mother'))
        if not os.path.exists(_path): os.makedirs(_path)

        # surprise
        hs.move_camera(pos=(0.0, 0.9, 0.0),
                       dir=(0.0, 0.0, -5.0),
                       angle=(8.5, 184.4, 0.0),
                       fov=23.0)
        # begin females
        hsfem = hs.HSFemale.create_female('[GX] Mother', attach=True)
        #hsfem.load_animation('adv/00.unity3d', 'adv_f_01_00')
        hsfem.play_ik('G Cover')
        hsfem.move(pos=(0.0, 0.0, 0.0), rot=(0.0, 0.0, 0.0))
        hsfem.chara.SetActiveTop(True)
        hsfem.chara.ChangeBlinkFlag(False)
        hsfem.chara.ChangeEyesPtn(11, True)
        hsfem.chara.ChangeMouthPtn(7, True)
        hsfem.chara.ChangeLookNeckPtn(3)
        hsfem.chara.ChangeLookEyesPtn(1)
        hsfem.set_clothes_state_all(2)
        hsfem.enable_accessories(0)
        yield os.path.join(_path, 'dailybath (1).png')

        hs.move_camera(pos=(-0.5, 1.0, 0.0),
                       dir=(0.0, 0.0, -3.8),
                       angle=(24.5, 193.4, 0.0),
                       fov=23.0)
        hsfem.reset()
        #hsfem.load_animation('adv/00.unity3d', 'adv_f_07_00')
        hsfem.play_ik('G Bath Step')
        hsfem.move(pos=(-0.5, -0.3, 0.0), rot=(359.2, 129.0, 359.4))
        hsfem.chara.ChangeBlinkFlag(False)
        hsfem.chara.ChangeEyesPtn(1, True)
        hsfem.chara.ChangeMouthPtn(1, True)
        hsfem.chara.ChangeLookNeckPtn(5)
        hsfem.chara.ChangeLookEyesPtn(1)
        hsfem.set_clothes_state_all(2)
        hsfem.enable_accessories(0)
        # begin items
        item = hs.HSItem.create_item('Bathtub (Yellow)', attach=True)
        item.move(pos=(0.2, -0.1, 0.0), rot=(0.0, 23.0, 4.0))
        yield os.path.join(_path, 'dailybath (2).png')

        hs.move_camera(pos=(-0.4, 0.5, -0.1),
                       dir=(0.0, 0.0, -3.5),
                       angle=(34.0, 157.1, -1.8),
                       fov=23.0)
        # begin females
        hsfem.reset()
        hsfem.load_animation('custom/cf_anim_custom.unity3d', 'edit_F')
        hsfem.play_ik('G Sit Bath 2')
        hsfem.move(pos=(0.0, 0.2, -0.6), rot=(359.7, 7.1, 1.0))
        hsfem.chara.ChangeBlinkFlag(True)
        hsfem.chara.ChangeEyesPtn(5, True)
        hsfem.chara.ChangeMouthPtn(1, True)
        hsfem.chara.ChangeLookNeckPtn(3)
        hsfem.chara.ChangeLookEyesPtn(0)
        hsfem.set_clothes_state_all(2)
        hsfem.enable_accessories(1)
        # begin items
        item = hs.HSItem.create_item('Bathtub (Yellow)', attach=True)
        item.move(pos=(0.0, 0.0, 0.0), rot=(0.0, 0.0, 0.0))
        yield os.path.join(_path, 'dailybath (3).png')

        yield None