-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkSkeletonAnimationKeys.cxx
75 lines (65 loc) · 2.21 KB
/
vtkSkeletonAnimationKeys.cxx
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "vtkSkeletonAnimationKeys.h"
#include <vtkFloatArray.h>
#include <vtkObjectFactory.h> // For New macro
////-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkSkeletonAnimationKeys)
//-----------------------------------------------------------------------------
vtkSkeletonAnimationKeys::vtkSkeletonAnimationKeys()
{
this->Data = vtkFloatArray::New();
this->Data->SetNumberOfComponents(3); // Default type to POSITION/SCALING
this->TimeData = vtkFloatArray::New();
this->TimeData->SetNumberOfComponents(1);
}
//-----------------------------------------------------------------------------
vtkSkeletonAnimationKeys::~vtkSkeletonAnimationKeys()
{
this->Data->Delete();
this->TimeData->Delete();
}
//-----------------------------------------------------------------------------
void vtkSkeletonAnimationKeys::SetType(vtkSkeletonAnimationKeys::KeyType type)
{
switch (type)
{
case vtkSkeletonAnimationKeys::POSITION:
case vtkSkeletonAnimationKeys::SCALING:
this->Data->SetNumberOfComponents(3);
break;
case vtkSkeletonAnimationKeys::ROTATION:
this->Data->SetNumberOfComponents(4);
break;
default:
break;
}
}
//-----------------------------------------------------------------------------
void vtkSkeletonAnimationKeys::SetNumberOfKeys(int nbKeys)
{
this->Data->SetNumberOfTuples(nbKeys);
this->TimeData->SetNumberOfTuples(nbKeys);
}
//-----------------------------------------------------------------------------
void vtkSkeletonAnimationKeys::InsertNextKey(double* data, double time)
{
this->Data->InsertNextTuple(data);
this->TimeData->InsertNextTuple1(time);
}
//-----------------------------------------------------------------------------
void vtkSkeletonAnimationKeys::SetKey(vtkIdType keyId, double* data, double time)
{
this->Data->SetTuple(keyId, data);
this->TimeData->SetTuple1(keyId, time);
}
//-----------------------------------------------------------------------------
vtkIdType vtkSkeletonAnimationKeys::GetKeyTimeIndex(double time)
{
for (vtkIdType k = 0; k < this->TimeData->GetNumberOfTuples(); k++)
{
if (this->TimeData->GetTuple1(k) > time)
{
return k-1; //WARNING: k == 0
}
}
return 0;
}