/* */ package com.sun.j3d.loaders.lw3d;
/* */
/* */ import java.io.StreamTokenizer;
/* */ import javax.vecmath.Matrix4d;
/* */ import javax.vecmath.Point3f;
/* */ import javax.vecmath.Vector3d;
/* */
/* */ class LwsFrame extends TextfileParser
/* */ {
/* */ double x;
/* */ double y;
/* */ double z;
/* */ double heading;
/* */ double pitch;
/* */ double bank;
/* */ double xScale;
/* */ double yScale;
/* */ double zScale;
/* */ double frameNumber;
/* */ int linearValue;
/* */ double tension;
/* */ double continuity;
/* */ double bias;
/* */
/* */ LwsFrame(StreamTokenizer st)
/* */ {
/* 73 */ this.x = getNumber(st);
/* 74 */ this.y = getNumber(st);
/* 75 */ this.z = (-getNumber(st));
/* 76 */ debugOutputLn(2, "x, y, z " + this.x + ", " + this.y + ", " + this.z);
/* 77 */ this.heading = getNumber(st);
/* 78 */ this.pitch = getNumber(st);
/* 79 */ this.bank = getNumber(st);
/* 80 */ debugOutputLn(2, "(degrees) h, p, b = " + this.heading + ", " + this.pitch + ", " + this.bank);
/* 81 */ this.heading *= 0.0174532925199433D;
/* 82 */ this.pitch *= 0.0174532925199433D;
/* 83 */ this.bank *= 0.0174532925199433D;
/* 84 */ debugOutputLn(2, "(radians) h, p, b = " + this.heading + ", " + this.pitch + ", " + this.bank);
/* 85 */ debugOutputLn(8, "got pos and ori");
/* 86 */ this.xScale = getNumber(st);
/* 87 */ this.yScale = getNumber(st);
/* 88 */ this.zScale = getNumber(st);
/* 89 */ debugOutputLn(2, "xs, ys, zs " + this.xScale + ", " + this.yScale + ", " + this.zScale);
/* 90 */ this.frameNumber = ((int)getNumber(st));
/* */
/* 92 */ this.linearValue = ((int)getNumber(st));
/* 93 */ debugOutputLn(2, "framenum, linear " + this.frameNumber + " , " + this.linearValue);
/* 94 */ this.tension = getNumber(st);
/* 95 */ this.continuity = getNumber(st);
/* 96 */ this.bias = getNumber(st);
/* 97 */ debugOutputLn(2, "tension, cont, bias = " + this.tension + ", " + this.continuity + ", " + this.bias);
/* */ }
/* */
/* */ LwsFrame(LwsFrame prevFrame, LwsFrame nextFrame, double ratio)
/* */ {
/* 109 */ prevFrame.x += (nextFrame.x - prevFrame.x) * ratio;
/* 110 */ prevFrame.y += (nextFrame.y - prevFrame.y) * ratio;
/* 111 */ prevFrame.z += (nextFrame.z - prevFrame.z) * ratio;
/* */
/* 113 */ prevFrame.heading += (nextFrame.heading - prevFrame.heading) * ratio;
/* */
/* 115 */ prevFrame.pitch += (nextFrame.pitch - prevFrame.pitch) * ratio;
/* */
/* 117 */ prevFrame.bank += (nextFrame.bank - prevFrame.bank) * ratio;
/* */
/* 119 */ prevFrame.xScale += (nextFrame.xScale - prevFrame.xScale) * ratio;
/* */
/* 121 */ prevFrame.yScale += (nextFrame.yScale - prevFrame.yScale) * ratio;
/* */
/* 123 */ prevFrame.zScale += (nextFrame.zScale - prevFrame.zScale) * ratio;
/* */
/* 125 */ prevFrame.frameNumber += (nextFrame.frameNumber - prevFrame.frameNumber) * ratio;
/* */
/* 129 */ this.linearValue = prevFrame.linearValue;
/* 130 */ this.tension = prevFrame.tension;
/* 131 */ this.continuity = prevFrame.continuity;
/* 132 */ this.bias = prevFrame.bias;
/* */ }
/* */
/* */ LwsFrame(LwsFrame prevFrame, LwsFrame frame1, LwsFrame frame2, LwsFrame nextFrame, double u, double adj0, double adj1)
/* */ {
/* 154 */ double u2 = u * u;
/* 155 */ double u3 = u2 * u;
/* 156 */ double z1 = 3.0D * u2 - u3 - u3;
/* 157 */ double h1 = 1.0D - z1;
/* 158 */ double h2 = z1;
/* 159 */ double h3 = u3 - u2 - u2 + u;
/* 160 */ double h4 = u3 - u2;
/* */
/* 162 */ double dd0a = (1.0D - frame1.tension) * (1.0D + frame1.continuity) * (1.0D + frame1.bias);
/* */
/* 165 */ double dd0b = (1.0D - frame1.tension) * (1.0D - frame1.continuity) * (1.0D - frame1.bias);
/* */
/* 168 */ double ds1a = (1.0D - frame2.tension) * (1.0D - frame2.continuity) * (1.0D + frame2.bias);
/* */
/* 171 */ double ds1b = (1.0D - frame2.tension) * (1.0D + frame2.continuity) * (1.0D - frame2.bias);
/* */
/* 174 */ double[] v = new double[4];
/* */
/* 177 */ v[0] = prevFrame.x; v[1] = frame1.x;
/* 178 */ v[2] = frame2.x; v[3] = nextFrame.x;
/* 179 */ this.x = computeInterpolation(v, dd0a, dd0b, ds1a, ds1b, adj0, adj1, h1, h2, h3, h4);
/* */
/* 181 */ v[0] = prevFrame.y; v[1] = frame1.y;
/* 182 */ v[2] = frame2.y; v[3] = nextFrame.y;
/* 183 */ this.y = computeInterpolation(v, dd0a, dd0b, ds1a, ds1b, adj0, adj1, h1, h2, h3, h4);
/* */
/* 185 */ v[0] = prevFrame.z; v[1] = frame1.z;
/* 186 */ v[2] = frame2.z; v[3] = nextFrame.z;
/* 187 */ this.z = computeInterpolation(v, dd0a, dd0b, ds1a, ds1b, adj0, adj1, h1, h2, h3, h4);
/* */
/* 191 */ v[0] = prevFrame.heading; v[1] = frame1.heading;
/* 192 */ v[2] = frame2.heading; v[3] = nextFrame.heading;
/* 193 */ this.heading = computeInterpolation(v, dd0a, dd0b, ds1a, ds1b, adj0, adj1, h1, h2, h3, h4);
/* */
/* 196 */ v[0] = prevFrame.pitch; v[1] = frame1.pitch;
/* 197 */ v[2] = frame2.pitch; v[3] = nextFrame.pitch;
/* 198 */ this.pitch = computeInterpolation(v, dd0a, dd0b, ds1a, ds1b, adj0, adj1, h1, h2, h3, h4);
/* */
/* 201 */ v[0] = prevFrame.bank; v[1] = frame1.bank;
/* 202 */ v[2] = frame2.bank; v[3] = nextFrame.bank;
/* 203 */ this.bank = computeInterpolation(v, dd0a, dd0b, ds1a, ds1b, adj0, adj1, h1, h2, h3, h4);
/* */
/* 207 */ frame1.xScale += (frame2.xScale - frame1.xScale) * u;
/* 208 */ frame1.yScale += (frame2.yScale - frame1.yScale) * u;
/* 209 */ frame1.zScale += (frame2.zScale - frame1.zScale) * u;
/* */
/* 212 */ frame1.frameNumber += (frame2.frameNumber - frame1.frameNumber) * u;
/* */
/* 216 */ this.linearValue = frame2.linearValue;
/* */
/* 219 */ this.tension = 0.0D;
/* 220 */ this.continuity = 0.0D;
/* 221 */ this.bias = 0.0D;
/* */ }
/* */
/* */ double computeInterpolation(double[] value, double dd0a, double dd0b, double ds1a, double ds1b, double adj0, double adj1, double h1, double h2, double h3, double h4)
/* */ {
/* 232 */ double delta = value[2] - value[1];
/* */ double dd0;
/* */ double dd0;
/* 236 */ if ((adj0 < -0.0001D) || (adj0 > 0.0001D))
/* 237 */ dd0 = adj0 * (dd0a * (value[1] - value[0]) + dd0b * delta);
/* */ else
/* 239 */ dd0 = 0.5D * (dd0a + dd0b) * delta;
/* */ double ds1;
/* */ double ds1;
/* 242 */ if ((adj1 < -0.0001D) || (adj1 > 0.0001D))
/* 243 */ ds1 = adj1 * (ds1a * delta + ds1b * (value[3] - value[2]));
/* */ else {
/* 245 */ ds1 = 0.5D * (ds1a + ds1b) * delta;
/* */ }
/* 247 */ double result = value[1] * h1 + value[2] * h2 + dd0 * h3 + ds1 * h4;
/* */
/* 249 */ return result;
/* */ }
/* */
/* */ double getHeading() {
/* 253 */ return this.heading;
/* */ }
/* */
/* */ double getPitch() {
/* 257 */ return this.pitch;
/* */ }
/* */
/* */ double getBank() {
/* 261 */ return this.bank;
/* */ }
/* */
/* */ void setMatrix(Matrix4d mat)
/* */ {
/* 269 */ setRotationMatrix(mat);
/* 270 */ mat.setTranslation(new Vector3d(this.x, this.y, this.z));
/* 271 */ Matrix4d m = new Matrix4d();
/* 272 */ m.setColumn(0, this.xScale, 0.0D, 0.0D, 0.0D);
/* 273 */ m.setColumn(1, 0.0D, this.yScale, 0.0D, 0.0D);
/* 274 */ m.setColumn(2, 0.0D, 0.0D, this.zScale, 0.0D);
/* 275 */ m.setColumn(3, 0.0D, 0.0D, 0.0D, 1.0D);
/* 276 */ mat.mul(m);
/* */ }
/* */
/* */ void setRotationMatrix(Matrix4d mat)
/* */ {
/* 284 */ debugOutputLn(1, "setRotMat()");
/* 285 */ debugOutputLn(2, " p, h, b = " + this.pitch + ", " + this.heading + ", " + this.bank);
/* */
/* 289 */ Matrix4d pitchMat = new Matrix4d();
/* 290 */ pitchMat.rotX(-this.pitch);
/* 291 */ Matrix4d bankMat = new Matrix4d();
/* 292 */ bankMat.rotZ(this.bank);
/* 293 */ mat.rotY(-this.heading);
/* 294 */ mat.mul(pitchMat);
/* 295 */ mat.mul(bankMat);
/* 296 */ debugOutputLn(2, "setRotMat(), mat = " + mat);
/* */ }
/* */
/* */ Point3f getPosition() {
/* 300 */ return new Point3f((float)this.x, (float)this.y, (float)this.z);
/* */ }
/* */
/* */ Point3f getScale()
/* */ {
/* 305 */ if (((this.xScale < -0.0001D) || (this.xScale > 0.0001D)) && ((this.yScale < -0.0001D) || (this.yScale > 0.0001D)) && ((this.zScale < -0.0001D) || (this.zScale > 0.0001D)))
/* */ {
/* 308 */ return new Point3f((float)this.xScale, (float)this.yScale, (float)this.zScale);
/* */ }
/* 310 */ return new Point3f(1.0F, 1.0F, 1.0F);
/* */ }
/* */
/* */ double getFrameNum()
/* */ {
/* 315 */ return this.frameNumber;
/* */ }
/* */
/* */ void printVals() {
/* 319 */ debugOutputLn(2, " x = " + this.x);
/* 320 */ debugOutputLn(2, " y = " + this.y);
/* 321 */ debugOutputLn(2, " z = " + this.z);
/* 322 */ debugOutputLn(2, " xScale = " + this.xScale);
/* 323 */ debugOutputLn(2, " yScale = " + this.yScale);
/* 324 */ debugOutputLn(2, " zScale = " + this.zScale);
/* 325 */ debugOutputLn(2, " heading = " + this.heading);
/* 326 */ debugOutputLn(2, " pitch = " + this.pitch);
/* 327 */ debugOutputLn(2, " bank = " + this.bank);
/* 328 */ debugOutputLn(2, " frameNum = " + this.frameNumber);
/* 329 */ debugOutputLn(2, " lin = " + this.linearValue);
/* 330 */ debugOutputLn(2, " tension = " + this.tension);
/* 331 */ debugOutputLn(2, " continuity = " + this.continuity);
/* 332 */ debugOutputLn(2, " bias = " + this.bias);
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\j3dutils.jar
* Qualified Name: com.sun.j3d.loaders.lw3d.LwsFrame
* JD-Core Version: 0.6.2
*/