當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。