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


Java Node.getChildren方法代碼示例

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


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

示例1: getIndex

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Get the index of the object in the model.
 */
private static boolean getIndex(@NotNull final Object model, @NotNull final Object object,
                                @NotNull final AtomicInteger counter) {
    counter.incrementAndGet();

    if (Objects.equals(model, object)) {
        return true;
    } else if (model instanceof Geometry) {
        return getIndex(((Geometry) model).getMesh(), object, counter);
    } else if (!(model instanceof Node)) {
        return false;
    }

    final Node node = (Node) model;
    final List<Spatial> children = node.getChildren();

    for (final Spatial child : children) {
        if (getIndex(child, object, counter)) {
            return true;
        }
    }

    return false;
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:27,代碼來源:GeomUtils.java

示例2: getObjectByIndex

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Find the object by the index in the model.
 */
@Nullable
private static Object getObjectByIndex(@NotNull final Object model, final int index,
                                       @NotNull final AtomicInteger counter) {

    if (counter.incrementAndGet() == index) {
        return model;
    } else if (model instanceof Geometry) {
        return getObjectByIndex(((Geometry) model).getMesh(), index, counter);
    } else if (!(model instanceof Node)) {
        return null;
    }

    final Node node = (Node) model;
    final List<Spatial> children = node.getChildren();

    for (final Spatial child : children) {
        final Object object = getObjectByIndex(child, index, counter);
        if (object != null) return object;
    }

    return null;
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:26,代碼來源:GeomUtils.java

示例3: findGeometry

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Find a first geometry in the {@link Spatial}.
 *
 * @param spatial the spatial
 * @param name    the name
 * @return the geometry
 */
public static @Nullable Geometry findGeometry(@NotNull final Spatial spatial, @NotNull final String name) {
    if (!(spatial instanceof Node)) return null;

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        final Geometry geometry = findGeometry(children, name);
        if (geometry != null) return geometry;
        if (children instanceof Geometry && StringUtils.equals(children.getName(), name)) {
            return (Geometry) children;
        }
    }

    return null;
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:23,代碼來源:NodeUtils.java

示例4: addSpatialWithAssetPath

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Collect all geometries from the asset path.
 *
 * @param spatial   the spatial
 * @param container the container
 * @param assetPath the asset path
 */
public static void addSpatialWithAssetPath(@NotNull final Spatial spatial, @NotNull final Array<Spatial> container,
                                           @NotNull final String assetPath) {
    if (StringUtils.isEmpty(assetPath)) return;

    final AssetKey key = spatial.getKey();

    if (key != null && StringUtils.equals(key.getName(), assetPath)) {
        container.add(spatial);
    }

    if (!(spatial instanceof Node)) {
        return;
    }

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        addSpatialWithAssetPath(children, container, assetPath);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:28,代碼來源:NodeUtils.java

示例5: visitGeometry

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Visit all geometries.
 *
 * @param spatial  the spatial
 * @param consumer the consumer
 */
public static void visitGeometry(@NotNull final Spatial spatial, @NotNull final Consumer<Geometry> consumer) {

    if (spatial instanceof Geometry) {
        consumer.accept((Geometry) spatial);
        return;
    } else if (!(spatial instanceof Node)) {
        return;
    }

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        visitGeometry(children, consumer);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:22,代碼來源:NodeUtils.java

示例6: visitSpatial

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Visit spatials of the target type.
 *
 * @param <T>      the type parameter
 * @param spatial  the spatial
 * @param type     the type
 * @param consumer the consumer
 */
public static <T extends Spatial> void visitSpatial(@NotNull final Spatial spatial, @NotNull final Class<T> type,
                                                    @NotNull final Consumer<T> consumer) {

    if (type.isInstance(spatial)) {
        consumer.accept(type.cast(spatial));
    }

    if (!(spatial instanceof Node)) {
        return;
    }

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        visitSpatial(children, type, consumer);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:26,代碼來源:NodeUtils.java

示例7: addGeometry

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Collect all geometries.
 *
 * @param spatial   the spatial
 * @param container the container
 */
public static void addGeometry(@NotNull final Spatial spatial, @NotNull final Array<Geometry> container) {

    if (spatial instanceof Geometry) {
        container.add((Geometry) spatial);
        return;
    } else if (!(spatial instanceof Node)) {
        return;
    }

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        addGeometry(children, container);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:22,代碼來源:NodeUtils.java

示例8: findSpatial

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Find a first spatial in the {@link Spatial}.
 *
 * @param spatial   the spatial
 * @param condition the condition
 * @return the spatial
 */
public static @Nullable Spatial findSpatial(@NotNull final Spatial spatial, @NotNull final Predicate<Spatial> condition) {
    if (condition.test(spatial)) return spatial;
    if (!(spatial instanceof Node)) return null;

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        final Spatial subSpatial = findSpatial(children, condition);
        if (subSpatial != null) return subSpatial;
    }

    return null;
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:21,代碼來源:NodeUtils.java

示例9: addGeometryWithMaterial

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Collect all geometries from the asset path.
 *
 * @param spatial   the spatial
 * @param container the container
 * @param assetPath the asset path
 */
public static void addGeometryWithMaterial(@NotNull final Spatial spatial, @NotNull final Array<Geometry> container,
                                           @NotNull final String assetPath) {
    if (StringUtils.isEmpty(assetPath)) return;

    if (spatial instanceof Geometry) {

        final Geometry geometry = (Geometry) spatial;
        final Material material = geometry.getMaterial();
        final String assetName = material == null ? null : material.getAssetName();

        if (StringUtils.equals(assetName, assetPath)) {
            container.add(geometry);
        }

        return;

    } else if (!(spatial instanceof Node)) {
        return;
    }

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        addGeometryWithMaterial(children, container, assetPath);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:34,代碼來源:NodeUtils.java

示例10: addLight

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Collect all lights.
 *
 * @param spatial   the spatial
 * @param container the container
 */
public static void addLight(@NotNull final Spatial spatial, @NotNull final Array<Light> container) {

    final LightList lightList = spatial.getLocalLightList();
    lightList.forEach(container::add);

    if (!(spatial instanceof Node)) return;

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        addLight(children, container);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:20,代碼來源:NodeUtils.java

示例11: addAudioNodes

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Collect all audio nodes.
 *
 * @param spatial   the spatial
 * @param container the container
 */
public static void addAudioNodes(@NotNull final Spatial spatial, @NotNull final Array<AudioNode> container) {
    if (!(spatial instanceof Node)) return;

    final Node node = (Node) spatial;

    for (final Spatial children : node.getChildren()) {
        if (children instanceof AudioNode) {
            container.add((AudioNode) children);
        }
        addAudioNodes(children, container);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:19,代碼來源:NodeUtils.java

示例12: getSpatials

import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
 * Gets spatials.
 *
 * @return the spatials
 */
protected @NotNull List<Spatial> getSpatials() {
    final Node element = getElement();
    return element.getChildren();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:10,代碼來源:NodeTreeNode.java


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