List of usage examples for com.badlogic.gdx.math Matrix4 M13
int M13
To view the source code for com.badlogic.gdx.math Matrix4 M13.
Click Source Link
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
/** * Preconcats the matrix with the specified scale. M' = M * S(sx, sy, px, py) *//*w w w.j a v a 2 s . c om*/ @Override public void preScale(float sx, float sy, float px, float py) { Matrix4 m = new Matrix4(); // set Scale sx,sy,px,py { m.val[Matrix4.M00] = sx; m.val[Matrix4.M11] = sy; m.val[Matrix4.M03] = px - sx * px; m.val[Matrix4.M13] = py - sy * py; } this.matrix4.mul(m); }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
@Override public void mapPoints(float[] src) { float[] dst = new float[src.length]; for (int i = 0; i * 2 < src.length; i++) { int j = i * 2; float x = src[j] * matrix4.val[Matrix4.M00] + src[j + 1] * matrix4.val[Matrix4.M01] + matrix4.val[Matrix4.M03]; float y = src[j] * matrix4.val[Matrix4.M10] + src[j + 1] * matrix4.val[Matrix4.M11] + matrix4.val[Matrix4.M13]; dst[j] = x;//from w w w.jav a 2 s. c om dst[j + 1] = y; } System.arraycopy(dst, 0, src, 0, src.length); }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
@Override public void setValues(float[] fs) { matrix4.val[Matrix4.M00] = fs[0]; matrix4.val[Matrix4.M01] = fs[1]; matrix4.val[Matrix4.M03] = fs[2]; matrix4.val[Matrix4.M10] = fs[3]; matrix4.val[Matrix4.M11] = fs[4]; matrix4.val[Matrix4.M13] = fs[5]; matrix4.val[Matrix4.M20] = fs[6]; matrix4.val[Matrix4.M21] = fs[7]; matrix4.val[Matrix4.M22] = fs[8]; }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
@Override public void preRotate(Float angle, Float px, Float py) { // ## native android ## // const SkScalar oneMinusCosV = 1 - cosV; ////from w w w .j a va2 s. c om // fMat[kMScaleX] = cosV; // fMat[kMSkewX] = -sinV; // fMat[kMTransX] = sdot(sinV, py, oneMinusCosV, px); // // fMat[kMSkewY] = sinV; // fMat[kMScaleY] = cosV; // fMat[kMTransY] = sdot(-sinV, px, oneMinusCosV, py); // // fMat[kMPersp0] = fMat[kMPersp1] = 0; // fMat[kMPersp2] = 1; Matrix4 m = new Matrix4(); m.rotate(0, 0, 1, angle); float oneMinusCosV = 1 - m.val[Matrix4.M00]; float sinV = m.val[Matrix4.M10]; m.val[Matrix4.M03] = sdot(sinV, py, oneMinusCosV, px); m.val[Matrix4.M13] = sdot(-sinV, px, oneMinusCosV, py); this.matrix4.mul(m); }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
@Override public void getValues(float[] mValues) { mValues[0] = matrix4.val[Matrix4.M00]; mValues[1] = matrix4.val[Matrix4.M01]; mValues[2] = matrix4.val[Matrix4.M03]; mValues[3] = matrix4.val[Matrix4.M10]; mValues[4] = matrix4.val[Matrix4.M11]; mValues[5] = matrix4.val[Matrix4.M13]; mValues[6] = matrix4.val[Matrix4.M20]; mValues[7] = matrix4.val[Matrix4.M21]; mValues[8] = matrix4.val[Matrix4.M22]; }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
@Override public String toString() { return "[" + this.matrix4.val[Matrix4.M00] + "|" + this.matrix4.val[Matrix4.M01] + "|" + this.matrix4.val[Matrix4.M03] + "]\n" + "[" + this.matrix4.val[Matrix4.M10] + "|" + this.matrix4.val[Matrix4.M11] + "|" + this.matrix4.val[Matrix4.M13] + "]\n" + "[" + this.matrix4.val[Matrix4.M20] + "|" + this.matrix4.val[Matrix4.M21] + "|" + this.matrix4.val[Matrix4.M22] + "]"; }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
public static void MapPoints(float[] values, Matrix4 matrix4) { int index = 0; while (index < values.length) { float x0 = values[index] * matrix4.val[Matrix4.M00] + values[index + 1] * matrix4.val[Matrix4.M01] + matrix4.val[Matrix4.M03]; float y0 = values[index] * matrix4.val[Matrix4.M10] + values[index + 1] * matrix4.val[Matrix4.M11] + matrix4.val[Matrix4.M13]; values[index] = x0;//from ww w .j a v a2 s . c o m values[index + 1] = y0; index += 2; } }
From source file:CB_UI_Base.graphics.GL_Matrix.java
License:Open Source License
public static void MapPoint(float x, float y, Matrix4 matrix4, float[] mapedPoint) { mapedPoint[0] = x * matrix4.val[Matrix4.M00] + y * matrix4.val[Matrix4.M01] + matrix4.val[Matrix4.M03]; mapedPoint[1] = x * matrix4.val[Matrix4.M10] + y * matrix4.val[Matrix4.M11] + matrix4.val[Matrix4.M13]; }
From source file:com.box2dLight.box2dLight.RayHandler.java
License:Apache License
/** Set combined camera matrix. Matrix will be copied and used for rendering lights, culling. Matrix must be set to work in * box2d coordinates. Matrix has to be updated every frame(if camera is changed) * //from ww w . jav a2 s.com * * NOTE: Matrix4 is assumed to be orthogonal for culling and directional lights. * * If any problems detected Use: [public void setCombinedMatrix(Matrix4 combined, float x, float y, float viewPortWidth, float * viewPortHeight)] Instead * * * @param combined matrix that include projection and translation matrices */ public void setCombinedMatrix(Matrix4 combined) { System.arraycopy(combined.val, 0, this.combined.val, 0, 16); // updateCameraCorners float invWidth = combined.val[Matrix4.M00]; final float halfViewPortWidth = 1f / invWidth; final float x = -halfViewPortWidth * combined.val[Matrix4.M03]; x1 = x - halfViewPortWidth; x2 = x + halfViewPortWidth; float invHeight = combined.val[Matrix4.M11]; final float halfViewPortHeight = 1f / invHeight; final float y = -halfViewPortHeight * combined.val[Matrix4.M13]; y1 = y - halfViewPortHeight; y2 = y + halfViewPortHeight; }
From source file:com.lyeeedar.Graphics.ParticleEffects.ParticleEmitter.java
License:Open Source License
public void update(float delta, Camera cam) { if (light != null) { light.positionAbsolutely(x + lightx + (ex / 2f), y + lighty + ey, z + lightz + (ez / 2)); if (lightFlicker) light.attenuation = (float) (lightAttenuation * (1 - ((1 - ((float) inactive.size / (float) active.size))) / 2)); }//from w ww . j a v a2s .c o m tmpRot.set(cam.view).inv(); tmpRot.getValues()[Matrix4.M03] = 0; tmpRot.getValues()[Matrix4.M13] = 0; tmpRot.getValues()[Matrix4.M23] = 0; Iterator<Particle> pItr = active.iterator(); i = 0; while (pItr.hasNext()) { Particle p = pItr.next(); float[] velocity = getAttributeValue(p.lifetime, ParticleAttribute.VELOCITY); p.update(delta, velocity[0], velocity[1], velocity[2]); if (p.lifetime > particleLifetime) { pItr.remove(); inactive.add(p); continue; } tmpMat.setToTranslation(p.x, p.y, p.z).mul(tmpRot); int sprite = (int) getAttributeValue(p.lifetime, ParticleAttribute.SPRITE)[0]; float[] size = getAttributeValue(p.lifetime, ParticleAttribute.SIZE); float[] colour = getAttributeValue(p.lifetime, ParticleAttribute.COLOUR); quad.set(-size[0] / 2, size[1] / 2, 0).mul(tmpMat); v = 0; vertices[(i * VERTEX_SIZE * 4) + v + 0] = quad.x; vertices[(i * VERTEX_SIZE * 4) + v + 1] = quad.y; vertices[(i * VERTEX_SIZE * 4) + v + 2] = quad.z; vertices[(i * VERTEX_SIZE * 4) + v + 3] = colour[0]; vertices[(i * VERTEX_SIZE * 4) + v + 4] = colour[1]; vertices[(i * VERTEX_SIZE * 4) + v + 5] = colour[2]; vertices[(i * VERTEX_SIZE * 4) + v + 6] = colour[3]; vertices[(i * VERTEX_SIZE * 4) + v + 7] = topLeftTexCoords[sprite][0]; vertices[(i * VERTEX_SIZE * 4) + v + 8] = topLeftTexCoords[sprite][1]; quad.set(size[0] / 2, size[1] / 2, 0).mul(tmpMat); v += VERTEX_SIZE; vertices[(i * VERTEX_SIZE * 4) + v + 0] = quad.x; vertices[(i * VERTEX_SIZE * 4) + v + 1] = quad.y; vertices[(i * VERTEX_SIZE * 4) + v + 2] = quad.z; vertices[(i * VERTEX_SIZE * 4) + v + 3] = colour[0]; vertices[(i * VERTEX_SIZE * 4) + v + 4] = colour[1]; vertices[(i * VERTEX_SIZE * 4) + v + 5] = colour[2]; vertices[(i * VERTEX_SIZE * 4) + v + 6] = colour[3]; vertices[(i * VERTEX_SIZE * 4) + v + 7] = topRightTexCoords[sprite][0]; vertices[(i * VERTEX_SIZE * 4) + v + 8] = topRightTexCoords[sprite][1]; quad.set(-size[0] / 2, -size[1] / 2, 0).mul(tmpMat); v += VERTEX_SIZE; vertices[(i * VERTEX_SIZE * 4) + v + 0] = quad.x; vertices[(i * VERTEX_SIZE * 4) + v + 1] = quad.y; vertices[(i * VERTEX_SIZE * 4) + v + 2] = quad.z; vertices[(i * VERTEX_SIZE * 4) + v + 3] = colour[0]; vertices[(i * VERTEX_SIZE * 4) + v + 4] = colour[1]; vertices[(i * VERTEX_SIZE * 4) + v + 5] = colour[2]; vertices[(i * VERTEX_SIZE * 4) + v + 6] = colour[3]; vertices[(i * VERTEX_SIZE * 4) + v + 7] = botLeftTexCoords[sprite][0]; vertices[(i * VERTEX_SIZE * 4) + v + 8] = botLeftTexCoords[sprite][1]; quad.set(size[0] / 2, -size[1] / 2, 0).mul(tmpMat); v += VERTEX_SIZE; vertices[(i * VERTEX_SIZE * 4) + v + 0] = quad.x; vertices[(i * VERTEX_SIZE * 4) + v + 1] = quad.y; vertices[(i * VERTEX_SIZE * 4) + v + 2] = quad.z; vertices[(i * VERTEX_SIZE * 4) + v + 3] = colour[0]; vertices[(i * VERTEX_SIZE * 4) + v + 4] = colour[1]; vertices[(i * VERTEX_SIZE * 4) + v + 5] = colour[2]; vertices[(i * VERTEX_SIZE * 4) + v + 6] = colour[3]; vertices[(i * VERTEX_SIZE * 4) + v + 7] = botRightTexCoords[sprite][0]; vertices[(i * VERTEX_SIZE * 4) + v + 8] = botRightTexCoords[sprite][1]; i++; } mesh.setVertices(vertices); emissionCD -= delta; arrayLen = inactive.size; if (arrayLen == 0) return; while (emissionCD < 0 && arrayLen > 0) { Particle p = inactive.remove(0); if (emissionType == 0) { signx = (ran.nextInt(2) == 0) ? 1 : -1; signy = (ran.nextInt(2) == 0) ? 1 : -1; signz = (ran.nextInt(2) == 0) ? 1 : -1; p.set(particleLifetimeVar * ran.nextFloat(), x + (float) (ex * ran.nextGaussian() * signx), y + (float) (ey * ran.nextGaussian() * signy), z + (float) (ez * ran.nextGaussian() * signz)); } else { System.err.println("Invalid emission type! " + emissionType); } active.add(p); emissionCD += emissionTime; arrayLen--; } }