mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 22:26:09 +08:00
Thank you, HomerHorwitz, for a patch that implements llSetCameraParams/llClearCameraParams.
Fixes Mantis #1867
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user