Thank you, HomerHorwitz, for a patch that implements llSetCameraParams/llClearCameraParams.

Fixes Mantis #1867
0.6.0-stable
Melanie Thielker 2008-07-31 12:31:31 +00:00
parent 244ad2e614
commit c441a03ea3
8 changed files with 230 additions and 4 deletions

View File

@ -718,5 +718,8 @@ namespace OpenSim.Framework
ClientInfo GetClientInfo();
void SetClientInfo(ClientInfo info);
void Terminate();
void SendSetFollowCamProperties(LLUUID objectID, SortedDictionary<int, float> parameters);
void SendClearFollowCamProperties(LLUUID objectID);
}
}

View File

@ -6281,5 +6281,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
#endregion
#region Camera
public void SendSetFollowCamProperties (LLUUID objectID, SortedDictionary<int, float> parameters)
{
SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
packet.ObjectData.ObjectID = objectID;
SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
uint idx = 0;
foreach(KeyValuePair<int, float> pair in parameters)
{
SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
block.Type = pair.Key;
block.Value = pair.Value;
camPropBlock[idx++] = block;
}
packet.CameraProperty = camPropBlock;
OutPacket(packet, ThrottleOutPacketType.Task);
}
public void SendClearFollowCamProperties (LLUUID objectID)
{
ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
packet.ObjectData.ObjectID = objectID;
OutPacket(packet, ThrottleOutPacketType.Task);
}
#endregion
}
}

View File

@ -824,5 +824,13 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
byte mediaLoop)
{
}
public void SendSetFollowCamProperties (LLUUID objectID, SortedDictionary<int, float> parameters)
{
}
public void SendClearFollowCamProperties (LLUUID objectID)
{
}
}
}

View File

@ -824,5 +824,13 @@ namespace OpenSim.Region.Examples.SimpleModule
{
}
public void SendSetFollowCamProperties (LLUUID objectID, SortedDictionary<int, float> parameters)
{
}
public void SendClearFollowCamProperties (LLUUID objectID)
{
}
}
}

View File

@ -2425,5 +2425,30 @@ namespace OpenSim.Region.ScriptEngine.Common
// Can not be public const?
public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
public static readonly rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
// constants for llSetCameraParams
public const int CAMERA_PITCH = 0;
public const int CAMERA_FOCUS_OFFSET = 1;
public const int CAMERA_FOCUS_OFFSET_X = 2;
public const int CAMERA_FOCUS_OFFSET_Y = 3;
public const int CAMERA_FOCUS_OFFSET_Z = 4;
public const int CAMERA_POSITION_LAG = 5;
public const int CAMERA_FOCUS_LAG = 6;
public const int CAMERA_DISTANCE = 7;
public const int CAMERA_BEHINDNESS_ANGLE = 8;
public const int CAMERA_BEHINDNESS_LAG = 9;
public const int CAMERA_POSITION_THRESHOLD = 10;
public const int CAMERA_FOCUS_THRESHOLD = 11;
public const int CAMERA_ACTIVE = 12;
public const int CAMERA_POSITION = 13;
public const int CAMERA_POSITION_X = 14;
public const int CAMERA_POSITION_Y = 15;
public const int CAMERA_POSITION_Z = 16;
public const int CAMERA_FOCUS = 17;
public const int CAMERA_FOCUS_X = 18;
public const int CAMERA_FOCUS_Y = 19;
public const int CAMERA_FOCUS_Z = 20;
public const int CAMERA_POSITION_LOCKED = 21;
public const int CAMERA_FOCUS_LOCKED = 22;
}
}

View File

@ -6917,13 +6917,77 @@ namespace OpenSim.Region.ScriptEngine.Common
public void llSetCameraParams(LSL_Types.list rules)
{
m_host.AddScriptLPS(1);
NotImplemented("llSetCameraParams");
// our key in the object we are in
LLUUID invItemID=InventorySelf();
if (invItemID == LLUUID.Zero) return;
// the object we are in
LLUUID objectID = m_host.ParentUUID;
if(objectID == LLUUID.Zero) return;
// we need the permission first, to know which avatar we want to set the camera for
LLUUID agentID = m_host.TaskInventory[invItemID].PermsGranter;
if (agentID == LLUUID.Zero) return;
if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
ScenePresence presence = World.GetScenePresence(agentID);
// we are not interested in child-agents
if(presence.IsChildAgent) return;
SortedDictionary<int, float> parameters = new SortedDictionary<int, float>();
object[] data = rules.Data;
for(int i = 0; i < data.Length; ++i) {
int type = Convert.ToInt32(data[i++]);
if(i >= data.Length) break; // odd number of entries => ignore the last
// some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3)
switch(type) {
case BuiltIn_Commands_BaseClass.CAMERA_FOCUS:
case BuiltIn_Commands_BaseClass.CAMERA_FOCUS_OFFSET:
case BuiltIn_Commands_BaseClass.CAMERA_POSITION:
LSL_Types.Vector3 v = (LSL_Types.Vector3)data[i];
parameters.Add(type + 1, (float)v.x);
parameters.Add(type + 2, (float)v.y);
parameters.Add(type + 3, (float)v.z);
break;
default:
// TODO: clean that up as soon as the implicit casts are in
if(data[i] is LSL_Types.LSLFloat)
parameters.Add(type, (float)((LSL_Types.LSLFloat)data[i]).value);
else if(data[i] is LSL_Types.LSLInteger)
parameters.Add(type, (float)((LSL_Types.LSLInteger)data[i]).value);
else parameters.Add(type, Convert.ToSingle(data[i]));
break;
}
}
if(parameters.Count > 0) presence.ControllingClient.SendSetFollowCamProperties(objectID, parameters);
}
public void llClearCameraParams()
{
m_host.AddScriptLPS(1);
NotImplemented("llClearCameraParams");
// our key in the object we are in
LLUUID invItemID=InventorySelf();
if (invItemID == LLUUID.Zero) return;
// the object we are in
LLUUID objectID = m_host.ParentUUID;
if(objectID == LLUUID.Zero) return;
// we need the permission first, to know which avatar we want to clear the camera for
LLUUID agentID = m_host.TaskInventory[invItemID].PermsGranter;
if (agentID == LLUUID.Zero) return;
if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
ScenePresence presence = World.GetScenePresence(agentID);
// we are not interested in child-agents
if(presence.IsChildAgent) return;
presence.ControllingClient.SendClearFollowCamProperties(objectID);
}
public double llListStatistics(int operation, LSL_Types.list src)

