aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/PrimitiveBaseShape.cs
diff options
context:
space:
mode:
authorlbsa712007-12-28 08:34:38 +0000
committerlbsa712007-12-28 08:34:38 +0000
commit8cd72beb86d2a563bdaf88b20aa76d9bafa6b971 (patch)
tree8eaac3b70eb4b62db89cdfc7b854e85fa2430255 /OpenSim/Framework/PrimitiveBaseShape.cs
parent* Patch from Melanie. Thanks Melanie! (diff)
downloadopensim-SC_OLD-8cd72beb86d2a563bdaf88b20aa76d9bafa6b971.zip
opensim-SC_OLD-8cd72beb86d2a563bdaf88b20aa76d9bafa6b971.tar.gz
opensim-SC_OLD-8cd72beb86d2a563bdaf88b20aa76d9bafa6b971.tar.bz2
opensim-SC_OLD-8cd72beb86d2a563bdaf88b20aa76d9bafa6b971.tar.xz
* Moved PrimitiveBaseShape subclasses into factory methods - the subclassing scheme won't hold for serialization
* Extracted out the 'old' AddNewPrimitive that places an object at an exact pos, without the raytracing
Diffstat (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs')
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs106
1 files changed, 48 insertions, 58 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 66511e6..1424395 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -112,22 +112,22 @@ namespace OpenSim.Framework
112 112
113 public ProfileShape ProfileShape 113 public ProfileShape ProfileShape
114 { 114 {
115 get { return (ProfileShape) (ProfileCurve & 0xf); } 115 get { return (ProfileShape)(ProfileCurve & 0xf); }
116 set 116 set
117 { 117 {
118 byte oldValueMasked = (byte) (ProfileCurve & 0xf0); 118 byte oldValueMasked = (byte)(ProfileCurve & 0xf0);
119 ProfileCurve = (byte) (oldValueMasked | (byte) value); 119 ProfileCurve = (byte)(oldValueMasked | (byte)value);
120 } 120 }
121 } 121 }
122 122
123 [XmlIgnore] 123 [XmlIgnore]
124 public HollowShape HollowShape 124 public HollowShape HollowShape
125 { 125 {
126 get { return (HollowShape) (ProfileCurve & 0xf0); } 126 get { return (HollowShape)(ProfileCurve & 0xf0); }
127 set 127 set
128 { 128 {
129 byte oldValueMasked = (byte) (ProfileCurve & 0x0f); 129 byte oldValueMasked = (byte)(ProfileCurve & 0x0f);
130 ProfileCurve = (byte) (oldValueMasked | (byte) value); 130 ProfileCurve = (byte)(oldValueMasked | (byte)value);
131 } 131 }
132 } 132 }
133 133
@@ -145,7 +145,7 @@ namespace OpenSim.Framework
145 145
146 public PrimitiveBaseShape() 146 public PrimitiveBaseShape()
147 { 147 {
148 PCode = (byte) PCodeEnum.Primitive; 148 PCode = (byte)PCodeEnum.Primitive;
149 ExtraParams = new byte[1]; 149 ExtraParams = new byte[1];
150 Textures = m_defaultTexture; 150 Textures = m_defaultTexture;
151 } 151 }
@@ -156,86 +156,76 @@ namespace OpenSim.Framework
156 return shape; 156 return shape;
157 } 157 }
158 158
159 //void returns need to change of course 159 public static PrimitiveBaseShape CreateBox()
160 public virtual void GetMesh()
161 { 160 {
162 } 161 PrimitiveBaseShape shape = Create();
163 162
164 public PrimitiveBaseShape Copy() 163 shape.PathCurve = (byte)Extrusion.Straight;
165 { 164 shape.ProfileShape = ProfileShape.Square;
166 return (PrimitiveBaseShape) MemberwiseClone(); 165 shape.PathScaleX = 100;
167 } 166 shape.PathScaleY = 100;
168 }
169 167
170 public class GenericShape : PrimitiveBaseShape 168 return shape;
171 {
172 public GenericShape()
173 : base()
174 {
175 } 169 }
176 }
177 170
178 public class BoxShape : PrimitiveBaseShape 171 public static PrimitiveBaseShape CreateCylinder()
179 {
180 public BoxShape()
181 : base()
182 { 172 {
183 PathCurve = (byte) Extrusion.Straight; 173 PrimitiveBaseShape shape = Create();
184 ProfileShape = ProfileShape.Square;
185 PathScaleX = 100;
186 PathScaleY = 100;
187 }
188 174
189 public BoxShape(float side) 175 shape.PathCurve = (byte)Extrusion.Curve1;
190 : this() 176 shape.ProfileShape = ProfileShape.Square;
191 {
192 SetSide(side);
193 }
194 177
195 public void SetSide(float side) 178 shape.PathScaleX = 100;
196 { 179 shape.PathScaleY = 100;
197 Scale = new LLVector3(side, side, side); 180
181 return shape;
198 } 182 }
199 183
200 public static BoxShape Default 184 public static PrimitiveBaseShape Default
201 { 185 {
202 get 186 get
203 { 187 {
204 BoxShape boxShape = new BoxShape(); 188 PrimitiveBaseShape boxShape = CreateBox();
205 189
206 boxShape.SetSide(0.5f); 190 boxShape.SetScale(0.5f);
207 191
208 return boxShape; 192 return boxShape;
209 } 193 }
210 } 194 }
211 }
212 195
213 public class CylinderShape : PrimitiveBaseShape 196 public void SetScale(float side)
214 {
215 public CylinderShape()
216 : base()
217 { 197 {
218 PathCurve = (byte) Extrusion.Straight; 198 Scale = new LLVector3(side, side, side);
219 ProfileShape = ProfileShape.Circle;
220 PathScaleX = 100;
221 PathScaleY = 100;
222 } 199 }
223 200
224 public CylinderShape(float radius, float heigth) 201 public void SetHeigth(float heigth)
225 : this()
226 { 202 {
227 SetRadius(radius); 203 Scale.Z = heigth;
228 SetHeigth(heigth);
229 } 204 }
230 205
231 private void SetHeigth(float heigth) 206 public void SetRadius(float radius)
207 {
208 Scale.X = Scale.Y = radius * 2f;
209 }
210
211 //void returns need to change of course
212 public virtual void GetMesh()
232 { 213 {
233 Scale.Z = heigth;
234 } 214 }
235 215
236 private void SetRadius(float radius) 216 public PrimitiveBaseShape Copy()
237 { 217 {
238 Scale.X = Scale.Y = radius*2f; 218 return (PrimitiveBaseShape)MemberwiseClone();
219 }
220
221 public static PrimitiveBaseShape CreateCylinder(float radius, float heigth)
222 {
223 PrimitiveBaseShape shape = CreateCylinder( );
224
225 shape.SetHeigth( heigth );
226 shape.SetRadius( radius );
227
228 return shape;
239 } 229 }
240 } 230 }
241} 231}