當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.getLocalScale方法代碼示例

本文整理匯總了Java中com.jme3.scene.Node.getLocalScale方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getLocalScale方法的具體用法?Java Node.getLocalScale怎麽用?Java Node.getLocalScale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jme3.scene.Node的用法示例。


在下文中一共展示了Node.getLocalScale方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: modifyHeight

import com.jme3.scene.Node; //導入方法依賴的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
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:66,代碼來源:RoughTerrainToolControl.java

示例2: modifyHeight

import com.jme3.scene.Node; //導入方法依賴的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
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:63,代碼來源:RaiseLowerTerrainToolControl.java


注:本文中的com.jme3.scene.Node.getLocalScale方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。