com.jme3.bullet.collision.shapes.infos.ChildCollisionShape Java Examples

The following examples show how to use com.jme3.bullet.collision.shapes.infos.ChildCollisionShape. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CollisionShapePropertyBuilder.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
@FxThread
private void build(@NotNull final ChildCollisionShape shape, @NotNull final VBox container,
                   @NotNull final ModelChangeConsumer changeConsumer) {

    final Vector3f location = shape.location;
    final Matrix3f rotation = shape.rotation;

    final DefaultSinglePropertyControl<ModelChangeConsumer, ChildCollisionShape, Vector3f> locationControl =
            new DefaultSinglePropertyControl<>(location, Messages.MODEL_PROPERTY_LOCATION, changeConsumer);

    locationControl.setSyncHandler(collisionShape -> collisionShape.location);
    locationControl.setToStringFunction(Vector3f::toString);
    locationControl.setEditObject(shape);

    final DefaultSinglePropertyControl<ModelChangeConsumer, ChildCollisionShape, Matrix3f> rotationControl =
            new DefaultSinglePropertyControl<>(rotation, Messages.MODEL_PROPERTY_ROTATION, changeConsumer);

    rotationControl.setSyncHandler(collisionShape -> collisionShape.rotation);
    rotationControl.setToStringFunction(matrix3f -> new Quaternion().fromRotationMatrix(matrix3f).toString());
    rotationControl.setEditObject(shape);
    rotationControl.reload();

    FXUtils.addToPane(locationControl, container);
    FXUtils.addToPane(rotationControl, container);
}
 
Example #2
Source File: CollisionShapeFactory.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * This method moves each child shape of a compound shape by the given vector
 * @param vector
 */
public static void shiftCompoundShapeContents(CompoundCollisionShape compoundShape, Vector3f vector) {
    for (Iterator<ChildCollisionShape> it = new LinkedList(compoundShape.getChildren()).iterator(); it.hasNext();) {
        ChildCollisionShape childCollisionShape = it.next();
        CollisionShape child = childCollisionShape.shape;
        Vector3f location = childCollisionShape.location;
        Matrix3f rotation = childCollisionShape.rotation;
        compoundShape.removeChildShape(child);
        compoundShape.addChildShape(child, location.add(vector), rotation);
    }
}
 
Example #3
Source File: CollisionShapePropertyBuilder.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent,
                            @NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer) {

    if (object instanceof ChildCollisionShape) {
        build((ChildCollisionShape) object, container, changeConsumer);
    }

    if (!(object instanceof CollisionShape)) {
        return;
    }

    if (object instanceof BoxCollisionShape) {
        build((BoxCollisionShape) object, container, changeConsumer);
    } else if (object instanceof SphereCollisionShape) {
        build((SphereCollisionShape) object, container, changeConsumer);
    } else if (object instanceof CapsuleCollisionShape) {
        build((CapsuleCollisionShape) object, container, changeConsumer);
    } else if (object instanceof ConeCollisionShape) {
        build((ConeCollisionShape) object, container, changeConsumer);
    } else if (object instanceof CylinderCollisionShape) {
        build((CylinderCollisionShape) object, container, changeConsumer);
    }

    build((CollisionShape) object, container, changeConsumer);
}
 
Example #4
Source File: CompoundCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    children = capsule.readSavableArrayList("children", new ArrayList<ChildCollisionShape>());
    cShape.setLocalScaling(Converter.convert(getScale()));
    cShape.setMargin(margin);
    loadChildren();
}
 
Example #5
Source File: CompoundCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * removes a child shape
 * @param shape the child shape to remove
 */
public void removeChildShape(CollisionShape shape) {
    ((CompoundShape) cShape).removeChildShape(shape.getCShape());
    for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
        ChildCollisionShape childCollisionShape = it.next();
        if (childCollisionShape.shape == shape) {
            it.remove();
        }
    }
}
 
Example #6
Source File: CompoundCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * adds a child shape at the given local translation
 * @param shape the child shape to add
 * @param location the local location of the child shape
 */
public void addChildShape(CollisionShape shape, Vector3f location, Matrix3f rotation) {
    if(shape instanceof CompoundCollisionShape){
        throw new IllegalStateException("CompoundCollisionShapes cannot have CompoundCollisionShapes as children!");
    }
    Transform transA = new Transform(Converter.convert(rotation));
    Converter.convert(location, transA.origin);
    Converter.convert(rotation, transA.basis);
    children.add(new ChildCollisionShape(location.clone(), rotation.clone(), shape));
    ((CompoundShape) cShape).addChildShape(transA, shape.getCShape());
}
 
