29 using System.Collections.Generic;
30 using System.Security;
32 using OpenMetaverse.Packets;
33 using OpenSim.Framework;
34 using OpenSim.Region.Framework.Interfaces;
35 using OpenSim.Region.Framework.Scenes;
36 using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object;
37 using OpenSim.Region.PhysicsModules.SharedBase;
41 namespace OpenSim.
Region.OptionalModules.Scripting.Minimodule
45 private readonly
Scene m_rootScene;
46 private readonly uint m_localID;
49 [Obsolete(
"Replace with 'credential' constructor [security]")]
52 m_rootScene = rootScene;
58 m_rootScene = rootScene;
60 m_security = credential;
70 return m_rootScene.GetSceneObjectPart(m_localID);
73 private bool CanEdit()
75 if (!m_security.CanEditObject(
this))
77 throw new SecurityException(
"Insufficient Permission to edit object with UUID [" + GetSOP().UUID +
"]");
85 private bool _OnTouchActive =
false;
95 GetSOP().Flags |= PrimFlags.Touch;
96 _OnTouchActive =
true;
97 m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab;
107 if (_OnTouch == null)
110 _OnTouchActive =
false;
111 m_rootScene.EventManager.OnObjectGrab -= EventManager_OnObjectGrab;
118 if (_OnTouchActive && m_localID == localID)
121 e.Avatar =
new SPAvatar(m_rootScene, remoteClient.
AgentId, m_security);
122 e.TouchBiNormal = surfaceArgs.Binormal;
123 e.TouchMaterialIndex = surfaceArgs.FaceIndex;
124 e.TouchNormal = surfaceArgs.Normal;
125 e.TouchPosition = surfaceArgs.Position;
126 e.TouchST =
new Vector2(surfaceArgs.
STCoord.X, surfaceArgs.
STCoord.Y);
127 e.TouchUV =
new Vector2(surfaceArgs.
UVCoord.X, surfaceArgs.
UVCoord.Y);
131 if (_OnTouch != null)
140 get {
return GetSOP() != null; }
145 get {
return m_localID; }
150 get {
return GetSOP().UUID; }
155 get {
return GetSOP().Name; }
159 GetSOP().Name = value;
163 public string Description
165 get {
return GetSOP().Description; }
169 GetSOP().Description = value;
175 get {
return GetSOP().OwnerID;}
178 public UUID CreatorId
180 get {
return GetSOP().CreatorID;}
190 int total = my.ParentGroup.PrimCount;
207 get {
return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId, m_security); }
217 for (
int i = 0; i < rets.Length; i++)
228 get {
return GetSOP().Scale; }
232 GetSOP().Scale = value;
236 public Quaternion WorldRotation
238 get {
throw new System.NotImplementedException(); }
239 set {
throw new System.NotImplementedException(); }
242 public Quaternion OffsetRotation
244 get {
throw new System.NotImplementedException(); }
245 set {
throw new System.NotImplementedException(); }
248 public Vector3 WorldPosition
250 get {
return GetSOP().AbsolutePosition; }
256 pos.UpdateOffSet(value - pos.AbsolutePosition);
261 public Vector3 OffsetPosition
263 get {
return GetSOP().OffsetPosition; }
268 GetSOP().OffsetPosition = value;
273 public Vector3 SitTarget
275 get {
return GetSOP().SitTargetPosition; }
280 GetSOP().SitTargetPosition = value;
285 public string SitTargetText
287 get {
return GetSOP().SitName; }
292 GetSOP().SitName = value;
297 public string TouchText
299 get {
return GetSOP().TouchName; }
304 GetSOP().TouchName = value;
311 get {
return GetSOP().Text; }
316 GetSOP().SetText(value,
new Vector3(1.0f,1.0f,1.0f),1.0f);
321 public bool IsRotationLockedX
323 get {
throw new System.NotImplementedException(); }
324 set {
throw new System.NotImplementedException(); }
327 public bool IsRotationLockedY
329 get {
throw new System.NotImplementedException(); }
330 set {
throw new System.NotImplementedException(); }
333 public bool IsRotationLockedZ
335 get {
throw new System.NotImplementedException(); }
336 set {
throw new System.NotImplementedException(); }
339 public bool IsSandboxed
341 get {
throw new System.NotImplementedException(); }
342 set {
throw new System.NotImplementedException(); }
345 public bool IsImmotile
347 get {
throw new System.NotImplementedException(); }
348 set {
throw new System.NotImplementedException(); }
351 public bool IsAlwaysReturned
353 get {
throw new System.NotImplementedException(); }
354 set {
throw new System.NotImplementedException(); }
357 public bool IsTemporary
359 get {
throw new System.NotImplementedException(); }
360 set {
throw new System.NotImplementedException(); }
363 public bool IsFlexible
365 get {
throw new System.NotImplementedException(); }
366 set {
throw new System.NotImplementedException(); }
371 get {
throw new System.NotImplementedException(); }
372 set {
throw new System.NotImplementedException(); }
390 #region Public Functions
392 public void Say(
string msg)
398 m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID,
false);
401 public void Say(
string msg,
int channel)
410 public void Dialog(UUID avatar,
string message,
string[] buttons,
int chat_channel)
420 if (buttons.Length < 1)
422 Say(
"ERROR: No less than 1 button can be shown",2147483647);
425 if (buttons.Length > 12)
427 Say(
"ERROR: No more than 12 buttons can be shown",2147483647);
431 foreach (
string button
in buttons)
433 if (button ==
String.Empty)
435 Say(
"ERROR: button label cannot be blank",2147483647);
438 if (button.Length > 24)
440 Say(
"ERROR: button label cannot be longer than 24 characters",2147483647);
446 avatar, GetSOP().Name, GetSOP().UUID, GetSOP().OwnerID,
447 message,
new UUID(
"00000000-0000-2222-3333-100000001000"), chat_channel, buttons);
454 #region Supporting Functions
457 private static void hasCutHollowDimpleProfileCut(
int primType,
PrimitiveBaseShape shape, out
bool hasCut, out
bool hasHollow,
458 out
bool hasDimple, out
bool hasProfileCut)
466 hasCut = (shape.ProfileBegin > 0) || (shape.
ProfileEnd > 0);
468 hasCut = (shape.PathBegin > 0) || (shape.
PathEnd > 0);
470 hasHollow = shape.ProfileHollow > 0;
471 hasDimple = (shape.ProfileBegin > 0) || (shape.
ProfileEnd > 0);
472 hasProfileCut = hasDimple;
479 return (
int) PrimType.Sculpt;
483 return (
int) PrimType.Box;
485 return (
int) PrimType.Tube;
490 return (
int) PrimType.Cylinder;
492 return (
int) PrimType.Torus;
497 return (
int) PrimType.Sphere;
502 return (
int) PrimType.Prism;
504 return (
int) PrimType.Ring;
506 return (
int) PrimType.NotPrimitive;
517 int primType = getScriptPrimType(part.
Shape);
518 hasCutHollowDimpleProfileCut(primType, part.
Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
523 case (
int) PrimType.Box:
525 if (hasCut) ret += 2;
526 if (hasHollow) ret += 1;
528 case (
int) PrimType.Cylinder:
530 if (hasCut) ret += 2;
531 if (hasHollow) ret += 1;
533 case (
int) PrimType.Prism:
535 if (hasCut) ret += 2;
536 if (hasHollow) ret += 1;
538 case (
int) PrimType.Sphere:
540 if (hasCut) ret += 2;
541 if (hasDimple) ret += 2;
546 case (
int) PrimType.Torus:
548 if (hasCut) ret += 2;
549 if (hasProfileCut) ret += 2;
550 if (hasHollow) ret += 1;
552 case (
int) PrimType.Tube:
554 if (hasCut) ret += 2;
555 if (hasProfileCut) ret += 2;
556 if (hasHollow) ret += 1;
558 case (
int) PrimType.Ring:
560 if (hasCut) ret += 2;
561 if (hasProfileCut) ret += 2;
562 if (hasHollow) ret += 1;
564 case (
int) PrimType.Sculpt:
574 #region IObjectPhysics
578 get {
throw new System.NotImplementedException(); }
579 set {
throw new System.NotImplementedException(); }
584 get {
throw new System.NotImplementedException(); }
585 set {
throw new System.NotImplementedException(); }
588 public bool PhantomCollisions
590 get {
throw new System.NotImplementedException(); }
591 set {
throw new System.NotImplementedException(); }
594 public double Density
596 get {
return (GetSOP().PhysActor.Mass/Scale.X*Scale.Y/Scale.Z); }
597 set {
throw new NotImplementedException(); }
602 get {
return GetSOP().PhysActor.Mass; }
603 set {
throw new NotImplementedException(); }
606 public double Buoyancy
608 get {
return GetSOP().PhysActor.Buoyancy; }
609 set { GetSOP().PhysActor.Buoyancy = (float)value; }
612 public Vector3 GeometricCenter
616 Vector3 tmp = GetSOP().PhysActor.GeometricCenter;
621 public Vector3 CenterOfMass
625 Vector3 tmp = GetSOP().PhysActor.CenterOfMass;
630 public Vector3 RotationalVelocity
634 Vector3 tmp = GetSOP().PhysActor.RotationalVelocity;
642 GetSOP().PhysActor.RotationalVelocity = value;
650 Vector3 tmp = GetSOP().PhysActor.Velocity;
658 GetSOP().PhysActor.Velocity = value;
662 public Vector3 Torque
666 Vector3 tmp = GetSOP().PhysActor.Torque;
674 GetSOP().PhysActor.Torque = value;
682 Vector3 tmp = GetSOP().PhysActor.Acceleration;
691 Vector3 tmp = GetSOP().PhysActor.Force;
699 GetSOP().PhysActor.Force = value;
703 public bool FloatOnWater
709 GetSOP().PhysActor.FloatOnWater = value;
713 public void AddForce(Vector3 force,
bool pushforce)
718 GetSOP().PhysActor.AddForce(force, pushforce);
726 GetSOP().PhysActor.AddAngularForce(force, pushforce);
734 GetSOP().PhysActor.SetMomentum(momentum);
739 #region Implementation of IObjectShape
741 private UUID m_sculptMap = UUID.Zero;
743 public UUID SculptMap
745 get {
return m_sculptMap; }
752 SetPrimitiveSculpted(SculptMap, (byte)
SculptType);
756 private SculptType m_sculptType = Object.SculptType.Default;
760 get {
return m_sculptType; }
766 m_sculptType = value;
767 SetPrimitiveSculpted(SculptMap, (byte)
SculptType);
773 get {
throw new System.NotImplementedException(); }
774 set {
throw new System.NotImplementedException(); }
777 public double HoleSize
779 get {
throw new System.NotImplementedException(); }
780 set {
throw new System.NotImplementedException(); }
785 get {
return (
PrimType)getScriptPrimType(GetSOP().Shape); }
786 set {
throw new System.NotImplementedException(); }
789 private void SetPrimitiveSculpted(UUID map, byte type)
791 ObjectShapePacket.ObjectDataBlock shapeBlock =
new ObjectShapePacket.ObjectDataBlock();
797 shapeBlock.ObjectLocalID = part.LocalId;
798 shapeBlock.PathScaleX = 100;
799 shapeBlock.PathScaleY = 150;
802 shapeBlock.PathCurve = part.Shape.PathCurve;
804 part.Shape.SetSculptProperties((byte)type, sculptId);
805 part.Shape.SculptEntry =
true;
806 part.UpdateShape(shapeBlock);
813 #region Implementation of IObjectSound
820 public void Play(UUID asset,
double volume)
827 module.SendSound(GetSOP().UUID, asset, volume,
true, 0, 0,
false,
false);
void Play(UUID asset, double volume)
SOPObject(Scene rootScene, uint localID, ISecurityCredential credential)
void SetMomentum(Vector3 momentum)
void Dialog(UUID avatar, string message, string[] buttons, int chat_channel)
Opens a Dialog Panel in the Users Viewer, equivilent to LSL/OSSL llDialog
SOPObject(Scene rootScene, uint localID)
OpenSim.Region.OptionalModules.Scripting.Minimodule.Object.SculptType SculptType
void AddAngularForce(Vector3 force, bool pushforce)
void AddForce(Vector3 force, bool pushforce)
SceneObjectGroup ParentGroup
OpenSim.Region.OptionalModules.Scripting.Minimodule.Object.PrimType PrimType
This implements an interface similar to that provided by physics engines to OpenSim internally...
delegate void OnTouchDelegate(IObject sender, TouchEventArgs e)
This implements the methods neccesary to operate on the inventory of an object
void Say(string msg)
Causes the object to speak to its surroundings, equivilent to LSL/OSSL llSay
void Say(string msg, int channel)
Causes the object to speak to on a specific channel, equivilent to LSL/OSSL llSay ...