diff options
Diffstat (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs')
-rw-r--r-- | OpenSim/Framework/PrimitiveBaseShape.cs | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs new file mode 100644 index 0000000..5cdbfb2 --- /dev/null +++ b/OpenSim/Framework/PrimitiveBaseShape.cs | |||
@@ -0,0 +1,214 @@ | |||
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 OpenSim 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 | |||
29 | using System.Xml.Serialization; | ||
30 | using libsecondlife; | ||
31 | |||
32 | namespace OpenSim.Framework | ||
33 | { | ||
34 | public enum ProfileShape : byte | ||
35 | { | ||
36 | Circle = 0, | ||
37 | Square = 1, | ||
38 | IsometricTriangle = 2, | ||
39 | EquilateralTriangle = 3, | ||
40 | RightTriangle = 4, | ||
41 | HalfCircle = 5 | ||
42 | } | ||
43 | |||
44 | public enum HollowShape : byte | ||
45 | { | ||
46 | Same = 0, | ||
47 | Circle = 16, | ||
48 | Square = 32, | ||
49 | Triangle = 48 | ||
50 | } | ||
51 | |||
52 | public enum PCodeEnum : byte | ||
53 | { | ||
54 | Primitive = 9, | ||
55 | Avatar = 47 | ||
56 | } | ||
57 | |||
58 | public enum Extrusion : byte | ||
59 | { | ||
60 | Straight = 16, | ||
61 | Curve1 = 32, | ||
62 | Curve2 = 48, | ||
63 | Flexible = 128 | ||
64 | } | ||
65 | |||
66 | public class PrimitiveBaseShape | ||
67 | { | ||
68 | private static byte[] m_defaultTextureEntry; | ||
69 | |||
70 | public byte PCode; | ||
71 | public ushort PathBegin; | ||
72 | public ushort PathEnd; | ||
73 | public byte PathScaleX; | ||
74 | public byte PathScaleY; | ||
75 | public byte PathShearX; | ||
76 | public byte PathShearY; | ||
77 | public sbyte PathSkew; | ||
78 | public ushort ProfileBegin; | ||
79 | public ushort ProfileEnd; | ||
80 | public LLVector3 Scale; | ||
81 | public byte PathCurve; | ||
82 | public byte ProfileCurve; | ||
83 | public ushort ProfileHollow; | ||
84 | public sbyte PathRadiusOffset; | ||
85 | public byte PathRevolutions; | ||
86 | public sbyte PathTaperX; | ||
87 | public sbyte PathTaperY; | ||
88 | public sbyte PathTwist; | ||
89 | public sbyte PathTwistBegin; | ||
90 | public byte[] TextureEntry; // a LL textureEntry in byte[] format | ||
91 | public byte[] ExtraParams; | ||
92 | |||
93 | public ProfileShape ProfileShape | ||
94 | { | ||
95 | get { return (ProfileShape) (ProfileCurve & 0xf); } | ||
96 | set | ||
97 | { | ||
98 | byte oldValueMasked = (byte) (ProfileCurve & 0xf0); | ||
99 | ProfileCurve = (byte) (oldValueMasked | (byte) value); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | [XmlIgnore] | ||
104 | public HollowShape HollowShape | ||
105 | { | ||
106 | get { return (HollowShape) (ProfileHollow & 0xf0); } | ||
107 | set | ||
108 | { | ||
109 | byte oldValueMasked = (byte) (ProfileHollow & 0xf0); | ||
110 | ProfileHollow = (byte) (oldValueMasked | (byte) value); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | public LLVector3 PrimScale | ||
115 | { | ||
116 | get { return Scale; } | ||
117 | } | ||
118 | |||
119 | static PrimitiveBaseShape() | ||
120 | { | ||
121 | m_defaultTextureEntry = | ||
122 | new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")).ToBytes(); | ||
123 | } | ||
124 | |||
125 | public PrimitiveBaseShape() | ||
126 | { | ||
127 | PCode = (byte) PCodeEnum.Primitive; | ||
128 | ExtraParams = new byte[1]; | ||
129 | TextureEntry = m_defaultTextureEntry; | ||
130 | } | ||
131 | |||
132 | //void returns need to change of course | ||
133 | public virtual void GetMesh() | ||
134 | { | ||
135 | } | ||
136 | |||
137 | public PrimitiveBaseShape Copy() | ||
138 | { | ||
139 | return (PrimitiveBaseShape) MemberwiseClone(); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | public class GenericShape : PrimitiveBaseShape | ||
144 | { | ||
145 | public GenericShape() | ||
146 | : base() | ||
147 | { | ||
148 | } | ||
149 | } | ||
150 | |||
151 | public class BoxShape : PrimitiveBaseShape | ||
152 | { | ||
153 | public BoxShape() | ||
154 | : base() | ||
155 | { | ||
156 | PathCurve = (byte) Extrusion.Straight; | ||
157 | ProfileShape = ProfileShape.Square; | ||
158 | PathScaleX = 100; | ||
159 | PathScaleY = 100; | ||
160 | } | ||
161 | |||
162 | public BoxShape(float side) | ||
163 | : this() | ||
164 | { | ||
165 | SetSide(side); | ||
166 | } | ||
167 | |||
168 | public void SetSide(float side) | ||
169 | { | ||
170 | Scale = new LLVector3(side, side, side); | ||
171 | } | ||
172 | |||
173 | public static BoxShape Default | ||
174 | { | ||
175 | get | ||
176 | { | ||
177 | BoxShape boxShape = new BoxShape(); | ||
178 | |||
179 | boxShape.SetSide(0.5f); | ||
180 | |||
181 | return boxShape; | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | |||
186 | public class CylinderShape : PrimitiveBaseShape | ||
187 | { | ||
188 | public CylinderShape() | ||
189 | : base() | ||
190 | { | ||
191 | PathCurve = (byte) Extrusion.Straight; | ||
192 | ProfileShape = ProfileShape.Circle; | ||
193 | PathScaleX = 100; | ||
194 | PathScaleY = 100; | ||
195 | } | ||
196 | |||
197 | public CylinderShape(float radius, float heigth) | ||
198 | : this() | ||
199 | { | ||
200 | SetRadius(radius); | ||
201 | SetHeigth(heigth); | ||
202 | } | ||
203 | |||
204 | private void SetHeigth(float heigth) | ||
205 | { | ||
206 | Scale.Z = heigth; | ||
207 | } | ||
208 | |||
209 | private void SetRadius(float radius) | ||
210 | { | ||
211 | Scale.X = Scale.Y = radius*2f; | ||
212 | } | ||
213 | } | ||
214 | } \ No newline at end of file | ||