public byte[] GetLightBytes() { byte[] data = new byte[16]; try { if (_lightIntensity > 1) { _lightIntensity = 1; } // Alpha channel in color is intensity Color4 tmpColor = new Color4(_lightColorR, _lightColorG, _lightColorB, _lightIntensity); tmpColor.GetBytes().CopyTo(data, 0); Utils.FloatToBytes(_lightRadius).CopyTo(data, 4); Utils.FloatToBytes(_lightCutoff).CopyTo(data, 8); Utils.FloatToBytes(_lightFalloff).CopyTo(data, 12); } catch (Exception ex) { m_log.Warn("Error GetLightBytes: " + ex.ToString()); } return(data); }
public byte[] GetLightBytes() { byte[] data = new byte[16]; // Alpha channel in color is intensity Color4 tmpColor = new Color4(_lightColorR, _lightColorG, _lightColorB, _lightIntensity); tmpColor.GetBytes().CopyTo(data, 0); Utils.FloatToBytes(_lightRadius).CopyTo(data, 4); Utils.FloatToBytes(_lightCutoff).CopyTo(data, 8); Utils.FloatToBytes(_lightFalloff).CopyTo(data, 12); return(data); }
/// <summary> /// Create a particle swirl around a target position using a <seealso cref="ViewerEffectPacket"/> packet /// </summary> /// <param name="globalOffset">global offset</param> /// <param name="color">A <see cref="Color4"/> object containing the combined red, green, blue and alpha /// color values of particle beam</param> /// <param name="duration">a float representing the duration the parcicle beam will last</param> /// <param name="effectID">A Unique ID for the beam</param> public void SphereEffect(Vector3d globalOffset, Color4 color, float duration, UUID effectID) { ViewerEffectPacket effect = new ViewerEffectPacket(); effect.AgentData.AgentID = Client.Self.AgentID; effect.AgentData.SessionID = Client.Self.SessionID; effect.Effect = new ViewerEffectPacket.EffectBlock[1]; effect.Effect[0] = new ViewerEffectPacket.EffectBlock(); effect.Effect[0].AgentID = Client.Self.AgentID; effect.Effect[0].Color = color.GetBytes(); effect.Effect[0].Duration = duration; effect.Effect[0].ID = effectID; effect.Effect[0].Type = (byte)EffectType.Sphere; byte[] typeData = new byte[56]; Buffer.BlockCopy(UUID.Zero.GetBytes(), 0, typeData, 0, 16); Buffer.BlockCopy(UUID.Zero.GetBytes(), 0, typeData, 16, 16); Buffer.BlockCopy(globalOffset.GetBytes(), 0, typeData, 32, 24); effect.Effect[0].TypeData = typeData; Client.Network.SendPacket(effect); }
public byte[] GetLightBytes() { byte[] data = new byte[16]; // Alpha channel in color is intensity Color4 tmpColor = new Color4(_lightColorR,_lightColorG,_lightColorB,_lightIntensity); tmpColor.GetBytes().CopyTo(data, 0); Utils.FloatToBytes(_lightRadius).CopyTo(data, 4); Utils.FloatToBytes(_lightCutoff).CopyTo(data, 8); Utils.FloatToBytes(_lightFalloff).CopyTo(data, 12); return data; }
public byte[] ExtraParamsToBytes() { // m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()"); const byte FlexiEP = 0x10; const byte LightEP = 0x20; const byte SculptEP = 0x30; const byte ProjectionEP = 0x40; int TotalBytesLength = 1; // ExtraParamsNum uint ExtraParamsNum = 0; if (_flexiEntry) { ExtraParamsNum++; TotalBytesLength += 16 + 2 + 4;// data } if (_lightEntry) { ExtraParamsNum++; TotalBytesLength += 16 + 2 + 4; // data } if (_sculptEntry) { ExtraParamsNum++; TotalBytesLength += 17 + 2 + 4;// data } if (_projectionEntry) { ExtraParamsNum++; TotalBytesLength += 28 + 2 + 4; // data } byte[] returnBytes = new byte[TotalBytesLength]; returnBytes[0] = (byte)ExtraParamsNum; if (ExtraParamsNum == 0) { return(returnBytes); } int i = 1; if (_flexiEntry) { returnBytes[i] = FlexiEP; // 2 bytes id code i += 2; returnBytes[i] = 16; // 4 bytes size i += 4; // Softness is packed in the upper bits of tension and drag returnBytes[i] = (byte)((_flexiSoftness & 2) << 6); returnBytes[i + 1] = (byte)((_flexiSoftness & 1) << 7); returnBytes[i++] |= (byte)((byte)(_flexiTension * 10.01f) & 0x7F); returnBytes[i++] |= (byte)((byte)(_flexiDrag * 10.01f) & 0x7F); returnBytes[i++] = (byte)((_flexiGravity + 10.0f) * 10.01f); returnBytes[i++] = (byte)(_flexiWind * 10.01f); Utils.FloatToBytes(_flexiForceX, returnBytes, i); Utils.FloatToBytes(_flexiForceY, returnBytes, i + 4); Utils.FloatToBytes(_flexiForceZ, returnBytes, i + 8); i += 12; } if (_lightEntry) { returnBytes[i] = LightEP; i += 2; returnBytes[i] = 16; i += 4; // Alpha channel in color is intensity Color4 tmpColor = new Color4(_lightColorR, _lightColorG, _lightColorB, _lightIntensity); tmpColor.GetBytes().CopyTo(returnBytes, i); Utils.FloatToBytes(_lightRadius, returnBytes, i + 4); Utils.FloatToBytes(_lightCutoff, returnBytes, i + 8); Utils.FloatToBytes(_lightFalloff, returnBytes, i + 12); i += 16; } if (_sculptEntry) { returnBytes[i] = SculptEP; i += 2; returnBytes[i] = 17; i += 4; _sculptTexture.GetBytes().CopyTo(returnBytes, i); i += 16; returnBytes[i++] = _sculptType; } if (_projectionEntry) { returnBytes[i] = ProjectionEP; i += 2; returnBytes[i] = 28; i += 4; _projectionTextureID.GetBytes().CopyTo(returnBytes, i); Utils.FloatToBytes(_projectionFOV).CopyTo(returnBytes, i + 16); Utils.FloatToBytes(_projectionFocus).CopyTo(returnBytes, i + 20); Utils.FloatToBytes(_projectionAmb).CopyTo(returnBytes, i + 24); } return(returnBytes); }
/// <summary> /// /// </summary> /// <param name="data"></param> public void PackColor(Color4 data) { byte[] bytes = data.GetBytes(); PackBitArray(bytes, 32); }
/// <summary> /// Create a particle beam between an avatar and an primitive /// </summary> /// <param name="sourceAvatar"><seealso cref="Guid"/> of sources avatar</param> /// <param name="targetObject"><seealso cref="Guid"/> of the target</param> /// <param name="globalOffset"><seealso cref="Vector3d"/>global offset</param> /// <param name="color"><seealso cref="Color4"/>Color values of beam</param> /// <param name="duration">a float representing the duration the beam will last</param> /// <param name="effectID"><seealso cref="Guid"/> of the Effect</param> public void BeamEffect(Guid sourceAvatar, Guid targetObject, Vector3d globalOffset, Color4 color, float duration, Guid effectID) { ViewerEffectPacket effect = new ViewerEffectPacket(); effect.AgentData.AgentID = Client.Self.AgentID; effect.AgentData.SessionID = Client.Self.SessionID; effect.Effect = new ViewerEffectPacket.EffectBlock[1]; effect.Effect[0] = new ViewerEffectPacket.EffectBlock(); effect.Effect[0].AgentID = Client.Self.AgentID; effect.Effect[0].Color = color.GetBytes(); effect.Effect[0].Duration = duration; effect.Effect[0].ID = effectID; effect.Effect[0].Type = (byte)EffectType.Beam; byte[] typeData = new byte[56]; Buffer.BlockCopy(sourceAvatar.GetBytes(), 0, typeData, 0, 16); Buffer.BlockCopy(targetObject.GetBytes(), 0, typeData, 16, 16); Buffer.BlockCopy(globalOffset.GetBytes(), 0, typeData, 32, 24); effect.Effect[0].TypeData = typeData; Client.Network.SendPacket(effect); }