diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a5296eb..8b5c348 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 |
@@ -737,6 +754,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
737 | } | 754 | } |
738 | } | 755 | } |
739 | 756 | ||
757 | /// <value> | ||
758 | /// Text color. | ||
759 | /// </value> | ||
740 | public Color Color | 760 | public Color Color |
741 | { | 761 | { |
742 | get { return m_color; } | 762 | get { return m_color; } |
@@ -2955,6 +2975,178 @@ namespace OpenSim.Region.Framework.Scenes | |||
2955 | } | 2975 | } |
2956 | } | 2976 | } |
2957 | 2977 | ||
2978 | /// <summary> | ||
2979 | /// Set the color of prim faces | ||
2980 | /// </summary> | ||
2981 | /// <param name="color"></param> | ||
2982 | /// <param name="face"></param> | ||
2983 | public void SetFaceColor(Vector3 color, int face) | ||
2984 | { | ||
2985 | Primitive.TextureEntry tex = Shape.Textures; | ||
2986 | Color4 texcolor; | ||
2987 | if (face >= 0 && face < GetNumberOfSides()) | ||
2988 | { | ||
2989 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
2990 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | ||
2991 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | ||
2992 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | ||
2993 | tex.FaceTextures[face].RGBA = texcolor; | ||
2994 | UpdateTexture(tex); | ||
2995 | return; | ||
2996 | } | ||
2997 | else if (face == ALL_SIDES) | ||
2998 | { | ||
2999 | for (uint i = 0; i < GetNumberOfSides(); i++) | ||
3000 | { | ||
3001 | if (tex.FaceTextures[i] != null) | ||
3002 | { | ||
3003 | texcolor = tex.FaceTextures[i].RGBA; | ||
3004 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | ||
3005 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | ||
3006 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | ||
3007 | tex.FaceTextures[i].RGBA = texcolor; | ||
3008 | } | ||
3009 | texcolor = tex.DefaultTexture.RGBA; | ||
3010 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | ||
3011 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | ||
3012 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | ||
3013 | tex.DefaultTexture.RGBA = texcolor; | ||
3014 | } | ||
3015 | UpdateTexture(tex); | ||
3016 | return; | ||
3017 | } | ||
3018 | } | ||
3019 | |||
3020 | /// <summary> | ||
3021 | /// Get the number of sides that this part has. | ||
3022 | /// </summary> | ||
3023 | /// <returns></returns> | ||
3024 | public int GetNumberOfSides() | ||
3025 | { | ||
3026 | int ret = 0; | ||
3027 | bool hasCut; | ||
3028 | bool hasHollow; | ||
3029 | bool hasDimple; | ||
3030 | bool hasProfileCut; | ||
3031 | |||
3032 | PrimType primType = getScriptPrimType(); | ||
3033 | hasCutHollowDimpleProfileCut(primType, Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); | ||
3034 | |||
3035 | switch (primType) | ||
3036 | { | ||
3037 | case PrimType.BOX: | ||
3038 | ret = 6; | ||
3039 | if (hasCut) ret += 2; | ||
3040 | if (hasHollow) ret += 1; | ||
3041 | break; | ||
3042 | case PrimType.CYLINDER: | ||
3043 | ret = 3; | ||
3044 | if (hasCut) ret += 2; | ||
3045 | if (hasHollow) ret += 1; | ||
3046 | break; | ||
3047 | case PrimType.PRISM: | ||
3048 | ret = 5; | ||
3049 | if (hasCut) ret += 2; | ||
3050 | if (hasHollow) ret += 1; | ||
3051 | break; | ||
3052 | case PrimType.SPHERE: | ||
3053 | ret = 1; | ||
3054 | if (hasCut) ret += 2; | ||
3055 | if (hasDimple) ret += 2; | ||
3056 | if (hasHollow) ret += 3; // Emulate lsl on secondlife (according to documentation it should have added only +1) | ||
3057 | break; | ||
3058 | case PrimType.TORUS: | ||
3059 | ret = 1; | ||
3060 | if (hasCut) ret += 2; | ||
3061 | if (hasProfileCut) ret += 2; | ||
3062 | if (hasHollow) ret += 1; | ||
3063 | break; | ||
3064 | case PrimType.TUBE: | ||
3065 | ret = 4; | ||
3066 | if (hasCut) ret += 2; | ||
3067 | if (hasProfileCut) ret += 2; | ||
3068 | if (hasHollow) ret += 1; | ||
3069 | break; | ||
3070 | case PrimType.RING: | ||
3071 | ret = 3; | ||
3072 | if (hasCut) ret += 2; | ||
3073 | if (hasProfileCut) ret += 2; | ||
3074 | if (hasHollow) ret += 1; | ||
3075 | break; | ||
3076 | case PrimType.SCULPT: | ||
3077 | ret = 1; | ||
3078 | break; | ||
3079 | } | ||
3080 | return ret; | ||
3081 | } | ||
3082 | |||
3083 | /// <summary> | ||
3084 | /// Tell us what type this prim is | ||
3085 | /// </summary> | ||
3086 | /// <param name="primShape"></param> | ||
3087 | /// <returns></returns> | ||
3088 | public PrimType getScriptPrimType() | ||
3089 | { | ||
3090 | if (Shape.SculptEntry) | ||
3091 | return PrimType.SCULPT; | ||
3092 | if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) | ||
3093 | { | ||
3094 | if (Shape.PathCurve == (byte)Extrusion.Straight) | ||
3095 | return PrimType.BOX; | ||
3096 | else if (Shape.PathCurve == (byte)Extrusion.Curve1) | ||
3097 | return PrimType.TUBE; | ||
3098 | } | ||
3099 | else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) | ||
3100 | { | ||
3101 | if (Shape.PathCurve == (byte)Extrusion.Straight) | ||
3102 | return PrimType.CYLINDER; | ||
3103 | // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits | ||
3104 | else if (Shape.PathCurve == (byte)Extrusion.Curve1) | ||
3105 | return PrimType.TORUS; | ||
3106 | } | ||
3107 | else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle) | ||
3108 | { | ||
3109 | if (Shape.PathCurve == (byte)Extrusion.Curve1 || Shape.PathCurve == (byte)Extrusion.Curve2) | ||
3110 | return PrimType.SPHERE; | ||
3111 | } | ||
3112 | else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle) | ||
3113 | { | ||
3114 | if (Shape.PathCurve == (byte)Extrusion.Straight) | ||
3115 | return PrimType.PRISM; | ||
3116 | else if (Shape.PathCurve == (byte)Extrusion.Curve1) | ||
3117 | return PrimType.RING; | ||
3118 | } | ||
3119 | |||
3120 | return PrimType.BOX; | ||
3121 | } | ||
3122 | |||
3123 | /// <summary> | ||
3124 | /// Tell us if this object has cut, hollow, dimple, and other factors affecting the number of faces | ||
3125 | /// </summary> | ||
3126 | /// <param name="primType"></param> | ||
3127 | /// <param name="shape"></param> | ||
3128 | /// <param name="hasCut"></param> | ||
3129 | /// <param name="hasHollow"></param> | ||
3130 | /// <param name="hasDimple"></param> | ||
3131 | /// <param name="hasProfileCut"></param> | ||
3132 | protected static void hasCutHollowDimpleProfileCut(PrimType primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, | ||
3133 | out bool hasDimple, out bool hasProfileCut) | ||
3134 | { | ||
3135 | if (primType == PrimType.BOX | ||
3136 | || | ||
3137 | primType == PrimType.CYLINDER | ||
3138 | || | ||
3139 | primType == PrimType.PRISM) | ||
3140 | |||
3141 | hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); | ||
3142 | else | ||
3143 | hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); | ||
3144 | |||
3145 | hasHollow = shape.ProfileHollow > 0; | ||
3146 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms | ||
3147 | hasProfileCut = hasDimple; // is it the same thing? | ||
3148 | } | ||
3149 | |||
2958 | public void SetGroup(UUID groupID, IClientAPI client) | 3150 | public void SetGroup(UUID groupID, IClientAPI client) |
2959 | { | 3151 | { |
2960 | _groupID = groupID; | 3152 | _groupID = groupID; |