Example #7
Source File: CompoundCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * adds a child shape at the given local translation
 * @param shape the child shape to add
 * @param location the local location of the child shape
 */
public void addChildShape(CollisionShape shape, Vector3f location) {
    Transform transA = new Transform(Converter.convert(new Matrix3f()));
    Converter.convert(location, transA.origin);
    children.add(new ChildCollisionShape(location.clone(), new Matrix3f(), shape));
    ((CompoundShape) cShape).addChildShape(transA, shape.getCShape());
}
 
Example #8
Source File: CollisionShapeFactory.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * This method moves each child shape of a compound shape by the given vector
 * @param vector
 */
public static void shiftCompoundShapeContents(CompoundCollisionShape compoundShape, Vector3f vector) {
    for (Iterator<ChildCollisionShape> it = new LinkedList(compoundShape.getChildren()).iterator(); it.hasNext();) {
        ChildCollisionShape childCollisionShape = it.next();
        CollisionShape child = childCollisionShape.shape;
        Vector3f location = childCollisionShape.location;
        Matrix3f rotation = childCollisionShape.rotation;
        compoundShape.removeChildShape(child);
        compoundShape.addChildShape(child, location.add(vector), rotation);
    }
}
 
Example #9
Source File: DebugShapeFactory.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Creates a debug shape from the given collision shape. This is mostly used internally.<br>
 * To attach a debug shape to a physics object, call <code>attachDebugShape(AssetManager manager);</code> on it.
 * @param collisionShape
 * @return
 */
public static Spatial getDebugShape(CollisionShape collisionShape) {
    if (collisionShape == null) {
        return null;
    }
    Spatial debugShape;
    if (collisionShape instanceof CompoundCollisionShape) {
        CompoundCollisionShape shape = (CompoundCollisionShape) collisionShape;
        List<ChildCollisionShape> children = shape.getChildren();
        Node node = new Node("DebugShapeNode");
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
            ChildCollisionShape childCollisionShape = it.next();
            CollisionShape ccollisionShape = childCollisionShape.shape;
            Geometry geometry = createDebugShape(ccollisionShape);

            // apply translation
            geometry.setLocalTranslation(childCollisionShape.location);

            // apply rotation
            TempVars vars = TempVars.get();                
            Matrix3f tempRot = vars.tempMat3;

            tempRot.set(geometry.getLocalRotation());
            childCollisionShape.rotation.mult(tempRot, tempRot);
            geometry.setLocalRotation(tempRot);

            vars.release();

            node.attachChild(geometry);
        }
        debugShape = node;
    } else {
        debugShape = createDebugShape(collisionShape);
    }
    if (debugShape == null) {
        return null;
    }
    debugShape.updateGeometricState();
    return debugShape;
}
 
Example #10
Source File: CompoundCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    children = capsule.readSavableArrayList("children", new ArrayList<ChildCollisionShape>());
    setScale(scale);
    setMargin(margin);
    loadChildren();
}
 
Example #11
Source File: CompoundCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
     * removes a child shape
     * @param shape the child shape to remove
     */
    public void removeChildShape(CollisionShape shape) {
        removeChildShape(objectId, shape.getObjectId());
//        ((CompoundShape) objectId).removeChildShape(shape.getObjectId());
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
            ChildCollisionShape childCollisionShape = it.next();
            if (childCollisionShape.shape == shape) {
                it.remove();
            }
        }
    }
 
Example #12
Source File: CompoundCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
     * adds a child shape at the given local translation
     * @param shape the child shape to add
     * @param location the local location of the child shape
     */
    public void addChildShape(CollisionShape shape, Vector3f location, Matrix3f rotation) {
        if(shape instanceof CompoundCollisionShape){
            throw new IllegalStateException("CompoundCollisionShapes cannot have CompoundCollisionShapes as children!");
        }
//        Transform transA = new Transform(Converter.convert(rotation));
//        Converter.convert(location, transA.origin);
//        Converter.convert(rotation, transA.basis);
        children.add(new ChildCollisionShape(location.clone(), rotation.clone(), shape));
        addChildShape(objectId, shape.getObjectId(), location, rotation);
//        ((CompoundShape) objectId).addChildShape(transA, shape.getObjectId());
    }
 
