?? selfconvertingpoint.java
字號:
/*
Netwar
Copyright (C) 2002 Daniel Grund, Kyle Kakligian, Jason Komutrattananon, & Brian Hibler.
This file is part of Netwar.
Netwar is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Netwar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Netwar; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package netwar.utils.vectorgraphics;
/** This class is used to represent a location or vector in gamespace and in screensspace with screen Z (for draw ordering).<br>
* <br>
* Using this point directly as a Point3D will have the effect of using gamespace coordinates.
* To access the screenspace coordinates use getScreenPoint().
* <br>
* Note that the get_ functions return a new Point2D/3D while the do_ funtions affect <B>this</B> SelfConvertingPoint.
* Exception: getScreenPoint returns the screen coordinates (with Z).
* @author Daniel Grund and Kyle Kakligian
*/
public class SelfConvertingPoint extends Point3D{
private Point3D screenPoint = new Point3D();
//True if screenPoint may not be accurate.
private boolean screenDirty = true;
private boolean onScreen = false;
private Transform trans = null;
private int iteration;
/** Constructor for the orgin.
*/
public SelfConvertingPoint() {}
/** Constructs a Point3D
* @param X X-axis value or length.
* @param Y Y-axis value or length.
* @param Z Z-axis value or length.
*/
public SelfConvertingPoint(float X, float Y, float Z) {super(X,Y,Z);}
/** Constructs a Point3D, converting the doubles to floats.
* @param X X-axis value or length.
* @param Y Y-axis value or length.
* @param Z Z-axis value or length.
*/
public SelfConvertingPoint(double X, double Y, double Z) {super(X,Y,Z);}
/** Copy constructor
* @param v Copy.
*/
public SelfConvertingPoint(Point3D v) {super(v);}
/** Updates the screen point and return it.
* @param t The transform which translates from game to screen.
* @return a Point3D containing screen coordinates and Z for Z-Ordering.
*/
public Point3D getScreenPoint(Transform t) {
if(screenDirty || t != trans || iteration != t.getIteration()) {
trans = t;
iteration = t.getIteration();
onScreen = t.getPoint2DwithZ(this, screenPoint);
screenDirty = false;
}
return screenPoint;
}
/** Updates the screen point and indicates whether it is now on the screen.
* @param t The transform which translates from game to screen.
* @return True iff the point is on the screenspace defined by t.
*/
public boolean isOnScreen(Transform t) {
if(screenDirty || t != trans || iteration != t.getIteration()) {
trans = t;
iteration = t.getIteration();
onScreen = t.getPoint2DwithZ(this, screenPoint);
screenDirty = false;
}
return onScreen;
}
public Point3D doCrossProduct(Point3D v) {
screenDirty = true;
return super.doCrossProduct(v);
}
public Point3D doDifference(Point3D v) {
screenDirty = true;
return super.doDifference(v);
}
public Point3D doProduct(float scalar) {
screenDirty = true;
return super.doProduct(scalar);
}
public Point3D doRotate(Point3D linePt, Point3D vec, int theta) {
screenDirty = true;
return super.doRotate(linePt, vec, theta);
}
public Point3D doSum(Point3D v) {
screenDirty = true;
return super.doSum(v);
}
public Point3D set(Point3D p){
screenDirty = true;
return super.set(p);
}
public Point3D set(float X, float Y, float Z){
screenDirty = true;
return super.set(X,Y,Z);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -