diff options
author | gareth | 2007-03-07 18:48:38 +0000 |
---|---|---|
committer | gareth | 2007-03-07 18:48:38 +0000 |
commit | b3844c1f7348b4296b5ab1df258935d7f971e412 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /src/world/Avatar.cs | |
parent | * Updating libsecondlife.dll to the latest version with a working LayerData f... (diff) | |
download | opensim-SC_OLD-b3844c1f7348b4296b5ab1df258935d7f971e412.zip opensim-SC_OLD-b3844c1f7348b4296b5ab1df258935d7f971e412.tar.gz opensim-SC_OLD-b3844c1f7348b4296b5ab1df258935d7f971e412.tar.bz2 opensim-SC_OLD-b3844c1f7348b4296b5ab1df258935d7f971e412.tar.xz |
Deleted old trunk code
Diffstat (limited to 'src/world/Avatar.cs')
-rw-r--r-- | src/world/Avatar.cs | 256 |
1 files changed, 0 insertions, 256 deletions
diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs deleted file mode 100644 index 9d8d7d2..0000000 --- a/src/world/Avatar.cs +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Text; | ||
5 | using libsecondlife; | ||
6 | using libsecondlife.Packets; | ||
7 | using Axiom.MathLib; | ||
8 | |||
9 | namespace OpenSim.world | ||
10 | { | ||
11 | public class Avatar : Entity | ||
12 | { | ||
13 | public string firstname; | ||
14 | public string lastname; | ||
15 | public OpenSimClient ControllingClient; | ||
16 | public LLVector3 oldvel; | ||
17 | public LLVector3 oldpos; | ||
18 | public uint CurrentKeyMask; | ||
19 | public bool walking; | ||
20 | |||
21 | private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; | ||
22 | |||
23 | public Avatar(OpenSimClient TheClient) { | ||
24 | OpenSim_Main.localcons.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); | ||
25 | ControllingClient=TheClient; | ||
26 | SetupTemplate("avatar-template.dat"); | ||
27 | |||
28 | position = new LLVector3(100.0f,100.0f,60.0f); | ||
29 | } | ||
30 | |||
31 | public override void update() { | ||
32 | lock(this) { | ||
33 | base.update(); | ||
34 | |||
35 | oldvel=this.velocity; | ||
36 | oldpos=this.position; | ||
37 | if((this.CurrentKeyMask & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) { | ||
38 | Vector3 tmpVelocity = this.rotation * new Vector3(1.0f,0.0f,0.0f); | ||
39 | tmpVelocity.Normalize(); tmpVelocity = tmpVelocity * 0.5f; | ||
40 | this.velocity.X = tmpVelocity.x; | ||
41 | this.velocity.Y = tmpVelocity.y; | ||
42 | this.velocity.Z = tmpVelocity.z; | ||
43 | this.walking=true; | ||
44 | } else { | ||
45 | this.velocity.X=0; | ||
46 | this.velocity.Y=0; | ||
47 | this.velocity.Z=0; | ||
48 | this.walking=false; | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | |||
53 | private void SetupTemplate(string name) | ||
54 | { | ||
55 | |||
56 | int i = 0; | ||
57 | FileInfo fInfo = new FileInfo(name); | ||
58 | long numBytes = fInfo.Length; | ||
59 | FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); | ||
60 | BinaryReader br = new BinaryReader(fStream); | ||
61 | byte [] data1 = br.ReadBytes((int)numBytes); | ||
62 | br.Close(); | ||
63 | fStream.Close(); | ||
64 | |||
65 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); | ||
66 | |||
67 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
68 | libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); | ||
69 | pos.X = 100f; | ||
70 | objdata.ID = this.localid; | ||
71 | objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); | ||
72 | libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f); | ||
73 | //objdata.FullID=user.AgentID; | ||
74 | byte[] pb = pos.GetBytes(); | ||
75 | Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); | ||
76 | |||
77 | AvatarTemplate = objdata; | ||
78 | |||
79 | } | ||
80 | |||
81 | public void CompleteMovement(World RegionInfo) { | ||
82 | OpenSim_Main.localcons.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); | ||
83 | AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); | ||
84 | mov.AgentData.SessionID = this.ControllingClient.SessionID; | ||
85 | mov.AgentData.AgentID = this.ControllingClient.AgentID; | ||
86 | mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle; | ||
87 | // TODO - dynamicalise this stuff | ||
88 | mov.Data.Timestamp = 1172750370; | ||
89 | mov.Data.Position = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); | ||
90 | mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); | ||
91 | |||
92 | OpenSim_Main.localcons.WriteLine("Sending AgentMovementComplete packet"); | ||
93 | ControllingClient.OutPacket(mov); | ||
94 | } | ||
95 | |||
96 | public void SendInitialPosition() { | ||
97 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
98 | |||
99 | |||
100 | //send a objectupdate packet with information about the clients avatar | ||
101 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
102 | objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; | ||
103 | objupdate.RegionData.TimeDilation = 64096; | ||
104 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
105 | |||
106 | objupdate.ObjectData[0] = AvatarTemplate; | ||
107 | //give this avatar object a local id and assign the user a name | ||
108 | objupdate.ObjectData[0].ID = this.localid; | ||
109 | //User_info.name="Test"+this.local_numer+" User"; | ||
110 | objupdate.ObjectData[0].FullID = ControllingClient.AgentID; | ||
111 | objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); | ||
112 | |||
113 | libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); | ||
114 | |||
115 | byte[] pb = pos2.GetBytes(); | ||
116 | |||
117 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
118 | OpenSim_Main.local_world._localNumber++; | ||
119 | this.ControllingClient.OutPacket(objupdate); | ||
120 | } | ||
121 | |||
122 | public override ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() { | ||
123 | byte[] bytes = new byte[60]; | ||
124 | int i=0; | ||
125 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
126 | |||
127 | dat.TextureEntry = AvatarTemplate.TextureEntry; | ||
128 | libsecondlife.LLVector3 pos2 = new LLVector3(this.position.X, this.position.Y, this.position.Z); | ||
129 | |||
130 | uint ID = this.localid; | ||
131 | bytes[i++] = (byte)(ID % 256); | ||
132 | bytes[i++] = (byte)((ID >> 8) % 256); | ||
133 | bytes[i++] = (byte)((ID >> 16) % 256); | ||
134 | bytes[i++] = (byte)((ID >> 24) % 256); | ||
135 | bytes[i++] = 0; | ||
136 | bytes[i++] = 1; | ||
137 | i += 14; | ||
138 | bytes[i++] = 128; | ||
139 | bytes[i++] = 63; | ||
140 | |||
141 | byte[] pb = pos2.GetBytes(); | ||
142 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
143 | i += 12; | ||
144 | |||
145 | |||
146 | ushort ac = 32767; | ||
147 | bytes[i++] = (byte)((ushort)(((this.velocity.X/128f)+1)*32767) % 256 ); | ||
148 | bytes[i++] = (byte)(((ushort)(((this.velocity.X/128f)+1)*32767) >> 8) % 256); | ||
149 | bytes[i++] = (byte)((ushort)(((this.velocity.Y/128f)+1)*32767) % 256); | ||
150 | bytes[i++] = (byte)(((ushort)(((this.velocity.Y/128f)+1)*32767) >> 8) % 256); | ||
151 | bytes[i++] = (byte)((ushort)(((this.velocity.Z/128f)+1)*32767) % 256); | ||
152 | bytes[i++] = (byte)(((ushort)(((this.velocity.Z/128f)+1)*32767) >> 8) % 256); | ||
153 | |||
154 | |||
155 | |||
156 | |||
157 | //accel | ||
158 | bytes[i++] = (byte)(ac % 256); | ||
159 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
160 | bytes[i++] = (byte)(ac % 256); | ||
161 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
162 | bytes[i++] = (byte)(ac % 256); | ||
163 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
164 | |||
165 | //rot | ||
166 | bytes[i++] = (byte)(ac % 256); | ||
167 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
168 | bytes[i++] = (byte)(ac % 256); | ||
169 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
170 | bytes[i++] = (byte)(ac % 256); | ||
171 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
172 | bytes[i++] = (byte)(ac % 256); | ||
173 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
174 | |||
175 | //rotation vel | ||
176 | bytes[i++] = (byte)(ac % 256); | ||
177 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
178 | bytes[i++] = (byte)(ac % 256); | ||
179 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
180 | bytes[i++] = (byte)(ac % 256); | ||
181 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
182 | |||
183 | dat.Data=bytes; | ||
184 | return(dat); | ||
185 | |||
186 | } | ||
187 | |||
188 | public void SendInitialAppearance() { | ||
189 | AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); | ||
190 | aw.AgentData.AgentID = this.ControllingClient.AgentID; | ||
191 | aw.AgentData.SerialNum = 0; | ||
192 | aw.AgentData.SessionID = ControllingClient.SessionID; | ||
193 | |||
194 | aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; | ||
195 | AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
196 | awb.WearableType = (byte)0; | ||
197 | awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
198 | awb.ItemID = LLUUID.Random(); | ||
199 | aw.WearableData[0] = awb; | ||
200 | |||
201 | for(int i=1; i<13; i++) { | ||
202 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
203 | awb.WearableType = (byte)i; | ||
204 | awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
205 | awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
206 | aw.WearableData[i] = awb; | ||
207 | } | ||
208 | |||
209 | ControllingClient.OutPacket(aw); | ||
210 | } | ||
211 | |||
212 | public void SendRegionHandshake(World RegionInfo) { | ||
213 | OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); | ||
214 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
215 | RegionHandshakePacket handshake = new RegionHandshakePacket(); | ||
216 | |||
217 | OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details"); | ||
218 | handshake.RegionInfo.BillableFactor = 0; | ||
219 | handshake.RegionInfo.IsEstateManager = false; | ||
220 | handshake.RegionInfo.TerrainHeightRange00 = 60; | ||
221 | handshake.RegionInfo.TerrainHeightRange01 = 60; | ||
222 | handshake.RegionInfo.TerrainHeightRange10 = 60; | ||
223 | handshake.RegionInfo.TerrainHeightRange11 = 60; | ||
224 | handshake.RegionInfo.TerrainStartHeight00 = 10; | ||
225 | handshake.RegionInfo.TerrainStartHeight01 = 10; | ||
226 | handshake.RegionInfo.TerrainStartHeight10 = 10; | ||
227 | handshake.RegionInfo.TerrainStartHeight11 = 10; | ||
228 | handshake.RegionInfo.SimAccess = 13; | ||
229 | handshake.RegionInfo.WaterHeight = 20.0f; | ||
230 | handshake.RegionInfo.RegionFlags = 72458694; // TODO: WTF sirs? Use an enum! | ||
231 | handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0"); | ||
232 | handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
233 | handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); | ||
234 | handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); | ||
235 | handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); | ||
236 | handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); | ||
237 | handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
238 | handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
239 | handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
240 | handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
241 | handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); | ||
242 | |||
243 | OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet"); | ||
244 | this.ControllingClient.OutPacket(handshake); | ||
245 | } | ||
246 | |||
247 | public void HandleAgentUpdate(AgentUpdatePacket update) { | ||
248 | lock(this) { | ||
249 | this.CurrentKeyMask = update.AgentData.ControlFlags; | ||
250 | this.rotation = new Quaternion(update.AgentData.BodyRotation.W, update.AgentData.BodyRotation.X, update.AgentData.BodyRotation.Y, update.AgentData.BodyRotation.Z); | ||
251 | this.needupdate = true; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | } | ||
256 | } | ||