29 using System.Collections.Generic;
30 using System.Reflection;
34 using NUnit.Framework;
36 using OpenMetaverse.Assets;
37 using OpenMetaverse.StructuredData;
38 using OpenSim.Framework;
39 using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40 using OpenSim.Region.OptionalModules.World.NPC;
41 using OpenSim.Region.Framework.Scenes;
42 using OpenSim.Region.ScriptEngine.Shared;
43 using OpenSim.Region.ScriptEngine.Shared.Api;
44 using OpenSim.Region.ScriptEngine.Shared.Instance;
45 using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
46 using OpenSim.Services.Interfaces;
47 using OpenSim.Tests.Common;
51 namespace OpenSim.
Region.ScriptEngine.Shared.Tests
56 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
57 private const float FLOAT_ACCURACY = 0.00005f;
67 IConfigSource initConfigSource =
new IniConfigSource();
68 IConfig config = initConfigSource.AddConfig(
"XEngine");
69 config.Set(
"Enabled",
"true");
72 SceneHelpers.SetupSceneModules(m_scene, initConfigSource);
75 m_engine.Initialise(initConfigSource);
76 m_engine.AddRegion(m_scene);
82 TestHelpers.InMethod();
83 TestHelpers.EnableLogging();
85 UUID ownerId = TestHelpers.ParseTail(0x1);
87 SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId,
"grp1-", 0x10);
88 grp1.AbsolutePosition =
new Vector3(10, 11, 12);
89 m_scene.AddSceneObject(grp1);
92 apiGrp1.Initialize(m_engine, grp1.RootPart, null);
99 Assert.That(resList.Length, Is.EqualTo(1));
105 = apiGrp1.llGetLinkPrimitiveParams(
113 Assert.That(resList.Length, Is.EqualTo(2));
121 Assert.That(resList.Length, Is.EqualTo(0));
127 = apiGrp1.llGetLinkPrimitiveParams(
135 Assert.That(resList.Length, Is.EqualTo(0));
141 = apiGrp1.llGetLinkPrimitiveParams(
149 Assert.That(resList.Length, Is.EqualTo(1));
157 TestHelpers.InMethod();
161 string obj1Name =
"Prim1";
162 UUID objUuid =
new UUID(
"00000000-0000-0000-0000-000000000001");
165 Vector3.Zero, Quaternion.Identity,
166 Vector3.Zero) { Name = obj1Name, UUID = objUuid };
167 Assert.That(scene.AddNewSceneObject(
new SceneObjectGroup(part1),
false), Is.True);
170 apiGrp1.Initialize(m_engine, part1, null);
178 CheckllSetPrimitiveParams(
182 ScriptBaseClass.PRIM_TYPE_SPHERE,
183 ScriptBaseClass.PRIM_HOLE_DEFAULT,
191 CheckllSetPrimitiveParams(
195 ScriptBaseClass.PRIM_TYPE_PRISM,
196 ScriptBaseClass.PRIM_HOLE_CIRCLE,
205 CheckllSetPrimitiveParams(
209 ScriptBaseClass.PRIM_TYPE_BOX,
210 ScriptBaseClass.PRIM_HOLE_TRIANGLE,
219 CheckllSetPrimitiveParams(
223 ScriptBaseClass.PRIM_TYPE_TUBE,
224 ScriptBaseClass.PRIM_HOLE_SQUARE,
227 new LSL_Types.Vector3(1.0d, -1.0d, 0.0d),
231 new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d),
235 new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d),
242 CheckllSetPrimitiveParams(
246 ScriptBaseClass.PRIM_TYPE_PRISM,
247 ScriptBaseClass.PRIM_HOLE_SQUARE,
252 new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d),
260 CheckllSetPrimitiveParams(
264 ScriptBaseClass.PRIM_TYPE_SCULPT,
265 "be293869-d0d9-0a69-5989-ad27f1946fd4",
266 ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE);
271 LSL_Types.Vector3 primSize,
int primType,
int primHoleType,
LSL_Types.Vector3 primCut,
273 float primHollowCheck)
276 api.llSetPrimitiveParams(
new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
277 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
278 primCut, primHollow, primTwist, primTaper, primShear));
282 api.llGetPrimitiveParams(
new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
285 CheckllSetPrimitiveParamsVector(primSize, api.
llList2Vector(primParams, 0), primTest +
" prim size");
286 Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
287 "TestllSetPrimitiveParams " + primTest +
" prim type check fail");
288 Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2),
289 "TestllSetPrimitiveParams " + primTest +
" prim hole default check fail");
290 CheckllSetPrimitiveParamsVector(primCut, api.
llList2Vector(primParams, 3), primTest +
" prim cut");
291 Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY,
292 "TestllSetPrimitiveParams " + primTest +
" prim hollow check fail");
293 CheckllSetPrimitiveParamsVector(primTwist, api.
llList2Vector(primParams, 5), primTest +
" prim twist");
294 CheckllSetPrimitiveParamsVector(primTaper, api.
llList2Vector(primParams, 6), primTest +
" prim taper");
295 CheckllSetPrimitiveParamsVector(primShear, api.
llList2Vector(primParams, 7), primTest +
" prim shear");
300 LSL_Types.Vector3 primSize,
int primType,
int primHoleType,
LSL_Types.Vector3 primCut,
301 float primHollow,
LSL_Types.Vector3 primTwist,
LSL_Types.Vector3 primDimple,
float primHollowCheck)
304 api.llSetPrimitiveParams(
new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
305 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
306 primCut, primHollow, primTwist, primDimple));
310 api.llGetPrimitiveParams(
new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
313 CheckllSetPrimitiveParamsVector(primSize, api.
llList2Vector(primParams, 0), primTest +
" prim size");
314 Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
315 "TestllSetPrimitiveParams " + primTest +
" prim type check fail");
316 Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2),
317 "TestllSetPrimitiveParams " + primTest +
" prim hole default check fail");
318 CheckllSetPrimitiveParamsVector(primCut, api.
llList2Vector(primParams, 3), primTest +
" prim cut");
319 Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY,
320 "TestllSetPrimitiveParams " + primTest +
" prim hollow check fail");
321 CheckllSetPrimitiveParamsVector(primTwist, api.
llList2Vector(primParams, 5), primTest +
" prim twist");
322 CheckllSetPrimitiveParamsVector(primDimple, api.
llList2Vector(primParams, 6), primTest +
" prim dimple");
327 LSL_Types.Vector3 primSize,
int primType,
int primHoleType,
LSL_Types.Vector3 primCut,
330 float primRev,
float primRadius,
float primSkew,
float primHollowCheck)
333 api.llSetPrimitiveParams(
new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
334 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
335 primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut,
336 primTaper, primRev, primRadius, primSkew));
340 api.llGetPrimitiveParams(
new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
343 CheckllSetPrimitiveParamsVector(primSize, api.
llList2Vector(primParams, 0), primTest +
" prim size");
344 Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
345 "TestllSetPrimitiveParams " + primTest +
" prim type check fail");
346 Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2),
347 "TestllSetPrimitiveParams " + primTest +
" prim hole default check fail");
348 CheckllSetPrimitiveParamsVector(primCut, api.
llList2Vector(primParams, 3), primTest +
" prim cut");
349 Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY,
350 "TestllSetPrimitiveParams " + primTest +
" prim hollow check fail");
351 CheckllSetPrimitiveParamsVector(primTwist, api.
llList2Vector(primParams, 5), primTest +
" prim twist");
352 CheckllSetPrimitiveParamsVector(primHoleSize, api.
llList2Vector(primParams, 6), primTest +
" prim hole size");
353 CheckllSetPrimitiveParamsVector(primShear, api.
llList2Vector(primParams, 7), primTest +
" prim shear");
354 CheckllSetPrimitiveParamsVector(primProfCut, api.
llList2Vector(primParams, 8), primTest +
" prim profile cut");
355 CheckllSetPrimitiveParamsVector(primTaper, api.
llList2Vector(primParams, 9), primTest +
" prim taper");
356 Assert.AreEqual(primRev, api.llList2Float(primParams, 10), FLOAT_ACCURACY,
357 "TestllSetPrimitiveParams " + primTest +
" prim revolutions fail");
358 Assert.AreEqual(primRadius, api.llList2Float(primParams, 11), FLOAT_ACCURACY,
359 "TestllSetPrimitiveParams " + primTest +
" prim radius fail");
360 Assert.AreEqual(primSkew, api.llList2Float(primParams, 12), FLOAT_ACCURACY,
361 "TestllSetPrimitiveParams " + primTest +
" prim skew fail");
366 LSL_Types.Vector3 primSize,
int primType,
string primMap,
int primSculptType)
369 api.llSetPrimitiveParams(
new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
370 ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType));
374 api.llGetPrimitiveParams(
new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
377 CheckllSetPrimitiveParamsVector(primSize, api.
llList2Vector(primParams, 0), primTest +
" prim size");
378 Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
379 "TestllSetPrimitiveParams " + primTest +
" prim type check fail");
380 Assert.AreEqual(primMap, (string)api.
llList2String(primParams, 2),
381 "TestllSetPrimitiveParams " + primTest +
" prim map check fail");
382 Assert.AreEqual(primSculptType, api.llList2Integer(primParams, 3),
383 "TestllSetPrimitiveParams " + primTest +
" prim type scuplt check fail");
389 Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY,
390 "TestllSetPrimitiveParams " + msg +
" vector check fail on x component");
391 Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY,
392 "TestllSetPrimitiveParams " + msg +
" vector check fail on y component");
393 Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY,
394 "TestllSetPrimitiveParams " + msg +
" vector check fail on z component");
OpenSim.Region.ScriptEngine.Shared.LSL_Types.list LSL_List
Contains all LSL ll-functions. This class will be in Default AppDomain.
void CheckllSetPrimitiveParams(LSL_Api api, string primTest, LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck)
void CheckllSetPrimitiveParams(LSL_Api api, string primTest, LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, float primRev, float primRadius, float primSkew, float primHollowCheck)
LSL_String llList2String(LSL_List src, int index)
void TestllSetPrimitiveParams()
static PrimitiveBaseShape Default
void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
LSL_Vector llList2Vector(LSL_List src, int index)
void TestllGetLinkPrimitiveParams()
void CheckllSetPrimitiveParams(LSL_Api api, string primTest, LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger LSL_Integer
Helpers for setting up scenes.
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger LSLInteger
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger LSL_Integer
const int PRIM_LINK_TARGET
void CheckllSetPrimitiveParams(LSL_Api api, string primTest, LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, float primHollowCheck)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.list LSL_List