Example #13
Source File: CompoundCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    children = capsule.readSavableArrayList("children", new ArrayList<ChildCollisionShape>());
    cShape.setLocalScaling(Converter.convert(getScale()));
    cShape.setMargin(margin);
    loadChildren();
}
 
Example #14
Source File: CompoundCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * removes a child shape
 * @param shape the child shape to remove
 */
public void removeChildShape(CollisionShape shape) {
    ((CompoundShape) cShape).removeChildShape(shape.getCShape());
    for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
        ChildCollisionShape childCollisionShape = it.next();
        if (childCollisionShape.shape == shape) {
            it.remove();
        }
    }
}
 
Example #15
Source File: CompoundCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * adds a child shape at the given local translation
 * @param shape the child shape to add
 * @param location the local location of the child shape
 */
public void addChildShape(CollisionShape shape, Vector3f location, Matrix3f rotation) {
    if(shape instanceof CompoundCollisionShape){
        throw new IllegalStateException("CompoundCollisionShapes cannot have CompoundCollisionShapes as children!");
    }
    Transform transA = new Transform(Converter.convert(rotation));
    Converter.convert(location, transA.origin);
    Converter.convert(rotation, transA.basis);
    children.add(new ChildCollisionShape(location.clone(), rotation.clone(), shape));
    ((CompoundShape) cShape).addChildShape(transA, shape.getCShape());
}
 
Example #16
Source File: CollisionShapeFactory.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * This method moves each child shape of a compound shape by the given vector
 * @param vector
 */
public static void shiftCompoundShapeContents(CompoundCollisionShape compoundShape, Vector3f vector) {
    for (Iterator<ChildCollisionShape> it = new LinkedList<>(compoundShape.getChildren()).iterator(); it.hasNext();) {
        ChildCollisionShape childCollisionShape = it.next();
        CollisionShape child = childCollisionShape.shape;
        Vector3f location = childCollisionShape.location;
        Matrix3f rotation = childCollisionShape.rotation;
        compoundShape.removeChildShape(child);
        compoundShape.addChildShape(child, location.add(vector), rotation);
    }
}
 
Example #17
Source File: CollisionTreeNodeFactory.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
public <T, V extends TreeNode<T>> @Nullable V createFor(@Nullable final T element, final long objectId) {

    if (element instanceof ChildCollisionShape) {
        return unsafeCast(new ChildCollisionShapeTreeNode((ChildCollisionShape) element, objectId));
    } else if (element instanceof CollisionShape) {
        if (element instanceof BoxCollisionShape) {
            return unsafeCast(new BoxCollisionShapeTreeNode((BoxCollisionShape) element, objectId));
        } else if (element instanceof CapsuleCollisionShape) {
            return unsafeCast(new CapsuleCollisionShapeTreeNode((CapsuleCollisionShape) element, objectId));
        } else if (element instanceof CompoundCollisionShape) {
            return unsafeCast(new ComputedCollisionShapeTreeNode((CompoundCollisionShape) element, objectId));
        } else if (element instanceof ConeCollisionShape) {
            return unsafeCast(new ConeCollisionShapeTreeNode((ConeCollisionShape) element, objectId));
        } else if (element instanceof CylinderCollisionShape) {
            return unsafeCast(new CylinderCollisionShapeTreeNode((CylinderCollisionShape) element, objectId));
        } else if (element instanceof GImpactCollisionShape) {
            return unsafeCast(new GImpactCollisionShapeTreeNode((GImpactCollisionShape) element, objectId));
        } else if (element instanceof HullCollisionShape) {
            return unsafeCast(new HullCollisionShapeTreeNode((HullCollisionShape) element, objectId));
        } else if (element instanceof MeshCollisionShape) {
            return unsafeCast(new MeshCollisionShapeTreeNode((MeshCollisionShape) element, objectId));
        } else if (element instanceof PlaneCollisionShape) {
            return unsafeCast(new PlaneCollisionShapeTreeNode((PlaneCollisionShape) element, objectId));
        } else if (element instanceof SphereCollisionShape) {
            return unsafeCast(new SphereCollisionShapeTreeNode((SphereCollisionShape) element, objectId));
        }
    }

    return null;
}
 
