-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCameraman.s3d
61 lines (53 loc) · 1.35 KB
/
Cameraman.s3d
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _CAMERAMAN
#define _CAMERAMAN
class Cameraman
{
var size;
var objs;
var head;
var tail;
Add(camera, endPos, endTarget, speed);
Update();
};
function Cameraman::Cameraman()
{
size = 6;
objs = Array(size);
head = 0;
tail = 0;
}
function Cameraman::Add(camera, endPos, endTarget, speed)
{
var s = speed != Void ? speed : 0.01;
objs[tail] = {0.0, camera, camera.GetPosition(), camera.GetTarget(), endPos, endTarget, s};
tail = (tail + 1) % size;
}
function Cameraman::Update()
{
var i = head;
while(i != tail)
{
var o = objs[i];
var t = o[0];
if(t < 1.0)
{
t = t + o[6];//0.01;
o[0] = t;
if(t > 0.0)
{
var newPosition = [o[2][0] * (1-t) + o[4][0] * t,
o[2][1] * (1-t) + o[4][1] * t,
o[2][2] * (1-t) + o[4][2] * t];
o[1].SetPosition(newPosition);
var newTarget = [ o[3][0] * (1-t) + o[5][0] * t,
o[3][1] * (1-t) + o[5][1] * t,
o[3][2] * (1-t) + o[5][2] * t];
o[1].SetTarget(newTarget);
}
}
else if(i == head)
head = (head + 1) % size;
i = (i+1) % size;
}
}
#endif