当前位置: 首页>>代码示例>>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;未经允许,请勿转载。