Example #18
Source File: ChildCollisionShapeTreeNode.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {

    final ChildCollisionShape element = getElement();
    final CollisionShape shape = element.shape;

    final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class, 1);
    result.add(FACTORY_REGISTRY.createFor(shape));

    return result;
}
 
Example #19
Source File: ComputedCollisionShapeTreeNode.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {

    final CompoundCollisionShape element = getElement();
    final List<ChildCollisionShape> children = element.getChildren();
    final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class);
    children.forEach(childCollisionShape -> result.add(FACTORY_REGISTRY.createFor(childCollisionShape)));

    return result;
}
 
Example #20
Source File: CompoundCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
     * Add a child shape with the specified local translation and orientation.
     *
     * @param shape the child shape to add (not null, not a compound shape,
     * alias created)
     * @param location the local coordinates of the child shape's center (not
     * null, unaffected)
     * @param rotation the local orientation of the child shape (not null,
     * unaffected)
     */
    public void addChildShape(CollisionShape shape, Vector3f location, Matrix3f rotation) {
        if(shape instanceof CompoundCollisionShape){
            throw new IllegalStateException("CompoundCollisionShapes cannot have CompoundCollisionShapes as children!");
        }
//        Transform transA = new Transform(Converter.convert(rotation));
//        Converter.convert(location, transA.origin);
//        Converter.convert(rotation, transA.basis);
        children.add(new ChildCollisionShape(location.clone(), rotation.clone(), shape));
        addChildShape(objectId, shape.getObjectId(), location, rotation);
//        ((CompoundShape) objectId).addChildShape(transA, shape.getObjectId());
    }
 
Example #21
Source File: CompoundCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
     * Remove a child from this shape.
     *
     * @param shape the child shape to remove (not null)
     */
    public void removeChildShape(CollisionShape shape) {
        removeChildShape(objectId, shape.getObjectId());
//        ((CompoundShape) objectId).removeChildShape(shape.getObjectId());
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
            ChildCollisionShape childCollisionShape = it.next();
            if (childCollisionShape.shape == shape) {
                it.remove();
            }
        }
    }
 
Example #22
Source File: CompoundCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Serialize this shape, for example when saving to a J3O file.
 *
 * @param ex exporter (not null)
 * @throws IOException from exporter
 */
@Override
public void write(JmeExporter ex) throws IOException {
    super.write(ex);
    OutputCapsule capsule = ex.getCapsule(this);
    capsule.writeSavableArrayList(children, "children", new ArrayList<ChildCollisionShape>());
}
 
Example #23
Source File: CompoundCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * De-serialize this shape, for example when loading from a J3O file.
 *
 * @param im importer (not null)
 * @throws IOException from importer
 */
@Override
@SuppressWarnings("unchecked")
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    children = capsule.readSavableArrayList("children", new ArrayList<ChildCollisionShape>());
    setScale(scale);
    setMargin(margin);
    loadChildren();
}
 
Example #24
Source File: CompoundCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * adds a child shape at the given local translation
 * @param shape the child shape to add
 * @param location the local location of the child shape
 */
public void addChildShape(CollisionShape shape, Vector3f location) {
    Transform transA = new Transform(Converter.convert(new Matrix3f()));
    Converter.convert(location, transA.origin);
    children.add(new ChildCollisionShape(location.clone(), new Matrix3f(), shape));
    ((CompoundShape) cShape).addChildShape(transA, shape.getCShape());
}
 
Example #25
Source File: DebugShapeFactory.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Create a debug spatial from the specified collision shape.
 * <p>
 * This is mostly used internally. To attach a debug shape to a physics
 * object, call <code>attachDebugShape(AssetManager manager);</code> on it.
 *
 * @param collisionShape the shape to visualize (may be null, unaffected)
 * @return a new tree of geometries, or null
 */
public static Spatial getDebugShape(CollisionShape collisionShape) {
    if (collisionShape == null) {
        return null;
    }
    Spatial debugShape;
    if (collisionShape instanceof CompoundCollisionShape) {
        CompoundCollisionShape shape = (CompoundCollisionShape) collisionShape;
        List<ChildCollisionShape> children = shape.getChildren();
        Node node = new Node("DebugShapeNode");
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
            ChildCollisionShape childCollisionShape = it.next();
            CollisionShape ccollisionShape = childCollisionShape.shape;
            Geometry geometry = createDebugShape(ccollisionShape);

            // apply translation
            geometry.setLocalTranslation(childCollisionShape.location);

            // apply rotation
            TempVars vars = TempVars.get();                
            Matrix3f tempRot = vars.tempMat3;

            tempRot.set(geometry.getLocalRotation());
            childCollisionShape.rotation.mult(tempRot, tempRot);
            geometry.setLocalRotation(tempRot);

            vars.release();

            node.attachChild(geometry);
        }
        debugShape = node;
    } else {
        debugShape = createDebugShape(collisionShape);
    }
    if (debugShape == null) {
        return null;
    }
    debugShape.updateGeometricState();
    return debugShape;
}
 
