/** * Calculate the character's scaled height. * * @return the height */ protected float getFinalHeight() { return height * scale.getY(); }
/** * Calculate the character's scaled height. * * @return the height */ protected float getFinalHeight() { return height * scale.getY(); }
/** * 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); } }
/** * 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.getX(); i++; array[i] = vector3f.getY(); i++; array[i] = vector3f.getZ();
array[i] = temp.getX(); i++; array[i] = temp.getY(); i++; array[i] = temp.getZ();
spline.interpolate((float) j / nbSubSegments, currentControlPoint, temp); array[lineIndex++] = temp.getX(); array[lineIndex++] = temp.getY(); array[lineIndex++] = temp.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 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 + 1] = vec.getY(); newPositions[i + 2] = vec.getZ();
private Node createPlayer() { Dome b = new Dome(Vector3f.ZERO, 10, 100, 1); Geometry playerMesh = new Geometry("Box", b); playerMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); playerMaterial.setColor("Color", ColorRGBA.Red); playerMesh.setMaterial(playerMaterial); playerMesh.setName("player"); Box floor = new Box(100, 0, 100); Geometry floorMesh = new Geometry("Box", floor); Vector3f translation = Vector3f.ZERO.add(playerMesh.getLocalTranslation().getX(), playerMesh.getLocalTranslation().getY() - 1, 0); floorMesh.setLocalTranslation(translation); floorMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); floorMaterial.setColor("Color", ColorRGBA.LightGray); floorMesh.setMaterial(floorMaterial); floorMesh.setName("floor"); Node playerNode = new Node(); playerNode.attachChild(playerMesh); playerNode.attachChild(floorMesh); return playerNode; }
box.yExtent = FastMath.abs(vars.vect2.getY()); box.zExtent = FastMath.abs(vars.vect2.getZ());
case Vector3: Vector3f v3 = (Vector3f) uniform.getValue(); gl.glUniform3f(loc, v3.getX(), v3.getY(), v3.getZ()); break; case Vector4:
public void prePhysicsTick(PhysicsSpace space, float f) { Vector3f angVel = getAngularVelocity(); float rotationVelocity = angVel.getY(); Vector3f dir = getForwardVector(tempVect2).multLocal(1, 0, 1).normalizeLocal(); getLinearVelocity(tempVect3);