本文整理汇总了Java中com.jme3.math.Vector3f.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3f.getX方法的具体用法?Java Vector3f.getX怎么用?Java Vector3f.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.math.Vector3f
的用法示例。
在下文中一共展示了Vector3f.getX方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyVelocitySeparately
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
private boolean applyVelocitySeparately(Vector3f velocity, float tpf){
float x = velocity.getX();
float y = velocity.getY();
float z = velocity.getZ();
boolean hit = false;
velocity.set(0, 0, 0);
velocity.setX(x);
if(applyVelocity(velocity, tpf)) hit = true;
velocity.setX(0);
velocity.setY(y);
if(applyVelocity(velocity, tpf)) hit = true;
velocity.setY(0);
velocity.setZ(z);
if(applyVelocity(velocity, tpf)) hit = true;
velocity.setZ(0);
velocity.set(x, y, z);
return hit;
}
示例2: paintTexture
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
/**
* Paint texture.
*
* @param editingInput the editing input.
* @param contactPoint the contact point.
*/
private void paintTexture(@NotNull final EditingInput editingInput, @NotNull final Vector3f contactPoint) {
final Texture alphaTexture = getAlphaTexture();
if (alphaTexture == null) return;
final LocalObjects local = LocalObjects.get();
final Spatial terrainNode = notNull(getEditedModel());
final Terrain terrain = (Terrain) terrainNode;
final Image image = alphaTexture.getImage();
final Vector3f worldTranslation = terrainNode.getWorldTranslation();
final Vector3f localPoint = contactPoint.subtract(worldTranslation, local.nextVector());
final Vector3f localScale = terrainNode.getLocalScale();
final Vector2f uv = getPointPercentagePosition(terrain, localPoint, localScale, local.nextVector2f());
final Vector2f temp = local.nextVector2f();
final ColorRGBA color = local.nextColor();
final int layer = getLayer();
// get the radius of the brush in pixel-percent
float brushSize = getBrushSize() / (terrain.getTerrainSize() * localScale.getX());
float brushPower = getBrushPower();
if (editingInput == EditingInput.MOUSE_SECONDARY) {
brushPower *= -1;
}
// selectedTextureIndex/4 is an int floor, do not simplify the equation
final ObjectFloatObjectConsumer<ColorRGBA, Boolean> colorFunction = COLOR_FUNCTIONS[layer - ((layer / 4) * 4)];
doPaintAction(colorFunction, image, uv, temp, color, brushSize, false, brushPower);
image.setUpdateNeeded();
}
示例3: getPointPercentagePosition
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
private @NotNull Vector2f getPointPercentagePosition(@NotNull final Terrain terrain, @NotNull final Vector3f localPoint,
@NotNull final Vector3f localScale, @NotNull final Vector2f result) {
result.set(localPoint.x, -localPoint.z);
float scale = localScale.getX();
// already centered on Terrain's node origin (0,0)
float scaledSize = terrain.getTerrainSize() * scale;
result.addLocal(scaledSize / 2, scaledSize / 2); // shift the bottom left corner up to 0,0
result.divideLocal(scaledSize); // get the location as a percentage
return result;
}
示例4: isVisibleOnScreen
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
/**
* Check visibility the position on the screen.
*
* @param position the position for checking.
* @param camera the camera of the screen.
* @return true of we can see the position on the screen.
*/
@FromAnyThread
public static boolean isVisibleOnScreen(@NotNull final Vector3f position, @NotNull final Camera camera) {
final int maxHeight = camera.getHeight();
final int maxWidth = camera.getWidth();
final boolean isBottom = position.getY() < 0;
final boolean isTop = position.getY() > maxHeight;
final boolean isLeft = position.getX() < 0;
final boolean isRight = position.getX() > maxWidth;
return !isBottom && !isLeft && !isTop && !isRight && position.getZ() < 1F;
}
示例5: isContains
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
/**
* Check that a point is contains in a geometry.
*
* @param geometry the geometry.
* @param x the X coord.
* @param y the Y coord.
* @return true of the mesh contains the point.
*/
public static boolean isContains(@NotNull final Geometry geometry, final float x, final float y) {
final Mesh mesh = geometry.getMesh();
final Vector3f localScale = geometry.getLocalScale();
if (mesh instanceof Sphere) {
final float radius = ((Sphere) mesh).getRadius() * localScale.getX();
final Vector2f point = new Vector2f(x, y);
// return true if the distance is less than equal to the radius
return Math.abs(point.length()) <= radius;
}
return false;
}
示例6: createMesh
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
@Override
@FXThread
protected @NotNull Mesh createMesh(@NotNull final VarTable vars) {
final Vector3f size = vars.get(PROPERTY_SIZE);
return new Box(size.getX(), size.getY(), size.getZ());
}
示例7: modifyHeight
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
/**
* Modify height of terrain points.
*
* @param contactPoint the contact point.
*/
private void modifyHeight(@NotNull final Vector3f contactPoint) {
final LocalObjects local = LocalObjects.get();
final Node terrainNode = (Node) notNull(getEditedModel());
final Vector3f worldTranslation = terrainNode.getWorldTranslation();
final Vector3f localScale = terrainNode.getLocalScale();
final Vector3f localPoint = contactPoint.subtract(worldTranslation, local.nextVector());
final Vector2f terrainLoc = local.nextVector2f();
final Vector2f effectPoint = local.nextVector2f();
final Terrain terrain = (Terrain) terrainNode;
final Geometry brush = getBrush();
final float brushSize = getBrushSize();
final int twoBrushSize = (int) (brushSize * 2);
final Basis fractalFilter = createFractalGenerator();
final FloatBuffer buffer = fractalFilter.getBuffer(terrainLoc.getX(), terrainLoc.getY(), 0, twoBrushSize);
final int radiusStepsX = (int) (brushSize / localScale.getX());
final int radiusStepsZ = (int) (brushSize / localScale.getY());
final float xStepAmount = localScale.getX();
final float zStepAmount = localScale.getZ();
final List<Vector2f> locs = new ArrayList<>();
final List<Float> heights = new ArrayList<>();
for (int z = -radiusStepsZ, yfb = 0; z < radiusStepsZ; z++, yfb++) {
for (int x = -radiusStepsX, xfb = 0; x < radiusStepsX; x++, xfb++) {
final float locX = localPoint.getX() + (x * xStepAmount);
final float locZ = localPoint.getZ() + (z * zStepAmount);
effectPoint.set(locX - localPoint.getX(), locZ - localPoint.getZ());
if (!isContains(brush, effectPoint.getX(), effectPoint.getX())) {
continue;
}
final float height = buffer.get(yfb * twoBrushSize + xfb);
terrainLoc.set(locX, locZ);
final float currentHeight = terrain.getHeightmapHeight(terrainLoc) * localScale.getY();
// see if it is in the radius of the tool
final float newHeight = calculateHeight(brushSize, height, effectPoint);
locs.add(terrainLoc.clone());
heights.add(currentHeight + newHeight);
}
}
locs.forEach(this::change);
// do the actual height adjustment
terrain.setHeight(locs, heights);
terrainNode.updateModelBound(); // or else we won't collide with it where we just edited
}
示例8: modifyHeight
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
/**
* Modify height of terrain points.
*
* @param editingInput the type of input.
* @param contactPoint the contact point.
*/
private void modifyHeight(@NotNull final EditingInput editingInput, @NotNull final Vector3f contactPoint) {
final LocalObjects local = LocalObjects.get();
final Node terrainNode = (Node) notNull(getEditedModel());
final Vector3f worldTranslation = terrainNode.getWorldTranslation();
final Vector3f localScale = terrainNode.getLocalScale();
final Vector3f localPoint = contactPoint.subtract(worldTranslation, local.nextVector());
final Vector2f terrainLoc = local.nextVector2f();
final Vector2f effectPoint = local.nextVector2f();
final Terrain terrain = (Terrain) terrainNode;
final Geometry brush = getBrush();
final float brushSize = getBrushSize();
final float brushPower = editingInput == EditingInput.MOUSE_PRIMARY ? getBrushPower() : getBrushPower() * -1F;
final int radiusStepsX = (int) (brushSize / localScale.getX());
final int radiusStepsZ = (int) (brushSize / localScale.getY());
final float xStepAmount = localScale.getX();
final float zStepAmount = localScale.getZ();
final List<Vector2f> locs = new ArrayList<>();
final List<Float> heights = new ArrayList<>();
for (int z = -radiusStepsZ; z < radiusStepsZ; z++) {
for (int x = -radiusStepsX; x < radiusStepsX; x++) {
float locX = localPoint.getX() + (x * xStepAmount);
float locZ = localPoint.getZ() + (z * zStepAmount);
effectPoint.set(locX - localPoint.getX(), locZ - localPoint.getZ());
if (!isContains(brush, effectPoint.getX(), effectPoint.getY())) {
continue;
}
terrainLoc.set(locX, locZ);
final float currentHeight = terrain.getHeightmapHeight(terrainLoc) * localScale.getY();
// adjust height based on radius of the tool
final float newHeight = calculateHeight(brushSize, brushPower, effectPoint.getX(), effectPoint.getY());
// increase the height
locs.add(terrainLoc.clone());
heights.add(currentHeight + newHeight);
}
}
locs.forEach(this::change);
// do the actual height adjustment
terrain.setHeight(locs, heights);
terrainNode.updateModelBound(); // or else we won't collide with it where we just edited
}