aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Examples/SimpleModule/ComplexObject.cs')
-rw-r--r--OpenSim/Region/Examples/SimpleModule/ComplexObject.cs137
1 files changed, 137 insertions, 0 deletions
diff --git a/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs b/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
new file mode 100644
index 0000000..42f517c
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs
@@ -0,0 +1,137 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using libsecondlife;
30using OpenSim.Framework;
31using OpenSim.Region.Environment.Scenes;
32
33namespace OpenSim.Region.Examples.SimpleModule
34{
35 public class ComplexObject : SceneObjectGroup
36 {
37 private readonly LLQuaternion m_rotationDirection;
38
39 protected override bool InSceneBackup
40 {
41 get
42 {
43 return false;
44 }
45 }
46
47 private class RotatingWheel : SceneObjectPart
48 {
49 private readonly LLQuaternion m_rotationDirection;
50
51 public RotatingWheel()
52 {
53
54 }
55
56 public RotatingWheel(ulong regionHandle, SceneObjectGroup parent, LLUUID ownerID, uint localID,
57 LLVector3 groupPosition, LLVector3 offsetPosition, LLQuaternion rotationDirection)
58 : base(
59 regionHandle, parent, ownerID, localID, PrimitiveBaseShape.Default, groupPosition, offsetPosition
60 )
61 {
62 m_rotationDirection = rotationDirection;
63
64 Flags |= LLObject.ObjectFlags.Touch;
65 }
66
67 public override void UpdateMovement()
68 {
69 UpdateRotation(RotationOffset*m_rotationDirection);
70 }
71 }
72
73 public override void UpdateMovement()
74 {
75 UpdateGroupRotation(GroupRotation*m_rotationDirection);
76
77 base.UpdateMovement();
78 }
79
80 public ComplexObject()
81 {
82
83 }
84
85 public ComplexObject(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos)
86 : base(scene, regionHandle, ownerID, localID, pos, PrimitiveBaseShape.Default)
87 {
88 m_rotationDirection = new LLQuaternion(0.05f, 0.1f, 0.15f);
89
90 AddPart(
91 new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0, 0.75f),
92 new LLQuaternion(0.05f, 0, 0)));
93 AddPart(
94 new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0, -0.75f),
95 new LLQuaternion(-0.05f, 0, 0)));
96
97 AddPart(
98 new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0.75f, 0),
99 new LLQuaternion(0.5f, 0, 0.05f)));
100 AddPart(
101 new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, -0.75f, 0),
102 new LLQuaternion(-0.5f, 0, -0.05f)));
103
104 AddPart(
105 new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0.75f, 0, 0),
106 new LLQuaternion(0, 0.5f, 0.05f)));
107 AddPart(
108 new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(-0.75f, 0, 0),
109 new LLQuaternion(0, -0.5f, -0.05f)));
110
111 RootPart.Flags |= LLObject.ObjectFlags.Touch;
112
113 UpdateParentIDs();
114 }
115
116 public override void OnGrabPart(SceneObjectPart part, LLVector3 offsetPos, IClientAPI remoteClient)
117 {
118 m_parts.Remove(part.UUID);
119
120 remoteClient.SendKillObject(m_regionHandle, part.LocalId);
121 remoteClient.AddMoney(1);
122 remoteClient.SendChatMessage("Poof!", 1, AbsolutePosition, "Party Party", LLUUID.Zero);
123 }
124
125 public override void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient)
126 {
127 if (m_parts.Count == 1)
128 {
129 m_parts.Remove(m_rootPart.UUID);
130 m_scene.RemoveEntity(this);
131 remoteClient.SendKillObject(m_regionHandle, m_rootPart.LocalId);
132 remoteClient.AddMoney(50);
133 remoteClient.SendChatMessage("KABLAM!!!", 1, AbsolutePosition, "Groupie Groupie", LLUUID.Zero);
134 }
135 }
136 }
137} \ No newline at end of file