@Override protected void processRoofEditPoints(final List<? extends ReadOnlyVector3> wallUpperPoints) { final ReadOnlyVector3 center = getCenter(); if (recalculateEditPoints) { recalculateEditPoints = false; points.get(0).set(toRelative(center)); // if (editPointIndex == -1) { recalculateEditPoints = false; points.add(toRelative(getCenter())); final Vector3 hipDirection = container.getAbsPoint(2).subtractLocal(container.getAbsPoint(0)).normalizeLocal(); Vector3 point1 = findFarthestIntersection( wallUpperPoints, center, center.add(hipDirection.multiply(-1000, null), null)); Vector3 point2 = findFarthestIntersection( wallUpperPoints, center, center.add(hipDirection.multiply(1000, null), null)); if (point1 == null) point1 = center.clone(); if (point2 == null) point2 = center.clone(); point1.addLocal(hipDirection.multiply(point1.distance(center) * 0.5, null)); point2.addLocal(hipDirection.multiply(-point2.distance(center) * 0.5, null)); points.get(1).set(toRelative(point1)); points.get(2).set(toRelative(point2)); computeHeight(wallUpperPoints); applyHeight(); // } } else { applyHeight(); } }
/** * update position (using current position and velocity), color (interpolating between start and * end color), size (interpolating between start and end size), spin (using parent's spin speed) * and current age of particle. If this particle's age is greater than its lifespan, it is set to * status DEAD. * * <p>Note that this only changes the parameters of the Particle, not the geometry the particle is * associated with. * * @param secondsPassed number of seconds passed since last update. * @return true if this particle is not ALIVE (in other words, if it is ready to be reused.) */ public boolean updateAndCheck(final double secondsPassed) { if (status != Status.Alive) { return true; } currentAge += secondsPassed * 1000; // add ms time to age if (currentAge > lifeSpan) { killParticle(); return true; } final Vector3 temp = Vector3.fetchTempInstance(); _position.addLocal(_velocity.multiply(secondsPassed * 1000f, temp)); Vector3.releaseTempInstance(temp); // get interpolated values from appearance ramp: parent.getRamp().getValuesAtAge(currentAge, lifeSpan, currColor, values, parent); // interpolate colors final int verts = ParticleSystem.getVertsForParticleType(type); for (int x = 0; x < verts; x++) { BufferUtils.setInBuffer( currColor, parent.getParticleGeometry().getMeshData().getColorBuffer(), startIndex + x); } // check for tex animation final int newTexIndex = parent.getTexAnimation().getTexIndexAtAge(currentAge, lifeSpan, parent); // Update tex coords if applicable if (currentTexIndex != newTexIndex) { // Only supported in Quad type for now. if (ParticleType.Quad.equals(parent.getParticleType())) { // determine side final float side = (float) Math.sqrt(parent.getTexQuantity()); int index = newTexIndex; if (index >= parent.getTexQuantity()) { index %= parent.getTexQuantity(); } // figure row / col final float row = side - (int) (index / side) - 1; final float col = index % side; // set texcoords final float sU = col / side, eU = (col + 1) / side; final float sV = row / side, eV = (row + 1) / side; final FloatBuffer texs = parent.getParticleGeometry().getMeshData().getTextureCoords(0).getBuffer(); texs.position(startIndex * 2); texs.put(eU).put(sV); texs.put(eU).put(eV); texs.put(sU).put(eV); texs.put(sU).put(sV); texs.clear(); } currentTexIndex = newTexIndex; } return false; }