diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/ContentManagementSystem/BeamMetaEntity.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/ContentManagementSystem/BeamMetaEntity.cs | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/BeamMetaEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/BeamMetaEntity.cs new file mode 100644 index 0000000..c0a0603 --- /dev/null +++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/BeamMetaEntity.cs | |||
@@ -0,0 +1,139 @@ | |||
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 | #region Header | ||
29 | |||
30 | // BeamMetaEntity.cs created with MonoDevelop | ||
31 | // User: bongiojp at 3:03 PMĀ 8/6/2008 | ||
32 | // | ||
33 | // To change standard headers go to Edit->Preferences->Coding->Standard Headers | ||
34 | // | ||
35 | |||
36 | #endregion Header | ||
37 | |||
38 | using System; | ||
39 | using System.Collections.Generic; | ||
40 | using System.Drawing; | ||
41 | |||
42 | using OpenMetaverse; | ||
43 | |||
44 | using Nini.Config; | ||
45 | |||
46 | using OpenSim.Framework; | ||
47 | using OpenSim.Region.Framework.Interfaces; | ||
48 | using OpenSim.Region.Framework.Scenes; | ||
49 | using OpenSim.Region.Physics.Manager; | ||
50 | |||
51 | using log4net; | ||
52 | |||
53 | namespace OpenSim.Region.OptionalModules.ContentManagement | ||
54 | { | ||
55 | public class BeamMetaEntity : PointMetaEntity | ||
56 | { | ||
57 | #region Constructors | ||
58 | |||
59 | public BeamMetaEntity(Scene scene, Vector3 groupPos, float transparency, SceneObjectPart To, Vector3 color) | ||
60 | : base(scene, groupPos, transparency) | ||
61 | { | ||
62 | SetBeamToUUID(To, color); | ||
63 | } | ||
64 | |||
65 | public BeamMetaEntity(Scene scene, UUID uuid, Vector3 groupPos, float transparency, SceneObjectPart To, Vector3 color) | ||
66 | : base(scene, uuid, groupPos, transparency) | ||
67 | { | ||
68 | SetBeamToUUID(To, color); | ||
69 | } | ||
70 | |||
71 | #endregion Constructors | ||
72 | |||
73 | #region Public Methods | ||
74 | |||
75 | public void SetBeamToUUID(SceneObjectPart To, Vector3 color) | ||
76 | { | ||
77 | SceneObjectPart From = m_Entity.RootPart; | ||
78 | //Scale size of particles to distance objects are apart (for better visibility) | ||
79 | Vector3 FromPos = From.GetWorldPosition(); | ||
80 | Vector3 ToPos = From.GetWorldPosition(); | ||
81 | // UUID toUUID = To.UUID; | ||
82 | float distance = (float) (Math.Sqrt(Math.Pow(FromPos.X-ToPos.X, 2) + | ||
83 | Math.Pow(FromPos.X-ToPos.Y, 2) + | ||
84 | Math.Pow(FromPos.X-ToPos.Z, 2) | ||
85 | ) | ||
86 | ); | ||
87 | //float rate = (float) (distance/4f); | ||
88 | float rate = 0.5f; | ||
89 | float scale = (float) (distance/128f); | ||
90 | float speed = (float) (2.0f - distance/128f); | ||
91 | |||
92 | SetBeamToUUID(From, To, color, rate, scale, speed); | ||
93 | } | ||
94 | |||
95 | public void SetBeamToUUID(SceneObjectPart From, SceneObjectPart To, Vector3 color, float rate, float scale, float speed) | ||
96 | { | ||
97 | Primitive.ParticleSystem prules = new Primitive.ParticleSystem(); | ||
98 | //prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Emissive | | ||
99 | // Primitive.ParticleSystem.ParticleDataFlags.FollowSrc; //PSYS_PART_FLAGS | ||
100 | prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Beam | | ||
101 | Primitive.ParticleSystem.ParticleDataFlags.TargetPos; | ||
102 | prules.PartStartColor.R = color.X; //PSYS_PART_START_COLOR | ||
103 | prules.PartStartColor.G = color.Y; | ||
104 | prules.PartStartColor.B = color.Z; | ||
105 | prules.PartStartColor.A = 1.0f; //PSYS_PART_START_ALPHA, transparency | ||
106 | prules.PartEndColor.R = color.X; //PSYS_PART_END_COLOR | ||
107 | prules.PartEndColor.G = color.Y; | ||
108 | prules.PartEndColor.B = color.Z; | ||
109 | prules.PartEndColor.A = 1.0f; //PSYS_PART_END_ALPHA, transparency | ||
110 | prules.PartStartScaleX = scale; //PSYS_PART_START_SCALE | ||
111 | prules.PartStartScaleY = scale; | ||
112 | prules.PartEndScaleX = scale; //PSYS_PART_END_SCALE | ||
113 | prules.PartEndScaleY = scale; | ||
114 | prules.PartMaxAge = 1.0f; //PSYS_PART_MAX_AGE | ||
115 | prules.PartAcceleration.X = 0.0f; //PSYS_SRC_ACCEL | ||
116 | prules.PartAcceleration.Y = 0.0f; | ||
117 | prules.PartAcceleration.Z = 0.0f; | ||
118 | //prules.Pattern = Primitive.ParticleSystem.SourcePattern.Explode; //PSYS_SRC_PATTERN | ||
119 | //prules.Texture = UUID.Zero;//= UUID //PSYS_SRC_TEXTURE, default used if blank | ||
120 | prules.BurstRate = rate; //PSYS_SRC_BURST_RATE | ||
121 | prules.BurstPartCount = 1; //PSYS_SRC_BURST_PART_COUNT | ||
122 | prules.BurstRadius = 0.5f; //PSYS_SRC_BURST_RADIUS | ||
123 | prules.BurstSpeedMin = speed; //PSYS_SRC_BURST_SPEED_MIN | ||
124 | prules.BurstSpeedMax = speed; //PSYS_SRC_BURST_SPEED_MAX | ||
125 | prules.MaxAge = 0.0f; //PSYS_SRC_MAX_AGE | ||
126 | prules.Target = To.UUID; //PSYS_SRC_TARGET_KEY | ||
127 | prules.AngularVelocity.X = 0.0f; //PSYS_SRC_OMEGA | ||
128 | prules.AngularVelocity.Y = 0.0f; | ||
129 | prules.AngularVelocity.Z = 0.0f; | ||
130 | prules.InnerAngle = 0.0f; //PSYS_SRC_ANGLE_BEGIN | ||
131 | prules.OuterAngle = 0.0f; //PSYS_SRC_ANGLE_END | ||
132 | |||
133 | prules.CRC = 1; //activates the particle system?? | ||
134 | From.AddNewParticleSystem(prules); | ||
135 | } | ||
136 | |||
137 | #endregion Public Methods | ||
138 | } | ||
139 | } | ||