当前位置: 首页>>代码示例>>Java>>正文


Java Spatial类代码示例

本文整理汇总了Java中com.jme3.scene.Spatial的典型用法代码示例。如果您正苦于以下问题:Java Spatial类的具体用法?Java Spatial怎么用?Java Spatial使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Spatial类属于com.jme3.scene包,在下文中一共展示了Spatial类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addObject

import com.jme3.scene.Spatial; //导入依赖的package包/类
@Override
protected Spatial addObject(Entity e) {
    Vector3f loc = e.get(PhysicsPosition.class).getLocation();
    Mesh mesh = MeshFactory.createSphere(0.25f);
    Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    material.setColor("Color", ColorRGBA.Orange);
    TextureKey key = new TextureKey("Interface/grid-shaded.png");
    key.setGenerateMips(true);
    Texture texture = assetManager.loadTexture(key);
    texture.setWrap(Texture.WrapMode.Repeat);
    material.setTexture("ColorMap", texture);
    Geometry geometry = new Geometry("PhysicsPosition: "+e.getId(), mesh);
    geometry.setMaterial(material);
    geometry.setLocalTranslation(loc);
    rootNode.attachChild(geometry);
    return geometry;
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:18,代码来源:ESDebugViewState.java

示例2: getChildren

import com.jme3.scene.Spatial; //导入依赖的package包/类
@Override
@FXThread
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {

    final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class);
    final Spatial element = getElement();

    final LightList lightList = element.getLocalLightList();
    lightList.forEach(light -> {
        if (!(light instanceof InvisibleObject)) {
            result.add(FACTORY_REGISTRY.createFor(light));
        }
    });

    final int numControls = element.getNumControls();

    for (int i = 0; i < numControls; i++) {
        final Control control = element.getControl(i);
        result.add(FACTORY_REGISTRY.createFor(control));
    }

    return result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:24,代码来源:SpatialTreeNode.java

示例3: getObjectByIndex

import com.jme3.scene.Spatial; //导入依赖的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

示例4: visitSpatial

import com.jme3.scene.Spatial; //导入依赖的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

示例5: notifyFXRemovedChild

import com.jme3.scene.Spatial; //导入依赖的package包/类
@Override
@FXThread
public void notifyFXRemovedChild(@NotNull final Object parent, @NotNull final Object removed) {
    super.notifyFXRemovedChild(parent, removed);

    final ModelEditor3DState editor3DState = getEditor3DState();

    if (removed instanceof Spatial) {

        final Spatial spatial = (Spatial) removed;
        final boolean isSky = spatial.getQueueBucket() == RenderQueue.Bucket.Sky;

        if (isSky) {
            editor3DState.removeCustomSky(spatial);
            editor3DState.updateLightProbe();
        }
    }

    EXECUTOR_MANAGER.addFXTask(() -> getBulletState().notifyRemoved(removed));
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:ModelFileEditor.java

示例6: createControl

import com.jme3.scene.Spatial; //导入依赖的package包/类
@Override
@FXThread
protected @NotNull Control createControl(@NotNull final Spatial parent) {

    final MotionPath motionPath = new MotionPath();
    motionPath.addWayPoint(Vector3f.ZERO.clone());
    motionPath.addWayPoint(new Vector3f(0f, 1f, 0f));
    motionPath.addWayPoint(new Vector3f(1f, 0f, 1f));

    final MotionEvent control = new MotionEvent();
    control.setLookAt(Vector3f.UNIT_Z, Vector3f.UNIT_Y);
    control.setRotation(Quaternion.IDENTITY);
    control.setPath(motionPath);

    return control;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:17,代码来源:CreateMotionControlAction.java

示例7: update

import com.jme3.scene.Spatial; //导入依赖的package包/类
@Override
@JMEThread
public void update(final float tpf) {
    super.update(tpf);

    if (frame == 2) {

        final Node customSkyNode = getCustomSkyNode();

        final Array<Spatial> customSky = getCustomSky();
        customSky.forEach(spatial -> customSkyNode.attachChild(spatial.clone(false)));

        EDITOR.updateLightProbe(probeHandler);
    }

    frame++;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:18,代码来源:ModelEditor3DState.java

示例8: processOpen

import com.jme3.scene.Spatial; //导入依赖的package包/类
/**
 * The process of opening file.
 *
 * @param file the file
 */
@FXThread
protected void processOpen(@NotNull final Path file) {

    final NodeTree<?> nodeTree = getNodeTree();
    final ChangeConsumer consumer = notNull(nodeTree.getChangeConsumer());
    final SceneLayer defaultLayer = getDefaultLayer(consumer);

    final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file);
    final String assetPath = toAssetPath(assetFile);

    final ModelKey modelKey = new ModelKey(assetPath);

    final AssetManager assetManager = EDITOR.getAssetManager();
    final Spatial loadedModel = assetManager.loadModel(modelKey);
    loadedModel.setUserData(LOADED_MODEL_KEY, true);

    if (defaultLayer != null) {
        SceneLayer.setLayer(defaultLayer, loadedModel);
    }

    final TreeNode<?> treeNode = getNode();
    final Node parent = (Node) treeNode.getElement();
    consumer.execute(new AddChildOperation(loadedModel, parent));
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:30,代码来源:LoadModelAction.java

示例9: addSpatialWithAssetPath

import com.jme3.scene.Spatial; //导入依赖的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

示例10: getChildren

import com.jme3.scene.Spatial; //导入依赖的package包/类
@Override
@FXThread
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {

    final SceneLayer element = getElement();

    final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class);
    final ModelChangeConsumer changeConsumer = (ModelChangeConsumer) notNull(nodeTree.getChangeConsumer());

    final Spatial currentModel = changeConsumer.getCurrentModel();
    currentModel.depthFirstTraversal(spatial -> {
        final SceneLayer layer = SceneLayer.getLayer(spatial);
        if(layer == element) {
            result.add(FACTORY_REGISTRY.createFor(spatial));
        }
    });

    return result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:20,代码来源:SceneLayerTreeNode.java

示例11: handleAddedObject

import com.jme3.scene.Spatial; //导入依赖的package包/类
@Override
@FXThread
protected void handleAddedObject(@NotNull final Spatial model) {
    super.handleAddedObject(model);

    if (!(model instanceof SceneNode)) {
        return;
    }

    final SceneNode sceneNode = (SceneNode) model;
    final SceneEditor3DState editor3DState = getEditor3DState();

    sceneNode.getFilters().stream()
            .filter(ScenePresentable.class::isInstance)
            .forEach(filter -> editor3DState.addPresentable((ScenePresentable) filter));
    sceneNode.getAppStates().stream()
            .filter(ScenePresentable.class::isInstance)
            .forEach(state -> editor3DState.addPresentable((ScenePresentable) state));
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:20,代码来源:SceneFileEditor.java

示例12: fillContextMenu

import com.jme3.scene.Spatial; //导入依赖的package包/类
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) {
    super.fillContextMenu(nodeTree, items);

    final Material material = getElement();
    final TreeNode<?> parent = notNull(getParent());
    final Object parentElement = parent.getElement();
    final Object linkNode = parentElement instanceof Spatial ?
            NodeUtils.findParent((Spatial) parentElement, AssetLinkNode.class::isInstance) : null;

    if (linkNode == null) {
        items.add(new SaveAsMaterialAction(nodeTree, this));
    }

    if (material.getKey() != null) {
        items.add(new MakeAsEmbeddedMaterialAction(nodeTree, this));
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:20,代码来源:MaterialTreeNode.java

示例13: notifyFXAddedChild

import com.jme3.scene.Spatial; //导入依赖的package包/类
@Override
@FXThread
public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index,
                               final boolean needSelect) {

    final MA editor3DState = getEditor3DState();
    final ModelNodeTree modelNodeTree = getModelNodeTree();
    modelNodeTree.notifyAdded(parent, added, index);

    if (added instanceof Light) {
        editor3DState.addLight((Light) added);
    } else if (added instanceof AudioNode) {
        editor3DState.addAudioNode((AudioNode) added);
    } else if (added instanceof Spatial) {
        handleAddedObject((Spatial) added);
    }

    if (needSelect) {
        EXECUTOR_MANAGER.addJMETask(() -> EXECUTOR_MANAGER.addFXTask(() -> modelNodeTree.select(added)));
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:22,代码来源:AbstractSceneFileEditor.java

示例14: showObject

import com.jme3.scene.Spatial; //导入依赖的package包/类
/**
 * Show a j3o object.
 *
 * @param path     the path to object.
 * @param external true if the object is external object.
 */
@JMEThread
private void showObject(@NotNull final String path, final boolean external) {
    prepareProcessor();

    final Editor editor = Editor.getInstance();
    final AssetManager assetManager = editor.getAssetManager();
    final Spatial model;

    FolderAssetLocator.setIgnore(external);
    try {
        model = assetManager.loadModel(path);

        if (external && EDITOR_CONFIG.isAutoTangentGenerating()) {
            TangentGenerator.useMikktspaceGenerator(model);
        }

    } finally {
        FolderAssetLocator.setIgnore(false);
    }

    tryToLoad(model);

    final Node rootNode = editor.getPreviewNode();
    rootNode.detachChild(modelNode);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:32,代码来源:JMEFilePreviewManager.java

示例15: notifyRemoved

import com.jme3.scene.Spatial; //导入依赖的package包/类
/**
 * Notify about removed a spatial.
 *
 * @param spatial the spatial.
 */
public void notifyRemoved(@NotNull final Spatial spatial) {
    spatial.depthFirstTraversal(child -> {

        final SceneLayer layer = SceneLayer.getLayer(child);
        if (layer == SceneLayer.NO_LAYER) return;

        final TreeItem<TreeNode<?>> newLayerItem = findItemForValue(getTreeView(), layer);
        final TreeItem<TreeNode<?>> treeItem = findItemForValue(getTreeView(), child);

        if (newLayerItem != null && treeItem != null) {
            newLayerItem.getChildren().remove(treeItem);
        }

    }, Spatial.DFSMode.POST_ORDER);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:LayerNodeTree.java


注:本文中的com.jme3.scene.Spatial类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。