implement osNpcGetRot() and osNpcSetRot()

Rotation works if done around the z axis.  Anything else leads to random results.
This commit is contained in:
Justin Clark-Casey (justincc)
2011-08-11 23:28:14 +01:00
parent b1ae930c6b
commit a21e98ae1a
4 changed files with 67 additions and 5 deletions

View File

@@ -2186,9 +2186,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (npcModule != null)
{
UUID npcId = new UUID(npc.m_string);
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return;
string appearanceSerialized = LoadNotecard(notecardNameOrUuid);
@@ -2210,8 +2209,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return;
Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
module.MoveToTarget(new UUID(npc.m_string), World, pos, false, true);
module.MoveToTarget(npcId, World, pos, false, true);
}
}
@@ -2222,6 +2225,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return;
Vector3 pos = new Vector3((float)position.x, (float)position.y, (float)position.z);
module.MoveToTarget(
new UUID(npc.m_string),
@@ -2232,6 +2239,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
public LSL_Rotation osNpcGetRot(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.High, "osNpcGetRot");
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
ScenePresence sp = World.GetScenePresence(npcId);
Quaternion rot = sp.Rotation;
return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W);
}
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W);
}
public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSetRot");
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
if (npcModule != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
return;
if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene))
return;
ScenePresence sp = World.GetScenePresence(npcId);
sp.Rotation = LSL_Api.Rot2Quaternion(rotation);
}
}
public void osNpcStopMoveTo(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo");