001: /*
002: * Copyright (c) 2001 Silvere Martin-Michiellot All Rights Reserved.
003: *
004: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
005: * royalty free, license to use, modify and redistribute this
006: * software in source and binary code form,
007: * provided that i) this copyright notice and license appear on all copies of
008: * the software; and ii) Licensee does not utilize the software in a manner
009: * which is disparaging to Silvere Martin-Michiellot.
010: *
011: * This software is provided "AS IS," without a warranty of any kind. ALL
012: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
013: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
014: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
015: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
016: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
017: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
018: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
019: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
020: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
021: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
022: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
023: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
024: *
025: * This software is not designed or intended for use in on-line control of
026: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
027: * the design, construction, operation or maintenance of any nuclear
028: * facility. Licensee represents and warrants that it will not use or
029: * redistribute the Software for such purposes.
030: *
031: * @Author: Silvere Martin-Michiellot
032: *
033: */
034:
035: package com.db.net;
036:
037: import java.io.Serializable;
038: import java.lang.IllegalArgumentException;
039: import java.security.PublicKey;
040: import java.util.*;
041: import javax.media.j3d.*;
042:
043: import com.db.server.Avatar;
044: import com.db.server.Trade;
045: import com.db.server.VirtualElement;
046:
047: /**
048: */
049: public class NetworkElement extends Message implements Serializable {
050:
051: //reserved ID to send information from the server to the client
052: //clients should generate ID for their requests different of this ID
053: public final static int NOT_REQUESTED = 0;
054:
055: //Lords and self are always allowed full rights
056:
057: public final static int NO_CAPABILITY = 0;
058:
059: public final static int SALABLE = 1;
060: public final static int RESHAPEABLE = 2;
061: public final static int SOUNDALTERABLE = 4;
062: public final static int VISIBLE = 8;
063: public final static int SONORE = 16;
064: public final static int MOVABLE = 32;
065: public final static int COLLIDABLE = 64;
066: public final static int INVENTORIZABLE = 128;
067: public final static int ACCESSORY = 256;
068: public final static int CUTABLE = 512;
069: public final static int GLUABLE = 1024;
070: public final static int DUPLICABLE = 2048;
071: public final static int GENERIC = 4096;
072: public final static int HEADUP = 8192;
073: public final static int FERTILE = 16384;
074: public final static int MANIPULATES = 32768;
075: public final static int SUPPRESSOR = 65536;
076: public final static int REMOTEVIEW = 131072;
077: public final static int HANDS = 4096;
078:
079: private static int LAST_CAPABILITY = (NetworkElement.REMOTEVIEW * 2) - 1;
080:
081: //Lords and self are always allowed full rights
082: public final static int HIDDEN = 0;
083: public final static int READ = 1;
084: public final static int READ_WRITE = 2;
085:
086: private final static String STRING_DATE = "Date";
087: private final static String STRING_AUTHOR_NAME = "Author Name";
088: private final static String STRING_AUTHOR_E_MAIL = "Author e-mail";
089: private final static String STRING_AUTHOR_PUBLIC_KEY = "Author Public Key";
090: private final static String STRING_NAME = "Name";
091: private final static String STRING_VERSION = "Version";
092:
093: //rights to activate a behavior for the object depending on the triggering user
094: private int[] othersAccessRights = { VirtualElement.READ,
095: VirtualElement.READ, VirtualElement.HIDDEN,
096: VirtualElement.READ };
097:
098: private long requestId;
099:
100: private Transform3D transform3D;
101: private Node geometryDescription;
102: private Sound soundDescription;
103: private Object status;
104: private int reference;
105:
106: private Hashtable information;
107: private float price;
108: private String currency;
109:
110: private int virtualElementCapabilities;
111:
112: public NetworkElement(long requestId, Transform3D transform3D,
113: Node geometryDescription, Sound soundDescription,
114: Object status, int reference) {
115:
116: this .requestId = requestId;
117: this .geometryDescription = geometryDescription;
118: this .soundDescription = soundDescription;
119: this .status = status;
120: this .reference = reference;
121: this .transform3D = transform3D;
122: this .information = new Hashtable();
123: this .price = 0;
124: this .currency = Trade.US_DOLLAR;
125:
126: }
127:
128: public long getRequestId() {
129:
130: return this .requestId;
131:
132: }
133:
134: public final Transform3D getTransform3D() {
135:
136: return this .transform3D;
137:
138: }
139:
140: //used to transfer ObjectWorld geometry (including avatar skin) and ToolWorld elements (Icon3D, Frame3D, Cursor3D)s
141: public final Node getGeometryDescription() {
142:
143: return this .geometryDescription;
144:
145: }
146:
147: public final Sound getSoundDescription() {
148:
149: return this .soundDescription;
150:
151: }
152:
153: public final Object getStatus() {
154:
155: return this .status;
156:
157: }
158:
159: public final int getObjectReference() {
160:
161: return this .reference;
162:
163: }
164:
165: public final Hashtable getInformation() {
166:
167: return this .information;
168:
169: }
170:
171: public final float getPrice() {
172:
173: return this .price;
174:
175: }
176:
177: public final String getCurrency() {
178:
179: return this .currency;
180:
181: }
182:
183: //public final void setStatus (Object status) {
184:
185: // this.status = status;
186:
187: //}
188:
189: //public final void setTransform3D (Transform3D transform3D) {
190:
191: // this.transform3D = transform3D;
192:
193: //}
194:
195: //public final void setGeometryDescription (Object geometryDescription) {
196:
197: // this.geometryDescription = geometryDescription;
198:
199: //}
200:
201: //public final void setSoundDescription (Sound soundDescription) {
202:
203: // this.soundDescription = soundDescription;
204:
205: //}
206:
207: //public final void setObjectReference(int reference) {
208:
209: // this.reference = reference;
210:
211: //}
212:
213: public final void setInformation(Hashtable information) {
214:
215: this .information = information;
216:
217: }
218:
219: //must be >= 0
220: public final void setPrice(float price) {
221:
222: if (price >= 0) {
223: this .price = price;
224: }
225:
226: }
227:
228: //any valid string will fit
229: public final void setCurrency(String currency) {
230:
231: if ((currency != null) && currency.length() > 0) {
232: this .currency = currency;
233: }
234:
235: }
236:
237: public final int[] getOthersAccessRights() {
238:
239: return this .othersAccessRights;
240:
241: }
242:
243: public final void setOthersAccessRights(int userKind, int capability) {
244:
245: if ((capability >= VirtualElement.HIDDEN)
246: && (capability <= VirtualElement.READ_WRITE)) {
247: switch (userKind) {
248: case Avatar.PEERSLORD:
249: othersAccessRights[0] = capability;
250: case Avatar.PEER:
251: othersAccessRights[1] = capability;
252: case Avatar.PEERSVASSAL:
253: othersAccessRights[2] = capability;
254: case Avatar.VASSAL:
255: othersAccessRights[3] = capability;
256: }
257: }
258:
259: }
260:
261: public final boolean getDesignerCapability(int capability) {
262:
263: return (this .getDesignerCapabilities() & capability) != 0;
264:
265: }
266:
267: public int getDesignerCapabilities() {
268:
269: return this .virtualElementCapabilities;
270:
271: }
272:
273: public void setDesignerCapabilities(int virtualElementCapabilities) {
274:
275: this .virtualElementCapabilities = virtualElementCapabilities;
276:
277: }
278:
279: public final Bounds getGeometryBounds() {
280:
281: return this .geometryDescription.getBounds();
282:
283: }
284:
285: public final Bounds getSoundBounds() {
286:
287: return this .soundDescription.getSchedulingBounds();
288:
289: }
290:
291: public final BoundingLeaf getSoundBoundingLeaf() {
292:
293: return this.soundDescription.getSchedulingBoundingLeaf();
294:
295: }
296:
297: }
|