Package com.sun.j3d.loaders.lw3d

Source Code of com.sun.j3d.loaders.lw3d.SequenceReader

/*     */ package com.sun.j3d.loaders.lw3d;
/*     */
/*     */ import com.sun.j3d.loaders.ParsingErrorException;
/*     */ import java.io.BufferedReader;
/*     */ import java.io.FileNotFoundException;
/*     */ import java.io.FileReader;
/*     */ import java.io.IOException;
/*     */ import java.io.StreamTokenizer;
/*     */ import java.util.Enumeration;
/*     */ import java.util.Vector;
/*     */ import javax.media.j3d.Alpha;
/*     */ import javax.media.j3d.BoundingSphere;
/*     */ import javax.media.j3d.Switch;
/*     */ import javax.media.j3d.TransformGroup;
/*     */ import javax.vecmath.Point3d;
/*     */
/*     */ class SequenceReader
/*     */ {
/*     */   Vector sequenceLines;
/*     */   float totalTime;
/*     */   int totalFrames;
/*     */   TransformGroup objectTransform;
/*     */   Vector behaviorVector;
/*     */
/*     */   SequenceReader(String filename, float time, int frames)
/*     */     throws ParsingErrorException
/*     */   {
/* 296 */     this.totalTime = time;
/* 297 */     this.totalFrames = frames;
/* 298 */     this.sequenceLines = new Vector();
/*     */     try
/*     */     {
/* 301 */       StreamTokenizer st = new StreamTokenizer(new BufferedReader(new FileReader(filename)));
/*     */
/* 303 */       st.wordChars(95, 95);
/* 304 */       st.wordChars(47, 47);
/* 305 */       int type = st.nextToken();
/* 306 */       while (st.ttype != -1) {
/* 307 */         this.sequenceLines.addElement(new SequenceLine(st, this.totalTime, this.totalFrames));
/*     */
/* 310 */         st.nextToken();
/*     */       }
/*     */     }
/*     */     catch (IOException e) {
/* 314 */       throw new ParsingErrorException(e.getMessage());
/*     */     }
/*     */   }
/*     */
/*     */   void createJava3dObjects(int debugVals, int loadBehaviors)
/*     */     throws FileNotFoundException
/*     */   {
/* 328 */     this.objectTransform = new TransformGroup();
/* 329 */     this.behaviorVector = new Vector();
/* 330 */     Enumeration e = this.sequenceLines.elements();
/* 331 */     Switch switchNode = new Switch();
/* 332 */     switchNode.setCapability(17);
/* 333 */     switchNode.setCapability(18);
/* 334 */     this.objectTransform.addChild(switchNode);
/* 335 */     while (e.hasMoreElements()) {
/* 336 */       SequenceLine line = (SequenceLine)e.nextElement();
/* 337 */       line.createJava3dObjects(debugVals, loadBehaviors);
/* 338 */       if (line.getGeometry() != null) {
/* 339 */         switchNode.addChild(line.getGeometry());
/*     */       }
/* 341 */       if (line.getBehavior() != null) {
/* 342 */         this.behaviorVector.addElement(line.getBehavior());
/*     */       }
/*     */     }
/* 345 */     float[] knots = new float[this.sequenceLines.size() + 1];
/* 346 */     for (int i = 0; i < knots.length - 1; i++) {
/* 347 */       SequenceLine sl = (SequenceLine)this.sequenceLines.elementAt(i);
/* 348 */       knots[i] = (sl.startFrame / this.totalFrames);
/*     */     }
/* 350 */     knots[(knots.length - 1)] = 1.0F;
/* 351 */     Alpha theAlpha = new Alpha(-1, 1, 0L, 0L, ()(1000.0F * this.totalTime), 0L, 0L, 0L, 0L, 0L);
/*     */
/* 355 */     SwitchPathInterpolator switchPath = new SwitchPathInterpolator(theAlpha, knots, switchNode);
/*     */
/* 359 */     BoundingSphere bounds = new BoundingSphere(new Point3d(0.0D, 0.0D, 0.0D), 1000000.0D);
/*     */
/* 361 */     switchPath.setSchedulingBounds(bounds);
/* 362 */     switchNode.addChild(switchPath);
/* 363 */     this.behaviorVector.addElement(switchPath);
/*     */   }
/*     */
/*     */   TransformGroup getObjectNode() {
/* 367 */     return this.objectTransform;
/*     */   }
/*     */
/*     */   Vector getObjectBehaviors() {
/* 371 */     return this.behaviorVector;
/*     */   }
/*     */
/*     */   void printLines() {
/* 375 */     Enumeration e = this.sequenceLines.elements();
/*     */     SequenceLine line;
/* 376 */     while (e.hasMoreElements())
/* 377 */       line = (SequenceLine)e.nextElement();
/*     */   }
/*     */ }

/* Location:           Z:\System\Library\Java\Extensions\j3dutils.jar
* Qualified Name:     com.sun.j3d.loaders.lw3d.SequenceReader
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of com.sun.j3d.loaders.lw3d.SequenceReader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.