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


Java Node類代碼示例

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


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

示例1: 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

示例2: addObject

import com.jme3.scene.Node; //導入依賴的package包/類
@Override
protected Spatial addObject(Entity e) {
    Mesh mesh = factory.getMesh(e.get(componentType));
    if(mesh == null){
        LOGGER.info("Factory doesn't provide mesh for "+componentType+" "+e.getId());
        return new Node("Empty mesh ("+componentType+") "+e.getId());
    }
    Geometry geom = new Geometry(componentType.getName()+" "+ e.getId(), mesh);
    RigidBody body = e.get(RigidBody.class);
    if(body.isKinematic()){
        geom.setMaterial(createMaterial(ColorRGBA.Green));
    }else {
        if(body.getMass() == 0) {
            geom.setMaterial(createMaterial(ColorRGBA.Cyan.mult(ColorRGBA.DarkGray)));
        }else {
            geom.setMaterial(createMaterial(ColorRGBA.Red));
        }
    }
    rootNode.attachChild(geom);
    return geom;
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:22,代碼來源:ESDebugViewState.java

示例3: updateObject

import com.jme3.scene.Node; //導入依賴的package包/類
@Override
protected void updateObject(Spatial geom, Entity e) {
    if(geom instanceof Node){
        LOGGER.info("Can't update mesh for "+e.getId()+" recreate it!");
        return;
    }
    Mesh mesh = factory.getMesh(e.get(componentType));
    ((Geometry)geom).setMesh(mesh);
    geom.updateModelBound();
    RigidBody body = e.get(RigidBody.class);
    if(body.isKinematic()){
        geom.setMaterial(createMaterial(ColorRGBA.Green));
    }else {
        if(body.getMass() == 0) {
            geom.setMaterial(createMaterial(ColorRGBA.Cyan.mult(ColorRGBA.DarkGray)));
        }else {
            geom.setMaterial(createMaterial(ColorRGBA.Red));
        }
    }
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:21,代碼來源:ESDebugViewState.java

示例4: processOpen

import com.jme3.scene.Node; //導入依賴的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

示例5: 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

示例6: moveDirectionCamera

import com.jme3.scene.Node; //導入依賴的package包/類
/**
 * Move a camera to direction.
 *
 * @param value the value to move.
 */
@JMEThread
private void moveDirectionCamera(final float value, final boolean isAction, final boolean isPressed, final int key) {
    if (!canCameraMove()) return;
    if (isAction && isPressed) startCameraMoving(key);
    else if (isAction) finishCameraMoving(key, false);
    if (!isCameraMoving() || isAction) return;

    final EditorCamera editorCamera = getEditorCamera();
    if (editorCamera == null) return;

    final Camera camera = EDITOR.getCamera();
    final Node nodeForCamera = getNodeForCamera();

    final LocalObjects local = LocalObjects.get();
    final Vector3f direction = camera.getDirection(local.nextVector());
    direction.multLocal(value * cameraSpeed);
    direction.addLocal(nodeForCamera.getLocalTranslation());

    nodeForCamera.setLocalTranslation(direction);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:26,代碼來源:AdvancedAbstractEditor3DState.java

示例7: change

import com.jme3.scene.Node; //導入依賴的package包/類
/**
 * Notify about wanting to change height of a point.
 *
 * @param point the point.
 */
protected void change(@NotNull final Vector2f point) {

    final Terrain terrain = (Terrain) notNull(copiedTerrain);
    final Node terrainNode = (Node) notNull(getEditedModel());
    final Vector3f scale = terrainNode.getWorldScale();

    final int halfSize = terrain.getTerrainSize() / 2;
    final int x = Math.round((point.x / scale.x) + halfSize);
    final int z = Math.round((point.y / scale.z) + halfSize);

    final HeightPoint heightPoint = new HeightPoint(point.getX(), point.getY(), x, z);

    final ObjectDictionary<HeightPoint, Float> originalHeight = getOriginalHeight();
    if(originalHeight.containsKey(heightPoint)) return;

    final float height = terrain.getHeightmapHeight(point);

    originalHeight.put(heightPoint, height);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:25,代碼來源:ChangeHeightTerrainToolControl.java

示例8: controlUpdate

import com.jme3.scene.Node; //導入依賴的package包/類
@Override
protected void controlUpdate(final float tpf) {

    final PhysicsCharacter body = getBody();
    final CollisionShape shape = body.getCollisionShape();

    if (currentShape != shape) {
        final Node node = (Node) getSpatial();
        node.detachChild(geom);
        geom = getDebugShape(shape);
        geom.setMaterial(debugAppState.getDebugPink());
        node.attachChild(geom);
        currentShape = shape;
    }

    final Vector3f physicsLocation = body.getPhysicsLocation(physicalLocation);

    applyPhysicsTransform(physicsLocation, Quaternion.IDENTITY);

    geom.setLocalScale(shape.getScale());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder-extension,代碼行數:22,代碼來源:BulletCharacterDebugControl.java

示例9: processChange

import com.jme3.scene.Node; //導入依賴的package包/類
/**
 * Handle changing sky type.
 */
@FXThread
private void processChange(@NotNull final SkyType newValue) {

    final VBox settingsRoot = getSettingsRoot();
    final GridPane singleTextureSettings = getSingleTextureSettings();
    final GridPane multiplyTextureSettings = getMultipleTextureSettings();

    final ObservableList<javafx.scene.Node> children = settingsRoot.getChildren();
    children.removeAll(singleTextureSettings, getMultipleTextureSettings());

    switch (newValue) {
        case SINGLE_TEXTURE: {
            children.add(singleTextureSettings);
            break;
        }
        case MULTIPLE_TEXTURE: {
            children.add(multiplyTextureSettings);
        }
    }

    validate();
    getDialog().sizeToScene();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:27,代碼來源:CreateSkyDialog.java

示例10: onEnable

import com.jme3.scene.Node; //導入依賴的package包/類
@Override
protected void onEnable() {
    super.onEnable();

    final Node pbrScene = getPbrScene();

    if (pbrScene == null) {
        return;
    }

    final LightList lightList = pbrScene.getLocalLightList();

    for (int i = 0; i < lightList.size(); i++) {
        if (lightList.get(i) == lightProbe) {
            return;
        }
    }

    pbrScene.addLight(lightProbe);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder-extension,代碼行數:21,代碼來源:StaticLightProbeSceneAppState.java

示例11: setNormal

import com.jme3.scene.Node; //導入依賴的package包/類
/**
 * Set a new normal texture to a level.
 *
 * @param texture the normal texture.
 * @param layer   the layer.
 */
@FromAnyThread
public void setNormal(@Nullable final Texture texture, final int layer) {

    final Function<Integer, String> layerToNormalName = getLayerToNormalName();
    if (layerToNormalName == null) return;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final String paramName = layerToNormalName.apply(layer);
    final MatParam matParam = material.getParam(paramName);
    final Texture current = matParam == null ? null : (Texture) matParam.getValue();

    if (texture != null) {
        texture.setWrap(Texture.WrapMode.Repeat);
    }

    final PropertyOperation<ChangeConsumer, Node, Texture> operation =
            new PropertyOperation<>(getTerrainNode(), TERRAIN_PARAM, texture, current);

    operation.setApplyHandler((node, newTexture) ->
            NodeUtils.visitGeometry(node, geometry -> updateTexture(newTexture, paramName, geometry)));

    final ModelChangeConsumer changeConsumer = editingComponent.getChangeConsumer();
    changeConsumer.execute(operation);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:32,代碼來源:TextureLayerSettings.java

示例12: 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

示例13: setCollisionPlane

import com.jme3.scene.Node; //導入依賴的package包/類
@Override
public void setCollisionPlane(@NotNull final CollisionResult collisionResult) {

    final EditorTransformSupport editorControl = getEditorControl();
    final Transform transform = editorControl.getTransformCenter();

    if (transform == null) {
        LOGGER.warning(this, "not found transform center for the " + editorControl);
        return;
    }

    detectPickedAxis(editorControl, collisionResult);

    // set the collision Plane location and rotation
    final Node collisionPlane = getCollisionPlane();
    collisionPlane.setLocalTranslation(transform.getTranslation());
    collisionPlane.setLocalRotation(Quaternion.IDENTITY);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:19,代碼來源:AbstractTransformControl.java

示例14: updateLightEnabledImpl

import com.jme3.scene.Node; //導入依賴的package包/類
/**
 * Update the light in the scene in the {@link EditorThread}.
 *
 * @param enabled true if light should be enabled.
 */
@JMEThread
protected void updateLightEnabledImpl(final boolean enabled) {
    if (enabled == isLightEnabled()) return;

    final DirectionalLight light = getLightForCamera();
    final Node stateNode = getStateNode();

    if (enabled) {
        stateNode.addLight(light);
    } else {
        stateNode.removeLight(light);
    }

    setLightEnabled(enabled);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:21,代碼來源:BaseMaterialEditor3DState.java

示例15: cleanup

import com.jme3.scene.Node; //導入依賴的package包/類
@Override
@JMEThread
public void cleanup() {
    super.cleanup();

    final TonegodTranslucentBucketFilter translucentBucketFilter = EDITOR.getTranslucentBucketFilter();
    translucentBucketFilter.setEnabled(false);

    final Node rootNode = EDITOR.getRootNode();
    rootNode.detachChild(getStateNode());

    final EditorCamera editorCamera = getEditorCamera();
    final InputManager inputManager = EDITOR.getInputManager();
    inputManager.removeListener(actionListener);
    inputManager.removeListener(analogListener);

    if (editorCamera != null) {
        editorCamera.setEnabled(false);
        editorCamera.unregisterInput(inputManager);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:22,代碼來源:AdvancedAbstractEditor3DState.java


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