Annotation of /trunk/IdealistViewer/Application/PrimitiveBaseShape.cs
Parent Directory
|
Revision Log
Revision 2 - (view) (download)
| 1 : | teravus | 2 | /* |
| 2 : | * Copyright (c) Contributors, http://openviewer.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 OpenViewer 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 System.Text; | ||
| 31 : | using OpenMetaverse; | ||
| 32 : | |||
| 33 : | namespace IdealistViewer | ||
| 34 : | { | ||
| 35 : | public enum ProfileShape : byte | ||
| 36 : | { | ||
| 37 : | Circle = 0, | ||
| 38 : | Square = 1, | ||
| 39 : | IsometricTriangle = 2, | ||
| 40 : | EquilateralTriangle = 3, | ||
| 41 : | RightTriangle = 4, | ||
| 42 : | HalfCircle = 5 | ||
| 43 : | } | ||
| 44 : | |||
| 45 : | public enum HollowShape : byte | ||
| 46 : | { | ||
| 47 : | Same = 0, | ||
| 48 : | Circle = 16, | ||
| 49 : | Square = 32, | ||
| 50 : | Triangle = 48 | ||
| 51 : | } | ||
| 52 : | |||
| 53 : | public enum PCodeEnum : byte | ||
| 54 : | { | ||
| 55 : | Primitive = 9, | ||
| 56 : | Avatar = 47 | ||
| 57 : | } | ||
| 58 : | |||
| 59 : | public enum Extrusion : byte | ||
| 60 : | { | ||
| 61 : | Straight = 16, | ||
| 62 : | Curve1 = 32, | ||
| 63 : | Curve2 = 48, | ||
| 64 : | Flexible = 128 | ||
| 65 : | } | ||
| 66 : | |||
| 67 : | public enum PrimType | ||
| 68 : | { | ||
| 69 : | Unknown, | ||
| 70 : | Box, | ||
| 71 : | Cylinder, | ||
| 72 : | Prism, | ||
| 73 : | Sphere, | ||
| 74 : | Torus, | ||
| 75 : | Tube, | ||
| 76 : | Ring, | ||
| 77 : | Sculpt | ||
| 78 : | } | ||
| 79 : | |||
| 80 : | [Serializable] | ||
| 81 : | public class PrimitiveBaseShape | ||
| 82 : | { | ||
| 83 : | public PrimType Type = PrimType.Box; | ||
| 84 : | public byte[] ExtraParams; | ||
| 85 : | private byte[] m_textureEntry; | ||
| 86 : | |||
| 87 : | public ushort PathBegin; | ||
| 88 : | public byte PathCurve; | ||
| 89 : | public ushort PathEnd; | ||
| 90 : | public sbyte PathRadiusOffset; | ||
| 91 : | public byte PathRevolutions; | ||
| 92 : | public byte PathScaleX; | ||
| 93 : | public byte PathScaleY; | ||
| 94 : | public byte PathShearX; | ||
| 95 : | public byte PathShearY; | ||
| 96 : | public sbyte PathSkew; | ||
| 97 : | public sbyte PathTaperX; | ||
| 98 : | public sbyte PathTaperY; | ||
| 99 : | public sbyte PathTwist; | ||
| 100 : | public sbyte PathTwistBegin; | ||
| 101 : | public byte PCode; | ||
| 102 : | public ushort ProfileBegin; | ||
| 103 : | |||
| 104 : | public byte ProfileCurve; | ||
| 105 : | |||
| 106 : | public ushort ProfileEnd; | ||
| 107 : | public ushort ProfileHollow; | ||
| 108 : | public Vector3 Scale; | ||
| 109 : | public byte State; | ||
| 110 : | |||
| 111 : | static PrimitiveBaseShape() | ||
| 112 : | { | ||
| 113 : | } | ||
| 114 : | |||
| 115 : | public PrimitiveBaseShape() | ||
| 116 : | { | ||
| 117 : | PCode = (byte)PCodeEnum.Primitive; | ||
| 118 : | ExtraParams = new byte[1]; | ||
| 119 : | } | ||
| 120 : | |||
| 121 : | public byte[] TextureEntry | ||
| 122 : | { | ||
| 123 : | get { return m_textureEntry; } | ||
| 124 : | set { m_textureEntry = value; } | ||
| 125 : | } | ||
| 126 : | |||
| 127 : | public ProfileShape ProfileShape | ||
| 128 : | { | ||
| 129 : | get { return (ProfileShape)(ProfileCurve & 0x0f); } | ||
| 130 : | set | ||
| 131 : | { | ||
| 132 : | byte oldValueMasked = (byte)(ProfileCurve & 0xf0); | ||
| 133 : | ProfileCurve = (byte)(oldValueMasked | (byte)value); | ||
| 134 : | } | ||
| 135 : | } | ||
| 136 : | |||
| 137 : | public HollowShape HollowShape | ||
| 138 : | { | ||
| 139 : | get { return (HollowShape)(ProfileCurve & 0xf0); } | ||
| 140 : | set | ||
| 141 : | { | ||
| 142 : | byte oldValueMasked = (byte)(ProfileCurve & 0x0f); | ||
| 143 : | ProfileCurve = (byte)(oldValueMasked | (byte)value); | ||
| 144 : | } | ||
| 145 : | } | ||
| 146 : | |||
| 147 : | public static PrimitiveBaseShape Default | ||
| 148 : | { | ||
| 149 : | get | ||
| 150 : | { | ||
| 151 : | PrimitiveBaseShape boxShape = CreateBox(); | ||
| 152 : | boxShape.SetScale(0.5f); | ||
| 153 : | return boxShape; | ||
| 154 : | } | ||
| 155 : | } | ||
| 156 : | |||
| 157 : | public static PrimitiveBaseShape Create() | ||
| 158 : | { | ||
| 159 : | PrimitiveBaseShape shape = new PrimitiveBaseShape(); | ||
| 160 : | return shape; | ||
| 161 : | } | ||
| 162 : | |||
| 163 : | public static PrimitiveBaseShape CreateBox() | ||
| 164 : | { | ||
| 165 : | PrimitiveBaseShape shape = Create(); | ||
| 166 : | |||
| 167 : | shape.PathCurve = (byte)Extrusion.Straight; | ||
| 168 : | shape.ProfileShape = ProfileShape.Square; | ||
| 169 : | shape.PathScaleX = 100; | ||
| 170 : | shape.PathScaleY = 100; | ||
| 171 : | |||
| 172 : | return shape; | ||
| 173 : | } | ||
| 174 : | |||
| 175 : | public static PrimitiveBaseShape CreateCylinder() | ||
| 176 : | { | ||
| 177 : | PrimitiveBaseShape shape = Create(); | ||
| 178 : | |||
| 179 : | shape.PathCurve = (byte)Extrusion.Curve1; | ||
| 180 : | shape.ProfileShape = ProfileShape.Square; | ||
| 181 : | |||
| 182 : | shape.PathScaleX = 100; | ||
| 183 : | shape.PathScaleY = 100; | ||
| 184 : | |||
| 185 : | return shape; | ||
| 186 : | } | ||
| 187 : | |||
| 188 : | public void SetScale(float side) | ||
| 189 : | { | ||
| 190 : | Scale = new Vector3(side, side, side); | ||
| 191 : | } | ||
| 192 : | |||
| 193 : | public void SetHeight(float height) | ||
| 194 : | { | ||
| 195 : | Scale.Z = height; | ||
| 196 : | } | ||
| 197 : | |||
| 198 : | public void SetRadius(float radius) | ||
| 199 : | { | ||
| 200 : | Scale.X = Scale.Y = radius * 2f; | ||
| 201 : | } | ||
| 202 : | |||
| 203 : | //void returns need to change of course | ||
| 204 : | public virtual void GetMesh() | ||
| 205 : | { | ||
| 206 : | } | ||
| 207 : | |||
| 208 : | public PrimitiveBaseShape Copy() | ||
| 209 : | { | ||
| 210 : | return (PrimitiveBaseShape)MemberwiseClone(); | ||
| 211 : | } | ||
| 212 : | |||
| 213 : | public static PrimitiveBaseShape CreateCylinder(float radius, float height) | ||
| 214 : | { | ||
| 215 : | PrimitiveBaseShape shape = CreateCylinder(); | ||
| 216 : | |||
| 217 : | shape.SetHeight(height); | ||
| 218 : | shape.SetRadius(radius); | ||
| 219 : | |||
| 220 : | return shape; | ||
| 221 : | } | ||
| 222 : | |||
| 223 : | public void SetPathRange(Vector3 pathRange) | ||
| 224 : | { | ||
| 225 : | // PathBegin = LLObject.PackBeginCut(pathRange.X); | ||
| 226 : | // PathEnd = LLObject.PackEndCut(pathRange.Y); | ||
| 227 : | } | ||
| 228 : | |||
| 229 : | public void SetProfileRange(Vector3 profileRange) | ||
| 230 : | { | ||
| 231 : | // ProfileBegin = LLObject.PackBeginCut(profileRange.X); | ||
| 232 : | // ProfileEnd = LLObject.PackEndCut(profileRange.Y); | ||
| 233 : | } | ||
| 234 : | } | ||
| 235 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