View File

@ -6695,13 +6695,77 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetCameraParams(LSL_Types.list rules)
{
m_host.AddScriptLPS(1);
NotImplemented("llSetCameraParams");
// our key in the object we are in
LLUUID invItemID=InventorySelf();
if (invItemID == LLUUID.Zero) return;
// the object we are in
LLUUID objectID = m_host.ParentUUID;
if(objectID == LLUUID.Zero) return;
// we need the permission first, to know which avatar we want to set the camera for
LLUUID agentID = m_host.TaskInventory[invItemID].PermsGranter;
if (agentID == LLUUID.Zero) return;
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
ScenePresence presence = World.GetScenePresence(agentID);
// we are not interested in child-agents
if(presence.IsChildAgent) return;
SortedDictionary<int, float> parameters = new SortedDictionary<int, float>();
object[] data = rules.Data;
for(int i = 0; i < data.Length; ++i) {
int type = Convert.ToInt32(data[i++]);
if(i >= data.Length) break; // odd number of entries => ignore the last
// some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3)
switch(type) {
case ScriptBaseClass.CAMERA_FOCUS:
case ScriptBaseClass.CAMERA_FOCUS_OFFSET:
case ScriptBaseClass.CAMERA_POSITION:
LSL_Types.Vector3 v = (LSL_Types.Vector3)data[i];
parameters.Add(type + 1, (float)v.x);
parameters.Add(type + 2, (float)v.y);
parameters.Add(type + 3, (float)v.z);
break;
default:
// TODO: clean that up as soon as the implicit casts are in
if(data[i] is LSL_Types.LSLFloat)
parameters.Add(type, (float)((LSL_Types.LSLFloat)data[i]).value);
else if(data[i] is LSL_Types.LSLInteger)
parameters.Add(type, (float)((LSL_Types.LSLInteger)data[i]).value);
else parameters.Add(type, Convert.ToSingle(data[i]));
break;
}
}
if(parameters.Count > 0) presence.ControllingClient.SendSetFollowCamProperties(objectID, parameters);
}
public void llClearCameraParams()
{
m_host.AddScriptLPS(1);
NotImplemented("llClearCameraParams");
// our key in the object we are in
LLUUID invItemID=InventorySelf();
if (invItemID == LLUUID.Zero) return;
// the object we are in
LLUUID objectID = m_host.ParentUUID;
if(objectID == LLUUID.Zero) return;
// we need the permission first, to know which avatar we want to clear the camera for
LLUUID agentID = m_host.TaskInventory[invItemID].PermsGranter;
if (agentID == LLUUID.Zero) return;
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
ScenePresence presence = World.GetScenePresence(agentID);
// we are not interested in child-agents
if(presence.IsChildAgent) return;
presence.ControllingClient.SendClearFollowCamProperties(objectID);
}
public double llListStatistics(int operation, LSL_Types.list src)

View File

@ -421,5 +421,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
public static readonly rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
// constants for llSetCameraParams
public const int CAMERA_PITCH = 0;
public const int CAMERA_FOCUS_OFFSET = 1;
public const int CAMERA_FOCUS_OFFSET_X = 2;
public const int CAMERA_FOCUS_OFFSET_Y = 3;
public const int CAMERA_FOCUS_OFFSET_Z = 4;
public const int CAMERA_POSITION_LAG = 5;
public const int CAMERA_FOCUS_LAG = 6;
public const int CAMERA_DISTANCE = 7;
public const int CAMERA_BEHINDNESS_ANGLE = 8;
public const int CAMERA_BEHINDNESS_LAG = 9;
public const int CAMERA_POSITION_THRESHOLD = 10;
public const int CAMERA_FOCUS_THRESHOLD = 11;
public const int CAMERA_ACTIVE = 12;
public const int CAMERA_POSITION = 13;
public const int CAMERA_POSITION_X = 14;
public const int CAMERA_POSITION_Y = 15;
public const int CAMERA_POSITION_Z = 16;
public const int CAMERA_FOCUS = 17;
public const int CAMERA_FOCUS_X = 18;
public const int CAMERA_FOCUS_Y = 19;
public const int CAMERA_FOCUS_Z = 20;
public const int CAMERA_POSITION_LOCKED = 21;
public const int CAMERA_FOCUS_LOCKED = 22;
}
}