001: /*
002: * $RCSfile: MFRotation.java,v $
003: *
004: * @(#)MFRotation.java 1.12 98/11/05 20:34:41
005: *
006: * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
007: *
008: * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
009: * modify and redistribute this software in source and binary code form,
010: * provided that i) this copyright notice and license appear on all copies of
011: * the software; and ii) Licensee does not utilize the software in a manner
012: * which is disparaging to Sun.
013: *
014: * This software is provided "AS IS," without a warranty of any kind. ALL
015: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
016: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
017: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
018: * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
019: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
020: * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
021: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
022: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
023: * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
024: * POSSIBILITY OF SUCH DAMAGES.
025: *
026: * This software is not designed or intended for use in on-line control of
027: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
028: * the design, construction, operation or maintenance of any nuclear
029: * facility. Licensee represents and warrants that it will not use or
030: * redistribute the Software for such purposes.
031: * $Revision: 1.2 $
032: * $Date: 2005/02/03 23:06:57 $
033: * $State: Exp $
034: */
035: /*
036: * @Author: Rick Goldberg
037: * @Author: Doug Gehringer
038: *
039: */
040: package org.jdesktop.j3d.loaders.vrml97.impl;
041:
042: import java.util.Observable;
043: import java.util.Observer;
044: import java.util.Vector;
045:
046: /** Description of the Class */
047: public class MFRotation extends MField {
048:
049: SFRotation[] rots;
050:
051: /**Constructor for the MFRotation object */
052: public MFRotation() {
053: rots = new SFRotation[0];
054: }
055:
056: /**
057: *Constructor for the MFRotation object
058: *
059: *@param size Description of the Parameter
060: *@param values Description of the Parameter
061: */
062: public MFRotation(int size, float[] values) {
063: setValue(size, values);
064: }
065:
066: /**
067: *Constructor for the MFRotation object
068: *
069: *@param values Description of the Parameter
070: */
071: public MFRotation(float[] values) {
072: setValue(values);
073: }
074:
075: /**
076: *Constructor for the MFRotation object
077: *
078: *@param values Description of the Parameter
079: */
080: public MFRotation(float[][] values) {
081: setValue(values);
082: }
083:
084: /**
085: * Gets the value attribute of the MFRotation object
086: *
087: *@param values Description of the Parameter
088: */
089: public void getValue(float[][] values) {
090: for (int i = 0; i < values.length; i++) {
091: System.arraycopy(rots[i].rot, 0, values[i], 0, 4);
092: }
093: }
094:
095: /**
096: * Gets the value attribute of the MFRotation object
097: *
098: *@param values Description of the Parameter
099: */
100: public void getValue(float[] values) {
101: for (int i = 0; i < values.length; i += 4) {
102: System.arraycopy(rots[i / 4].rot, 0, values, i, 4);
103: }
104: }
105:
106: /**
107: * Description of the Method
108: *
109: *@param index Description of the Parameter
110: *@param values Description of the Parameter
111: */
112: public void get1Value(int index, float[] values) {
113: System.arraycopy(rots[index].rot, 0, values, 0, 4);
114: }
115:
116: /**
117: * Description of the Method
118: *
119: *@param index Description of the Parameter
120: *@param vec Description of the Parameter
121: */
122: public void get1Value(int index, SFRotation vec) {
123: vec.setValue(rots[index].rot);
124: }
125:
126: /**
127: * Sets the value attribute of the MFRotation object
128: *
129: *@param values The new value value
130: */
131: public void setValue(float[][] values) {
132: rots = new SFRotation[values.length];
133: for (int i = 0; i < values.length; i++) {
134: rots[i] = new SFRotation(values[i]);
135: }
136: route();
137: }
138:
139: /**
140: * Sets the value attribute of the MFRotation object
141: *
142: *@param values The new value value
143: */
144: public void setValue(float[] values) {
145: rots = new SFRotation[values.length / 4];
146: for (int i = 0; i < values.length; i += 4) {
147: rots[i / 4] = new SFRotation(values[i], values[i + 1],
148: values[i + 2], values[i + 3]);
149: }
150: route();
151: }
152:
153: /**
154: * Sets the value attribute of the MFRotation object
155: *
156: *@param size The new value value
157: *@param values The new value value
158: */
159: public void setValue(int size, float[] values) {
160: // TODO: should use size?
161: setValue(values);
162: }
163:
164: /**
165: * Sets the value attribute of the MFRotation object
166: *
167: *@param values The new value value
168: */
169: public void setValue(MFRotation values) {
170: rots = new SFRotation[values.rots.length];
171: for (int i = 0; i < values.rots.length; i++) {
172: rots[i] = new SFRotation(values.rots[i].rot);
173: }
174: route();
175: }
176:
177: /**
178: * Sets the value attribute of the MFRotation object
179: *
180: *@param values The new value value
181: */
182: public void setValue(ConstMFRotation values) {
183: setValue((MFRotation) values.ownerField);
184: }
185:
186: /**
187: * Description of the Method
188: *
189: *@param index Description of the Parameter
190: *@param constvec Description of the Parameter
191: */
192: public void set1Value(int index, ConstSFRotation constvec) {
193: set1Value(index, (SFRotation) constvec.ownerField);
194: }
195:
196: /**
197: * Description of the Method
198: *
199: *@param index Description of the Parameter
200: *@param vec Description of the Parameter
201: */
202: public void set1Value(int index, SFRotation vec) {
203: set1Value(index, vec.rot[0], vec.rot[1], vec.rot[2], vec.rot[3]);
204: }
205:
206: /**
207: * Description of the Method
208: *
209: *@param index Description of the Parameter
210: *@param x Description of the Parameter
211: *@param y Description of the Parameter
212: *@param z Description of the Parameter
213: *@param angle Description of the Parameter
214: */
215: public void set1Value(int index, float x, float y, float z,
216: float angle) {
217: rots[index].rot[0] = x;
218: rots[index].rot[1] = y;
219: rots[index].rot[2] = z;
220: rots[index].rot[3] = angle;
221: route();
222: }
223:
224: /**
225: * Description of the Method
226: *
227: *@param index Description of the Parameter
228: *@param constvec Description of the Parameter
229: */
230: public void insertValue(int index, ConstSFRotation constvec) {
231: insertValue(index, (SFRotation) constvec.ownerField);
232: }
233:
234: /**
235: * Description of the Method
236: *
237: *@param index Description of the Parameter
238: *@param vec Description of the Parameter
239: */
240: public void insertValue(int index, SFRotation vec) {
241: insertValue(index, vec.rot[0], vec.rot[1], vec.rot[2],
242: vec.rot[3]);
243: }
244:
245: /**
246: * Description of the Method
247: *
248: *@param index Description of the Parameter
249: *@param x Description of the Parameter
250: *@param y Description of the Parameter
251: *@param z Description of the Parameter
252: *@param angle Description of the Parameter
253: */
254: public void insertValue(int index, float x, float y, float z,
255: float angle) {
256: Vector veclist = new Vector(rots.length + 1);
257: float[] sfr = new float[4];
258: sfr[0] = x;
259: sfr[1] = y;
260: sfr[2] = z;
261: sfr[3] = angle;
262: for (int i = 0; i < rots.length; i++) {
263: veclist.addElement(rots[i]);
264: }
265: veclist.insertElementAt(new SFRotation(sfr), index);
266: rots = new SFRotation[veclist.size()];
267: veclist.copyInto(rots);
268: route();
269: }
270:
271: /**
272: * Description of the Method
273: *
274: *@param field Description of the Parameter
275: */
276: public void update(Field field) {
277: setValue((MFRotation) field);
278: }
279:
280: /**
281: * Description of the Method
282: *
283: *@return Description of the Return Value
284: */
285: public synchronized Object clone() {
286: SFRotation[] tmp = new SFRotation[rots.length];
287: MFRotation ref = new MFRotation();
288: ref.rots = tmp;
289: System.arraycopy(rots, 0, ref.rots, 0, rots.length);
290: return ref;
291: }
292:
293: /**
294: * Description of the Method
295: *
296: *@return Description of the Return Value
297: */
298: public synchronized ConstField constify() {
299: if (constField == null) {
300: constField = new ConstMFRotation(this );
301: }
302: return constField;
303: }
304:
305: /**
306: * Gets the size attribute of the MFRotation object
307: *
308: *@return The size value
309: */
310: public int getSize() {
311: return rots.length;
312: }
313:
314: /** Description of the Method */
315: public void clear() {
316: rots = new SFRotation[1];
317: }
318:
319: /**
320: * Description of the Method
321: *
322: *@param i Description of the Parameter
323: */
324: public void delete(int i) {
325: ;
326: }// TBD
327:
328: /**
329: * Description of the Method
330: *
331: *@return Description of the Return Value
332: */
333: public vrml.Field wrap() {
334: return new vrml.field.MFRotation(this);
335: }
336: }
|