public void AddNewParticleSystem(Primitive.ParticleSystem pSystem) { m_particleSystem = pSystem.GetBytes(); }
/// <summary> /// Update the textures on the part. /// </summary> /// <remarks> /// Added to handle bug in libsecondlife's TextureEntry.ToBytes() /// not handling RGBA properly. Cycles through, and "fixes" the color /// info /// </remarks> /// <param name="tex"></param> public void UpdateTexture(Primitive.TextureEntry tex) { //Color4 tmpcolor; //for (uint i = 0; i < 32; i++) //{ // if (tex.FaceTextures[i] != null) // { // tmpcolor = tex.GetFace((uint) i).RGBA; // tmpcolor.A = tmpcolor.A*255; // tmpcolor.R = tmpcolor.R*255; // tmpcolor.G = tmpcolor.G*255; // tmpcolor.B = tmpcolor.B*255; // tex.FaceTextures[i].RGBA = tmpcolor; // } //} //tmpcolor = tex.DefaultTexture.RGBA; //tmpcolor.A = tmpcolor.A*255; //tmpcolor.R = tmpcolor.R*255; //tmpcolor.G = tmpcolor.G*255; //tmpcolor.B = tmpcolor.B*255; //tex.DefaultTexture.RGBA = tmpcolor; UpdateTextureEntry(tex.GetBytes()); }
/// <summary> /// Set the sculptie texture and data on an object /// </summary> /// <param name="simulator">A reference to the <seealso cref="OpenMetaverse.Simulator"/> object where the object resides</param> /// <param name="localID">The objects ID which is local to the simulator the object is in</param> /// <param name="sculpt">A <seealso cref="Primitive.SculptData"/> object containing the data to set</param> public void SetSculpt(Simulator simulator, uint localID, Primitive.SculptData sculpt) { ObjectExtraParamsPacket extra = new ObjectExtraParamsPacket(); extra.AgentData.AgentID = Client.Self.AgentID; extra.AgentData.SessionID = Client.Self.SessionID; extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1]; extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock(); extra.ObjectData[0].ObjectLocalID = localID; extra.ObjectData[0].ParamType = (byte)ExtraParamType.Sculpt; extra.ObjectData[0].ParamInUse = true; extra.ObjectData[0].ParamData = sculpt.GetBytes(); extra.ObjectData[0].ParamSize = (uint)extra.ObjectData[0].ParamData.Length; Client.Network.SendPacket(extra, simulator); // Not sure why, but if you don't send this the sculpted prim disappears ObjectShapePacket shape = new ObjectShapePacket(); shape.AgentData.AgentID = Client.Self.AgentID; shape.AgentData.SessionID = Client.Self.SessionID; shape.ObjectData = new OpenMetaverse.Packets.ObjectShapePacket.ObjectDataBlock[1]; shape.ObjectData[0] = new OpenMetaverse.Packets.ObjectShapePacket.ObjectDataBlock(); shape.ObjectData[0].ObjectLocalID = localID; shape.ObjectData[0].PathScaleX = 100; shape.ObjectData[0].PathScaleY = 150; shape.ObjectData[0].PathCurve = 32; Client.Network.SendPacket(shape, simulator); }
/// <summary> /// Set the textures to apply to the faces of an object /// </summary> /// <param name="simulator">A reference to the <seealso cref="OpenMetaverse.Simulator"/> object where the object resides</param> /// <param name="localID">The objects ID which is local to the simulator the object is in</param> /// <param name="textures">The texture data to apply</param> /// <param name="mediaUrl">A media URL (not used)</param> public void SetTextures(Simulator simulator, uint localID, Primitive.TextureEntry textures, string mediaUrl) { ObjectImagePacket image = new ObjectImagePacket(); image.AgentData.AgentID = Client.Self.AgentID; image.AgentData.SessionID = Client.Self.SessionID; image.ObjectData = new ObjectImagePacket.ObjectDataBlock[1]; image.ObjectData[0] = new ObjectImagePacket.ObjectDataBlock(); image.ObjectData[0].ObjectLocalID = localID; image.ObjectData[0].TextureEntry = textures.GetBytes(); image.ObjectData[0].MediaURL = Utils.StringToBytes(mediaUrl); Client.Network.SendPacket(image, simulator); }
/// <summary> /// Set the flexible data on an object /// </summary> /// <param name="simulator">A reference to the <seealso cref="OpenMetaverse.Simulator"/> object where the object resides</param> /// <param name="localID">The objects ID which is local to the simulator the object is in</param> /// <param name="flexible">A <seealso cref="Primitive.FlexibleData"/> object containing the data to set</param> public void SetFlexible(Simulator simulator, uint localID, Primitive.FlexibleData flexible) { ObjectExtraParamsPacket extra = new ObjectExtraParamsPacket(); extra.AgentData.AgentID = Client.Self.AgentID; extra.AgentData.SessionID = Client.Self.SessionID; extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1]; extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock(); extra.ObjectData[0].ObjectLocalID = localID; extra.ObjectData[0].ParamType = (byte)ExtraParamType.Flexible; extra.ObjectData[0].ParamInUse = true; extra.ObjectData[0].ParamData = flexible.GetBytes(); extra.ObjectData[0].ParamSize = (uint)extra.ObjectData[0].ParamData.Length; Client.Network.SendPacket(extra, simulator); }
/// <summary> /// Set the Light data on an object /// </summary> /// <param name="simulator">A reference to the <seealso cref="OpenMetaverse.Simulator"/> object where the object resides</param> /// <param name="localID">The objects ID which is local to the simulator the object is in</param> /// <param name="light">A <seealso cref="Primitive.LightData"/> object containing the data to set</param> public void SetLight(Simulator simulator, uint localID, Primitive.LightData light) { ObjectExtraParamsPacket extra = new ObjectExtraParamsPacket(); extra.AgentData.AgentID = Client.Self.AgentID; extra.AgentData.SessionID = Client.Self.SessionID; extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1]; extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock(); extra.ObjectData[0].ObjectLocalID = localID; extra.ObjectData[0].ParamType = (byte)ExtraParamType.Light; if (light.Intensity == 0.0f) { // Disables the light if intensity is 0 extra.ObjectData[0].ParamInUse = false; } else { extra.ObjectData[0].ParamInUse = true; } extra.ObjectData[0].ParamData = light.GetBytes(); extra.ObjectData[0].ParamSize = (uint)extra.ObjectData[0].ParamData.Length; Client.Network.SendPacket(extra, simulator); }
/// <summary> /// Update the texture entry for this part. /// </summary> /// <param name="newTex"></param> public void UpdateTextureEntry(Primitive.TextureEntry newTex) { Primitive.TextureEntry oldTex = Shape.Textures; Changed changeFlags = 0; Primitive.TextureEntryFace fallbackNewFace = newTex.DefaultTexture; Primitive.TextureEntryFace fallbackOldFace = oldTex.DefaultTexture; // On Incoming packets, sometimes newText.DefaultTexture is null. The assumption is that all // other prim-sides are set, but apparently that's not always the case. Lets assume packet/data corruption at this point. if (fallbackNewFace == null) { fallbackNewFace = new Primitive.TextureEntry(Util.BLANK_TEXTURE_UUID).CreateFace(0); newTex.DefaultTexture = fallbackNewFace; } if (fallbackOldFace == null) { fallbackOldFace = new Primitive.TextureEntry(Util.BLANK_TEXTURE_UUID).CreateFace(0); oldTex.DefaultTexture = fallbackOldFace; } // Materials capable viewers can send a ObjectImage packet // when nothing in TE has changed. MaterialID should be updated // by the RenderMaterials CAP handler, so updating it here may cause a // race condtion. Therefore, if no non-materials TE fields have changed, // we should ignore any changes and not update Shape.TextureEntry bool otherFieldsChanged = false; for (int i = 0 ; i < GetNumberOfSides(); i++) { Primitive.TextureEntryFace newFace = newTex.DefaultTexture; Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture; if (oldTex.FaceTextures[i] != null) oldFace = oldTex.FaceTextures[i]; if (newTex.FaceTextures[i] != null) newFace = newTex.FaceTextures[i]; Color4 oldRGBA = oldFace.RGBA; Color4 newRGBA = newFace.RGBA; if (oldRGBA.R != newRGBA.R || oldRGBA.G != newRGBA.G || oldRGBA.B != newRGBA.B || oldRGBA.A != newRGBA.A) changeFlags |= Changed.COLOR; if (oldFace.TextureID != newFace.TextureID) changeFlags |= Changed.TEXTURE; // Max change, skip the rest of testing if (changeFlags == (Changed.TEXTURE | Changed.COLOR)) break; if (!otherFieldsChanged) { if (oldFace.Bump != newFace.Bump) otherFieldsChanged = true; if (oldFace.Fullbright != newFace.Fullbright) otherFieldsChanged = true; if (oldFace.Glow != newFace.Glow) otherFieldsChanged = true; if (oldFace.MediaFlags != newFace.MediaFlags) otherFieldsChanged = true; if (oldFace.OffsetU != newFace.OffsetU) otherFieldsChanged = true; if (oldFace.OffsetV != newFace.OffsetV) otherFieldsChanged = true; if (oldFace.RepeatU != newFace.RepeatU) otherFieldsChanged = true; if (oldFace.RepeatV != newFace.RepeatV) otherFieldsChanged = true; if (oldFace.Rotation != newFace.Rotation) otherFieldsChanged = true; if (oldFace.Shiny != newFace.Shiny) otherFieldsChanged = true; if (oldFace.TexMapType != newFace.TexMapType) otherFieldsChanged = true; } } if (changeFlags != 0 || otherFieldsChanged) { m_shape.TextureEntry = newTex.GetBytes(); if (changeFlags != 0) TriggerScriptChangedEvent(changeFlags); UpdateFlag = UpdateRequired.FULL; ParentGroup.HasGroupChanged = true; //This is madness.. //ParentGroup.ScheduleGroupForFullUpdate(); //This is sparta ScheduleFullUpdate(); } }
/// <summary> /// Update the texture entry for this part. /// </summary> /// <param name="newTex"></param> public void UpdateTextureEntry(Primitive.TextureEntry newTex) { Primitive.TextureEntry oldTex = Shape.Textures; Changed changeFlags = 0; for (int i = 0 ; i < GetNumberOfSides(); i++) { Primitive.TextureEntryFace newFace = newTex.DefaultTexture; Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture; if (oldTex.FaceTextures[i] != null) oldFace = oldTex.FaceTextures[i]; if (newTex.FaceTextures[i] != null) newFace = newTex.FaceTextures[i]; Color4 oldRGBA = oldFace.RGBA; Color4 newRGBA = newFace.RGBA; if (oldRGBA.R != newRGBA.R || oldRGBA.G != newRGBA.G || oldRGBA.B != newRGBA.B || oldRGBA.A != newRGBA.A) changeFlags |= Changed.COLOR; if (oldFace.TextureID != newFace.TextureID) changeFlags |= Changed.TEXTURE; // Max change, skip the rest of testing if (changeFlags == (Changed.TEXTURE | Changed.COLOR)) break; } m_shape.TextureEntry = newTex.GetBytes(); if (changeFlags != 0) TriggerScriptChangedEvent(changeFlags); UpdateFlag = UpdateRequired.FULL; ParentGroup.HasGroupChanged = true; //This is madness.. //ParentGroup.ScheduleGroupForFullUpdate(); //This is sparta ScheduleFullUpdate(); }
/// <summary> /// Update the texture entry for this part. /// </summary> /// <param name="newTex"></param> public void UpdateTextureEntry(Primitive.TextureEntry newTex) { Primitive.TextureEntry oldTex = Shape.Textures; Changed changeFlags = 0; Primitive.TextureEntryFace fallbackNewFace = newTex.DefaultTexture; Primitive.TextureEntryFace fallbackOldFace = oldTex.DefaultTexture; // On Incoming packets, sometimes newText.DefaultTexture is null. The assumption is that all // other prim-sides are set, but apparently that's not always the case. Lets assume packet/data corruption at this point. if (fallbackNewFace == null) { fallbackNewFace = new Primitive.TextureEntry(Util.BLANK_TEXTURE_UUID).CreateFace(0); newTex.DefaultTexture = fallbackNewFace; } if (fallbackOldFace == null) { fallbackOldFace = new Primitive.TextureEntry(Util.BLANK_TEXTURE_UUID).CreateFace(0); oldTex.DefaultTexture = fallbackOldFace; } for (int i = 0 ; i < GetNumberOfSides(); i++) { Primitive.TextureEntryFace newFace = newTex.DefaultTexture; Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture; if (oldTex.FaceTextures[i] != null) oldFace = oldTex.FaceTextures[i]; if (newTex.FaceTextures[i] != null) newFace = newTex.FaceTextures[i]; Color4 oldRGBA = oldFace.RGBA; Color4 newRGBA = newFace.RGBA; if (oldRGBA.R != newRGBA.R || oldRGBA.G != newRGBA.G || oldRGBA.B != newRGBA.B || oldRGBA.A != newRGBA.A) changeFlags |= Changed.COLOR; if (oldFace.TextureID != newFace.TextureID) changeFlags |= Changed.TEXTURE; // Max change, skip the rest of testing if (changeFlags == (Changed.TEXTURE | Changed.COLOR)) break; } m_shape.TextureEntry = newTex.GetBytes(); if (changeFlags != 0) TriggerScriptChangedEvent(changeFlags); UpdateFlag = UpdateRequired.FULL; ParentGroup.HasGroupChanged = true; //This is madness.. //ParentGroup.ScheduleGroupForFullUpdate(); //This is sparta ScheduleFullUpdate(); }