static void Objects_OnNewPrim(Simulator simulator, Primitive prim, ulong regionHandle, ushort timeDilation) { if (CurrentSculpt != null && (prim.Flags & PrimFlags.CreateSelected) != 0 && !RezzedPrims.Contains(prim.LocalID)) { lock (RezzedPrims) RezzedPrims.Add(prim.LocalID); Console.WriteLine("Rezzed prim " + CurrentSculpt.Name + ", setting properties"); // Deselect the prim Client.Objects.DeselectObject(Client.Network.CurrentSim, prim.LocalID); // Set the prim position Client.Objects.SetPosition(Client.Network.CurrentSim, prim.LocalID, RootPosition + CurrentSculpt.Offset); // Set the texture Primitive.TextureEntry textures = new Primitive.TextureEntry(CurrentSculpt.TextureID); Client.Objects.SetTextures(Client.Network.CurrentSim, prim.LocalID, textures); // Turn it in to a sculpted prim Primitive.SculptData sculpt = new Primitive.SculptData(); sculpt.SculptTexture = CurrentSculpt.SculptID; sculpt.Type = SculptType.Sphere; Client.Objects.SetSculpt(Client.Network.CurrentSim, prim.LocalID, sculpt); // Set the prim name if (!String.IsNullOrEmpty(CurrentSculpt.Name)) { Client.Objects.SetName(Client.Network.CurrentSim, prim.LocalID, CurrentSculpt.Name); } RezzedEvent.Set(); } }
private static Primitive.SculptData FromPrimObjectSculpt(PrimObject.SculptBlock objSculpt) { if (objSculpt == null) { return(null); } Primitive.SculptData sculpt = new Primitive.SculptData(); sculpt.Type = (SculptType)objSculpt.Type; sculpt.SculptTexture = objSculpt.Texture; return(sculpt); }
private static string DecodeObjectExtraParams(string fieldName, object fieldData) { byte[] data = (byte[])fieldData; int i = 0; //int totalLength = 1; Primitive.FlexibleData Flexible = null; Primitive.LightData Light = null; Primitive.SculptData Sculpt = null; byte extraParamCount = data[i++]; for (int k = 0; k < extraParamCount; k++) { ExtraParamType type = (ExtraParamType)Utils.BytesToUInt16(data, i); i += 2; uint paramLength = Utils.BytesToUInt(data, i); i += 4; if (type == ExtraParamType.Flexible) Flexible = new Primitive.FlexibleData(data, i); else if (type == ExtraParamType.Light) Light = new Primitive.LightData(data, i); else if (type == ExtraParamType.Sculpt) Sculpt = new Primitive.SculptData(data, i); i += (int)paramLength; //totalLength += (int)paramLength + 6; } StringBuilder result = new StringBuilder(); result.AppendFormat("{0,30}", "<ExtraParams>" + Environment.NewLine); if (Flexible != null) { result.AppendFormat("{0,30}", "<Flexible>" + Environment.NewLine); GenericTypeDecoder(Flexible, ref result); result.AppendFormat("{0,30}", "</Flexible>" + Environment.NewLine); } if (Sculpt != null) { result.AppendFormat("{0,30}", "<Sculpt>" + Environment.NewLine); GenericTypeDecoder(Sculpt, ref result); result.AppendFormat("{0,30}", "</Sculpt>" + Environment.NewLine); } if (Light != null) { result.AppendFormat("{0,30}", "<Light>" + Environment.NewLine); GenericTypeDecoder(Light, ref result); result.AppendFormat("{0,30}", "</Light>" + Environment.NewLine); } result.AppendFormat("{0,30}", "</ExtraParams>"); return result.ToString(); }
/// <summary> /// Parses ad request /// </summary> /// <param name = "request"></param> /// <param name = "AgentId"></param> /// <param name = "cap"></param> /// <returns></returns> public byte[] ProcessAdd(Stream request, OSHttpResponse response, UUID AgentId) { IScenePresence avatar; if (!m_scene.TryGetScenePresence(AgentId, out avatar)) { return(MainServer.NoResponse); } OSDMap r = (OSDMap)OSDParser.Deserialize(request); UploadObjectAssetMessage message = new UploadObjectAssetMessage(); try { message.Deserialize(r); } catch (Exception ex) { MainConsole.Instance.Error("[UploadObjectAssetModule]: Error deserializing message " + ex); message = null; } if (message == null) { response.StatusCode = 400; //501; //410; //404; return(Encoding.UTF8.GetBytes("<llsd><map><key>error</key><string>Error parsing Object</string></map></llsd>")); } Vector3 pos = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation); Quaternion rot = Quaternion.Identity; Vector3 rootpos = Vector3.Zero; SceneObjectGroup rootGroup = null; SceneObjectGroup[] allparts = new SceneObjectGroup[message.Objects.Length]; for (int i = 0; i < message.Objects.Length; i++) { UploadObjectAssetMessage.Object obj = message.Objects[i]; PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); if (i == 0) { rootpos = obj.Position; } // Combine the extraparams data into it's ugly blob again.... //int bytelength = 0; //for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) //{ // bytelength += obj.ExtraParams[extparams].ExtraParamData.Length; //} //byte[] extraparams = new byte[bytelength]; //int position = 0; //for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) //{ // Buffer.BlockCopy(obj.ExtraParams[extparams].ExtraParamData, 0, extraparams, position, // obj.ExtraParams[extparams].ExtraParamData.Length); // // position += obj.ExtraParams[extparams].ExtraParamData.Length; // } //pbs.ExtraParams = extraparams; foreach (UploadObjectAssetMessage.Object.ExtraParam extraParam in obj.ExtraParams) { switch ((ushort)extraParam.Type) { case (ushort)ExtraParamType.Sculpt: Primitive.SculptData sculpt = new Primitive.SculptData(extraParam.ExtraParamData, 0); pbs.SculptEntry = true; pbs.SculptTexture = obj.SculptID; pbs.SculptType = (byte)sculpt.Type; break; case (ushort)ExtraParamType.Flexible: Primitive.FlexibleData flex = new Primitive.FlexibleData(extraParam.ExtraParamData, 0); pbs.FlexiEntry = true; pbs.FlexiDrag = flex.Drag; pbs.FlexiForceX = flex.Force.X; pbs.FlexiForceY = flex.Force.Y; pbs.FlexiForceZ = flex.Force.Z; pbs.FlexiGravity = flex.Gravity; pbs.FlexiSoftness = flex.Softness; pbs.FlexiTension = flex.Tension; pbs.FlexiWind = flex.Wind; break; case (ushort)ExtraParamType.Light: Primitive.LightData light = new Primitive.LightData(extraParam.ExtraParamData, 0); pbs.LightColorA = light.Color.A; pbs.LightColorB = light.Color.B; pbs.LightColorG = light.Color.G; pbs.LightColorR = light.Color.R; pbs.LightCutoff = light.Cutoff; pbs.LightEntry = true; pbs.LightFalloff = light.Falloff; pbs.LightIntensity = light.Intensity; pbs.LightRadius = light.Radius; break; case 0x40: pbs.ReadProjectionData(extraParam.ExtraParamData, 0); break; } } pbs.PathBegin = (ushort)obj.PathBegin; pbs.PathCurve = (byte)obj.PathCurve; pbs.PathEnd = (ushort)obj.PathEnd; pbs.PathRadiusOffset = (sbyte)obj.RadiusOffset; pbs.PathRevolutions = (byte)obj.Revolutions; pbs.PathScaleX = (byte)obj.ScaleX; pbs.PathScaleY = (byte)obj.ScaleY; pbs.PathShearX = (byte)obj.ShearX; pbs.PathShearY = (byte)obj.ShearY; pbs.PathSkew = (sbyte)obj.Skew; pbs.PathTaperX = (sbyte)obj.TaperX; pbs.PathTaperY = (sbyte)obj.TaperY; pbs.PathTwist = (sbyte)obj.Twist; pbs.PathTwistBegin = (sbyte)obj.TwistBegin; pbs.HollowShape = (HollowShape)obj.ProfileHollow; pbs.PCode = (byte)PCode.Prim; pbs.ProfileBegin = (ushort)obj.ProfileBegin; pbs.ProfileCurve = (byte)obj.ProfileCurve; pbs.ProfileEnd = (ushort)obj.ProfileEnd; pbs.Scale = obj.Scale; pbs.State = 0; SceneObjectPart prim = new SceneObjectPart(AgentId, pbs, obj.Position, obj.Rotation, Vector3.Zero, obj.Name, m_scene) { UUID = UUID.Random(), CreatorID = AgentId, OwnerID = AgentId, GroupID = obj.GroupID }; prim.LastOwnerID = prim.OwnerID; prim.CreationDate = Util.UnixTimeSinceEpoch(); prim.Name = obj.Name; prim.Description = ""; prim.PayPrice[0] = -2; prim.PayPrice[1] = -2; prim.PayPrice[2] = -2; prim.PayPrice[3] = -2; prim.PayPrice[4] = -2; Primitive.TextureEntry tmp = new Primitive.TextureEntry(UUID.Parse("89556747-24cb-43ed-920b-47caed15465f")); for (int j = 0; j < obj.Faces.Length; j++) { UploadObjectAssetMessage.Object.Face face = obj.Faces[j]; Primitive.TextureEntryFace primFace = tmp.CreateFace((uint)j); primFace.Bump = face.Bump; primFace.RGBA = face.Color; primFace.Fullbright = face.Fullbright; primFace.Glow = face.Glow; primFace.TextureID = face.ImageID; primFace.Rotation = face.ImageRot; primFace.MediaFlags = ((face.MediaFlags & 1) != 0); primFace.OffsetU = face.OffsetS; primFace.OffsetV = face.OffsetT; primFace.RepeatU = face.ScaleS; primFace.RepeatV = face.ScaleT; primFace.TexMapType = (MappingType)(face.MediaFlags & 6); } pbs.TextureEntry = tmp.GetBytes(); prim.Shape = pbs; prim.Scale = obj.Scale; SceneObjectGroup grp = new SceneObjectGroup(prim, m_scene); prim.ParentID = 0; if (i == 0) { rootGroup = grp; } grp.AbsolutePosition = obj.Position; prim.RotationOffset = obj.Rotation; grp.RootPart.IsAttachment = false; string reason; if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos, out reason)) { m_scene.SceneGraph.AddPrimToScene(grp); grp.AbsolutePosition = obj.Position; } else { //Stop now then avatar.ControllingClient.SendAlertMessage("You do not have permission to rez objects here: " + reason); return(MainServer.NoResponse); } allparts[i] = grp; } for (int j = 1; j < allparts.Length; j++) { rootGroup.LinkToGroup(allparts[j]); } rootGroup.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate); pos = m_scene.SceneGraph.GetNewRezLocation(Vector3.Zero, rootpos, UUID.Zero, rot, 1, 1, true, allparts[0].GroupScale(), false); OSDMap map = new OSDMap(); map["local_id"] = allparts[0].LocalId; return(OSDParser.SerializeLLSDXmlBytes(map)); }
/// <summary> /// Parses ad request /// </summary> /// <param name="request"></param> /// <param name="AgentId"></param> /// <param name="cap"></param> /// <returns></returns> public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap) { Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 400; //501; //410; //404; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; responsedata["str_response_string"] = "Request wasn't what was expected"; ScenePresence avatar; if (!m_scene.TryGetScenePresence(AgentId, out avatar)) { return(responsedata); } OSDMap r = (OSDMap)OSDParser.Deserialize((string)request["requestbody"]); UploadObjectAssetMessage message = new UploadObjectAssetMessage(); try { message.Deserialize(r); } catch (Exception ex) { m_log.Error("[UPLOAD OBJECT ASSET MODULE]: Error deserializing message " + ex.ToString()); message = null; } if (message == null) { responsedata["int_response_code"] = 400; //501; //410; //404; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; responsedata["str_response_string"] = "<llsd><map><key>error</key><string>Error parsing Object</string></map></llsd>"; return(responsedata); } Vector3 pos = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation); Quaternion rot = Quaternion.Identity; Vector3 rootpos = Vector3.Zero; // Quaternion rootrot = Quaternion.Identity; SceneObjectGroup rootGroup = null; SceneObjectGroup[] allparts = new SceneObjectGroup[message.Objects.Length]; for (int i = 0; i < message.Objects.Length; i++) { UploadObjectAssetMessage.Object obj = message.Objects[i]; PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); if (i == 0) { rootpos = obj.Position; // rootrot = obj.Rotation; } // Combine the extraparams data into it's ugly blob again.... //int bytelength = 0; //for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) //{ // bytelength += obj.ExtraParams[extparams].ExtraParamData.Length; //} //byte[] extraparams = new byte[bytelength]; //int position = 0; //for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) //{ // Buffer.BlockCopy(obj.ExtraParams[extparams].ExtraParamData, 0, extraparams, position, // obj.ExtraParams[extparams].ExtraParamData.Length); // // position += obj.ExtraParams[extparams].ExtraParamData.Length; // } //pbs.ExtraParams = extraparams; for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) { UploadObjectAssetMessage.Object.ExtraParam extraParam = obj.ExtraParams[extparams]; switch ((ushort)extraParam.Type) { case (ushort)ExtraParamType.Sculpt: Primitive.SculptData sculpt = new Primitive.SculptData(extraParam.ExtraParamData, 0); pbs.SculptEntry = true; pbs.SculptTexture = obj.SculptID; pbs.SculptType = (byte)sculpt.Type; break; case (ushort)ExtraParamType.Flexible: Primitive.FlexibleData flex = new Primitive.FlexibleData(extraParam.ExtraParamData, 0); pbs.FlexiEntry = true; pbs.FlexiDrag = flex.Drag; pbs.FlexiForceX = flex.Force.X; pbs.FlexiForceY = flex.Force.Y; pbs.FlexiForceZ = flex.Force.Z; pbs.FlexiGravity = flex.Gravity; pbs.FlexiSoftness = flex.Softness; pbs.FlexiTension = flex.Tension; pbs.FlexiWind = flex.Wind; break; case (ushort)ExtraParamType.Light: Primitive.LightData light = new Primitive.LightData(extraParam.ExtraParamData, 0); pbs.LightColorA = light.Color.A; pbs.LightColorB = light.Color.B; pbs.LightColorG = light.Color.G; pbs.LightColorR = light.Color.R; pbs.LightCutoff = light.Cutoff; pbs.LightEntry = true; pbs.LightFalloff = light.Falloff; pbs.LightIntensity = light.Intensity; pbs.LightRadius = light.Radius; break; case 0x40: pbs.ReadProjectionData(extraParam.ExtraParamData, 0); break; } } pbs.PathBegin = (ushort)obj.PathBegin; pbs.PathCurve = (byte)obj.PathCurve; pbs.PathEnd = (ushort)obj.PathEnd; pbs.PathRadiusOffset = (sbyte)obj.RadiusOffset; pbs.PathRevolutions = (byte)obj.Revolutions; pbs.PathScaleX = (byte)obj.ScaleX; pbs.PathScaleY = (byte)obj.ScaleY; pbs.PathShearX = (byte)obj.ShearX; pbs.PathShearY = (byte)obj.ShearY; pbs.PathSkew = (sbyte)obj.Skew; pbs.PathTaperX = (sbyte)obj.TaperX; pbs.PathTaperY = (sbyte)obj.TaperY; pbs.PathTwist = (sbyte)obj.Twist; pbs.PathTwistBegin = (sbyte)obj.TwistBegin; pbs.HollowShape = (HollowShape)obj.ProfileHollow; pbs.PCode = (byte)PCode.Prim; pbs.ProfileBegin = (ushort)obj.ProfileBegin; pbs.ProfileCurve = (byte)obj.ProfileCurve; pbs.ProfileEnd = (ushort)obj.ProfileEnd; pbs.Scale = obj.Scale; pbs.State = (byte)0; SceneObjectPart prim = new SceneObjectPart(); prim.UUID = UUID.Random(); prim.CreatorID = AgentId; prim.OwnerID = AgentId; prim.GroupID = obj.GroupID; prim.LastOwnerID = prim.OwnerID; prim.CreationDate = Util.UnixTimeSinceEpoch(); prim.Name = obj.Name; prim.Description = ""; prim.PayPrice[0] = -2; prim.PayPrice[1] = -2; prim.PayPrice[2] = -2; prim.PayPrice[3] = -2; prim.PayPrice[4] = -2; Primitive.TextureEntry tmp = new Primitive.TextureEntry(UUID.Parse("89556747-24cb-43ed-920b-47caed15465f")); for (int j = 0; j < obj.Faces.Length; j++) { UploadObjectAssetMessage.Object.Face face = obj.Faces[j]; Primitive.TextureEntryFace primFace = tmp.CreateFace((uint)j); primFace.Bump = face.Bump; primFace.RGBA = face.Color; primFace.Fullbright = face.Fullbright; primFace.Glow = face.Glow; primFace.TextureID = face.ImageID; primFace.Rotation = face.ImageRot; primFace.MediaFlags = ((face.MediaFlags & 1) != 0); primFace.OffsetU = face.OffsetS; primFace.OffsetV = face.OffsetT; primFace.RepeatU = face.ScaleS; primFace.RepeatV = face.ScaleT; primFace.TexMapType = (MappingType)(face.MediaFlags & 6); } pbs.TextureEntry = tmp.GetBytes(); prim.Shape = pbs; prim.Scale = obj.Scale; SceneObjectGroup grp = new SceneObjectGroup(); grp.SetRootPart(prim); prim.ParentID = 0; if (i == 0) { rootGroup = grp; } grp.AttachToScene(m_scene); grp.AbsolutePosition = obj.Position; prim.RotationOffset = obj.Rotation; grp.RootPart.IsAttachment = false; // Required for linking grp.RootPart.UpdateFlag = 0; if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) { m_scene.AddSceneObject(grp); grp.AbsolutePosition = obj.Position; } allparts[i] = grp; } for (int j = 1; j < allparts.Length; j++) { rootGroup.RootPart.UpdateFlag = 0; allparts[j].RootPart.UpdateFlag = 0; rootGroup.LinkToGroup(allparts[j]); } rootGroup.ScheduleGroupForFullUpdate(); pos = m_scene.GetNewRezLocation(Vector3.Zero, rootpos, UUID.Zero, rot, (byte)1, 1, true, allparts[0].GroupScale(), false); responsedata["int_response_code"] = 200; //501; //410; //404; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(allparts[0].LocalId)); return(responsedata); }
private void SetPrimType(IScriptInstance script, object[] rules, ref int i) { LLPrimitive prim = script.Host as LLPrimitive; if (prim == null) { return; } int code = llList2Integer(script, rules, i++); switch (code) { case LSLConstants.PRIM_TYPE_BOX: { int holeShape = llList2Integer(script, rules, i++); Vector3 cut = llList2Vector(script, rules, i++); float hollow = llList2Float(script, rules, i++); Vector3 twist = llList2Vector(script, rules, i++); Vector3 topSize = llList2Vector(script, rules, i++); Vector3 topShear = llList2Vector(script, rules, i++); Primitive.ConstructionData primData = ObjectManager.BuildBasicShape(PrimType.Box); primData.Material = prim.Prim.PrimData.Material; primData.State = prim.Prim.PrimData.State; prim.Prim.PrimData = primData; prim.Prim.Sculpt = null; SetPrimShapeParams(prim, holeShape, cut, hollow, twist, topSize, topShear); break; } case LSLConstants.PRIM_TYPE_CYLINDER: { int holeShape = llList2Integer(script, rules, i++); Vector3 cut = llList2Vector(script, rules, i++); float hollow = llList2Float(script, rules, i++); Vector3 twist = llList2Vector(script, rules, i++); Vector3 topSize = llList2Vector(script, rules, i++); Vector3 topShear = llList2Vector(script, rules, i++); Primitive.ConstructionData primData = ObjectManager.BuildBasicShape(PrimType.Cylinder); primData.Material = prim.Prim.PrimData.Material; primData.State = prim.Prim.PrimData.State; prim.Prim.PrimData = primData; prim.Prim.Sculpt = null; SetPrimShapeParams(prim, holeShape, cut, hollow, twist, topSize, topShear); break; } case LSLConstants.PRIM_TYPE_PRISM: { int holeShape = llList2Integer(script, rules, i++); Vector3 cut = llList2Vector(script, rules, i++); float hollow = llList2Float(script, rules, i++); Vector3 twist = llList2Vector(script, rules, i++); Vector3 topSize = llList2Vector(script, rules, i++); Vector3 topShear = llList2Vector(script, rules, i++); Primitive.ConstructionData primData = ObjectManager.BuildBasicShape(PrimType.Prism); primData.Material = prim.Prim.PrimData.Material; primData.State = prim.Prim.PrimData.State; prim.Prim.PrimData = primData; prim.Prim.Sculpt = null; SetPrimShapeParams(prim, holeShape, cut, hollow, twist, topSize, topShear); break; } case LSLConstants.PRIM_TYPE_SPHERE: { int holeShape = llList2Integer(script, rules, i++); Vector3 cut = llList2Vector(script, rules, i++); float hollow = llList2Float(script, rules, i++); Vector3 twist = llList2Vector(script, rules, i++); Vector3 dimple = llList2Vector(script, rules, i++); Primitive.ConstructionData primData = ObjectManager.BuildBasicShape(PrimType.Sphere); primData.Material = prim.Prim.PrimData.Material; primData.State = prim.Prim.PrimData.State; prim.Prim.PrimData = primData; prim.Prim.Sculpt = null; SetPrimShapeParams(prim, holeShape, cut, hollow, twist, dimple); break; } case LSLConstants.PRIM_TYPE_TORUS: { int holeShape = llList2Integer(script, rules, i++); Vector3 cut = llList2Vector(script, rules, i++); float hollow = llList2Float(script, rules, i++); Vector3 twist = llList2Vector(script, rules, i++); Vector3 topSize = llList2Vector(script, rules, i++); Vector3 topShear = llList2Vector(script, rules, i++); Vector3 advCut = llList2Vector(script, rules, i++); Vector3 taper = llList2Vector(script, rules, i++); float revolutions = llList2Float(script, rules, i++); float radiusOffset = llList2Float(script, rules, i++); float skew = llList2Float(script, rules, i++); Primitive.ConstructionData primData = ObjectManager.BuildBasicShape(PrimType.Torus); primData.Material = prim.Prim.PrimData.Material; primData.State = prim.Prim.PrimData.State; prim.Prim.PrimData = primData; prim.Prim.Sculpt = null; SetPrimShapeParams(prim, holeShape, cut, hollow, twist, topSize, topShear, advCut, taper, revolutions, radiusOffset, skew); break; } case LSLConstants.PRIM_TYPE_TUBE: { int holeShape = llList2Integer(script, rules, i++); Vector3 cut = llList2Vector(script, rules, i++); float hollow = llList2Float(script, rules, i++); Vector3 twist = llList2Vector(script, rules, i++); Vector3 topSize = llList2Vector(script, rules, i++); Vector3 topShear = llList2Vector(script, rules, i++); Vector3 advCut = llList2Vector(script, rules, i++); Vector3 taper = llList2Vector(script, rules, i++); float revolutions = llList2Float(script, rules, i++); float radiusOffset = llList2Float(script, rules, i++); float skew = llList2Float(script, rules, i++); Primitive.ConstructionData primData = ObjectManager.BuildBasicShape(PrimType.Tube); primData.Material = prim.Prim.PrimData.Material; primData.State = prim.Prim.PrimData.State; prim.Prim.PrimData = primData; prim.Prim.Sculpt = null; SetPrimShapeParams(prim, holeShape, cut, hollow, twist, topSize, topShear, advCut, taper, revolutions, radiusOffset, skew); break; } case LSLConstants.PRIM_TYPE_RING: { int holeShape = llList2Integer(script, rules, i++); Vector3 cut = llList2Vector(script, rules, i++); float hollow = llList2Float(script, rules, i++); Vector3 twist = llList2Vector(script, rules, i++); Vector3 topSize = llList2Vector(script, rules, i++); Vector3 topShear = llList2Vector(script, rules, i++); Vector3 advCut = llList2Vector(script, rules, i++); Vector3 taper = llList2Vector(script, rules, i++); float revolutions = llList2Float(script, rules, i++); float radiusOffset = llList2Float(script, rules, i++); float skew = llList2Float(script, rules, i++); Primitive.ConstructionData primData = ObjectManager.BuildBasicShape(PrimType.Ring); primData.Material = prim.Prim.PrimData.Material; primData.State = prim.Prim.PrimData.State; prim.Prim.PrimData = primData; prim.Prim.Sculpt = null; SetPrimShapeParams(prim, holeShape, cut, hollow, twist, topSize, topShear, advCut, taper, revolutions, radiusOffset, skew); break; } case LSLConstants.PRIM_TYPE_SCULPT: { string sculptMap = llList2String(script, rules, i++); SculptType type = (SculptType)llList2Integer(script, rules, i++); UUID textureID = InventoryKey(script, sculptMap, AssetType.Texture); if (textureID == UUID.Zero) { return; } Primitive.ConstructionData primData = ObjectManager.BuildBasicShape(PrimType.Sculpt); primData.Material = prim.Prim.PrimData.Material; primData.State = prim.Prim.PrimData.State; Primitive.SculptData sculpt = new Primitive.SculptData(); sculpt.Type = type; sculpt.SculptTexture = textureID; prim.Prim.PrimData = primData; prim.Prim.Sculpt = sculpt; break; } } }
// partly from OpenSim.Region.Physics.Meshing public static SculptMesh ToSculptMesh(byte[] sculptData, Primitive.SculptData sculptDataIn, string sculptDataString)//( Vector3 size, Quaternion Rotation) { SculptMesh sculptMesh; if (sculptData == null || sculptData.Length == 0) { Error("[PHYSICS]: Missing Sclupt Data ", sculptDataString); return(null); } System.Drawing.Image idata = null; try { OpenMetaverse.Imaging.ManagedImage managedImage; // we never use this if (!OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(sculptData, out managedImage, out idata)) { Error("[PHYSICS]: OpenMetaverse.Imaging.OpenJPEG.DecodeToImage failed ", sculptDataString); return(null); } } catch (DllNotFoundException) { Error( "[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed. Often times this is because of an old version of GLIBC. You must have version 2.4 or above!", sculptDataString); return(null); } catch (IndexOutOfRangeException e) { Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed " + e, sculptDataString); return(null); } catch (Exception e) { Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed! " + e, sculptDataString); return(null); } SculptMesh.SculptType sculptType; switch (sculptDataIn.Type) { case OpenMetaverse.SculptType.Cylinder: sculptType = SculptMesh.SculptType.cylinder; break; case OpenMetaverse.SculptType.Plane: sculptType = SculptMesh.SculptType.plane; break; case OpenMetaverse.SculptType.Torus: sculptType = SculptMesh.SculptType.torus; break; case OpenMetaverse.SculptType.Sphere: default: sculptType = SculptMesh.SculptType.sphere; break; } if (idata == null) { Error("[PHYSICS]: IData Null ", sculptDataString); return(null); } sculptMesh = new SculptMesh((System.Drawing.Bitmap)idata, sculptType, (int)32, false, sculptDataIn.Mirror, sculptDataIn.Invert); idata.Dispose(); // sculptMesh.DumpRaw(baseDir, primName, "primMesh"); return(sculptMesh); }
public Mesh PrimitiveToMesh(Primitive primitive, Vector3 Scale, Quaternion rot) { bool wasSculpt = primitive.Sculpt != null; if (wasSculpt && WorldPathSystem.SculptCollisions) { Primitive.SculptData SD = primitive.Sculpt; UUID Id = SD.SculptTexture; SculptMesh SM; if (!SculptedMeshes.TryGetValue(Id, out SM)) { byte[] bytes = WorldObjects.GridMaster.TextureBytesForUUID(SD.SculptTexture); SM = ToSculptMesh(bytes, primitive.Sculpt, "" + primitive); if (MaintainSculptPool) { SculptedMeshes[Id] = SM; } // SM.DumpRaw(".", primitive.ID.ToString(), "sculptMesh" + primitive.LocalID); } if (SM != null) { SM = SM.Copy(); SM.Scale(Scale.X, Scale.Y, Scale.Z); SM.AddRot(QuaternionToQuat(rot)); return(ToMesh( #if COLLIDER_ODE PrimToBaseShape(primitive), #endif SM.coords, SM.faces, SM.viewerFaces, primitive.Type == PrimType.Sphere)); } } this.scaleSize = Scale.X + Scale.Y + Scale.Z; bool UseExtremeDetail = scaleSize > UseExtremeDetailSize; //LevelOfDetail detail; if (scaleSize < UseLowDetailSize) { detail = LevelOfDetail.Low; } else { detail = LevelOfDetail.Medium; } if (UseExtremeDetail) { if (primitive.Type == PrimType.Box) { detail = LevelOfDetail.Medium; } else { detail = LevelOfDetail.High; } } PrimMesh primMesh = ConstructionDataToPrimMesh(primitive.PrimData, detail, UseExtremeDetail ? 2 : 1); primMesh.Scale(Scale.X, Scale.Y, Scale.Z); primMesh.AddRot(QuaternionToQuat(rot)); Mesh m = PrimMeshToMesh(primMesh); #if COLLIDER_ODE m.PBS = PrimToBaseShape(primitive); #endif return(m); }
/// <summary> /// Parses add request /// </summary> /// <param name="request"></param> /// <param name="agentID"></param> /// <param name="cap"></param> /// <returns></returns> public void ProcessAdd(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, OSDMap map, UUID agentID, Caps cap) { httpResponse.KeepAlive = false; if (!m_scene.TryGetScenePresence(agentID, out ScenePresence avatar)) { httpResponse.StatusCode = (int)HttpStatusCode.Gone; return; } UploadObjectAssetMessage message = new UploadObjectAssetMessage(); try { message.Deserialize(map); } catch (Exception ex) { m_log.Error("[UPLOAD OBJECT ASSET MODULE]: Error deserializing message " + ex.ToString()); message = null; } if (message == null) { httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; return; } try { Vector3 pos = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation); Quaternion rot = Quaternion.Identity; Vector3 rootpos = Vector3.Zero; SceneObjectGroup rootGroup = null; SceneObjectGroup[] allparts = new SceneObjectGroup[message.Objects.Length]; for (int i = 0; i < message.Objects.Length; i++) { UploadObjectAssetMessage.Object obj = message.Objects[i]; PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); if (i == 0) { rootpos = obj.Position; } for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) { UploadObjectAssetMessage.Object.ExtraParam extraParam = obj.ExtraParams[extparams]; switch ((ushort)extraParam.Type) { case (ushort)ExtraParamType.Sculpt: Primitive.SculptData sculpt = new Primitive.SculptData(extraParam.ExtraParamData, 0); pbs.SculptEntry = true; pbs.SculptTexture = obj.SculptID; pbs.SculptType = (byte)sculpt.Type; break; case (ushort)ExtraParamType.Flexible: Primitive.FlexibleData flex = new Primitive.FlexibleData(extraParam.ExtraParamData, 0); pbs.FlexiEntry = true; pbs.FlexiDrag = flex.Drag; pbs.FlexiForceX = flex.Force.X; pbs.FlexiForceY = flex.Force.Y; pbs.FlexiForceZ = flex.Force.Z; pbs.FlexiGravity = flex.Gravity; pbs.FlexiSoftness = flex.Softness; pbs.FlexiTension = flex.Tension; pbs.FlexiWind = flex.Wind; break; case (ushort)ExtraParamType.Light: Primitive.LightData light = new Primitive.LightData(extraParam.ExtraParamData, 0); pbs.LightColorA = light.Color.A; pbs.LightColorB = light.Color.B; pbs.LightColorG = light.Color.G; pbs.LightColorR = light.Color.R; pbs.LightCutoff = light.Cutoff; pbs.LightEntry = true; pbs.LightFalloff = light.Falloff; pbs.LightIntensity = light.Intensity; pbs.LightRadius = light.Radius; break; case 0x40: pbs.ReadProjectionData(extraParam.ExtraParamData, 0); break; } } pbs.PathBegin = (ushort)obj.PathBegin; pbs.PathCurve = (byte)obj.PathCurve; pbs.PathEnd = (ushort)obj.PathEnd; pbs.PathRadiusOffset = (sbyte)obj.RadiusOffset; pbs.PathRevolutions = (byte)obj.Revolutions; pbs.PathScaleX = (byte)obj.ScaleX; pbs.PathScaleY = (byte)obj.ScaleY; pbs.PathShearX = (byte)obj.ShearX; pbs.PathShearY = (byte)obj.ShearY; pbs.PathSkew = (sbyte)obj.Skew; pbs.PathTaperX = (sbyte)obj.TaperX; pbs.PathTaperY = (sbyte)obj.TaperY; pbs.PathTwist = (sbyte)obj.Twist; pbs.PathTwistBegin = (sbyte)obj.TwistBegin; pbs.HollowShape = (HollowShape)obj.ProfileHollow; pbs.PCode = (byte)PCode.Prim; pbs.ProfileBegin = (ushort)obj.ProfileBegin; pbs.ProfileCurve = (byte)obj.ProfileCurve; pbs.ProfileEnd = (ushort)obj.ProfileEnd; pbs.Scale = obj.Scale; pbs.State = (byte)0; pbs.LastAttachPoint = (byte)0; SceneObjectPart prim = new SceneObjectPart(); prim.UUID = UUID.Random(); prim.CreatorID = agentID; prim.OwnerID = agentID; prim.GroupID = obj.GroupID; prim.LastOwnerID = prim.OwnerID; prim.RezzerID = agentID; prim.CreationDate = Util.UnixTimeSinceEpoch(); prim.Name = obj.Name; prim.Description = ""; prim.PayPrice[0] = -2; prim.PayPrice[1] = -2; prim.PayPrice[2] = -2; prim.PayPrice[3] = -2; prim.PayPrice[4] = -2; Primitive.TextureEntry tmp = new Primitive.TextureEntry(UUID.Parse("89556747-24cb-43ed-920b-47caed15465f")); for (int j = 0; j < obj.Faces.Length; j++) { UploadObjectAssetMessage.Object.Face face = obj.Faces[j]; Primitive.TextureEntryFace primFace = tmp.CreateFace((uint)j); primFace.Bump = face.Bump; primFace.RGBA = face.Color; primFace.Fullbright = face.Fullbright; primFace.Glow = face.Glow; primFace.TextureID = face.ImageID; primFace.Rotation = face.ImageRot; primFace.MediaFlags = ((face.MediaFlags & 1) != 0); primFace.OffsetU = face.OffsetS; primFace.OffsetV = face.OffsetT; primFace.RepeatU = face.ScaleS; primFace.RepeatV = face.ScaleT; primFace.TexMapType = (MappingType)(face.MediaFlags & 6); } pbs.TextureEntry = tmp.GetBytes(); prim.Shape = pbs; prim.Scale = obj.Scale; SceneObjectGroup grp = new SceneObjectGroup(); grp.SetRootPart(prim); prim.ParentID = 0; if (i == 0) { rootGroup = grp; } grp.AttachToScene(m_scene); grp.AbsolutePosition = obj.Position; prim.RotationOffset = obj.Rotation; // Required for linking grp.RootPart.ClearUpdateSchedule(); if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) { m_scene.AddSceneObject(grp); grp.AbsolutePosition = obj.Position; } allparts[i] = grp; } for (int j = 1; j < allparts.Length; j++) { // Required for linking rootGroup.RootPart.ClearUpdateSchedule(); allparts[j].RootPart.ClearUpdateSchedule(); rootGroup.LinkToGroup(allparts[j]); } rootGroup.ScheduleGroupForFullAnimUpdate(); httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.RawBuffer = Util.UTF8NBGetbytes(String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(allparts[0].LocalId))); } catch { } httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; }