Example #26
Source File: DebugShapeFactory.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a debug shape from the given collision shape. This is mostly used internally.<br>
 * To attach a debug shape to a physics object, call <code>attachDebugShape(AssetManager manager);</code> on it.
 * @param collisionShape
 * @return
 */
public static Spatial getDebugShape(CollisionShape collisionShape) {
    if (collisionShape == null) {
        return null;
    }
    Spatial debugShape;
    if (collisionShape instanceof CompoundCollisionShape) {
        CompoundCollisionShape shape = (CompoundCollisionShape) collisionShape;
        List<ChildCollisionShape> children = shape.getChildren();
        Node node = new Node("DebugShapeNode");
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
            ChildCollisionShape childCollisionShape = it.next();
            CollisionShape ccollisionShape = childCollisionShape.shape;
            Geometry geometry = createDebugShape(ccollisionShape);

            // apply translation
            geometry.setLocalTranslation(childCollisionShape.location);

            // apply rotation
            TempVars vars = TempVars.get();
            Matrix3f tempRot = vars.tempMat3;

            tempRot.set(geometry.getLocalRotation());
            childCollisionShape.rotation.mult(tempRot, tempRot);
            geometry.setLocalRotation(tempRot);
            geometry.setLocalScale(ccollisionShape.getScale());

            vars.release();

            node.attachChild(geometry);
        }
        debugShape = node;
    } else {
        debugShape = createDebugShape(collisionShape);
    }
    if (debugShape == null) {
        return null;
    }
    debugShape.updateGeometricState();
    return debugShape;
}
 
Example #27
Source File: DebugShapeFactory.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates a debug shape from the given collision shape. This is mostly used internally.<br>
 * To attach a debug shape to a physics object, call <code>attachDebugShape(AssetManager manager);</code> on it.
 * @param collisionShape
 * @return
 */
public static Spatial getDebugShape(CollisionShape collisionShape) {
    if (collisionShape == null) {
        return null;
    }
    Spatial debugShape;
    if (collisionShape instanceof CompoundCollisionShape) {
        CompoundCollisionShape shape = (CompoundCollisionShape) collisionShape;
        List<ChildCollisionShape> children = shape.getChildren();
        Node node = new Node("DebugShapeNode");
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
            ChildCollisionShape childCollisionShape = it.next();
            CollisionShape ccollisionShape = childCollisionShape.shape;
            Geometry geometry = createDebugShape(ccollisionShape);

            // apply translation
            geometry.setLocalTranslation(childCollisionShape.location);

            // apply rotation
            TempVars vars = TempVars.get();

            Matrix3f tempRot = vars.tempMat3;

            tempRot.set(geometry.getLocalRotation());
            childCollisionShape.rotation.mult(tempRot, tempRot);
            geometry.setLocalRotation(tempRot);

            vars.release();

            node.attachChild(geometry);
        }
        debugShape = node;
    } else {
        debugShape = createDebugShape(collisionShape);
    }
    if (debugShape == null) {
        return null;
    }
    debugShape.updateGeometricState();
    return debugShape;
}
 
Example #28
Source File: CompoundCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void loadChildren() {
    for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) {
        ChildCollisionShape child = it.next();
        addChildShapeDirect(child.shape, child.location, child.rotation);
    }
}
 
Example #29
Source File: ChildCollisionShapeTreeNode.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
public ChildCollisionShapeTreeNode(@NotNull final ChildCollisionShape element, final long objectId) {
    super(element, objectId);
}
 
Example #30
Source File: CompoundCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void write(JmeExporter ex) throws IOException {
    super.write(ex);
    OutputCapsule capsule = ex.getCapsule(this);
    capsule.writeSavableArrayList(children, "children", new ArrayList<ChildCollisionShape>());
}