aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs203
1 files changed, 200 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index da7ec44..fe1e218 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -90,10 +90,27 @@ namespace OpenSim.Region.Framework.Scenes
90 SCALE = 0x40 90 SCALE = 0x40
91 } 91 }
92 92
93 public enum PrimType : int
94 {
95 BOX = 0,
96 CYLINDER = 1,
97 PRISM = 2,
98 SPHERE = 3,
99 TORUS = 4,
100 TUBE = 5,
101 RING = 6,
102 SCULPT = 7
103 }
104
93 #endregion Enumerations 105 #endregion Enumerations
94 106
95 public class SceneObjectPart : IScriptHost 107 public class SceneObjectPart : IScriptHost
96 { 108 {
109 /// <value>
110 /// Denote all sides of the prim
111 /// </value>
112 public const int ALL_SIDES = -1;
113
97 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 114 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
98 115
99 // use only one serializer to give the runtime a chance to optimize it (it won't do that if you 116 // use only one serializer to give the runtime a chance to optimize it (it won't do that if you
@@ -741,6 +758,9 @@ namespace OpenSim.Region.Framework.Scenes
741 } 758 }
742 } 759 }
743 760
761 /// <value>
762 /// Text color.
763 /// </value>
744 public Color Color 764 public Color Color
745 { 765 {
746 get { return m_color; } 766 get { return m_color; }
@@ -1910,7 +1930,7 @@ namespace OpenSim.Region.Framework.Scenes
1910 foreach (uint localId in startedColliders) 1930 foreach (uint localId in startedColliders)
1911 { 1931 {
1912 if (localId == 0) 1932 if (localId == 0)
1913 return; 1933 continue;
1914 // always running this check because if the user deletes the object it would return a null reference. 1934 // always running this check because if the user deletes the object it would return a null reference.
1915 if (m_parentGroup == null) 1935 if (m_parentGroup == null)
1916 return; 1936 return;
@@ -2046,7 +2066,7 @@ namespace OpenSim.Region.Framework.Scenes
2046 { 2066 {
2047 // always running this check because if the user deletes the object it would return a null reference. 2067 // always running this check because if the user deletes the object it would return a null reference.
2048 if (localId == 0) 2068 if (localId == 0)
2049 return; 2069 continue;
2050 2070
2051 if (m_parentGroup == null) 2071 if (m_parentGroup == null)
2052 return; 2072 return;
@@ -2178,7 +2198,7 @@ namespace OpenSim.Region.Framework.Scenes
2178 foreach (uint localId in endedColliders) 2198 foreach (uint localId in endedColliders)
2179 { 2199 {
2180 if (localId == 0) 2200 if (localId == 0)
2181 return; 2201 continue;
2182 2202
2183 // always running this check because if the user deletes the object it would return a null reference. 2203 // always running this check because if the user deletes the object it would return a null reference.
2184 if (m_parentGroup == null) 2204 if (m_parentGroup == null)
@@ -2981,6 +3001,178 @@ namespace OpenSim.Region.Framework.Scenes
2981 PhysActor.VehicleFlagsRemove(flags); 3001 PhysActor.VehicleFlagsRemove(flags);
2982 } 3002 }
2983 } 3003 }
3004
3005 /// <summary>
3006 /// Set the color of prim faces
3007 /// </summary>
3008 /// <param name="color"></param>
3009 /// <param name="face"></param>
3010 public void SetFaceColor(Vector3 color, int face)
3011 {
3012 Primitive.TextureEntry tex = Shape.Textures;
3013 Color4 texcolor;
3014 if (face >= 0 && face < GetNumberOfSides())
3015 {
3016 texcolor = tex.CreateFace((uint)face).RGBA;
3017 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
3018 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
3019 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
3020 tex.FaceTextures[face].RGBA = texcolor;
3021 UpdateTexture(tex);
3022 return;
3023 }
3024 else if (face == ALL_SIDES)
3025 {
3026 for (uint i = 0; i < GetNumberOfSides(); i++)
3027 {
3028 if (tex.FaceTextures[i] != null)
3029 {
3030 texcolor = tex.FaceTextures[i].RGBA;
3031 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
3032 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
3033 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
3034 tex.FaceTextures[i].RGBA = texcolor;
3035 }
3036 texcolor = tex.DefaultTexture.RGBA;
3037 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
3038 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
3039 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
3040 tex.DefaultTexture.RGBA = texcolor;
3041 }
3042 UpdateTexture(tex);
3043 return;
3044 }
3045 }
3046
3047 /// <summary>
3048 /// Get the number of sides that this part has.
3049 /// </summary>
3050 /// <returns></returns>
3051 public int GetNumberOfSides()
3052 {
3053 int ret = 0;
3054 bool hasCut;
3055 bool hasHollow;
3056 bool hasDimple;
3057 bool hasProfileCut;
3058
3059 PrimType primType = GetPrimType();
3060 HasCutHollowDimpleProfileCut(primType, Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
3061
3062 switch (primType)
3063 {
3064 case PrimType.BOX:
3065 ret = 6;
3066 if (hasCut) ret += 2;
3067 if (hasHollow) ret += 1;
3068 break;
3069 case PrimType.CYLINDER:
3070 ret = 3;
3071 if (hasCut) ret += 2;
3072 if (hasHollow) ret += 1;
3073 break;
3074 case PrimType.PRISM:
3075 ret = 5;
3076 if (hasCut) ret += 2;
3077 if (hasHollow) ret += 1;
3078 break;
3079 case PrimType.SPHERE:
3080 ret = 1;
3081 if (hasCut) ret += 2;
3082 if (hasDimple) ret += 2;
3083 if (hasHollow) ret += 1;
3084 break;
3085 case PrimType.TORUS:
3086 ret = 1;
3087 if (hasCut) ret += 2;
3088 if (hasProfileCut) ret += 2;
3089 if (hasHollow) ret += 1;
3090 break;
3091 case PrimType.TUBE:
3092 ret = 4;
3093 if (hasCut) ret += 2;
3094 if (hasProfileCut) ret += 2;
3095 if (hasHollow) ret += 1;
3096 break;
3097 case PrimType.RING:
3098 ret = 3;
3099 if (hasCut) ret += 2;
3100 if (hasProfileCut) ret += 2;
3101 if (hasHollow) ret += 1;
3102 break;
3103 case PrimType.SCULPT:
3104 ret = 1;
3105 break;
3106 }
3107 return ret;
3108 }
3109
3110 /// <summary>
3111 /// Tell us what type this prim is
3112 /// </summary>
3113 /// <param name="primShape"></param>
3114 /// <returns></returns>
3115 public PrimType GetPrimType()
3116 {
3117 if (Shape.SculptEntry)
3118 return PrimType.SCULPT;
3119 if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
3120 {
3121 if (Shape.PathCurve == (byte)Extrusion.Straight)
3122 return PrimType.BOX;
3123 else if (Shape.PathCurve == (byte)Extrusion.Curve1)
3124 return PrimType.TUBE;
3125 }
3126 else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
3127 {
3128 if (Shape.PathCurve == (byte)Extrusion.Straight)
3129 return PrimType.CYLINDER;
3130 // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
3131 else if (Shape.PathCurve == (byte)Extrusion.Curve1)
3132 return PrimType.TORUS;
3133 }
3134 else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
3135 {
3136 if (Shape.PathCurve == (byte)Extrusion.Curve1 || Shape.PathCurve == (byte)Extrusion.Curve2)
3137 return PrimType.SPHERE;
3138 }
3139 else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
3140 {
3141 if (Shape.PathCurve == (byte)Extrusion.Straight)
3142 return PrimType.PRISM;
3143 else if (Shape.PathCurve == (byte)Extrusion.Curve1)
3144 return PrimType.RING;
3145 }
3146
3147 return PrimType.BOX;
3148 }
3149
3150 /// <summary>
3151 /// Tell us if this object has cut, hollow, dimple, and other factors affecting the number of faces
3152 /// </summary>
3153 /// <param name="primType"></param>
3154 /// <param name="shape"></param>
3155 /// <param name="hasCut"></param>
3156 /// <param name="hasHollow"></param>
3157 /// <param name="hasDimple"></param>
3158 /// <param name="hasProfileCut"></param>
3159 protected static void HasCutHollowDimpleProfileCut(PrimType primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow,
3160 out bool hasDimple, out bool hasProfileCut)
3161 {
3162 if (primType == PrimType.BOX
3163 ||
3164 primType == PrimType.CYLINDER
3165 ||
3166 primType == PrimType.PRISM)
3167
3168 hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
3169 else
3170 hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);
3171
3172 hasHollow = shape.ProfileHollow > 0;
3173 hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
3174 hasProfileCut = hasDimple; // is it the same thing?
3175 }
2984 3176
2985 public void SetGroup(UUID groupID, IClientAPI client) 3177 public void SetGroup(UUID groupID, IClientAPI client)
2986 { 3178 {
@@ -3013,6 +3205,11 @@ namespace OpenSim.Region.Framework.Scenes
3013 } 3205 }
3014 } 3206 }
3015 3207
3208 /// <summary>
3209 /// Set the events that this part will pass on to listeners.
3210 /// </summary>
3211 /// <param name="scriptid"></param>
3212 /// <param name="events"></param>
3016 public void SetScriptEvents(UUID scriptid, int events) 3213 public void SetScriptEvents(UUID scriptid, int events)
3017 { 3214 {
3018 // scriptEvents oldparts; 3215 // scriptEvents oldparts;