本文整理汇总了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() );
}
}
}
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}