home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Late Night VRML 2.0 with Java CD-ROM
/
code.zip
/
Ch13
/
hash
/
ControlPoint.java
< prev
next >
Wrap
Text File
|
1997-01-14
|
4KB
|
82 lines
// A single AnimationMaster spline control point
// Written by Bernie Roehl, November 1996
package hash;
import java.io.*;
import java.util.*;
public class ControlPoint {
protected int cpid;
protected boolean smooth;
protected boolean loop;
protected boolean attach;
protected int attached_cpid;
protected double x, y, z;
protected double outalpha, outgamma, outmag;
protected double inalpha, ingamma, inmag;
public int getCPID() { return cpid; }
public boolean isSmooth() { return smooth; }
public boolean isLooped() { return loop; }
public boolean isAttached() { return attach; }
public int getAttachedCPID() { return attached_cpid; }
public double getX() { return x; }
public double getY() { return y; }
public double getZ() { return z; }
public void dump() {
System.out.println(" CPID = " + cpid + " smooth = " + smooth
+ " loop = " + loop + " attach = " + attach);
if (attach) System.out.println(" attached_cpid = " + attached_cpid);
else System.out.println(" x = " + x + " y = " + y + " z = " + z);
System.out.print(" in: " + inalpha + " " + ingamma + " " + inmag);
System.out.println(" out: " + outalpha + " " + outgamma + " " + outmag);
}
public ControlPoint(DataInputStream input)
throws IOException, HashSyntaxException {
StringTokenizer s;
s = new StringTokenizer(input.readLine());
if (s.countTokens() != 3)
throw new HashSyntaxException("missing fields on spline point header");
int type = Integer.parseInt(s.nextToken());
smooth = ((type & 0x01) != 0) ? true : false;
loop = ((type & 0x04) != 0) ? true : false;
attach = (Integer.parseInt(s.nextToken()) != 0) ? true : false;
cpid = Integer.parseInt(s.nextToken());
if (attach)
attached_cpid = Integer.parseInt(input.readLine());
else {
s = new StringTokenizer(input.readLine());
if (s.countTokens() != 3)
throw new HashSyntaxException("missing fields in spline point x,y,z line");
x = Float.valueOf(s.nextToken()).floatValue();
y = Float.valueOf(s.nextToken()).floatValue();
z = Float.valueOf(s.nextToken()).floatValue();
}
s = new StringTokenizer(input.readLine());
outalpha = (new Float(s.nextToken())).floatValue();
outmag = 100; // default value
if (s.hasMoreTokens()) {
outgamma = Float.valueOf(s.nextToken()).floatValue();
if (s.hasMoreTokens())
outmag = Float.valueOf(s.nextToken()).floatValue();
}
s = new StringTokenizer(input.readLine());
inalpha = Float.valueOf(s.nextToken()).floatValue();
inmag = 100; // default value
if (s.hasMoreTokens()) {
ingamma = Float.valueOf(s.nextToken()).floatValue();
if (s.hasMoreTokens())
inmag = Float.valueOf(s.nextToken()).floatValue();
}
}
}