consistent formatting
This commit is contained in:
@@ -15,6 +15,7 @@ public class GwtBitmap implements Bitmap {
|
||||
Pixmap pixmap;
|
||||
Image image;
|
||||
boolean disposable;
|
||||
|
||||
public GwtBitmap(Image data) {
|
||||
ImageElement imageElement = ImageElement.as(data.getElement());
|
||||
pixmap = new Pixmap(imageElement);
|
||||
@@ -60,12 +61,11 @@ public class GwtBitmap implements Bitmap {
|
||||
public int uploadToTexture(boolean replace) {
|
||||
|
||||
Gdx.gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(),
|
||||
pixmap.getHeight(), 0,
|
||||
pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
|
||||
pixmap.getHeight(), 0,
|
||||
pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
|
||||
|
||||
|
||||
if (disposable || image != null){
|
||||
Log.d("", "dispose pixmap " +getWidth() +"/" + getHeight());
|
||||
if (disposable || image != null) {
|
||||
Log.d("", "dispose pixmap " + getWidth() + "/" + getHeight());
|
||||
pixmap.dispose();
|
||||
|
||||
if (image != null)
|
||||
|
||||
@@ -119,7 +119,7 @@ class GwtGdxMap extends GdxMap {
|
||||
//rot = rot < 0 ? -rot : rot;
|
||||
|
||||
if (curZoom != pos.zoomLevel || curLat != lat || curLon != lon
|
||||
|| curTilt != rot || curRot != (int) (pos.angle)) {
|
||||
|| curTilt != rot || curRot != (int) (pos.angle)) {
|
||||
|
||||
curLat = lat;
|
||||
curLon = lon;
|
||||
@@ -128,11 +128,11 @@ class GwtGdxMap extends GdxMap {
|
||||
curRot = rot;
|
||||
|
||||
String newURL = Window.Location
|
||||
.createUrlBuilder()
|
||||
.setHash("scale=" + pos.zoomLevel + ",rot=" + curRot
|
||||
+ ",tilt=" + curTilt + ",lat=" + (curLat / 1000f)
|
||||
+ ",lon=" + (curLon / 1000f))
|
||||
.buildString();
|
||||
.createUrlBuilder()
|
||||
.setHash("scale=" + pos.zoomLevel + ",rot=" + curRot
|
||||
+ ",tilt=" + curTilt + ",lat=" + (curLat / 1000f)
|
||||
+ ",lon=" + (curLon / 1000f))
|
||||
.buildString();
|
||||
Window.Location.replace(newURL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ public class GwtLauncher extends GwtApplication {
|
||||
|
||||
@Override
|
||||
public GwtApplicationConfiguration getConfig() {
|
||||
GwtApplicationConfiguration cfg = new GwtApplicationConfiguration(
|
||||
GwtGraphics.getWindowWidthJSNI(),
|
||||
GwtGraphics.getWindowHeightJSNI());
|
||||
GwtApplicationConfiguration cfg =
|
||||
new GwtApplicationConfiguration(GwtGraphics.getWindowWidthJSNI(),
|
||||
GwtGraphics.getWindowHeightJSNI());
|
||||
|
||||
DockLayoutPanel p = new DockLayoutPanel(Unit.EM);
|
||||
p.setHeight("100%");
|
||||
|
||||
@@ -47,7 +47,7 @@ public class GwtPaint implements Paint {
|
||||
float a = ((color >>> 24) & 0xff) / 255f;
|
||||
int r = (color >>> 16) & 0xff;
|
||||
int g = (color >>> 8) & 0xff;
|
||||
int b = (color & 0xff) ;
|
||||
int b = (color & 0xff);
|
||||
|
||||
this.color = Pixmap.make(r, g, b, a);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class GwtPaint implements Paint {
|
||||
return 4 + strokeWidth;
|
||||
}
|
||||
|
||||
void buildFont(){
|
||||
void buildFont() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (this.fontStyle == FontStyle.BOLD)
|
||||
|
||||
@@ -34,4 +34,3 @@ class MapConfig extends JavaScriptObject {
|
||||
return this.background;
|
||||
}-*/;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class SearchBox {
|
||||
}
|
||||
|
||||
final static class NominatimData extends JavaScriptObject implements
|
||||
PoiData {
|
||||
PoiData {
|
||||
|
||||
protected NominatimData() {
|
||||
}
|
||||
@@ -83,7 +83,8 @@ public class SearchBox {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final native String getId() /*-{
|
||||
public final native String getId()
|
||||
/*-{
|
||||
return this.osm_id;
|
||||
}-*/;
|
||||
|
||||
@@ -155,7 +156,7 @@ public class SearchBox {
|
||||
|
||||
@Override
|
||||
public void render(com.google.gwt.cell.client.Cell.Context context,
|
||||
PoiData value, SafeHtmlBuilder sb) {
|
||||
PoiData value, SafeHtmlBuilder sb) {
|
||||
|
||||
// Value can be null, so do a null check..
|
||||
if (value == null) {
|
||||
@@ -203,10 +204,10 @@ public class SearchBox {
|
||||
|
||||
// Create a CellList that uses the cell.
|
||||
final CellList<PoiData> cellList = new CellList<PoiData>(poiCell,
|
||||
PoiData.KEY_PROVIDER);
|
||||
PoiData.KEY_PROVIDER);
|
||||
|
||||
final SingleSelectionModel<PoiData> selectionModel = new SingleSelectionModel<PoiData>(
|
||||
PoiData.KEY_PROVIDER);
|
||||
PoiData.KEY_PROVIDER);
|
||||
cellList.setSelectionModel(selectionModel);
|
||||
|
||||
final ScrollPanel scroller = new ScrollPanel(cellList);
|
||||
@@ -235,7 +236,7 @@ public class SearchBox {
|
||||
BoundingBox b = d.getBoundingBox();
|
||||
if (b != null) {
|
||||
if (b.maxLatitudeE6 - b.minLatitudeE6 < 100 &&
|
||||
b.maxLongitudeE6 - b.minLongitudeE6 < 100)
|
||||
b.maxLongitudeE6 - b.minLongitudeE6 < 100)
|
||||
// for small bbox use zoom=16 to get an overview
|
||||
map.getAnimator().animateTo(500, b.getCenterPoint(), 1 << 16, false);
|
||||
else
|
||||
@@ -311,8 +312,8 @@ public class SearchBox {
|
||||
searchButton.setEnabled(false);
|
||||
|
||||
String url = URL
|
||||
.encode(NOMINATIM_GLOBAL
|
||||
+ textToServer);
|
||||
.encode(NOMINATIM_GLOBAL
|
||||
+ textToServer);
|
||||
|
||||
JsonpRequestBuilder builder = new JsonpRequestBuilder();
|
||||
builder.setCallbackParam("json_callback");
|
||||
|
||||
@@ -88,7 +88,7 @@ public class WKTReader {
|
||||
}
|
||||
|
||||
private static void parsePoly(GeometryBuffer geom, String wkt, int len, int[] adv)
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
// outer ring
|
||||
ensure(wkt, adv, '(');
|
||||
parseLine(geom, wkt, len, adv);
|
||||
@@ -102,7 +102,7 @@ public class WKTReader {
|
||||
}
|
||||
|
||||
private static void parseLine(GeometryBuffer geom, String wkt, int len, int[] adv)
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
ensure(wkt, adv, '(');
|
||||
|
||||
parsePoint(geom, wkt, len, adv);
|
||||
@@ -204,21 +204,21 @@ public class WKTReader {
|
||||
return neg ? -val : val;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// WKTReader r = new WKTReader();
|
||||
// GeometryBuffer geom = new GeometryBuffer(10, 10);
|
||||
// try {
|
||||
// String wkt = "MULTIPOINT(0 0,1 0)";
|
||||
// r.parse(wkt, geom);
|
||||
// for (int i = 0; i < geom.index.length; i++) {
|
||||
// int len = geom.index[i];
|
||||
// if (len < 0)
|
||||
// break;
|
||||
// for (int p = 0; p < len; p += 2)
|
||||
// System.out.println(len + ": " + geom.points[p] + "," + geom.points[p + 1]);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// public static void main(String[] args) {
|
||||
// WKTReader r = new WKTReader();
|
||||
// GeometryBuffer geom = new GeometryBuffer(10, 10);
|
||||
// try {
|
||||
// String wkt = "MULTIPOINT(0 0,1 0)";
|
||||
// r.parse(wkt, geom);
|
||||
// for (int i = 0; i < geom.index.length; i++) {
|
||||
// int len = geom.index[i];
|
||||
// if (len < 0)
|
||||
// break;
|
||||
// for (int p = 0; p < len; p += 2)
|
||||
// System.out.println(len + ": " + geom.points[p] + "," + geom.points[p + 1]);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ public class MalformedURLException extends Exception {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ public class CopyOnWriteArrayList<E> extends ArrayList<E> {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ import org.xml.sax.Attributes;
|
||||
import com.google.gwt.xml.client.NamedNodeMap;
|
||||
import com.google.gwt.xml.client.Node;
|
||||
|
||||
public class MyAttributes implements Attributes{
|
||||
public class MyAttributes implements Attributes {
|
||||
private NamedNodeMap map;
|
||||
|
||||
public MyAttributes(Node n){
|
||||
public MyAttributes(Node n) {
|
||||
map = n.getAttributes();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
public class XMLReaderAdapter {
|
||||
public void parse(DefaultHandler handler, InputStream is) throws IOException, SAXException {
|
||||
public void parse(DefaultHandler handler, InputStream is) throws IOException, SAXException {
|
||||
|
||||
MyXMLReader xmlReader = new MyXMLReader();
|
||||
xmlReader.setContentHandler(handler);
|
||||
xmlReader.parse(is);
|
||||
MyXMLReader xmlReader = new MyXMLReader();
|
||||
xmlReader.setContentHandler(handler);
|
||||
xmlReader.parse(is);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
||||
mLatScaleFactor = 0.4f + 0.6f * ((float) Math.sin(Math.abs(latitude) * (Math.PI / 180)));
|
||||
|
||||
mGroundResolution = (float) (Math.cos(latitude * (Math.PI / 180))
|
||||
* MercatorProjection.EARTH_CIRCUMFERENCE
|
||||
/ ((long) Tile.SIZE << mTile.zoomLevel));
|
||||
* MercatorProjection.EARTH_CIRCUMFERENCE
|
||||
/ ((long) Tile.SIZE << mTile.zoomLevel));
|
||||
|
||||
mTile.layers = new ElementLayers();
|
||||
|
||||
@@ -173,7 +173,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
||||
|
||||
/**
|
||||
* Sets the scale stroke factor for the given zoom level.
|
||||
*
|
||||
*
|
||||
* @param zoomLevel
|
||||
* the zoom level for which the scale stroke factor should be
|
||||
* set.
|
||||
@@ -327,7 +327,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
||||
}
|
||||
|
||||
lineLayer.addLine(mElement.points, mElement.index,
|
||||
mElement.type == GeometryType.POLY);
|
||||
mElement.type == GeometryType.POLY);
|
||||
|
||||
// keep reference for outline layer
|
||||
mCurLineLayer = lineLayer;
|
||||
@@ -431,7 +431,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
||||
break;
|
||||
|
||||
WayDecorator.renderText(mClipper, mElement.points, value, text,
|
||||
offset, length, mTile);
|
||||
offset, length, mTile);
|
||||
offset += length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
|
||||
public class GLMatrix {
|
||||
|
||||
public static final int M00 = 0;// 0;
|
||||
@@ -41,21 +40,27 @@ public class GLMatrix {
|
||||
public static final int M32 = 11;// 14;
|
||||
public static final int M33 = 15;// 15;
|
||||
|
||||
private final FloatBuffer buffer = ByteBuffer.allocateDirect(16 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||
|
||||
private final FloatBuffer buffer = ByteBuffer.allocateDirect(16 * 4)
|
||||
.order(ByteOrder.nativeOrder())
|
||||
.asFloatBuffer();
|
||||
|
||||
private final static String INVALID_INPUT = "Bad Array!";
|
||||
|
||||
public final float tmp[] = new float[16];
|
||||
public final float val[] = new float[16];
|
||||
|
||||
/** Sets the matrix to the given matrix as a float array. The float array must have at least 16 elements; the first 16 will be
|
||||
/**
|
||||
* Sets the matrix to the given matrix as a float array. The float array
|
||||
* must have at least 16 elements; the first 16 will be
|
||||
* copied.
|
||||
*
|
||||
* @param values The matrix, in float form, that is to be copied. Remember that this matrix is in <a
|
||||
* href="http://en.wikipedia.org/wiki/Row-major_order">column major</a> order.
|
||||
* @return This matrix for the purpose of chaining methods together. */
|
||||
public void set (float[] values) {
|
||||
*
|
||||
* @param values The matrix, in float form, that is to be copied. Remember
|
||||
* that this matrix is in <a
|
||||
* href="http://en.wikipedia.org/wiki/Row-major_order">column
|
||||
* major</a> order.
|
||||
* @return This matrix for the purpose of chaining methods together.
|
||||
*/
|
||||
public void set(float[] values) {
|
||||
val[M00] = values[M00];
|
||||
val[M10] = values[M10];
|
||||
val[M20] = values[M20];
|
||||
@@ -73,9 +78,10 @@ public class GLMatrix {
|
||||
val[M23] = values[M23];
|
||||
val[M33] = values[M33];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Matrix as float array
|
||||
*
|
||||
*
|
||||
* @param m float array to store Matrix
|
||||
*/
|
||||
public void get(float[] m) {
|
||||
@@ -88,7 +94,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Copy values from mat
|
||||
*
|
||||
*
|
||||
* @param mat Matrix to copy
|
||||
*/
|
||||
public void copy(GLMatrix m) {
|
||||
@@ -100,7 +106,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Project Vector with Matrix
|
||||
*
|
||||
*
|
||||
* @param vec3 Vector to project
|
||||
*/
|
||||
public void prj(float[] vec3) {
|
||||
@@ -110,7 +116,7 @@ public class GLMatrix {
|
||||
matrix4_proj(val, vec3);
|
||||
}
|
||||
|
||||
static void matrix4_proj (float[] mat, float[] vec) {
|
||||
static void matrix4_proj(float[] mat, float[] vec) {
|
||||
float inv_w = 1.0f / (vec[0] * mat[M30] + vec[1] * mat[M31] + vec[2] * mat[M32] + mat[M33]);
|
||||
float x = (vec[0] * mat[M00] + vec[1] * mat[M01] + vec[2] * mat[M02] + mat[M03]) * inv_w;
|
||||
float y = (vec[0] * mat[M10] + vec[1] * mat[M11] + vec[2] * mat[M12] + mat[M13]) * inv_w;
|
||||
@@ -122,7 +128,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Multiply rhs onto Matrix.
|
||||
*
|
||||
*
|
||||
* @param rhs right hand side
|
||||
*/
|
||||
public void multiplyRhs(GLMatrix rhs) {
|
||||
@@ -131,7 +137,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Use this matrix as rhs, multiply it on lhs and store result.
|
||||
*
|
||||
*
|
||||
* @param lhs right hand side
|
||||
*/
|
||||
public void multiplyLhs(GLMatrix lhs) {
|
||||
@@ -142,12 +148,12 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Multiply rhs onto lhs and store result in Matrix.
|
||||
*
|
||||
*
|
||||
* This matrix MUST be different from lhs and rhs!
|
||||
*
|
||||
*
|
||||
* As you know, when combining matrices for vector projection
|
||||
* this has the same effect first as applying rhs then lhs.
|
||||
*
|
||||
*
|
||||
* @param lhs left hand side
|
||||
* @param rhs right hand side
|
||||
*/
|
||||
@@ -159,7 +165,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Transpose mat and store result in Matrix
|
||||
*
|
||||
*
|
||||
* @param mat to transpose
|
||||
*/
|
||||
public void transposeM(GLMatrix mat) {
|
||||
@@ -183,7 +189,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Set rotation
|
||||
*
|
||||
*
|
||||
* @param a angle in degree
|
||||
* @param x around x-axis
|
||||
* @param y around y-axis
|
||||
@@ -195,7 +201,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Set translation
|
||||
*
|
||||
*
|
||||
* @param x along x-axis
|
||||
* @param y along y-axis
|
||||
* @param z along z-axis
|
||||
@@ -209,7 +215,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Set scale factor
|
||||
*
|
||||
*
|
||||
* @param x axis
|
||||
* @param y axis
|
||||
* @param z axis
|
||||
@@ -223,7 +229,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Set translation and x,y scale
|
||||
*
|
||||
*
|
||||
* @param tx translate x
|
||||
* @param ty translate y
|
||||
* @param scale factor x,y
|
||||
@@ -239,7 +245,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Set Matrix with glUniformMatrix
|
||||
*
|
||||
*
|
||||
* @param location GL location id
|
||||
*/
|
||||
public void setAsUniform(int location) {
|
||||
@@ -251,21 +257,23 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Set single value
|
||||
*
|
||||
*
|
||||
* @param pos at position
|
||||
* @param value value to set
|
||||
*/
|
||||
public void setValue(int pos, float value) {
|
||||
val[pos] = value;
|
||||
}
|
||||
|
||||
static float PiTimesThumb = 1.0f / (1 << 11);
|
||||
|
||||
/**
|
||||
* add some offset (similar to glDepthOffset)
|
||||
*
|
||||
*
|
||||
* @param delta offset
|
||||
*/
|
||||
public void addDepthOffset(int delta) {
|
||||
val[10] *= 1.0f + PiTimesThumb * delta;
|
||||
val[10] *= 1.0f + PiTimesThumb * delta;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,42 +298,58 @@ public class GLMatrix {
|
||||
val[M33] = 1;
|
||||
}
|
||||
|
||||
static void matrix4_mul (float[] mata, float[] matb) {
|
||||
static void matrix4_mul(float[] mata, float[] matb) {
|
||||
float tmp[] = new float[16];
|
||||
tmp[M00] = mata[M00] * matb[M00] + mata[M01] * matb[M10] + mata[M02] * matb[M20] + mata[M03] * matb[M30];
|
||||
tmp[M01] = mata[M00] * matb[M01] + mata[M01] * matb[M11] + mata[M02] * matb[M21] + mata[M03] * matb[M31];
|
||||
tmp[M02] = mata[M00] * matb[M02] + mata[M01] * matb[M12] + mata[M02] * matb[M22] + mata[M03] * matb[M32];
|
||||
tmp[M03] = mata[M00] * matb[M03] + mata[M01] * matb[M13] + mata[M02] * matb[M23] + mata[M03] * matb[M33];
|
||||
tmp[M10] = mata[M10] * matb[M00] + mata[M11] * matb[M10] + mata[M12] * matb[M20] + mata[M13] * matb[M30];
|
||||
tmp[M11] = mata[M10] * matb[M01] + mata[M11] * matb[M11] + mata[M12] * matb[M21] + mata[M13] * matb[M31];
|
||||
tmp[M12] = mata[M10] * matb[M02] + mata[M11] * matb[M12] + mata[M12] * matb[M22] + mata[M13] * matb[M32];
|
||||
tmp[M13] = mata[M10] * matb[M03] + mata[M11] * matb[M13] + mata[M12] * matb[M23] + mata[M13] * matb[M33];
|
||||
tmp[M20] = mata[M20] * matb[M00] + mata[M21] * matb[M10] + mata[M22] * matb[M20] + mata[M23] * matb[M30];
|
||||
tmp[M21] = mata[M20] * matb[M01] + mata[M21] * matb[M11] + mata[M22] * matb[M21] + mata[M23] * matb[M31];
|
||||
tmp[M22] = mata[M20] * matb[M02] + mata[M21] * matb[M12] + mata[M22] * matb[M22] + mata[M23] * matb[M32];
|
||||
tmp[M23] = mata[M20] * matb[M03] + mata[M21] * matb[M13] + mata[M22] * matb[M23] + mata[M23] * matb[M33];
|
||||
tmp[M30] = mata[M30] * matb[M00] + mata[M31] * matb[M10] + mata[M32] * matb[M20] + mata[M33] * matb[M30];
|
||||
tmp[M31] = mata[M30] * matb[M01] + mata[M31] * matb[M11] + mata[M32] * matb[M21] + mata[M33] * matb[M31];
|
||||
tmp[M32] = mata[M30] * matb[M02] + mata[M31] * matb[M12] + mata[M32] * matb[M22] + mata[M33] * matb[M32];
|
||||
tmp[M33] = mata[M30] * matb[M03] + mata[M31] * matb[M13] + mata[M32] * matb[M23] + mata[M33] * matb[M33];
|
||||
tmp[M00] = mata[M00] * matb[M00] + mata[M01] * matb[M10] + mata[M02] * matb[M20]
|
||||
+ mata[M03] * matb[M30];
|
||||
tmp[M01] = mata[M00] * matb[M01] + mata[M01] * matb[M11] + mata[M02] * matb[M21]
|
||||
+ mata[M03] * matb[M31];
|
||||
tmp[M02] = mata[M00] * matb[M02] + mata[M01] * matb[M12] + mata[M02] * matb[M22]
|
||||
+ mata[M03] * matb[M32];
|
||||
tmp[M03] = mata[M00] * matb[M03] + mata[M01] * matb[M13] + mata[M02] * matb[M23]
|
||||
+ mata[M03] * matb[M33];
|
||||
tmp[M10] = mata[M10] * matb[M00] + mata[M11] * matb[M10] + mata[M12] * matb[M20]
|
||||
+ mata[M13] * matb[M30];
|
||||
tmp[M11] = mata[M10] * matb[M01] + mata[M11] * matb[M11] + mata[M12] * matb[M21]
|
||||
+ mata[M13] * matb[M31];
|
||||
tmp[M12] = mata[M10] * matb[M02] + mata[M11] * matb[M12] + mata[M12] * matb[M22]
|
||||
+ mata[M13] * matb[M32];
|
||||
tmp[M13] = mata[M10] * matb[M03] + mata[M11] * matb[M13] + mata[M12] * matb[M23]
|
||||
+ mata[M13] * matb[M33];
|
||||
tmp[M20] = mata[M20] * matb[M00] + mata[M21] * matb[M10] + mata[M22] * matb[M20]
|
||||
+ mata[M23] * matb[M30];
|
||||
tmp[M21] = mata[M20] * matb[M01] + mata[M21] * matb[M11] + mata[M22] * matb[M21]
|
||||
+ mata[M23] * matb[M31];
|
||||
tmp[M22] = mata[M20] * matb[M02] + mata[M21] * matb[M12] + mata[M22] * matb[M22]
|
||||
+ mata[M23] * matb[M32];
|
||||
tmp[M23] = mata[M20] * matb[M03] + mata[M21] * matb[M13] + mata[M22] * matb[M23]
|
||||
+ mata[M23] * matb[M33];
|
||||
tmp[M30] = mata[M30] * matb[M00] + mata[M31] * matb[M10] + mata[M32] * matb[M20]
|
||||
+ mata[M33] * matb[M30];
|
||||
tmp[M31] = mata[M30] * matb[M01] + mata[M31] * matb[M11] + mata[M32] * matb[M21]
|
||||
+ mata[M33] * matb[M31];
|
||||
tmp[M32] = mata[M30] * matb[M02] + mata[M31] * matb[M12] + mata[M32] * matb[M22]
|
||||
+ mata[M33] * matb[M32];
|
||||
tmp[M33] = mata[M30] * matb[M03] + mata[M31] * matb[M13] + mata[M32] * matb[M23]
|
||||
+ mata[M33] * matb[M33];
|
||||
System.arraycopy(tmp, 0, mata, 0, 16);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void finalize() {
|
||||
// if (pointer != 0)
|
||||
// delete(pointer);
|
||||
// }
|
||||
// @Override
|
||||
// public void finalize() {
|
||||
// if (pointer != 0)
|
||||
// delete(pointer);
|
||||
// }
|
||||
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -334,262 +358,263 @@ public class GLMatrix {
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define a projection matrix in terms of six clip planes
|
||||
* @param m the float array that holds the perspective matrix
|
||||
* @param offset the offset into float array m where the perspective
|
||||
* matrix data is written
|
||||
*/
|
||||
public static void frustumM(float[] m, int offset,
|
||||
float left, float right, float bottom, float top,
|
||||
float near, float far) {
|
||||
if (left == right) {
|
||||
throw new IllegalArgumentException("left == right");
|
||||
}
|
||||
if (top == bottom) {
|
||||
throw new IllegalArgumentException("top == bottom");
|
||||
}
|
||||
if (near == far) {
|
||||
throw new IllegalArgumentException("near == far");
|
||||
}
|
||||
if (near <= 0.0f) {
|
||||
throw new IllegalArgumentException("near <= 0.0f");
|
||||
}
|
||||
if (far <= 0.0f) {
|
||||
throw new IllegalArgumentException("far <= 0.0f");
|
||||
}
|
||||
final float r_width = 1.0f / (right - left);
|
||||
final float r_height = 1.0f / (top - bottom);
|
||||
final float r_depth = 1.0f / (near - far);
|
||||
final float x = 2.0f * (near * r_width);
|
||||
final float y = 2.0f * (near * r_height);
|
||||
final float A = (right + left) * r_width;
|
||||
final float B = (top + bottom) * r_height;
|
||||
final float C = (far + near) * r_depth;
|
||||
final float D = 2.0f * (far * near * r_depth);
|
||||
m[offset + 0] = x;
|
||||
m[offset + 5] = y;
|
||||
m[offset + 8] = A;
|
||||
m[offset + 9] = B;
|
||||
m[offset + 10] = C;
|
||||
m[offset + 14] = D;
|
||||
m[offset + 11] = -1.0f;
|
||||
m[offset + 1] = 0.0f;
|
||||
m[offset + 2] = 0.0f;
|
||||
m[offset + 3] = 0.0f;
|
||||
m[offset + 4] = 0.0f;
|
||||
m[offset + 6] = 0.0f;
|
||||
m[offset + 7] = 0.0f;
|
||||
m[offset + 12] = 0.0f;
|
||||
m[offset + 13] = 0.0f;
|
||||
m[offset + 15] = 0.0f;
|
||||
}
|
||||
* Define a projection matrix in terms of six clip planes
|
||||
*
|
||||
* @param m the float array that holds the perspective matrix
|
||||
* @param offset the offset into float array m where the perspective
|
||||
* matrix data is written
|
||||
*/
|
||||
public static void frustumM(float[] m, int offset,
|
||||
float left, float right, float bottom, float top,
|
||||
float near, float far) {
|
||||
if (left == right) {
|
||||
throw new IllegalArgumentException("left == right");
|
||||
}
|
||||
if (top == bottom) {
|
||||
throw new IllegalArgumentException("top == bottom");
|
||||
}
|
||||
if (near == far) {
|
||||
throw new IllegalArgumentException("near == far");
|
||||
}
|
||||
if (near <= 0.0f) {
|
||||
throw new IllegalArgumentException("near <= 0.0f");
|
||||
}
|
||||
if (far <= 0.0f) {
|
||||
throw new IllegalArgumentException("far <= 0.0f");
|
||||
}
|
||||
final float r_width = 1.0f / (right - left);
|
||||
final float r_height = 1.0f / (top - bottom);
|
||||
final float r_depth = 1.0f / (near - far);
|
||||
final float x = 2.0f * (near * r_width);
|
||||
final float y = 2.0f * (near * r_height);
|
||||
final float A = (right + left) * r_width;
|
||||
final float B = (top + bottom) * r_height;
|
||||
final float C = (far + near) * r_depth;
|
||||
final float D = 2.0f * (far * near * r_depth);
|
||||
m[offset + 0] = x;
|
||||
m[offset + 5] = y;
|
||||
m[offset + 8] = A;
|
||||
m[offset + 9] = B;
|
||||
m[offset + 10] = C;
|
||||
m[offset + 14] = D;
|
||||
m[offset + 11] = -1.0f;
|
||||
m[offset + 1] = 0.0f;
|
||||
m[offset + 2] = 0.0f;
|
||||
m[offset + 3] = 0.0f;
|
||||
m[offset + 4] = 0.0f;
|
||||
m[offset + 6] = 0.0f;
|
||||
m[offset + 7] = 0.0f;
|
||||
m[offset + 12] = 0.0f;
|
||||
m[offset + 13] = 0.0f;
|
||||
m[offset + 15] = 0.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverts a 4 x 4 matrix.
|
||||
*
|
||||
* @param mInv the array that holds the output inverted matrix
|
||||
* @param mInvOffset an offset into mInv where the inverted matrix is
|
||||
* stored.
|
||||
* @param m the input array
|
||||
* @param mOffset an offset into m where the matrix is stored.
|
||||
* @return true if the matrix could be inverted, false if it could not.
|
||||
*/
|
||||
public static boolean invertM(float[] mInv, int mInvOffset, float[] m,
|
||||
int mOffset) {
|
||||
// Invert a 4 x 4 matrix using Cramer's Rule
|
||||
/**
|
||||
* Inverts a 4 x 4 matrix.
|
||||
*
|
||||
* @param mInv the array that holds the output inverted matrix
|
||||
* @param mInvOffset an offset into mInv where the inverted matrix is
|
||||
* stored.
|
||||
* @param m the input array
|
||||
* @param mOffset an offset into m where the matrix is stored.
|
||||
* @return true if the matrix could be inverted, false if it could not.
|
||||
*/
|
||||
public static boolean invertM(float[] mInv, int mInvOffset, float[] m,
|
||||
int mOffset) {
|
||||
// Invert a 4 x 4 matrix using Cramer's Rule
|
||||
|
||||
// transpose matrix
|
||||
final float src0 = m[mOffset + 0];
|
||||
final float src4 = m[mOffset + 1];
|
||||
final float src8 = m[mOffset + 2];
|
||||
final float src12 = m[mOffset + 3];
|
||||
// transpose matrix
|
||||
final float src0 = m[mOffset + 0];
|
||||
final float src4 = m[mOffset + 1];
|
||||
final float src8 = m[mOffset + 2];
|
||||
final float src12 = m[mOffset + 3];
|
||||
|
||||
final float src1 = m[mOffset + 4];
|
||||
final float src5 = m[mOffset + 5];
|
||||
final float src9 = m[mOffset + 6];
|
||||
final float src13 = m[mOffset + 7];
|
||||
final float src1 = m[mOffset + 4];
|
||||
final float src5 = m[mOffset + 5];
|
||||
final float src9 = m[mOffset + 6];
|
||||
final float src13 = m[mOffset + 7];
|
||||
|
||||
final float src2 = m[mOffset + 8];
|
||||
final float src6 = m[mOffset + 9];
|
||||
final float src10 = m[mOffset + 10];
|
||||
final float src14 = m[mOffset + 11];
|
||||
final float src2 = m[mOffset + 8];
|
||||
final float src6 = m[mOffset + 9];
|
||||
final float src10 = m[mOffset + 10];
|
||||
final float src14 = m[mOffset + 11];
|
||||
|
||||
final float src3 = m[mOffset + 12];
|
||||
final float src7 = m[mOffset + 13];
|
||||
final float src11 = m[mOffset + 14];
|
||||
final float src15 = m[mOffset + 15];
|
||||
final float src3 = m[mOffset + 12];
|
||||
final float src7 = m[mOffset + 13];
|
||||
final float src11 = m[mOffset + 14];
|
||||
final float src15 = m[mOffset + 15];
|
||||
|
||||
// calculate pairs for first 8 elements (cofactors)
|
||||
final float atmp0 = src10 * src15;
|
||||
final float atmp1 = src11 * src14;
|
||||
final float atmp2 = src9 * src15;
|
||||
final float atmp3 = src11 * src13;
|
||||
final float atmp4 = src9 * src14;
|
||||
final float atmp5 = src10 * src13;
|
||||
final float atmp6 = src8 * src15;
|
||||
final float atmp7 = src11 * src12;
|
||||
final float atmp8 = src8 * src14;
|
||||
final float atmp9 = src10 * src12;
|
||||
final float atmp10 = src8 * src13;
|
||||
final float atmp11 = src9 * src12;
|
||||
// calculate pairs for first 8 elements (cofactors)
|
||||
final float atmp0 = src10 * src15;
|
||||
final float atmp1 = src11 * src14;
|
||||
final float atmp2 = src9 * src15;
|
||||
final float atmp3 = src11 * src13;
|
||||
final float atmp4 = src9 * src14;
|
||||
final float atmp5 = src10 * src13;
|
||||
final float atmp6 = src8 * src15;
|
||||
final float atmp7 = src11 * src12;
|
||||
final float atmp8 = src8 * src14;
|
||||
final float atmp9 = src10 * src12;
|
||||
final float atmp10 = src8 * src13;
|
||||
final float atmp11 = src9 * src12;
|
||||
|
||||
// calculate first 8 elements (cofactors)
|
||||
final float dst0 = (atmp0 * src5 + atmp3 * src6 + atmp4 * src7)
|
||||
- (atmp1 * src5 + atmp2 * src6 + atmp5 * src7);
|
||||
final float dst1 = (atmp1 * src4 + atmp6 * src6 + atmp9 * src7)
|
||||
- (atmp0 * src4 + atmp7 * src6 + atmp8 * src7);
|
||||
final float dst2 = (atmp2 * src4 + atmp7 * src5 + atmp10 * src7)
|
||||
- (atmp3 * src4 + atmp6 * src5 + atmp11 * src7);
|
||||
final float dst3 = (atmp5 * src4 + atmp8 * src5 + atmp11 * src6)
|
||||
- (atmp4 * src4 + atmp9 * src5 + atmp10 * src6);
|
||||
final float dst4 = (atmp1 * src1 + atmp2 * src2 + atmp5 * src3)
|
||||
- (atmp0 * src1 + atmp3 * src2 + atmp4 * src3);
|
||||
final float dst5 = (atmp0 * src0 + atmp7 * src2 + atmp8 * src3)
|
||||
- (atmp1 * src0 + atmp6 * src2 + atmp9 * src3);
|
||||
final float dst6 = (atmp3 * src0 + atmp6 * src1 + atmp11 * src3)
|
||||
- (atmp2 * src0 + atmp7 * src1 + atmp10 * src3);
|
||||
final float dst7 = (atmp4 * src0 + atmp9 * src1 + atmp10 * src2)
|
||||
- (atmp5 * src0 + atmp8 * src1 + atmp11 * src2);
|
||||
// calculate first 8 elements (cofactors)
|
||||
final float dst0 = (atmp0 * src5 + atmp3 * src6 + atmp4 * src7)
|
||||
- (atmp1 * src5 + atmp2 * src6 + atmp5 * src7);
|
||||
final float dst1 = (atmp1 * src4 + atmp6 * src6 + atmp9 * src7)
|
||||
- (atmp0 * src4 + atmp7 * src6 + atmp8 * src7);
|
||||
final float dst2 = (atmp2 * src4 + atmp7 * src5 + atmp10 * src7)
|
||||
- (atmp3 * src4 + atmp6 * src5 + atmp11 * src7);
|
||||
final float dst3 = (atmp5 * src4 + atmp8 * src5 + atmp11 * src6)
|
||||
- (atmp4 * src4 + atmp9 * src5 + atmp10 * src6);
|
||||
final float dst4 = (atmp1 * src1 + atmp2 * src2 + atmp5 * src3)
|
||||
- (atmp0 * src1 + atmp3 * src2 + atmp4 * src3);
|
||||
final float dst5 = (atmp0 * src0 + atmp7 * src2 + atmp8 * src3)
|
||||
- (atmp1 * src0 + atmp6 * src2 + atmp9 * src3);
|
||||
final float dst6 = (atmp3 * src0 + atmp6 * src1 + atmp11 * src3)
|
||||
- (atmp2 * src0 + atmp7 * src1 + atmp10 * src3);
|
||||
final float dst7 = (atmp4 * src0 + atmp9 * src1 + atmp10 * src2)
|
||||
- (atmp5 * src0 + atmp8 * src1 + atmp11 * src2);
|
||||
|
||||
// calculate pairs for second 8 elements (cofactors)
|
||||
final float btmp0 = src2 * src7;
|
||||
final float btmp1 = src3 * src6;
|
||||
final float btmp2 = src1 * src7;
|
||||
final float btmp3 = src3 * src5;
|
||||
final float btmp4 = src1 * src6;
|
||||
final float btmp5 = src2 * src5;
|
||||
final float btmp6 = src0 * src7;
|
||||
final float btmp7 = src3 * src4;
|
||||
final float btmp8 = src0 * src6;
|
||||
final float btmp9 = src2 * src4;
|
||||
final float btmp10 = src0 * src5;
|
||||
final float btmp11 = src1 * src4;
|
||||
// calculate pairs for second 8 elements (cofactors)
|
||||
final float btmp0 = src2 * src7;
|
||||
final float btmp1 = src3 * src6;
|
||||
final float btmp2 = src1 * src7;
|
||||
final float btmp3 = src3 * src5;
|
||||
final float btmp4 = src1 * src6;
|
||||
final float btmp5 = src2 * src5;
|
||||
final float btmp6 = src0 * src7;
|
||||
final float btmp7 = src3 * src4;
|
||||
final float btmp8 = src0 * src6;
|
||||
final float btmp9 = src2 * src4;
|
||||
final float btmp10 = src0 * src5;
|
||||
final float btmp11 = src1 * src4;
|
||||
|
||||
// calculate second 8 elements (cofactors)
|
||||
final float dst8 = (btmp0 * src13 + btmp3 * src14 + btmp4 * src15)
|
||||
- (btmp1 * src13 + btmp2 * src14 + btmp5 * src15);
|
||||
final float dst9 = (btmp1 * src12 + btmp6 * src14 + btmp9 * src15)
|
||||
- (btmp0 * src12 + btmp7 * src14 + btmp8 * src15);
|
||||
final float dst10 = (btmp2 * src12 + btmp7 * src13 + btmp10 * src15)
|
||||
- (btmp3 * src12 + btmp6 * src13 + btmp11 * src15);
|
||||
final float dst11 = (btmp5 * src12 + btmp8 * src13 + btmp11 * src14)
|
||||
- (btmp4 * src12 + btmp9 * src13 + btmp10 * src14);
|
||||
final float dst12 = (btmp2 * src10 + btmp5 * src11 + btmp1 * src9 )
|
||||
- (btmp4 * src11 + btmp0 * src9 + btmp3 * src10);
|
||||
final float dst13 = (btmp8 * src11 + btmp0 * src8 + btmp7 * src10)
|
||||
- (btmp6 * src10 + btmp9 * src11 + btmp1 * src8 );
|
||||
final float dst14 = (btmp6 * src9 + btmp11 * src11 + btmp3 * src8 )
|
||||
- (btmp10 * src11 + btmp2 * src8 + btmp7 * src9 );
|
||||
final float dst15 = (btmp10 * src10 + btmp4 * src8 + btmp9 * src9 )
|
||||
- (btmp8 * src9 + btmp11 * src10 + btmp5 * src8 );
|
||||
// calculate second 8 elements (cofactors)
|
||||
final float dst8 = (btmp0 * src13 + btmp3 * src14 + btmp4 * src15)
|
||||
- (btmp1 * src13 + btmp2 * src14 + btmp5 * src15);
|
||||
final float dst9 = (btmp1 * src12 + btmp6 * src14 + btmp9 * src15)
|
||||
- (btmp0 * src12 + btmp7 * src14 + btmp8 * src15);
|
||||
final float dst10 = (btmp2 * src12 + btmp7 * src13 + btmp10 * src15)
|
||||
- (btmp3 * src12 + btmp6 * src13 + btmp11 * src15);
|
||||
final float dst11 = (btmp5 * src12 + btmp8 * src13 + btmp11 * src14)
|
||||
- (btmp4 * src12 + btmp9 * src13 + btmp10 * src14);
|
||||
final float dst12 = (btmp2 * src10 + btmp5 * src11 + btmp1 * src9)
|
||||
- (btmp4 * src11 + btmp0 * src9 + btmp3 * src10);
|
||||
final float dst13 = (btmp8 * src11 + btmp0 * src8 + btmp7 * src10)
|
||||
- (btmp6 * src10 + btmp9 * src11 + btmp1 * src8);
|
||||
final float dst14 = (btmp6 * src9 + btmp11 * src11 + btmp3 * src8)
|
||||
- (btmp10 * src11 + btmp2 * src8 + btmp7 * src9);
|
||||
final float dst15 = (btmp10 * src10 + btmp4 * src8 + btmp9 * src9)
|
||||
- (btmp8 * src9 + btmp11 * src10 + btmp5 * src8);
|
||||
|
||||
// calculate determinant
|
||||
final float det =
|
||||
src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3;
|
||||
// calculate determinant
|
||||
final float det =
|
||||
src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3;
|
||||
|
||||
if (det == 0.0f) {
|
||||
return false;
|
||||
}
|
||||
if (det == 0.0f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// calculate matrix inverse
|
||||
final float invdet = 1.0f / det;
|
||||
mInv[ mInvOffset] = dst0 * invdet;
|
||||
mInv[ 1 + mInvOffset] = dst1 * invdet;
|
||||
mInv[ 2 + mInvOffset] = dst2 * invdet;
|
||||
mInv[ 3 + mInvOffset] = dst3 * invdet;
|
||||
// calculate matrix inverse
|
||||
final float invdet = 1.0f / det;
|
||||
mInv[mInvOffset] = dst0 * invdet;
|
||||
mInv[1 + mInvOffset] = dst1 * invdet;
|
||||
mInv[2 + mInvOffset] = dst2 * invdet;
|
||||
mInv[3 + mInvOffset] = dst3 * invdet;
|
||||
|
||||
mInv[ 4 + mInvOffset] = dst4 * invdet;
|
||||
mInv[ 5 + mInvOffset] = dst5 * invdet;
|
||||
mInv[ 6 + mInvOffset] = dst6 * invdet;
|
||||
mInv[ 7 + mInvOffset] = dst7 * invdet;
|
||||
mInv[4 + mInvOffset] = dst4 * invdet;
|
||||
mInv[5 + mInvOffset] = dst5 * invdet;
|
||||
mInv[6 + mInvOffset] = dst6 * invdet;
|
||||
mInv[7 + mInvOffset] = dst7 * invdet;
|
||||
|
||||
mInv[ 8 + mInvOffset] = dst8 * invdet;
|
||||
mInv[ 9 + mInvOffset] = dst9 * invdet;
|
||||
mInv[10 + mInvOffset] = dst10 * invdet;
|
||||
mInv[11 + mInvOffset] = dst11 * invdet;
|
||||
mInv[8 + mInvOffset] = dst8 * invdet;
|
||||
mInv[9 + mInvOffset] = dst9 * invdet;
|
||||
mInv[10 + mInvOffset] = dst10 * invdet;
|
||||
mInv[11 + mInvOffset] = dst11 * invdet;
|
||||
|
||||
mInv[12 + mInvOffset] = dst12 * invdet;
|
||||
mInv[13 + mInvOffset] = dst13 * invdet;
|
||||
mInv[14 + mInvOffset] = dst14 * invdet;
|
||||
mInv[15 + mInvOffset] = dst15 * invdet;
|
||||
mInv[12 + mInvOffset] = dst12 * invdet;
|
||||
mInv[13 + mInvOffset] = dst13 * invdet;
|
||||
mInv[14 + mInvOffset] = dst14 * invdet;
|
||||
mInv[15 + mInvOffset] = dst15 * invdet;
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void setRotateM(float[] rm, int rmOffset, float a, float x, float y, float z)
|
||||
{
|
||||
rm[rmOffset + 3] = 0;
|
||||
rm[rmOffset + 7] = 0;
|
||||
rm[rmOffset + 11] = 0;
|
||||
rm[rmOffset + 12] = 0;
|
||||
rm[rmOffset + 13] = 0;
|
||||
rm[rmOffset + 14] = 0;
|
||||
rm[rmOffset + 15] = 1;
|
||||
a *= (float) (Math.PI / 180.0f);
|
||||
float s = (float) Math.sin(a);
|
||||
float c = (float) Math.cos(a);
|
||||
if (1.0f == x && 0.0f == y && 0.0f == z)
|
||||
{
|
||||
rm[rmOffset + 5] = c;
|
||||
rm[rmOffset + 10] = c;
|
||||
rm[rmOffset + 6] = s;
|
||||
rm[rmOffset + 9] = -s;
|
||||
rm[rmOffset + 1] = 0;
|
||||
rm[rmOffset + 2] = 0;
|
||||
rm[rmOffset + 4] = 0;
|
||||
rm[rmOffset + 8] = 0;
|
||||
rm[rmOffset + 0] = 1;
|
||||
}
|
||||
else if (0.0f == x && 1.0f == y && 0.0f == z)
|
||||
{
|
||||
rm[rmOffset + 0] = c;
|
||||
rm[rmOffset + 10] = c;
|
||||
rm[rmOffset + 8] = s;
|
||||
rm[rmOffset + 2] = -s;
|
||||
rm[rmOffset + 1] = 0;
|
||||
rm[rmOffset + 4] = 0;
|
||||
rm[rmOffset + 6] = 0;
|
||||
rm[rmOffset + 9] = 0;
|
||||
rm[rmOffset + 5] = 1;
|
||||
}
|
||||
else if (0.0f == x && 0.0f == y && 1.0f == z)
|
||||
{
|
||||
rm[rmOffset + 0] = c;
|
||||
rm[rmOffset + 5] = c;
|
||||
rm[rmOffset + 1] = s;
|
||||
rm[rmOffset + 4] = -s;
|
||||
rm[rmOffset + 2] = 0;
|
||||
rm[rmOffset + 6] = 0;
|
||||
rm[rmOffset + 8] = 0;
|
||||
rm[rmOffset + 9] = 0;
|
||||
rm[rmOffset + 10] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
float len = (float) Math.sqrt(x * x + y * y + z * z);
|
||||
if (1.0f != len)
|
||||
{
|
||||
float recipLen = 1.0f / len;
|
||||
x *= recipLen;
|
||||
y *= recipLen;
|
||||
z *= recipLen;
|
||||
}
|
||||
float nc = 1.0f - c;
|
||||
float xy = x * y;
|
||||
float yz = y * z;
|
||||
float zx = z * x;
|
||||
float xs = x * s;
|
||||
float ys = y * s;
|
||||
float zs = z * s;
|
||||
rm[rmOffset + 0] = x * x * nc + c;
|
||||
rm[rmOffset + 4] = xy * nc - zs;
|
||||
rm[rmOffset + 8] = zx * nc + ys;
|
||||
rm[rmOffset + 1] = xy * nc + zs;
|
||||
rm[rmOffset + 5] = y * y * nc + c;
|
||||
rm[rmOffset + 9] = yz * nc - xs;
|
||||
rm[rmOffset + 2] = zx * nc - ys;
|
||||
rm[rmOffset + 6] = yz * nc + xs;
|
||||
rm[rmOffset + 10] = z * z * nc + c;
|
||||
}
|
||||
}
|
||||
void setRotateM(float[] rm, int rmOffset, float a, float x, float y, float z)
|
||||
{
|
||||
rm[rmOffset + 3] = 0;
|
||||
rm[rmOffset + 7] = 0;
|
||||
rm[rmOffset + 11] = 0;
|
||||
rm[rmOffset + 12] = 0;
|
||||
rm[rmOffset + 13] = 0;
|
||||
rm[rmOffset + 14] = 0;
|
||||
rm[rmOffset + 15] = 1;
|
||||
a *= (float) (Math.PI / 180.0f);
|
||||
float s = (float) Math.sin(a);
|
||||
float c = (float) Math.cos(a);
|
||||
if (1.0f == x && 0.0f == y && 0.0f == z)
|
||||
{
|
||||
rm[rmOffset + 5] = c;
|
||||
rm[rmOffset + 10] = c;
|
||||
rm[rmOffset + 6] = s;
|
||||
rm[rmOffset + 9] = -s;
|
||||
rm[rmOffset + 1] = 0;
|
||||
rm[rmOffset + 2] = 0;
|
||||
rm[rmOffset + 4] = 0;
|
||||
rm[rmOffset + 8] = 0;
|
||||
rm[rmOffset + 0] = 1;
|
||||
}
|
||||
else if (0.0f == x && 1.0f == y && 0.0f == z)
|
||||
{
|
||||
rm[rmOffset + 0] = c;
|
||||
rm[rmOffset + 10] = c;
|
||||
rm[rmOffset + 8] = s;
|
||||
rm[rmOffset + 2] = -s;
|
||||
rm[rmOffset + 1] = 0;
|
||||
rm[rmOffset + 4] = 0;
|
||||
rm[rmOffset + 6] = 0;
|
||||
rm[rmOffset + 9] = 0;
|
||||
rm[rmOffset + 5] = 1;
|
||||
}
|
||||
else if (0.0f == x && 0.0f == y && 1.0f == z)
|
||||
{
|
||||
rm[rmOffset + 0] = c;
|
||||
rm[rmOffset + 5] = c;
|
||||
rm[rmOffset + 1] = s;
|
||||
rm[rmOffset + 4] = -s;
|
||||
rm[rmOffset + 2] = 0;
|
||||
rm[rmOffset + 6] = 0;
|
||||
rm[rmOffset + 8] = 0;
|
||||
rm[rmOffset + 9] = 0;
|
||||
rm[rmOffset + 10] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
float len = (float) Math.sqrt(x * x + y * y + z * z);
|
||||
if (1.0f != len)
|
||||
{
|
||||
float recipLen = 1.0f / len;
|
||||
x *= recipLen;
|
||||
y *= recipLen;
|
||||
z *= recipLen;
|
||||
}
|
||||
float nc = 1.0f - c;
|
||||
float xy = x * y;
|
||||
float yz = y * z;
|
||||
float zx = z * x;
|
||||
float xs = x * s;
|
||||
float ys = y * s;
|
||||
float zs = z * s;
|
||||
rm[rmOffset + 0] = x * x * nc + c;
|
||||
rm[rmOffset + 4] = xy * nc - zs;
|
||||
rm[rmOffset + 8] = zx * nc + ys;
|
||||
rm[rmOffset + 1] = xy * nc + zs;
|
||||
rm[rmOffset + 5] = y * y * nc + c;
|
||||
rm[rmOffset + 9] = yz * nc - xs;
|
||||
rm[rmOffset + 2] = zx * nc - ys;
|
||||
rm[rmOffset + 6] = yz * nc + xs;
|
||||
rm[rmOffset + 10] = z * z * nc + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class RenderThemeHandler2 {
|
||||
private final static int LINE_HIGHWAY = 2;
|
||||
private final static Tag TAG_WATER = new Tag("natural", "water");
|
||||
private final static Tag TAG_WOOD = new Tag("natural", "wood");
|
||||
private final static Tag TAG_FOREST= new Tag("landuse", "forest");
|
||||
private final static Tag TAG_FOREST = new Tag("landuse", "forest");
|
||||
|
||||
private static RenderInstruction[][] instructions = {
|
||||
// water
|
||||
@@ -38,7 +38,7 @@ public class RenderThemeHandler2 {
|
||||
if (e.tags.contains(TAG_WATER))
|
||||
return instructions[AREA_WATER];
|
||||
|
||||
if (e.tags.contains(TAG_WOOD) ||e.tags.contains(TAG_FOREST))
|
||||
if (e.tags.contains(TAG_WOOD) || e.tags.contains(TAG_FOREST))
|
||||
return instructions[AREA_WOOD];
|
||||
|
||||
} else if (e.isLine()) {
|
||||
|
||||
@@ -172,7 +172,7 @@ public class LwHttp {
|
||||
|
||||
/**
|
||||
* Write custom tile url
|
||||
*
|
||||
*
|
||||
* @param tile Tile
|
||||
* @param path to write url string
|
||||
* @param curPos current position
|
||||
|
||||
@@ -54,6 +54,7 @@ public final class IOUtils {
|
||||
Log.d(IOUtils.class.getName(), e.getMessage() + " " + e);
|
||||
}
|
||||
}
|
||||
|
||||
private IOUtils() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@ import com.google.gwt.typedarrays.shared.Int32Array;
|
||||
public class Tessellator {
|
||||
|
||||
public static synchronized int triangulate(float[] points, int ppos, int plen, short[] index,
|
||||
int ipos, int rings, int vertexOffset, VertexItem outTris) {
|
||||
int ipos, int rings, int vertexOffset, VertexItem outTris) {
|
||||
|
||||
//JavaScriptObject o;
|
||||
Int32Array io;
|
||||
try{
|
||||
try {
|
||||
io = tessellate(JsArrayUtils.readOnlyJsArray(points), ppos, plen,
|
||||
JsArrayUtils.readOnlyJsArray(index), ipos, rings);
|
||||
} catch(JavaScriptException e){
|
||||
JsArrayUtils.readOnlyJsArray(index), ipos, rings);
|
||||
} catch (JavaScriptException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
@@ -27,22 +27,22 @@ public class Tessellator {
|
||||
//Float32Array vo = getPoints(o);
|
||||
//Int32Array io = getIndices(o);
|
||||
|
||||
if (io == null){
|
||||
if (io == null) {
|
||||
Log.d("Triangulator", "building tessellation failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if (vo.length() != plen) {
|
||||
// // TODO handle different output points
|
||||
// Log.d("", "other points out" + plen + ":" + vo.length() + ", " + io.length());
|
||||
//
|
||||
// //for (int i = 0; i < vo.length(); i += 2)
|
||||
// // Log.d("<", vo.get(i) + " " + vo.get(i + 1));
|
||||
// //for (int i = ppos; i < ppos + plen; i += 2)
|
||||
// // Log.d(">", points[i]+ " " + points[i + 1]);
|
||||
//
|
||||
// return 0;
|
||||
// }
|
||||
// if (vo.length() != plen) {
|
||||
// // TODO handle different output points
|
||||
// Log.d("", "other points out" + plen + ":" + vo.length() + ", " + io.length());
|
||||
//
|
||||
// //for (int i = 0; i < vo.length(); i += 2)
|
||||
// // Log.d("<", vo.get(i) + " " + vo.get(i + 1));
|
||||
// //for (int i = ppos; i < ppos + plen; i += 2)
|
||||
// // Log.d(">", points[i]+ " " + points[i + 1]);
|
||||
//
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int numIndices = io.length();
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Tessellator {
|
||||
if (k + cnt > numIndices)
|
||||
cnt = numIndices - k;
|
||||
|
||||
for (int i = 0; i < cnt; i++){
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
int idx = (vertexOffset + io.get(k + i));
|
||||
outTris.vertices[outTris.used + i] = (short) idx;
|
||||
}
|
||||
@@ -69,25 +69,25 @@ public class Tessellator {
|
||||
}
|
||||
|
||||
static native Int32Array tessellate(JsArrayNumber points, int pOffset, int pLength,
|
||||
JsArrayInteger bounds, int bOffset, int bLength)/*-{
|
||||
JsArrayInteger bounds, int bOffset, int bLength)/*-{
|
||||
|
||||
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
bOffset, bOffset + bLength);
|
||||
}-*/;
|
||||
|
||||
// static native JavaScriptObject tessellate(JsArrayNumber points, int pOffset, int pLength,
|
||||
// JsArrayInteger bounds, int bOffset, int bLength)/*-{
|
||||
//
|
||||
// return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
// bOffset, bOffset + bLength);
|
||||
// }-*/;
|
||||
// static native JavaScriptObject tessellate(JsArrayNumber points, int pOffset, int pLength,
|
||||
// JsArrayInteger bounds, int bOffset, int bLength)/*-{
|
||||
//
|
||||
// return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
// bOffset, bOffset + bLength);
|
||||
// }-*/;
|
||||
|
||||
// static native Float32Array getPoints(JavaScriptObject result)/*-{
|
||||
// return result.vertices;
|
||||
// }-*/;
|
||||
// static native Float32Array getPoints(JavaScriptObject result)/*-{
|
||||
// return result.vertices;
|
||||
// }-*/;
|
||||
|
||||
// static native Int32Array getIndices(JavaScriptObject result)/*-{
|
||||
// return result.triangles;
|
||||
// }-*/;
|
||||
// static native Int32Array getIndices(JavaScriptObject result)/*-{
|
||||
// return result.triangles;
|
||||
// }-*/;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,14 +5,16 @@ import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
/**
|
||||
* GWT emulation of AsynchExecutor, will call tasks immediately :D
|
||||
*
|
||||
* @author badlogic
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class AsyncExecutor implements Disposable {
|
||||
|
||||
/**
|
||||
* Creates a new AsynchExecutor that allows maxConcurrent
|
||||
* {@link Runnable} instances to run in parallel.
|
||||
* Creates a new AsynchExecutor that allows maxConcurrent {@link Runnable}
|
||||
* instances to run in parallel.
|
||||
*
|
||||
* @param maxConcurrent
|
||||
*/
|
||||
public AsyncExecutor(int maxConcurrent) {
|
||||
@@ -23,6 +25,7 @@ public class AsyncExecutor implements Disposable {
|
||||
* Submits a {@link Runnable} to be executed asynchronously. If
|
||||
* maxConcurrent runnables are already running, the runnable
|
||||
* will be queued.
|
||||
*
|
||||
* @param task the task to execute asynchronously
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@@ -33,7 +36,7 @@ public class AsyncExecutor implements Disposable {
|
||||
try {
|
||||
task.run();
|
||||
result = task.getResult();
|
||||
} catch(Throwable t) {
|
||||
} catch (Throwable t) {
|
||||
error = true;
|
||||
}
|
||||
if (error)
|
||||
@@ -46,17 +49,19 @@ public class AsyncExecutor implements Disposable {
|
||||
* Submits a {@link Runnable} to be executed asynchronously. If
|
||||
* maxConcurrent runnables are already running, the runnable
|
||||
* will be queued.
|
||||
*
|
||||
* @param task the task to execute asynchronously
|
||||
*/
|
||||
public void post(Runnable task) {
|
||||
Gdx.app.postRunnable(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for running {@link AsyncTask} instances to finish,
|
||||
* then destroys any resources like threads. Can not be used
|
||||
* after this method is called.
|
||||
*/
|
||||
@Override
|
||||
public void dispose () {
|
||||
public void dispose() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ package org.oscim.utils.async;
|
||||
//import java.util.concurrent.ExecutionException;
|
||||
//import java.util.concurrent.Future;
|
||||
|
||||
|
||||
/**
|
||||
* Returned by {@link AsyncExecutor#submit(AsyncTask)}, allows to poll
|
||||
* for the result of the asynch workload.
|
||||
*
|
||||
* @author badlogic
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class AsyncResult<T> {
|
||||
private final T result;
|
||||
@@ -41,7 +41,8 @@ public class AsyncResult<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the result, or null if there was an error, no result, or the task is still running
|
||||
* @return the result, or null if there was an error, no result, or the task
|
||||
* is still running
|
||||
*/
|
||||
public T get() {
|
||||
return result;
|
||||
|
||||
@@ -16,13 +16,15 @@
|
||||
|
||||
package org.oscim.utils.async;
|
||||
|
||||
|
||||
/**
|
||||
* Task to be submitted to an {@link AsyncExecutor}, returning a result of type T.
|
||||
* Task to be submitted to an {@link AsyncExecutor}, returning a result of type
|
||||
* T.
|
||||
*
|
||||
* @author badlogic
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface AsyncTask<T> extends Runnable{
|
||||
public interface AsyncTask<T> extends Runnable {
|
||||
public boolean cancel();
|
||||
|
||||
public T getResult() throws Exception;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,9 @@ package org.oscim.utils.async;
|
||||
|
||||
/**
|
||||
* GWT emulation of ThreadUtils, does nothing.
|
||||
*
|
||||
* @author badlogic
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ThreadUtils {
|
||||
public static void yield() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.xml.sax;
|
||||
|
||||
|
||||
public abstract interface Attributes {
|
||||
public abstract int getLength();
|
||||
|
||||
@@ -25,4 +24,4 @@ public abstract interface Attributes {
|
||||
public abstract String getValue(String paramString1, String paramString2);
|
||||
|
||||
public abstract String getValue(String paramString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class SAXException extends IOException {
|
||||
public SAXException(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public SAXException(String str, Throwable throwable)
|
||||
{
|
||||
super(str);
|
||||
|
||||
@@ -10,6 +10,7 @@ public class SAXParseException extends SAXException {
|
||||
public SAXParseException(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public SAXParseException(String str, Throwable throwable)
|
||||
{
|
||||
super(str);
|
||||
|
||||
@@ -12,12 +12,13 @@ public class DefaultHandler {
|
||||
public void error(SAXParseException exception) {
|
||||
|
||||
}
|
||||
|
||||
public void warning(SAXParseException exception) {
|
||||
|
||||
}
|
||||
|
||||
public void startElement(String uri, String localName, String qName,
|
||||
Attributes attributes) throws SAXException {
|
||||
Attributes attributes) throws SAXException {
|
||||
|
||||
}
|
||||
|
||||
@@ -25,5 +26,4 @@ public class DefaultHandler {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user