반응형

DOTween의 Sequence 예제


아래와 같은 스크립트를 만든다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
 
public class Tween : MonoBehaviour
{
    public Ease ease;
 
    // Start is called before the first frame update
    void Start()
    {
        // static DOTween.Init(bool recycleAllByDefault = false, bool useSafeMode = true, LogBehaviour logBehaviour = LogBehaviour.ErrorsOnly)
        // Initializes DOTween.
        DOTween.Init(falsetrue, LogBehaviour.ErrorsOnly);
 
        // static DOTween.Sequence()
        // Returns a usable Sequence which you can store and add tweens to.
        Sequence mySeq = DOTween.Sequence();
 
        // Delays and loops (when not infinite) will work even inside nested tweens.
 
        // Append(Tween tween)
        // Adds the given tween to the end of the Sequence.
        mySeq.Append(transform.DOMove(new Vector3(5.0f, 0.0f, 5.0f), 2false).SetEase(ease).SetLoops(3, LoopType.Yoyo));
        mySeq.Append(transform.DOMove(new Vector3(-5.0f, 0.0f, 5.0f), 2false).SetEase(ease).SetLoops(3, LoopType.Yoyo));
        // 첫 번째 DOMove를 3회 반복, 그리고 두 번째 DOMove를 3회 반복 한다. 전체(첫 번째 + 두 번째) DOMove를 3회 반복하는게 아니다.
 
        // Insert a lookat tween for the whole duration of the Sequence
 
        // Insert(float atPosition, Tween tween)
        // Inserts the given tween at the given time position, thus allowing you to overlap tweens instead of just placing them one after each other.
        mySeq.Insert(0, transform.DOLookAt(new Vector3(0.0f, 0.0f, 0.0f), mySeq.Duration()));
        // float Duration(bool includeLoops = true)
        // Returns the duration of the tween(delays excluded, loops included if includeLoops is TRUE).
    }
 
    // Update is called once per frame
    void Update()
    {
 
    }
}
 


스크립트 이름은 Tween으로 지정 한다.


Cube를 생성하고 Tween 스크립트를 추가한다.


Inspector 창의 Tween 스크립트에서 Ease 변수를 In Bounce 등 원하는 ease로 변경한다.


플레이 버튼을 클릭 하면 Cube가 첫 번째 DOMove 3회, 두 번째 DOMove 3회를 반복하며 전체 시간에 걸쳐 원점을 향해 회전 한다.


반응형
Posted by J-sean
:
반응형

Explains how to play image sequence like a video file using OpenCV VideoCapture class.


Camera, video file등 영상을 가져오는 C++ API인 VideoCapture Class로 수백장의 image sequence를 차례로 로드해 영상처럼 재생하는 방법을 설명 합니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <opencv2/opencv.hpp>
 
using namespace cv;
 
int main(int argc, char** argv)
{
    VideoCapture cap("Cat\\Cat_%03d.jpg");
    // image sequence (eg. img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
    if (!cap.isOpened())
        return -1;
 
    Mat frame;
 
    while (1)
    {
        cap.read(frame);
        if (frame.empty())
            break;
 
        imshow("Image", frame);
 
        if (waitKey(33>= 0)
            break;
    }
 
    return 0;
cs




반응형
Posted by J-sean
: