diff options
author | Melanie Thielker | 2014-09-25 21:53:32 +0200 |
---|---|---|
committer | Melanie Thielker | 2014-09-25 21:53:32 +0200 |
commit | 2e6fd6536b9359dbd7802c5db0bfe092644f838d (patch) | |
tree | f4bc2bed7ea763b2d45fb7148889f1e5bf6c3504 /OpenSim/Framework/AnimationSet.cs | |
parent | Extend upload verification to all upload paths (diff) | |
download | opensim-SC_OLD-2e6fd6536b9359dbd7802c5db0bfe092644f838d.zip opensim-SC_OLD-2e6fd6536b9359dbd7802c5db0bfe092644f838d.tar.gz opensim-SC_OLD-2e6fd6536b9359dbd7802c5db0bfe092644f838d.tar.bz2 opensim-SC_OLD-2e6fd6536b9359dbd7802c5db0bfe092644f838d.tar.xz |
Add the AnimationSet skel
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/AnimationSet.cs | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/OpenSim/Framework/AnimationSet.cs b/OpenSim/Framework/AnimationSet.cs new file mode 100644 index 0000000..8b6baab --- /dev/null +++ b/OpenSim/Framework/AnimationSet.cs | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Framework | ||
33 | { | ||
34 | public delegate bool Validator(UUID animID); | ||
35 | |||
36 | public class AnimationSet | ||
37 | { | ||
38 | private readonly int m_maxAnimations = 255; | ||
39 | |||
40 | public int AnimationCount { get; private set; } | ||
41 | private Dictionary<int, UUID> m_animations = new Dictionary<int, UUID>(); | ||
42 | |||
43 | public UUID AnimationAt(int index) | ||
44 | { | ||
45 | if (m_animations.ContainsKey(index)) | ||
46 | return m_animations[index]; | ||
47 | return UUID.Zero; | ||
48 | } | ||
49 | |||
50 | public void SetAnimation(int index, UUID animation) | ||
51 | { | ||
52 | if (index < 0 || index > m_maxAnimations) | ||
53 | return; | ||
54 | |||
55 | m_animations[index] = animation; | ||
56 | } | ||
57 | |||
58 | public AnimationSet(Byte[] assetData) | ||
59 | { | ||
60 | if (assetData.Length < 2) | ||
61 | throw new System.ArgumentException(); | ||
62 | |||
63 | if (assetData[0] != 1) // Only version 1 is supported | ||
64 | throw new System.ArgumentException(); | ||
65 | |||
66 | AnimationCount = assetData[1]; | ||
67 | if (assetData.Length - 2 != 16 * AnimationCount) | ||
68 | throw new System.ArgumentException(); | ||
69 | |||
70 | // TODO: Read anims from blob | ||
71 | } | ||
72 | |||
73 | public Byte[] ToBytes() | ||
74 | { | ||
75 | // TODO: Make blob from anims | ||
76 | return new Byte[0]; | ||
77 | } | ||
78 | |||
79 | public bool Validate(Validator val) | ||
80 | { | ||
81 | List<int> badAnims = new List<int>(); | ||
82 | |||
83 | bool allOk = true; | ||
84 | foreach (KeyValuePair<int, UUID> kvp in m_animations) | ||
85 | { | ||
86 | if (!val(kvp.Value)) | ||
87 | { | ||
88 | allOk = false; | ||
89 | badAnims.Add(kvp.Key); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | foreach (int idx in badAnims) | ||
94 | m_animations.Remove(idx); | ||
95 | |||
96 | return allOk; | ||
97 | } | ||
98 | } | ||
99 | } | ||