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


Java PhysicsControl类代码示例

本文整理汇总了Java中com.jme3.bullet.control.PhysicsControl的典型用法代码示例。如果您正苦于以下问题:Java PhysicsControl类的具体用法?Java PhysicsControl怎么用?Java PhysicsControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: add

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
/**
 * adds an object to the physics space
 * @param obj the PhysicsControl or Spatial with PhysicsControl to add
 */
public void add(Object obj) {
    if (obj instanceof PhysicsControl) {
        ((PhysicsControl) obj).setPhysicsSpace(this);
    } else if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        PhysicsControl control = node.getControl(PhysicsControl.class);
        control.setPhysicsSpace(this);
    } else if (obj instanceof PhysicsCollisionObject) {
        addCollisionObject((PhysicsCollisionObject) obj);
    } else if (obj instanceof PhysicsJoint) {
        addJoint((PhysicsJoint) obj);
    } else {
        throw (new UnsupportedOperationException("Cannot add this kind of object to the physics space."));
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:PhysicsSpace.java

示例2: remove

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
/**
 * removes an object from the physics space
 * @param obj the PhysicsControl or Spatial with PhysicsControl to remove
 */
public void remove(Object obj) {
    if (obj instanceof PhysicsControl) {
        ((PhysicsControl) obj).setPhysicsSpace(null);
    } else if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        PhysicsControl control = node.getControl(PhysicsControl.class);
        control.setPhysicsSpace(null);
    } else if (obj instanceof PhysicsCollisionObject) {
        removeCollisionObject((PhysicsCollisionObject) obj);
    } else if (obj instanceof PhysicsJoint) {
        removeJoint((PhysicsJoint) obj);
    } else {
        throw (new UnsupportedOperationException("Cannot remove this kind of object from the physics space."));
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:PhysicsSpace.java

示例3: attachSelectionShape

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
protected void attachSelectionShape(Spatial spat) {
    if (selectionShape != null) {
        selectionShape.removeFromParent();
        selectionShape = null;
    }
    if (spat instanceof ParticleEmitter) {
        attachBoxSelection(spat);

    } else if (spat instanceof Geometry) {
        attachGeometrySelection((Geometry) spat);
    } else if (spat.getControl(PhysicsControl.class) != null) {
        attachPhysicsSelection(spat);
    } else {
        attachBoxSelection(spat);
    }
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:17,代码来源:SceneToolController.java

示例4: add

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
/**
 * adds an object to the physics space
 *
 * @param obj the PhysicsControl or Spatial with PhysicsControl to add
 */
public static void add(PhysicsSpace space, Object obj) {
    if (obj == null) {
        return;
    }
    if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        for (int i = 0; i < node.getNumControls(); i++) {
            if (node.getControl(i) instanceof PhysicsControl) {
                space.add(((PhysicsControl) node.getControl(i)));
            }
        }
    } else {
        space.add(obj);
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:21,代码来源:PhysicsWorkaround.java

示例5: remove

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
/**
 * removes an object from the physics space
 *
 * @param obj the PhysicsControl or Spatial with PhysicsControl to remove
 */
public static void remove(PhysicsSpace space, Object obj) {
    if (obj == null) {
        return;
    }

    if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        for (int i = 0; i < node.getNumControls(); i++) {
            if (node.getControl(i) instanceof PhysicsControl) {
                space.remove(((PhysicsControl) node.getControl(i)));
            }
        }
    } else {
        space.remove(obj);
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:22,代码来源:PhysicsWorkaround.java

示例6: remove

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
/**
 * removes an object from the physics space
 * @param obj the PhysicsControl or Spatial with PhysicsControl to remove
 */
public void remove(Object obj) {
    if (obj instanceof PhysicsControl) {
        ((PhysicsControl) obj).setPhysicsSpace(null);
    } else if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        PhysicsControl control = node.getControl(PhysicsControl.class);
        control.setPhysicsSpace(null);
    } else if (obj instanceof PhysicsCollisionObject) {
        removeCollisionObject((PhysicsCollisionObject) obj);
    } else if (obj instanceof PhysicsJoint) {
        removeJoint((PhysicsJoint) obj);
    } else if (obj == null) {
        return;
    } else {
        throw (new UnsupportedOperationException("Cannot remove this kind of object from the physics space."+obj));
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:22,代码来源:PhysicsSpace.java

示例7: attachSelectionShape

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
protected void attachSelectionShape(Spatial spat) {
    if (selectionShape != null) {
        selectionShape.removeFromParent();
        selectionShape = null;
    }
    selctionShapeOffset.set(Vector3f.ZERO);
    if (spat instanceof ParticleEmitter) {
        attachBoxSelection(spat);

    } else if (spat instanceof Geometry) {
        attachGeometrySelection((Geometry) spat);
    } else if (spat.getControl(PhysicsControl.class) != null) {
        attachPhysicsSelection(spat);
    } else {
        attachBoxSelection(spat);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:18,代码来源:SceneToolController.java

示例8: notifyAdded

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
@Override
public void notifyAdded(@NotNull final Object object) {
    if (object instanceof PhysicsControl) {
        ((PhysicsControl) object).setPhysicsSpace(getPhysicsSpace());
    } else if (object instanceof Spatial) {
        updateNode((Spatial) object, getPhysicsSpace());
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:9,代码来源:EditableBulletSceneAppState.java

示例9: notifyRemoved

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
@Override
public void notifyRemoved(@NotNull final Object object) {
    if (object instanceof PhysicsControl) {
        ((PhysicsControl) object).setPhysicsSpace(null);
    } else if (object instanceof Spatial) {
        updateNode((Spatial) object, null);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:9,代码来源:EditableBulletSceneAppState.java

示例10: updateNode

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
/**
 * Update a spatial.
 *
 * @param spatial      the spatial.
 * @param physicsSpace the new physical space or null.
 */
private void updateNode(@NotNull final Spatial spatial, @Nullable final PhysicsSpace physicsSpace) {
    spatial.depthFirstTraversal(spatial1 -> {

        final int numControls = spatial1.getNumControls();

        for (int i = 0; i < numControls; i++) {
            final Control control = spatial1.getControl(i);
            if (control instanceof PhysicsControl) {
                ((PhysicsControl) control).setPhysicsSpace(physicsSpace);
            }
        }
    });
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:20,代码来源:ModelEditorBulletState.java

示例11: isObstacle

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
private static boolean isObstacle(Spatial spatial) {
    if (spatial.getControl(PhysicsControl.class) != null) {
        return true;
    } else if (spatial.getParent() != null) {
        return isObstacle(spatial.getParent());
    }
    return false;
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:9,代码来源:SummonItem.java

示例12: simpleUpdate

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
@Override
public void simpleUpdate(float tpf) {
    if (ghostControl.getOverlappingObjects().contains(collisionNode.getControl(PhysicsControl.class))) {
        fpsText.setText("collide");
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:TestAttachGhostObject.java

示例13: addAll

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
/**
 * adds all physics controls and joints in the given spatial node to the physics space
 * (e.g. after loading from disk) - recursive if node
 * @param spatial the rootnode containing the physics objects
 */
public void addAll(Spatial spatial) {
    if (spatial.getControl(RigidBodyControl.class) != null) {
        RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class);
        if (!physicsNodes.containsValue(physicsNode)) {
            physicsNode.setPhysicsSpace(this);
        }
        //add joints
        List<PhysicsJoint> joints = physicsNode.getJoints();
        for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) {
            PhysicsJoint physicsJoint = it1.next();
            //add connected physicsnodes if they are not already added
            if (!physicsNodes.containsValue(physicsJoint.getBodyA())) {
                if (physicsJoint.getBodyA() instanceof PhysicsControl) {
                    add(physicsJoint.getBodyA());
                } else {
                    addRigidBody(physicsJoint.getBodyA());
                }
            }
            if (!physicsNodes.containsValue(physicsJoint.getBodyB())) {
                if (physicsJoint.getBodyA() instanceof PhysicsControl) {
                    add(physicsJoint.getBodyB());
                } else {
                    addRigidBody(physicsJoint.getBodyB());
                }
            }
            if (!physicsJoints.contains(physicsJoint)) {
                addJoint(physicsJoint);
            }
        }
    } else if (spatial.getControl(PhysicsControl.class) != null) {
        spatial.getControl(PhysicsControl.class).setPhysicsSpace(this);
    }
    //recursion
    if (spatial instanceof Node) {
        List<Spatial> children = ((Node) spatial).getChildren();
        for (Iterator<Spatial> it = children.iterator(); it.hasNext();) {
            Spatial spat = it.next();
            addAll(spat);
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:47,代码来源:PhysicsSpace.java

示例14: removeAll

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
/**
 * Removes all physics controls and joints in the given spatial from the physics space
 * (e.g. before saving to disk) - recursive if node
 * @param spatial the rootnode containing the physics objects
 */
public void removeAll(Spatial spatial) {
    if (spatial.getControl(RigidBodyControl.class) != null) {
        RigidBodyControl physicsNode = spatial.getControl(RigidBodyControl.class);
        if (physicsNodes.containsValue(physicsNode)) {
            physicsNode.setPhysicsSpace(null);
        }
        //remove joints
        List<PhysicsJoint> joints = physicsNode.getJoints();
        for (Iterator<PhysicsJoint> it1 = joints.iterator(); it1.hasNext();) {
            PhysicsJoint physicsJoint = it1.next();
            //add connected physicsnodes if they are not already added
            if (physicsNodes.containsValue(physicsJoint.getBodyA())) {
                if (physicsJoint.getBodyA() instanceof PhysicsControl) {
                    remove(physicsJoint.getBodyA());
                } else {
                    removeRigidBody(physicsJoint.getBodyA());
                }
            }
            if (physicsNodes.containsValue(physicsJoint.getBodyB())) {
                if (physicsJoint.getBodyA() instanceof PhysicsControl) {
                    remove(physicsJoint.getBodyB());
                } else {
                    removeRigidBody(physicsJoint.getBodyB());
                }
            }
            if (physicsJoints.contains(physicsJoint)) {
                removeJoint(physicsJoint);
            }
        }
    } else if (spatial.getControl(PhysicsControl.class) != null) {
        spatial.getControl(PhysicsControl.class).setPhysicsSpace(null);
    }
    //recursion
    if (spatial instanceof Node) {
        List<Spatial> children = ((Node) spatial).getChildren();
        for (Iterator<Spatial> it = children.iterator(); it.hasNext();) {
            Spatial spat = it.next();
            removeAll(spat);
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:47,代码来源:PhysicsSpace.java

示例15: disablePhysics

import com.jme3.bullet.control.PhysicsControl; //导入依赖的package包/类
public void disablePhysics() {
    PhysicsControl pc = this.getControl(PhysicsControl.class);
    if (pc != null) {
        pc.setEnabled(false);
    }
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:7,代码来源:Prefab.java


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