private void button1_Click(object sender, System.EventArgs e)
{
Selectbeam(_zyngoData.PointAtTargetId);
_client.Self.Touch(_zyngoData.LocalId);
Unselectbeam();
}
using System;
using OpenMetaverse;
namespace ZyngoClass
{
public partial class ZyngoClass
{
UUID _beamkey = UUID.Zero; // zero then unused
UUID _pointkey = UUID.Zero; // else filt wit random uniek number( inuse).
#region bug fix color.
private void BeamEffect(UUID sourceAvatar,
UUID targetObject,
Vector3d globalOffset,
Color4 color,
float duration,
UUID effectId)
{
//OpenMetaverse.Packets.ViewerEffectPacket effect = new OpenMetaverse.Packets.ViewerEffectPacket();
var effect
= new OpenMetaverse.
Packets.
ViewerEffectPacket
{
AgentData =
{
AgentID = _client.Self.AgentID,
SessionID = _client.Self.SessionID
},
Effect
= new OpenMetaverse.
Packets.
ViewerEffectPacket.
EffectBlock[1
]
};
effect.
Effect[0
] = new OpenMetaverse.
Packets.
ViewerEffectPacket.
EffectBlock
{
AgentID = _client.Self.AgentID,
Color = color.GetBytes(),
Duration = duration,
ID = effectId,
Type = (byte) EffectType.Beam
};
var 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);
}
#endregion
void Selectbeam(UUID objectuuid)
{
// restore animation in case of busy ?
// 09-02-2010
if (_client.Self.SignaledAnimations.ContainsKey(Animations.BUSY))
_client.Self.AnimationStop(Animations.BUSY, true);
Unselectbeam();
//logstatus("Selecting object with beam.");
while (UUID.Zero == (_beamkey = UUID.Random())) { };// new code !!
while (UUID.Zero == (_pointkey = UUID.Random())) { };// new code !!
//LogText ("debug start point : "+_beamkey.ToString()+ " // "+ _pointkey.ToString(),Color.Yellow);
BeamEffect(_client.Self.AgentID,
objectuuid,
Vector3d.Zero,
new Color4
(1f, 1f, 1f, 1f
),
1f, // 1 seconden !!!!
_beamkey);
_client.Self.PointAtEffect(_client.Self.AgentID,
objectuuid,
Vector3d.Zero,
PointAtType.Select,
_pointkey);
}
private void Unselectbeam()
{
if (_beamkey != UUID.Zero)
{
//LogText("debug : stop beam", Color.White);
BeamEffect(_client.Self.AgentID,
UUID.Zero,
Vector3d.Zero,
_client.Settings.DEFAULT_EFFECT_COLOR,
//new Color4(1f, 1f, 1f, 1f),
0f,
_beamkey);
// 09-02-2010 2x?
BeamEffect(_client.Self.AgentID,
UUID.Zero,
Vector3d.Zero,
new Color4
(0f, 0f, 0f, 0f
),
0f,
_beamkey);
_beamkey = UUID.Zero;// clear
}
if (_pointkey == UUID.Zero) return;
//LogText("debug : stop point", Color.White);
_client.Self.PointAtEffect(_client.Self.AgentID,
UUID.Zero,
Vector3d.Zero,
PointAtType.None,
_pointkey);
_client.Self.PointAtEffect(_client.Self.AgentID,
UUID.Zero,
Vector3d.Zero,
PointAtType.None,
_pointkey);
_pointkey = UUID.Zero; // clear
}
}
}