| .. | .. | 
|---|
| 334 | 334 |  	 | 
|---|
| 335 | 335 |  	void RotateInterest(float dx, float dy) | 
|---|
| 336 | 336 |  	{ | 
|---|
 | 337 | +            right.mul(-1);  | 
|---|
 | 338 | +              | 
|---|
| 337 | 339 |              cStatic.point1.set(location); | 
|---|
| 338 | 340 |              location.set(lookAt); | 
|---|
| 339 | 341 |              lookAt.set(cStatic.point1); | 
|---|
| 340 |  | -            right.mul(-1);  | 
|---|
 | 342 | +              | 
|---|
 | 343 | +            cStatic.point1.set(locationBuf);  | 
|---|
 | 344 | +            locationBuf.set(lookAtBuf);  | 
|---|
 | 345 | +            lookAtBuf.set(cStatic.point1);  | 
|---|
| 341 | 346 |           //   UP.mul(-1); | 
|---|
| 342 | 347 |               | 
|---|
| 343 | 348 |              RotatePosition(dx,-dy); | 
|---|
| 344 | 349 |               | 
|---|
| 345 | 350 |           //   UP.mul(-1); | 
|---|
| 346 | 351 |              right.mul(-1); | 
|---|
 | 352 | +              | 
|---|
| 347 | 353 |              cStatic.point1.set(location); | 
|---|
| 348 | 354 |              location.set(lookAt); | 
|---|
| 349 | 355 |              lookAt.set(cStatic.point1); | 
|---|
 | 356 | +              | 
|---|
 | 357 | +            cStatic.point1.set(locationBuf);  | 
|---|
 | 358 | +            locationBuf.set(lookAtBuf);  | 
|---|
 | 359 | +            lookAtBuf.set(cStatic.point1);  | 
|---|
| 350 | 360 |               | 
|---|
| 351 | 361 |              computeTransform(); | 
|---|
| 352 | 362 |  	} | 
|---|
| .. | .. | 
|---|
| 361 | 371 |              fromScreen = LA.newMatrix(); | 
|---|
| 362 | 372 |          } | 
|---|
| 363 | 373 |           | 
|---|
 | 374 | +        if (locationBuf == null)  | 
|---|
 | 375 | +        {  | 
|---|
 | 376 | +            locationBuf = new cVector();  | 
|---|
 | 377 | +            locationBuf.set(location);  | 
|---|
 | 378 | +            lookAtBuf = new cVector();  | 
|---|
 | 379 | +            lookAtBuf.set(lookAt);  | 
|---|
 | 380 | +            upBuf = new cVector();  | 
|---|
 | 381 | +            upBuf.set(UP);  | 
|---|
 | 382 | +//            up2Buf = new cVector();  | 
|---|
 | 383 | +//            up2Buf.set(UP2);  | 
|---|
 | 384 | +        }  | 
|---|
 | 385 | +        else  | 
|---|
 | 386 | +        {  | 
|---|
 | 387 | +            double K = 0.25;  | 
|---|
 | 388 | +              | 
|---|
 | 389 | +            locationBuf.y = location.y * K + locationBuf.y * (1 - K);  | 
|---|
 | 390 | +            lookAtBuf.y = lookAt.y * K + lookAtBuf.y * (1 - K);  | 
|---|
 | 391 | +              | 
|---|
 | 392 | +            upBuf.x = UP.x * K + upBuf.x * (1 - K);  | 
|---|
 | 393 | +            upBuf.y = UP.y * K + upBuf.y * (1 - K);  | 
|---|
 | 394 | +            upBuf.z = UP.z * K + upBuf.z * (1 - K);  | 
|---|
 | 395 | +            upBuf.normalize();  | 
|---|
 | 396 | +//            up2Buf.x = UP2.x * K + up2Buf.x * (1 - K);  | 
|---|
 | 397 | +//            up2Buf.y = UP2.y * K + up2Buf.y * (1 - K);  | 
|---|
 | 398 | +//            up2Buf.z = UP2.z * K + up2Buf.z * (1 - K);  | 
|---|
 | 399 | +              | 
|---|
 | 400 | +            K = 1;  | 
|---|
 | 401 | +              | 
|---|
 | 402 | +            locationBuf.x = location.x * K + locationBuf.x * (1 - K);  | 
|---|
 | 403 | +            locationBuf.z = location.z * K + locationBuf.z * (1 - K);  | 
|---|
 | 404 | +            lookAtBuf.x = lookAt.x * K + lookAtBuf.x * (1 - K);  | 
|---|
 | 405 | +            lookAtBuf.z = lookAt.z * K + lookAtBuf.z * (1 - K);  | 
|---|
 | 406 | +        }  | 
