diff options
author | Justin Clark-Casey (justincc) | 2011-08-11 23:28:14 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-11 23:28:14 +0100 |
commit | a21e98ae1a3e2f570cc119e020d4d4ea111e0ad2 (patch) | |
tree | a74d900e3d6ebc4b6fea7b2d4450505b960c4739 | |
parent | Implement osAgentSaveAppearance() to save the appearance of an avatar in the ... (diff) | |
download | opensim-SC_OLD-a21e98ae1a3e2f570cc119e020d4d4ea111e0ad2.zip opensim-SC_OLD-a21e98ae1a3e2f570cc119e020d4d4ea111e0ad2.tar.gz opensim-SC_OLD-a21e98ae1a3e2f570cc119e020d4d4ea111e0ad2.tar.bz2 opensim-SC_OLD-a21e98ae1a3e2f570cc119e020d4d4ea111e0ad2.tar.xz |
implement osNpcGetRot() and osNpcSetRot()
Rotation works if done around the z axis. Anything else leads to random results.
4 files changed, 67 insertions, 5 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 86ee28a..8a281d4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -369,7 +369,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
369 | } | 369 | } |
370 | 370 | ||
371 | // convert a LSL_Rotation to a Quaternion | 371 | // convert a LSL_Rotation to a Quaternion |
372 | protected Quaternion Rot2Quaternion(LSL_Rotation r) | 372 | public static Quaternion Rot2Quaternion(LSL_Rotation r) |
373 | { | 373 | { |
374 | Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | 374 | Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); |
375 | q.Normalize(); | 375 | q.Normalize(); |
@@ -2061,6 +2061,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2061 | { | 2061 | { |
2062 | return llGetRootRotation(); | 2062 | return llGetRootRotation(); |
2063 | } | 2063 | } |
2064 | |||
2064 | m_host.AddScriptLPS(1); | 2065 | m_host.AddScriptLPS(1); |
2065 | Quaternion q = m_host.GetWorldRotation(); | 2066 | Quaternion q = m_host.GetWorldRotation(); |
2066 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); | 2067 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 939602a..1874826 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2186,9 +2186,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2186 | 2186 | ||
2187 | if (npcModule != null) | 2187 | if (npcModule != null) |
2188 | { | 2188 | { |
2189 | UUID npcId = new UUID(npc.m_string); | 2189 | UUID npcId; |
2190 | 2190 | if (!UUID.TryParse(npc.m_string, out npcId)) | |
2191 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2192 | return; | 2191 | return; |
2193 | 2192 | ||
2194 | string appearanceSerialized = LoadNotecard(notecardNameOrUuid); | 2193 | string appearanceSerialized = LoadNotecard(notecardNameOrUuid); |
@@ -2210,8 +2209,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2210 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2209 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2211 | if (module != null) | 2210 | if (module != null) |
2212 | { | 2211 | { |
2212 | UUID npcId; | ||
2213 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2214 | return; | ||
2215 | |||
2213 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); | 2216 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); |
2214 | module.MoveToTarget(new UUID(npc.m_string), World, pos, false, true); | 2217 | module.MoveToTarget(npcId, World, pos, false, true); |
2215 | } | 2218 | } |
2216 | } | 2219 | } |
2217 | 2220 | ||
@@ -2222,6 +2225,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2222 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2225 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2223 | if (module != null) | 2226 | if (module != null) |
2224 | { | 2227 | { |
2228 | UUID npcId; | ||
2229 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2230 | return; | ||
2231 | |||
2225 | Vector3 pos = new Vector3((float)position.x, (float)position.y, (float)position.z); | 2232 | Vector3 pos = new Vector3((float)position.x, (float)position.y, (float)position.z); |
2226 | module.MoveToTarget( | 2233 | module.MoveToTarget( |
2227 | new UUID(npc.m_string), | 2234 | new UUID(npc.m_string), |
@@ -2232,6 +2239,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2232 | } | 2239 | } |
2233 | } | 2240 | } |
2234 | 2241 | ||
2242 | public LSL_Rotation osNpcGetRot(LSL_Key npc) | ||
2243 | { | ||
2244 | CheckThreatLevel(ThreatLevel.High, "osNpcGetRot"); | ||
2245 | |||
2246 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2247 | if (npcModule != null) | ||
2248 | { | ||
2249 | UUID npcId; | ||
2250 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2251 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | ||
2252 | |||
2253 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2254 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | ||
2255 | |||
2256 | ScenePresence sp = World.GetScenePresence(npcId); | ||
2257 | Quaternion rot = sp.Rotation; | ||
2258 | |||
2259 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | ||
2260 | } | ||
2261 | |||
2262 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | ||
2263 | } | ||
2264 | |||
2265 | public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) | ||
2266 | { | ||
2267 | CheckThreatLevel(ThreatLevel.High, "osNpcSetRot"); | ||
2268 | |||
2269 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2270 | if (npcModule != null) | ||
2271 | { | ||
2272 | UUID npcId; | ||
2273 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2274 | return; | ||
2275 | |||
2276 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2277 | return; | ||
2278 | |||
2279 | ScenePresence sp = World.GetScenePresence(npcId); | ||
2280 | sp.Rotation = LSL_Api.Rot2Quaternion(rotation); | ||
2281 | } | ||
2282 | } | ||
2283 | |||
2235 | public void osNpcStopMoveTo(LSL_Key npc) | 2284 | public void osNpcStopMoveTo(LSL_Key npc) |
2236 | { | 2285 | { |
2237 | CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); | 2286 | CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 88e1f15..7c08e84 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -173,6 +173,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
173 | void osNpcLoadAppearance(key npc, string notecardNameOrUuid); | 173 | void osNpcLoadAppearance(key npc, string notecardNameOrUuid); |
174 | void osNpcMoveTo(key npc, vector position); | 174 | void osNpcMoveTo(key npc, vector position); |
175 | void osNpcMoveToTarget(key npc, vector position, int options); | 175 | void osNpcMoveToTarget(key npc, vector position, int options); |
176 | rotation osNpcGetRot(key npc); | ||
177 | void osNpcSetRot(LSL_Key npc, rotation rot); | ||
176 | void osNpcStopMoveTo(LSL_Key npc); | 178 | void osNpcStopMoveTo(LSL_Key npc); |
177 | void osNpcSay(key npc, string message); | 179 | void osNpcSay(key npc, string message); |
178 | void osNpcRemove(key npc); | 180 | void osNpcRemove(key npc); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 4701736..e8e5f52 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -503,6 +503,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
503 | m_OSSL_Functions.osNpcMoveToTarget(npc, position, options); | 503 | m_OSSL_Functions.osNpcMoveToTarget(npc, position, options); |
504 | } | 504 | } |
505 | 505 | ||
506 | public rotation osNpcGetRot(key npc) | ||
507 | { | ||
508 | return m_OSSL_Functions.osNpcGetRot(npc); | ||
509 | } | ||
510 | |||
511 | public void osNpcSetRot(key npc, rotation rot) | ||
512 | { | ||
513 | m_OSSL_Functions.osNpcSetRot(npc, rot); | ||
514 | } | ||
515 | |||
506 | public void osNpcStopMoveTo(LSL_Key npc) | 516 | public void osNpcStopMoveTo(LSL_Key npc) |
507 | { | 517 | { |
508 | m_OSSL_Functions.osNpcStopMoveTo(npc); | 518 | m_OSSL_Functions.osNpcStopMoveTo(npc); |