diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/ContentManagementSystem/AuraMetaEntity.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/ContentManagementSystem/AuraMetaEntity.cs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/ContentManagementSystem/AuraMetaEntity.cs b/OpenSim/Region/Environment/Modules/ContentManagementSystem/AuraMetaEntity.cs new file mode 100644 index 0000000..2155b4c --- /dev/null +++ b/OpenSim/Region/Environment/Modules/ContentManagementSystem/AuraMetaEntity.cs | |||
@@ -0,0 +1,114 @@ | |||
1 | // AuraMetaEntity.cs created with MonoDevelop | ||
2 | // User: bongiojp at 3:03 PMĀ 8/6/2008 | ||
3 | // | ||
4 | // To change standard headers go to Edit->Preferences->Coding->Standard Headers | ||
5 | // | ||
6 | |||
7 | using System; | ||
8 | using System.Collections.Generic; | ||
9 | using System.Drawing; | ||
10 | using libsecondlife; | ||
11 | using Nini.Config; | ||
12 | using OpenSim.Framework; | ||
13 | using OpenSim.Region.Environment.Interfaces; | ||
14 | using OpenSim.Region.Environment.Scenes; | ||
15 | using log4net; | ||
16 | using OpenSim.Region.Physics.Manager; | ||
17 | using Axiom.Math; | ||
18 | |||
19 | namespace OpenSim.Region.Environment.Modules.ContentManagement | ||
20 | { | ||
21 | |||
22 | |||
23 | public class AuraMetaEntity : PointMetaEntity | ||
24 | { | ||
25 | //transparency of root part, NOT particle system. Should probably add support for changing particle system transparency. | ||
26 | public AuraMetaEntity(Scene scene, uint LocalId, LLVector3 groupPos, float transparency, LLVector3 color, LLVector3 scale) : base(scene, LocalId, groupPos, transparency) | ||
27 | { | ||
28 | SetAura(color, scale); | ||
29 | } | ||
30 | |||
31 | public AuraMetaEntity(Scene scene, LLUUID uuid, uint LocalId, LLVector3 groupPos, float transparency, LLVector3 color, LLVector3 scale) : base(scene, uuid, LocalId, groupPos, transparency) | ||
32 | { | ||
33 | SetAura(color, scale); | ||
34 | } | ||
35 | |||
36 | private float Average(LLVector3 values) | ||
37 | { | ||
38 | return (values.X + values.Y + values.Z)/3f; | ||
39 | } | ||
40 | |||
41 | public void SetAura(LLVector3 color, LLVector3 scale) | ||
42 | { | ||
43 | SetAura(color, Average(scale) * 2.0f); | ||
44 | } | ||
45 | |||
46 | public void SetAura(LLVector3 color, float radius) | ||
47 | { | ||
48 | SceneObjectPart From = m_Entity.RootPart; | ||
49 | |||
50 | //m_log.Debug("[META ENTITY] BEFORE: radius = " + radius); | ||
51 | float burstRadius = 0.1f; | ||
52 | Primitive.ParticleSystem.SourcePattern patternFlags = Primitive.ParticleSystem.SourcePattern.None; | ||
53 | float age = 1.5f; | ||
54 | float burstRate = 0.4f; | ||
55 | if (radius >= 8.0f) | ||
56 | { | ||
57 | //float sizeOfObject = radius / 2.0f; | ||
58 | burstRadius = (radius - 8.0f)/3f; | ||
59 | burstRate = 1.5f; | ||
60 | radius = 7.99f; | ||
61 | patternFlags = Primitive.ParticleSystem.SourcePattern.Explode; | ||
62 | age = 4.0f; | ||
63 | } | ||
64 | SetAura(From, color, radius, burstRadius, age, burstRate, patternFlags); | ||
65 | } | ||
66 | public void SetAura(SceneObjectPart From, LLVector3 color, float radius, float burstRadius, float age, float burstRate, libsecondlife.Primitive.ParticleSystem.SourcePattern patternFlags) | ||
67 | { | ||
68 | Primitive.ParticleSystem prules = new Primitive.ParticleSystem(); | ||
69 | //prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Emissive | | ||
70 | // Primitive.ParticleSystem.ParticleDataFlags.FollowSrc; //PSYS_PART_FLAGS | ||
71 | //prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Beam | | ||
72 | // Primitive.ParticleSystem.ParticleDataFlags.TargetPos; | ||
73 | prules.PartStartColor.R = color.X; //PSYS_PART_START_COLOR | ||
74 | prules.PartStartColor.G = color.Y; | ||
75 | prules.PartStartColor.B = color.Z; | ||
76 | prules.PartStartColor.A = 0.5f; //PSYS_PART_START_ALPHA, transparency | ||
77 | prules.PartEndColor.R = color.X; //PSYS_PART_END_COLOR | ||
78 | prules.PartEndColor.G = color.Y; | ||
79 | prules.PartEndColor.B = color.Z; | ||
80 | prules.PartEndColor.A = 0.5f; //PSYS_PART_END_ALPHA, transparency | ||
81 | /*prules.PartStartScaleX = 0.5f; //PSYS_PART_START_SCALE | ||
82 | prules.PartStartScaleY = 0.5f; | ||
83 | prules.PartEndScaleX = 0.5f; //PSYS_PART_END_SCALE | ||
84 | prules.PartEndScaleY = 0.5f; | ||
85 | */ | ||
86 | prules.PartStartScaleX = radius; //PSYS_PART_START_SCALE | ||
87 | prules.PartStartScaleY = radius; | ||
88 | prules.PartEndScaleX = radius; //PSYS_PART_END_SCALE | ||
89 | prules.PartEndScaleY = radius; | ||
90 | prules.PartMaxAge = age; //PSYS_PART_MAX_AGE | ||
91 | prules.PartAcceleration.X = 0.0f; //PSYS_SRC_ACCEL | ||
92 | prules.PartAcceleration.Y = 0.0f; | ||
93 | prules.PartAcceleration.Z = 0.0f; | ||
94 | prules.Pattern = patternFlags; //PSYS_SRC_PATTERN | ||
95 | //prules.Texture = LLUUID.Zero;//= LLUUID //PSYS_SRC_TEXTURE, default used if blank | ||
96 | prules.BurstRate = burstRate; //PSYS_SRC_BURST_RATE | ||
97 | prules.BurstPartCount = 2; //PSYS_SRC_BURST_PART_COUNT | ||
98 | //prules.BurstRadius = radius; //PSYS_SRC_BURST_RADIUS | ||
99 | prules.BurstRadius = burstRadius; //PSYS_SRC_BURST_RADIUS | ||
100 | prules.BurstSpeedMin = 0.001f; //PSYS_SRC_BURST_SPEED_MIN | ||
101 | prules.BurstSpeedMax = 0.001f; //PSYS_SRC_BURST_SPEED_MAX | ||
102 | prules.MaxAge = 0.0f; //PSYS_SRC_MAX_AGE | ||
103 | //prules.Target = To; //PSYS_SRC_TARGET_KEY | ||
104 | prules.AngularVelocity.X = 0.0f; //PSYS_SRC_OMEGA | ||
105 | prules.AngularVelocity.Y = 0.0f; | ||
106 | prules.AngularVelocity.Z = 0.0f; | ||
107 | prules.InnerAngle = 0.0f; //PSYS_SRC_ANGLE_BEGIN | ||
108 | prules.OuterAngle = 0.0f; //PSYS_SRC_ANGLE_END | ||
109 | |||
110 | prules.CRC = 1; //activates the particle system?? | ||
111 | From.AddNewParticleSystem(prules); | ||
112 | } | ||
113 | } | ||
114 | } | ||