|---|
 | 407 | +          | 
|---|
| 364 | 408 |          cVector up2 = up; | 
|---|
| 365 | 409 |          cVector right2 = right; | 
|---|
| 366 | 410 |           | 
|---|
| 367 |  | -	up2.x = UP.x;  | 
|---|
| 368 |  | -	up2.y = UP.y;  | 
|---|
| 369 |  | -	up2.z = UP.z;  | 
|---|
| 370 |  | -        LA.vecSub(lookAt, location, away);  | 
|---|
 | 411 | +	up2.x = upBuf.x;  | 
|---|
 | 412 | +	up2.y = upBuf.y;  | 
|---|
 | 413 | +	up2.z = upBuf.z;  | 
|---|
 | 414 | +        LA.vecSub(lookAtBuf, locationBuf, away);  | 
|---|
| 371 | 415 |          LA.vecNormalize(away); | 
|---|
| 372 | 416 |          LA.vecCross(away, up2, right2); | 
|---|
| 373 | 417 |  		if (right2.length2() < 0.0001) | 
|---|
| 374 | 418 |  		{ | 
|---|
 | 419 | +                    //System.out.println("right2.length2() < 0.0001");  | 
|---|
| 375 | 420 |  			// UP failed | 
|---|
| 376 | 421 |  			up2.x = UP2.x; | 
|---|
| 377 | 422 |  			up2.y = UP2.y; | 
|---|
| .. | .. | 
|---|
| 381 | 426 |  			LA.vecCross(away, up2, right2); | 
|---|
| 382 | 427 |  			if (!(right2.length2() > 0)) | 
|---|
| 383 | 428 |                          { | 
|---|
 | 429 | +                    System.exit(0);  | 
|---|
| 384 | 430 |                              // old problem... | 
|---|
| 385 | 431 |                              assert (right2.length2() <= 0 || right2.length2() > 0); // weirdest thing ever | 
|---|
| 386 | 432 |                              up2.x = UP.x = 0; | 
|---|
| .. | .. | 
|---|
| 410 | 456 |  		} | 
|---|
| 411 | 457 |   | 
|---|
| 412 | 458 |          for (int i=0; i < 3; i++) | 
|---|
| 413 |  | -            fromScreen[3][i] = location.get(i);  | 
|---|
 | 459 | +            fromScreen[3][i] = locationBuf.get(i);  | 
|---|
| 414 | 460 |   | 
|---|
| 415 | 461 |          for (int i=0; i < 3; i++) | 
|---|
| 416 |  | -            temp[3][i] = -location.get(i);  | 
|---|
 | 462 | +            temp[3][i] = -locationBuf.get(i);  | 
|---|
| 417 | 463 |   | 
|---|
| 418 | 464 |          LA.matConcat(temp, toScreen, toScreen); | 
|---|
| 419 | 465 |   | 
|---|
| .. | .. | 
|---|
| 500 | 546 |      static final int viewFront = 2; | 
|---|
| 501 | 547 |      static final int viewSide = 3; | 
|---|
| 502 | 548 |      int viewCode; | 
|---|
 | 549 | +      | 
|---|
| 503 | 550 |      cVector location; | 
|---|
| 504 | 551 |      cVector lookAt; | 
|---|
 | 552 | +      | 
|---|
 | 553 | +    transient cVector locationBuf;  | 
|---|
 | 554 | +    transient cVector lookAtBuf;  | 
|---|
 | 555 | +    transient cVector upBuf;  | 
|---|
 | 556 | +    //transient cVector up2Buf;  | 
|---|
 | 557 | +      | 
|---|
| 505 | 558 |      cVector direction; | 
|---|
 | 559 | +      | 
|---|
| 506 | 560 |      double[][] toScreen; | 
|---|
| 507 | 561 |      double[][] fromScreen; | 
|---|
 | 562 | +      | 
|---|
| 508 | 563 |      boolean perspective; | 
|---|
| 509 | 564 |      int hAspect = 0; // Free camera | 
|---|
| 510 | 565 |      int vAspect; | 
|---|