List of usage examples for com.google.gwt.typedarrays.shared TypedArrays createFloat64Array
public static Float64Array createFloat64Array(int length)
From source file:thothbot.parallax.core.client.shaders.UniformsLib.java
License:Open Source License
public static Map<String, Uniform> getLights() { Map<String, Uniform> retval = new HashMap<String, Uniform>(); retval.put("ambientLightColor", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("directionalLightDirection", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("directionalLightColor", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("hemisphereLightPosition", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("hemisphereLightSkyColor", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("hemisphereLightGroundColor", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("pointLightColor", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("pointLightPosition", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("pointLightDistance", new Uniform(Uniform.TYPE.FV1, TypedArrays.createFloat64Array(0))); retval.put("spotLightColor", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("spotLightPosition", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("spotLightDirection", new Uniform(Uniform.TYPE.FV, TypedArrays.createFloat64Array(0))); retval.put("spotLightDistance", new Uniform(Uniform.TYPE.FV1, TypedArrays.createFloat64Array(0))); retval.put("spotLightAngle", new Uniform(Uniform.TYPE.FV1, TypedArrays.createFloat64Array(0))); retval.put("spotLightExponent", new Uniform(Uniform.TYPE.FV1, TypedArrays.createFloat64Array(0))); return retval; }
From source file:thothbot.parallax.core.client.shaders.UniformsLib.java
License:Open Source License
public static Map<String, Uniform> getShadowmap() { Map<String, Uniform> retval = new HashMap<String, Uniform>(); retval.put("shadowMap", new Uniform(Uniform.TYPE.TV, new ArrayList<Texture>())); retval.put("shadowMapSize", new Uniform(Uniform.TYPE.V2V, new ArrayList<Vector2>())); retval.put("shadowBias", new Uniform(Uniform.TYPE.FV1, TypedArrays.createFloat64Array(0))); retval.put("shadowDarkness", new Uniform(Uniform.TYPE.FV1, TypedArrays.createFloat64Array(0))); retval.put("shadowMatrix", new Uniform(Uniform.TYPE.M4V, new ArrayList<Matrix4>())); return retval; }
From source file:thothbot.parallax.core.shared.core.GeometryBuffer.java
License:Open Source License
@Override public void computeVertexNormals() { if (getWebGlVertexArray() != null && getWebGlIndexArray() != null) { int nVertexElements = getWebGlVertexArray().length(); if (getWebGlNormalArray() == null) { setWebGlNormalArray(TypedArrays.createFloat64Array(nVertexElements)); } else {//from w w w . j a v a 2 s .c o m // reset existing normals to zero for (int i = 0, il = getWebGlNormalArray().length(); i < il; i++) { getWebGlNormalArray().set(i, 0); } } List<GeometryBuffer.Offset> offsets = this.offsets; Int16Array indices = getWebGlIndexArray(); Float64Array positions = getWebGlVertexArray(); Float64Array normals = getWebGlNormalArray(); Vector3 pA = new Vector3(); Vector3 pB = new Vector3(); Vector3 pC = new Vector3(); Vector3 cb = new Vector3(); Vector3 ab = new Vector3(); for (int j = 0, jl = offsets.size(); j < jl; ++j) { int start = offsets.get(j).start; int count = offsets.get(j).count; int index = offsets.get(j).index; for (int i = start, il = start + count; i < il; i += 3) { int vA = index + indices.get(i); int vB = index + indices.get(i + 1); int vC = index + indices.get(i + 2); pA.set(positions.get(vA * 3), positions.get(vA * 3 + 1), positions.get(vA * 3 + 2)); pB.set(positions.get(vB * 3), positions.get(vB * 3 + 1), positions.get(vB * 3 + 2)); pC.set(positions.get(vC * 3), positions.get(vC * 3 + 1), positions.get(vC * 3 + 2)); cb.sub(pC, pB); ab.sub(pA, pB); cb.cross(ab); normals.set(vA * 3, normals.get(vA * 3) + cb.x); normals.set(vA * 3 + 1, normals.get(vA * 3 + 1) + cb.y); normals.set(vA * 3 + 2, normals.get(vA * 3 + 2) + cb.z); normals.set(vB * 3, normals.get(vB * 3) + cb.x); normals.set(vB * 3 + 1, normals.get(vB * 3 + 1) + cb.y); normals.set(vB * 3 + 2, normals.get(vB * 3 + 2) + cb.z); normals.set(vC * 3, normals.get(vC * 3) + cb.x); normals.set(vC * 3 + 1, normals.get(vC * 3 + 1) + cb.y); normals.set(vC * 3 + 2, normals.get(vC * 3 + 2) + cb.z); } } // normalize normals for (int i = 0, il = normals.length(); i < il; i += 3) { double x = normals.get(i); double y = normals.get(i + 1); double z = normals.get(i + 2); double n = 1.0 / Math.sqrt(x * x + y * y + z * z); normals.set(i, normals.get(i) * n); normals.set(i + 1, normals.get(i + 1) * n); normals.set(i + 2, normals.get(i + 2) * n); } setNormalsNeedUpdate(true); } }
From source file:thothbot.parallax.core.shared.core.GeometryBuffer.java
License:Open Source License
/** * Based on < href="http://www.terathon.com/code/tangent.html">terathon.com</a> * (per vertex tangents)//from ww w. j a v a 2 s . co m */ @Override public void computeTangents() { if (getWebGlIndexArray() == null || getWebGlVertexArray() == null || getWebGlNormalArray() == null || getWebGlUvArray() == null) { Log.warn( "Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()"); return; } Int16Array indices = getWebGlIndexArray(); Float64Array positions = getWebGlVertexArray(); getWebGlNormalArray(); getWebGlUvArray(); int nVertices = positions.length() / 3; if (getWebGlTangentArray() == null) { int nTangentElements = 4 * nVertices; setWebGlTangentArray(TypedArrays.createFloat64Array(nTangentElements)); } getWebGlTangentArray(); List<Vector3> tan1 = new ArrayList<Vector3>(); List<Vector3> tan2 = new ArrayList<Vector3>(); for (int k = 0; k < nVertices; k++) { tan1.add(new Vector3()); tan2.add(new Vector3()); } List<GeometryBuffer.Offset> offsets = this.offsets; for (int j = 0, jl = offsets.size(); j < jl; ++j) { int start = offsets.get(j).start; int count = offsets.get(j).count; int index = offsets.get(j).index; for (int i = start, il = start + count; i < il; i += 3) { int iA = index + indices.get(i); int iB = index + indices.get(i + 1); int iC = index + indices.get(i + 2); handleTriangle(tan1, tan2, iA, iB, iC); } } for (int j = 0, jl = offsets.size(); j < jl; ++j) { int start = offsets.get(j).start; int count = offsets.get(j).count; int index = offsets.get(j).index; for (int i = start, il = start + count; i < il; i += 3) { int iA = index + indices.get(i); int iB = index + indices.get(i + 1); int iC = index + indices.get(i + 2); handleVertex(tan1, tan2, iA); handleVertex(tan1, tan2, iB); handleVertex(tan1, tan2, iC); } } this.setHasTangents(true); this.setTangentsNeedUpdate(true); }
From source file:thothbot.parallax.core.shared.core.Matrix3.java
License:Open Source License
/** * Default constructor will make empty three-dimensional matrix. */ public Matrix3() { this.elements = TypedArrays.createFloat64Array(9); }
From source file:thothbot.parallax.core.shared.core.Matrix3.java
License:Open Source License
/** * Transpose the current matrix into new Matrix which is represented * by Array[9] /*www.ja v a2s .c o m*/ * * @return an array of new transposed matrix. */ public Float64Array transposeIntoArray() { Float64Array r = TypedArrays.createFloat64Array(9); Float64Array m = this.getArray(); r.set(0, m.get(0)); r.set(1, m.get(3)); r.set(2, m.get(6)); r.set(3, m.get(1)); r.set(4, m.get(4)); r.set(5, m.get(7)); r.set(6, m.get(2)); r.set(7, m.get(5)); r.set(8, m.get(8)); return r; }
From source file:thothbot.parallax.core.shared.core.Matrix4.java
License:Open Source License
/** * Default constructor will make identity four-dimensional matrix. * /*from w ww . j av a 2 s .c o m*/ * <pre>{@code * 1 0 0 0 * 0 1 0 0 * 0 0 1 0 * 0 0 0 1 * }</pre> */ public Matrix4() { this.elements = TypedArrays.createFloat64Array(16); identity(); }
From source file:thothbot.parallax.core.shared.core.Matrix4.java
License:Open Source License
/** * This constructor will create four-dimensional matrix. * This matrix uses input values n11-n44 and represented as * the following://from w ww . ja v a 2 s.c om * * <pre>{@code * n11 n12 n13 n14 * n21 n22 n23 n24 * n31 n32 n33 n34 * n41 n42 n43 n44 * }</pre> */ public Matrix4(double n11, double n12, double n13, double n14, double n21, double n22, double n23, double n24, double n31, double n32, double n33, double n34, double n41, double n42, double n43, double n44) { this.elements = TypedArrays.createFloat64Array(16); set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44); }
From source file:thothbot.parallax.core.shared.objects.GeometryObject.java
License:Open Source License
protected void initCustomAttributes(WebGLRenderingContext gl, Geometry geometry) { int nvertices = geometry.getVertices().size(); Material material = this.getMaterial(); Map<String, Attribute> attributes = material.getShader().getAttributes(); if (attributes != null) { if (geometry.__webglCustomAttributesList == null) geometry.__webglCustomAttributesList = new ArrayList<Attribute>(); for (String a : attributes.keySet()) { Attribute attribute = attributes.get(a); if (!attribute.__webglInitialized || attribute.createUniqueBuffers) { attribute.__webglInitialized = true; int size = 1; // "f" and "i" if (attribute.type == Attribute.TYPE.V2) size = 2;/*from w w w . j av a 2s. c o m*/ else if (attribute.type == Attribute.TYPE.V3) size = 3; else if (attribute.type == Attribute.TYPE.V4) size = 4; else if (attribute.type == Attribute.TYPE.C) size = 3; attribute.size = size; attribute.array = TypedArrays.createFloat64Array(nvertices * size); attribute.buffer = gl.createBuffer(); attribute.belongsToAttribute = a; attribute.needsUpdate = true; } geometry.__webglCustomAttributesList.add(attribute); } } }
From source file:thothbot.parallax.core.shared.objects.Line.java
License:Open Source License
private void initBuffers(WebGLRenderingContext gl, Geometry geometry) { int nvertices = geometry.getVertices().size(); geometry.setWebGlVertexArray(TypedArrays.createFloat64Array(nvertices * 3)); geometry.setWebGlColorArray(TypedArrays.createFloat64Array(nvertices * 3)); geometry.__webglLineCount = nvertices; initCustomAttributes(gl, geometry);// w w w.j a v a 2s .c o m }