Skip to content

Commit 38507a2

Browse files
committed
update name and config
1 parent 59ee0ce commit 38507a2

9 files changed

Lines changed: 37 additions & 32 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ result, valid = player.play_frame(0.5,
6363

6464
```python
6565
from PySide6.QtCore import Signal
66-
from unity_animation_player import PysideAnimationPlayer
66+
from unity_animation_player import SignalAnimationPlayer
6767

6868
class MyWindow(QWidget):
6969
anim_signal = Signal(dict)
7070

7171
def __init__(self):
7272
super().__init__()
73-
self.player = PysideAnimationPlayer(
73+
self.player = SignalAnimationPlayer(
7474
self.anim_signal,
7575
"animation.anim"
7676
)

docs/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ AnimationPlayer(path: str, stop_time: Optional[float] = None)
125125
}
126126
```
127127

128-
### PysideAnimationPlayer
128+
### SignalAnimationPlayer
129129

130130
Inherits from AnimationPlayer, integrates PySide6 timer for GUI applications.
131131

132132
**Constructor**
133133

134134
```python
135-
PysideAnimationPlayer(signal: Signal, file_path: str, stop_time: float = None, **kwargs)
135+
SignalAnimationPlayer(signal: Signal, file_path: str, stop_time: float = None, **kwargs)
136136
```
137137

138138
**Main Methods**
@@ -444,14 +444,14 @@ def fast_sample_range(player, sample_rate=0.01):
444444

445445
```python
446446
from PySide6.QtCore import Signal
447-
from unity_animation_player import PysideAnimationPlayer
447+
from unity_animation_player import SignalAnimationPlayer
448448

449449
class MyWidget(QWidget):
450450
anim_signal = Signal(dict)
451451

452452
def __init__(self):
453453
super().__init__()
454-
self.player = PysideAnimationPlayer(
454+
self.player = SignalAnimationPlayer(
455455
self.anim_signal,
456456
"animation.anim",
457457
position_ratio=(2.0, 2.0)
@@ -560,7 +560,7 @@ Register event callback function.
560560
- `function`: Callback function
561561
- `args`: Tuple of event parameter names to pass to callback
562562

563-
### PysideAnimationPlayer
563+
### SignalAnimationPlayer
564564

565565
**Methods**
566566

examples/pygame_viewer_example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,12 @@ def apply_2d_transforms(self, frame_data, image_surface):
224224

225225
# 3. Apply rotation
226226
angle = 0
227-
if 'rotation' in frame_data:
228-
angle = frame_data['rotation']
227+
if 'euler' in frame_data:
228+
angle = frame_data['euler']
229229
# If radians convert to degrees (assuming return is radians)
230230
# angle = math.degrees(angle)
231-
elif 'euler' in frame_data:
232-
angle = frame_data['euler']
231+
elif 'rotation' in frame_data:
232+
angle = frame_data['rotation']
233233
# If radians convert to degrees (assuming return is radians)
234234
# angle = math.degrees(angle)
235235

examples/pyside_popup_window_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Base Class
22
from PySide6.QtWidgets import QWidget
33
from PySide6.QtCore import Qt, Signal
4-
from unity_animation_player import PysideAnimationPlayer
4+
from unity_animation_player import SignalAnimationPlayer
55

66
class PopupWindow(QWidget):
77
anim_signal = Signal(dict)
@@ -18,7 +18,7 @@ def __init__(self, anim='examples/AnimationClip/UIAni_Popup_System.anim', **kwar
1818
self.switch_anim(anim, **kwargs)
1919
def switch_anim(self, anim, **kwargs):
2020
self.anim_signal.connect(self.anim_signal_received)
21-
self.animation_player = PysideAnimationPlayer(self.anim_signal, anim, kwargs.get('stop_time', None), **kwargs)
21+
self.animation_player = SignalAnimationPlayer(self.anim_signal, anim, kwargs.get('stop_time', None), **kwargs)
2222

2323
def play_anim(self, mode=1, initial_time=0, initial_invisiable=True):
2424
self.position0 = (self.pos().x(), self.pos().y())

examples/qml_window_example_windows/ball_window.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from PySide6.QtCore import qInstallMessageHandler, QtMsgType
1212
import os
1313

14-
from unity_animation_player import PysideAnimationPlayer
14+
from unity_animation_player import SignalAnimationPlayer
1515
from .popup_window import PopupWindow
1616
from .graph_window import AnimGraphWidget
1717

@@ -60,13 +60,13 @@ def qml_message_handler(mode, context, message):
6060
class ButtonAnimationData(QObject):
6161
"""避免Signal只能作为类属性创建而无法动态创建的问题"""
6262
button_name: str
63-
player: PysideAnimationPlayer
63+
player: SignalAnimationPlayer
6464
signal: Signal = Signal(dict)
6565

6666
def __init__(self, button_name: str):
6767
super().__init__()
6868
self.button_name = button_name
69-
self.player = PysideAnimationPlayer(self.signal, f"examples/AnimationClip/UIAni_Button_Scale.anim")
69+
self.player = SignalAnimationPlayer(self.signal, f"examples/AnimationClip/UIAni_Button_Scale.anim")
7070

7171

7272
class ExampleWindow(PopupWindow):
@@ -103,8 +103,8 @@ def __init__(self) -> None:
103103
self.setup_multiple_animations(self.animated_buttons)
104104

105105
self.ball_animation_signal.connect(self.on_ball_signal_received)
106-
#self.ball_animation_player = PysideAnimationPlayer(self.ball_animation_signal, "examples/AnimationClip/Hihumi_Original_TSS_Interaction01.anim", stop_time=None, position_ratio=(-24000, -6000), path="bone_root/Bip001")
107-
self.ball_animation_player = PysideAnimationPlayer(self.ball_animation_signal, "examples/AnimationClip/T.anim", stop_time=None, position_ratio=(9, 4))
106+
#self.ball_animation_player = SignalAnimationPlayer(self.ball_animation_signal, "examples/AnimationClip/Hihumi_Original_TSS_Interaction01.anim", stop_time=None, position_ratio=(-24000, -6000), path="bone_root/Bip001")
107+
self.ball_animation_player = SignalAnimationPlayer(self.ball_animation_signal, "examples/AnimationClip/T.anim", stop_time=None, position_ratio=(9, 4))
108108

109109
self.ball_animation_player.register_event('eventTriggered', self.event_triggered, ('data',))
110110

examples/qml_window_example_windows/popup_window.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from PySide6.QtWidgets import QWidget
22
from PySide6.QtCore import Qt, Signal
3-
from unity_animation_player import PysideAnimationPlayer
3+
from unity_animation_player import SignalAnimationPlayer
44

55
import time
66

@@ -31,7 +31,7 @@ def play_anim(self, **kwargs):
3131
self.show()
3232

3333
self.anim_signal.connect(self.anim_signal_received)
34-
self.animation_player = PysideAnimationPlayer(self.anim_signal, anim, kwargs.get('stop_time', None), **kwargs)
34+
self.animation_player = SignalAnimationPlayer(self.anim_signal, anim, kwargs.get('stop_time', None), **kwargs)
3535
self.animation_player.play()
3636

3737
def anim_signal_received(self, dic):

unity_animation_player/__init__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
from .animation_player import AnimationPlayer
2-
from .pyside_animation_player import PysideAnimationPlayer
2+
from .signal_animation_player import SignalAnimationPlayer
33
from .animation_events import AnimationEvents
44
from .kwargs import PlayKwargsDict, type_kwargs
55
from .numba_optimized.rational_bezier_interpolator import RationalBezierInterpolation
6-
from .config import USE_JIT
6+
from .numba_optimized.spherical_linear_interpolator import SphericalLinearInterpolation, EulerSphericalLinearInterpolation
7+
from . import config
78

8-
if USE_JIT:
9+
if config.USE_JIT:
910
# Compile in advance
10-
_ = RationalBezierInterpolation(0, 1, 0, 1, 0, 0, 1, 1, 1, 1)
11-
_(0.5)
11+
RationalBezierInterpolation(0, 1, 0, 1, 0, 0, 1, 1, 1, 1)(0.5)
12+
SphericalLinearInterpolation(0, 1, 0, 1, 0, 0, 1, 1, 0, 1)(0.5)
13+
EulerSphericalLinearInterpolation(0, 1, 0, 1, 0, 0, 0, 1)(0.5)
14+
1215

1316
__all__ = [
1417
"AnimationPlayer",
15-
"PysideAnimationPlayer",
18+
"SignalAnimationPlayer",
1619
"AnimationEvents",
1720
"PlayKwargsDict",
18-
"type_kwargs"
21+
"type_kwargs",
22+
"config"
1923
]

unity_animation_player/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
USE_JIT = True
1+
USE_JIT = True
2+
FPS = 60

unity_animation_player/pyside_animation_player.py renamed to unity_animation_player/signal_animation_player.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from typing import Any, Dict, Tuple, Union
2-
from PySide6.QtCore import QTimer, Signal
2+
from qtpy.QtCore import QTimer, Signal
33
from .animation_player import AnimationPlayer
44

55
from .kwargs import type_kwargs
66

7-
from .utils import timer
7+
from .config import FPS
88

9-
class PysideAnimationPlayer(AnimationPlayer):
9+
class SignalAnimationPlayer(AnimationPlayer):
1010
def __init__(self, signal: Signal, file_path: str, stop_time: float = None,
1111
**kwargs: Union[str, bool, Tuple, float]):
1212
"""All available kwargs are listed in kwargs.py"""
@@ -19,7 +19,7 @@ def __init__(self, signal: Signal, file_path: str, stop_time: float = None,
1919
self.mode = 1 # 0: stop, >0: forward_play, <0: backward_play
2020
self.time_reverse = False
2121
self.t = 0
22-
self.delta_t = 1/60
22+
self.delta_t = 1/FPS
2323
self.timer = QTimer()
2424
self.timer.timeout.connect(self._pyside_play_frame)
2525

0 commit comments

Comments
 (0)