/** * Calculate the character's scaled radius. * * @return the radius */ protected float getFinalRadius() { return radius * scale.getZ(); }
/** * Calculate the character's scaled radius. * * @return the radius */ protected float getFinalRadius() { return radius * scale.getZ(); }
/** * Writes the value to the data buffer. * * @param data the data buffer. * @param value the value. */ protected void write(final ByteBuffer data, final Vector3f value) { if (value == null) { data.putLong(0).putInt(0); } else { data.putFloat(value.getX()) .putFloat(value.getY()) .putFloat(value.getZ()); } if (layout == Layout.std140) { data.putInt(0); } }
/** * Set the position of the picture in pixels. * The origin (0, 0) is at the bottom-left of the screen. * * @param x The x coordinate * @param y The y coordinate */ public void setPosition(float x, float y){ float z = getLocalTranslation().getZ(); setLocalTranslation(x, y, z); }
/** * Apply a scale to this matrix. * * @param scale * the scale to apply */ public void scale(Vector3f scale) { m00 *= scale.getX(); m10 *= scale.getX(); m20 *= scale.getX(); m30 *= scale.getX(); m01 *= scale.getY(); m11 *= scale.getY(); m21 *= scale.getY(); m31 *= scale.getY(); m02 *= scale.getZ(); m12 *= scale.getZ(); m22 *= scale.getZ(); m32 *= scale.getZ(); }
@Override protected void serialize(int i, Vector3f store) { int j = i*getTupleSize(); array[j] = store.getX(); array[j+1] = store.getY(); array[j+2] = store.getZ(); }
/** * The method updates the geometry according to the poitions of the bones. */ public void updateGeometry() { VertexBuffer vb = this.getBuffer(Type.Position); FloatBuffer posBuf = this.getFloatBuffer(Type.Position); posBuf.clear(); for (int i = 0; i < skeleton.getBoneCount(); ++i) { Bone bone = skeleton.getBone(i); Vector3f head = bone.getModelSpacePosition(); posBuf.put(head.getX()).put(head.getY()).put(head.getZ()); if (boneLengths != null) { Vector3f tail = head.add(bone.getModelSpaceRotation().mult(Vector3f.UNIT_Y.mult(boneLengths.get(i)))); posBuf.put(tail.getX()).put(tail.getY()).put(tail.getZ()); } } posBuf.flip(); vb.updateData(posBuf); this.updateBound(); }
/** * The method updates the geometry according to the positions of the bones. */ public void updateGeometry() { VertexBuffer vb = this.getBuffer(Type.Position); FloatBuffer posBuf = this.getFloatBuffer(Type.Position); posBuf.clear(); for (int i = 0; i < skeleton.getBoneCount(); ++i) { Bone bone = skeleton.getBone(i); Vector3f head = bone.getModelSpacePosition(); posBuf.put(head.getX()).put(head.getY()).put(head.getZ()); if (boneLengths != null) { Vector3f tail = head.add(bone.getModelSpaceRotation().mult(Vector3f.UNIT_Y.mult(boneLengths.get(i)))); posBuf.put(tail.getX()).put(tail.getY()).put(tail.getZ()); } } posBuf.flip(); vb.updateData(posBuf); this.updateBound(); } }
array[i] = vector3f.getY(); i++; array[i] = vector3f.getZ(); i++; if (it.hasNext()) {
array[i] = temp.getY(); i++; array[i] = temp.getZ(); i++;
/** * Randomly Places a cube on the map between 30 and 90 paces away from player */ private void randomizeCube() { Geometry cube = fcube.clone(); int playerX = (int) player.getLocalTranslation().getX(); int playerZ = (int) player.getLocalTranslation().getZ(); // float x = FastMath.nextRandomInt(playerX + difficulty + 10, playerX + difficulty + 150); float x = FastMath.nextRandomInt(playerX + difficulty + 30, playerX + difficulty + 90); float z = FastMath.nextRandomInt(playerZ - difficulty - 50, playerZ + difficulty + 50); cube.getLocalTranslation().set(x, 0, z); // playerX+difficulty+30,playerX+difficulty+90 Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); if (!solidBox){ mat.getAdditionalRenderState().setWireframe(true); } mat.setColor("Color", obstacleColors.get(FastMath.nextRandomInt(0, obstacleColors.size() - 1))); cube.setMaterial(mat); rootNode.attachChild(cube); cubeField.add(cube); }
/** * The method updates the geometry according to the poitions of the bones. */ public void updateGeometry() { VertexBuffer vb = this.getBuffer(Type.Position); FloatBuffer posBuf = this.getFloatBuffer(Type.Position); posBuf.clear(); for (int i = 0; i < skeleton.getBoneCount(); ++i) { Bone bone = skeleton.getBone(i); Vector3f parentTail = bone.getModelSpacePosition().add(bone.getModelSpaceRotation().mult(Vector3f.UNIT_Y.mult(boneLengths.get(i)))); for (Bone child : bone.getChildren()) { Vector3f childHead = child.getModelSpacePosition(); Vector3f v = childHead.subtract(parentTail); float pointDelta = v.length() / POINT_AMOUNT; v.normalizeLocal().multLocal(pointDelta); Vector3f pointPosition = parentTail.clone(); for (int j = 0; j < POINT_AMOUNT; ++j) { posBuf.put(pointPosition.getX()).put(pointPosition.getY()).put(pointPosition.getZ()); pointPosition.addLocal(v); } } } posBuf.flip(); vb.updateData(posBuf); this.updateBound(); }
/** * <code>whichSide</code> takes a plane (typically provided by a view * frustum) to determine which side this bound is on. * * @param plane * the plane to check against. */ public Plane.Side whichSide(Plane plane) { float radius = FastMath.abs(xExtent * plane.getNormal().getX()) + FastMath.abs(yExtent * plane.getNormal().getY()) + FastMath.abs(zExtent * plane.getNormal().getZ()); float distance = plane.pseudoDistance(center); //changed to < and > to prevent floating point precision problems if (distance < -radius) { return Plane.Side.Negative; } else if (distance > radius) { return Plane.Side.Positive; } else { return Plane.Side.None; } }
private String formatValue(MatParam param) { Object value = param.getValue(); if (value == null) { return null; } switch (param.getVarType()) { case Vector2: Vector2f v2 = (Vector2f) value; return v2.getX() + " " + v2.getY(); case Vector3: Vector3f v3 = (Vector3f) value; return v3.getX() + " " + v3.getY() + " " + v3.getZ(); case Vector4: if (value instanceof ColorRGBA) { ColorRGBA c = (ColorRGBA) value; return c.getRed() + " " + c.getGreen() + " " + c.getBlue() + " " + c.getAlpha(); } else { Vector4f v4 = (Vector4f) value; return v4.getX() + " " + v4.getY() + " " + v4.getZ() + " " + v4.getW(); } default: return value.toString(); } } }
case Vector3: Vector3f v3 = (Vector3f) val; return v3.getX() + " " + v3.getY() + " " + v3.getZ(); case Vector4:
public BoundingVolume transform(Matrix4f trans, BoundingVolume store) { BoundingBox box; if (store == null || store.getType() != Type.AABB) { box = new BoundingBox(); } else { box = (BoundingBox) store; } TempVars vars = TempVars.get(); float w = trans.multProj(center, box.center); box.center.divideLocal(w); Matrix3f transMatrix = vars.tempMat3; trans.toRotationMatrix(transMatrix); // Make the rotation matrix all positive to get the maximum x/y/z extent transMatrix.absoluteLocal(); vars.vect1.set(xExtent, yExtent, zExtent); transMatrix.mult(vars.vect1, vars.vect1); // Assign the biggest rotations after scales. box.xExtent = FastMath.abs(vars.vect1.getX()); box.yExtent = FastMath.abs(vars.vect1.getY()); box.zExtent = FastMath.abs(vars.vect1.getZ()); vars.release(); return box; }
newPositions[i + 2] = vec.getZ();
box.zExtent = FastMath.abs(vars.vect2.getZ());