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


Java Spatial.getParent方法代码示例

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


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

示例1: onAnalog

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
public void onAnalog( String name, float intensity, float tpf ) {
	
	if ( name.equals( CLICK ) ) {

		if ( tool.isDragging() ) {

			tool.dragging( inputManager.getCursorPosition(), getSurfaceSelected( 0 ) );
			checkForEnd = false;
		} else {
			CollisionResult cr = getClicked();

			if ( cr == null )
				tool.clear();

			if ( tool instanceof PlaneTool || (cr != null && cr.getGeometry().getUserData( CLICK ) instanceof Handle ) ) {
				tool.dragStart( cr == null ? null : cr.getGeometry(), inputManager.getCursorPosition(), getSurfaceSelected( 0 ) );
				checkForEnd = false;
			} else {

				if ( cr != null ) {

					Spatial target = cr.getGeometry();

					while ( target.getParent().getUserData( HandleMe.class.getSimpleName() ) != null )
						target = target.getParent();

					tool.clickedOn( target, cr.getContactPoint(), inputManager.getCursorPosition() );
				}
			}

		}
	}
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:34,代码来源:Tweed.java

示例2: applyPhysicsTransform

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
protected void applyPhysicsTransform(@NotNull final Vector3f worldLocation, @NotNull final Quaternion worldRotation,
                                     @Nullable final Spatial spatial) {
    if (spatial == null) return;

    final Vector3f localLocation = spatial.getLocalTranslation();
    final Quaternion localRotation = spatial.getLocalRotation();

    final Node parent = spatial.getParent();

    if (parent == null) {
        spatial.setLocalTranslation(worldLocation);
        spatial.setLocalRotation(worldRotation);
    } else {

        localLocation.set(worldLocation)
                     .subtractLocal(parent.getWorldTranslation());

        localLocation.divideLocal(parent.getWorldScale());

        inverseWorldRotation.set(parent.getWorldRotation())
                            .inverseLocal()
                            .multLocal(localLocation);

        localRotation.set(worldRotation);

        inverseWorldRotation.set(parent.getWorldRotation())
                            .inverseLocal()
                            .mult(localRotation, localRotation);

        spatial.setLocalTranslation(localLocation);
        spatial.setLocalRotation(localRotation);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:34,代码来源:AbstractPhysicsDebugControl.java

示例3: accept

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
@Override
public void accept(@NotNull final ChangeConsumer changeConsumer, @NotNull final Object object,
                   final boolean isCopy) {

    final T newParent = getElement();

    if (object instanceof Spatial) {

        final Spatial spatial = (Spatial) object;

        if (isCopy) {

            final Spatial clone = spatial.clone();
            final SceneLayer layer = SceneLayer.getLayer(spatial);

            if (layer != null) {
                SceneLayer.setLayer(layer, clone);
            }

            changeConsumer.execute(new AddChildOperation(clone, newParent, true));

        } else {
            final Node parent = spatial.getParent();
            final int childIndex = parent.getChildIndex(spatial);
            changeConsumer.execute(new MoveChildOperation(spatial, parent, newParent, childIndex));
        }
    }

    super.accept(changeConsumer, object, isCopy);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:31,代码来源:NodeTreeNode.java

示例4: getIndex

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Get the index of the object in the model.
 *
 * @param model  the model
 * @param object the object
 * @return the index
 */
public static int getIndex(@NotNull final Spatial model, @NotNull final Object object) {

    Spatial parent = model;
    int parentIndex = 0;

    while (parent != null) {
        if (Objects.equals(parent, object)) return parentIndex;
        parent = parent.getParent();
        parentIndex--;
    }

    if (!(model instanceof Node)) {
        return -1;
    }

    final AtomicInteger counter = new AtomicInteger(0);
    final Node node = (Node) model;

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

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

    return -1;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:34,代码来源:GeomUtils.java

示例5: getObjectByIndex

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Find the object by the index in the model.
 *
 * @param model the model
 * @param index the index
 * @return the object by index
 */
@Nullable
public static Object getObjectByIndex(@NotNull final Spatial model, final int index) {

    Spatial parent = model;
    int parentIndex = 0;

    while (parent != null) {
        if (parentIndex == index) return parent;
        parent = parent.getParent();
        parentIndex--;
    }

    if (!(model instanceof Node)) {
        return null;
    }

    final AtomicInteger counter = new AtomicInteger(0);
    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,代码行数:36,代码来源:GeomUtils.java

示例6: canAttach

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Can attach boolean.
 *
 * @param node    the node
 * @param spatial the spatial
 * @param isCopy  true if the spatial need to copy.
 * @return true if the spatial can be attached to the node.
 */
public static boolean canAttach(@NotNull final Node node, @NotNull final Spatial spatial, final boolean isCopy) {

    if (spatial.getParent() == node && !isCopy) {
        return false;
    } else if (node instanceof AssetLinkNode) {
        return false;
    }

    final AssetLinkNode linkNode =
            isCopy ? null : NodeUtils.findParent(spatial.getParent(), AssetLinkNode.class::isInstance);

    return linkNode == null;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:22,代码来源:GeomUtils.java

示例7: findParent

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Find the parent of the model.
 *
 * @param spatial the spatial
 * @param count   the count
 * @return the spatial
 */
public static @Nullable Spatial findParent(@NotNull final Spatial spatial, int count) {

    Spatial parent = spatial;

    while (count-- > 0 && parent != null) {
        parent = parent.getParent();
    }

    return parent;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:18,代码来源:NodeUtils.java

示例8: clickedOn

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
@Override
public void clickedOn( Spatial target, Vector3f vector3f, Vector2f cursorPosition ) {
	if ( System.currentTimeMillis() - lastClick > 500 ) {

		
		do {
			
			Object[] directHandler = target.getUserData( ClickMe.class.getSimpleName() );

			if ( directHandler != null ) {
				( (ClickMe) directHandler[ 0 ] ).clicked( vector3f );
				break;
			}

			target = target.getParent();
			
		} while ( target != null );
		
		lastClick = System.currentTimeMillis();
	}
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:22,代码来源:SelectTool.java


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