Java Code Examples for com.jme3.scene.Spatial#setLocalRotation()

The following examples show how to use com.jme3.scene.Spatial#setLocalRotation() . 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: AbstractPhysicsDebugControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Apply the specified location and orientation to the specified spatial.
 *
 * @param worldLocation location vector (in physics-space coordinates, not
 * null, unaffected)
 * @param worldRotation orientation (in physics-space coordinates, not null,
 * unaffected)
 * @param spatial where to apply (may be null)
 */
protected void applyPhysicsTransform(Vector3f worldLocation, Quaternion worldRotation, Spatial spatial) {
    if (spatial != null) {
        Vector3f localLocation = spatial.getLocalTranslation();
        Quaternion localRotationQuat = spatial.getLocalRotation();
        if (spatial.getParent() != null) {
            localLocation.set(worldLocation).subtractLocal(spatial.getParent().getWorldTranslation());
            localLocation.divideLocal(spatial.getParent().getWorldScale());
            tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
            localRotationQuat.set(worldRotation);
            tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);
            spatial.setLocalTranslation(localLocation);
            spatial.setLocalRotation(localRotationQuat);
        } else {
            spatial.setLocalTranslation(worldLocation);
            spatial.setLocalRotation(worldRotation);
        }
    }

}
 
Example 2
Source File: RigidBodyMotionState.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * applies the current transform to the given jme Node if the location has been updated on the physics side
 * @param spatial
 */
public boolean applyTransform(Spatial spatial) {
    if (!physicsLocationDirty) {
        return false;
    }
    if (!applyPhysicsLocal && spatial.getParent() != null) {
        localLocation.set(worldLocation).subtractLocal(spatial.getParent().getWorldTranslation());
        localLocation.divideLocal(spatial.getParent().getWorldScale());
        tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);

        localRotationQuat.set(worldRotationQuat);
        tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);

        spatial.setLocalTranslation(localLocation);
        spatial.setLocalRotation(localRotationQuat);
    } else {
        spatial.setLocalTranslation(worldLocation);
        spatial.setLocalRotation(worldRotationQuat);
    }
    physicsLocationDirty = false;
    return true;
}
 
Example 3
Source File: PMDPhysicsWorld.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void updateRigidBodyPos() {
    for (PMDRigidBody rbarray[] : nodeRigidBodyArray) {
        for (int i = 0; i < rbarray.length; i++) {
            PMDRigidBody rb = rbarray[i];
            if (true) {
                PMDNode pmdNode = rb.getPmdNode();
                Node rigidBodyNode = pmdNode.getRigidBodyNode();
                if (rigidBodyNode != null) {
                    Spatial spaital = rigidBodyNode.getChild(i);
                    spaital.setLocalRotation(rb.getPhysicsRotation());
                    spaital.setLocalTranslation(rb.getPhysicsLocation());
                }
            }
        }
    }
}
 
Example 4
Source File: KinematicRagdollControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * For internal use only
 * specific render for the ragdoll(if debugging)      
 * @param rm
 * @param vp 
 */
public void render(RenderManager rm, ViewPort vp) {
    if (enabled && space != null && space.getDebugManager() != null) {
        if (!debug) {
            attachDebugShape(space.getDebugManager());
        }
        for (Iterator<PhysicsBoneLink> it = boneLinks.values().iterator(); it.hasNext();) {
            PhysicsBoneLink physicsBoneLink = it.next();
            Spatial debugShape = physicsBoneLink.rigidBody.debugShape();
            if (debugShape != null) {
                debugShape.setLocalTranslation(physicsBoneLink.rigidBody.getMotionState().getWorldLocation());
                debugShape.setLocalRotation(physicsBoneLink.rigidBody.getMotionState().getWorldRotationQuat());
                debugShape.updateGeometricState();
                rm.renderScene(debugShape, vp);
            }
        }
    }
}
 
Example 5
Source File: RigidBodyMotionState.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * applies the current transform to the given jme Node if the location has been updated on the physics side
 * @param spatial
 */
public synchronized boolean applyTransform(Spatial spatial) {
    if (!physicsLocationDirty) {
        return false;
    }
    if (!applyPhysicsLocal && spatial.getParent() != null) {
        localLocation.set(worldLocation).subtractLocal(spatial.getParent().getWorldTranslation());
        localLocation.divideLocal(spatial.getParent().getWorldScale());
        tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);

        localRotationQuat.set(worldRotationQuat);
        tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);

        spatial.setLocalTranslation(localLocation);
        spatial.setLocalRotation(localRotationQuat);
    } else {
        spatial.setLocalTranslation(worldLocation);
        spatial.setLocalRotation(worldRotationQuat);
    }
    physicsLocationDirty = false;
    return true;
}
 
Example 6
Source File: KinematicRagdollControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * For internal use only
 * specific render for the ragdoll(if debugging)      
 * @param rm
 * @param vp 
 */
public void render(RenderManager rm, ViewPort vp) {
    if (enabled && space != null && space.getDebugManager() != null) {
        if (!debug) {
            attachDebugShape(space.getDebugManager());
        }
        for (Iterator<PhysicsBoneLink> it = boneLinks.values().iterator(); it.hasNext();) {
            PhysicsBoneLink physicsBoneLink = it.next();
            Spatial debugShape = physicsBoneLink.rigidBody.debugShape();
            if (debugShape != null) {
                debugShape.setLocalTranslation(physicsBoneLink.rigidBody.getMotionState().getWorldLocation());
                debugShape.setLocalRotation(physicsBoneLink.rigidBody.getMotionState().getWorldRotationQuat());
                debugShape.updateGeometricState();
                rm.renderScene(debugShape, vp);
            }
        }
    }
}
 
Example 7
Source File: TestHoveringTank.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void makeMissile() {
    Vector3f pos = spaceCraft.getWorldTranslation().clone();
    Quaternion rot = spaceCraft.getWorldRotation();
    Vector3f dir = rot.getRotationColumn(2);

    Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml");
    missile.scale(0.5f);
    missile.rotate(0, FastMath.PI, 0);
    missile.updateGeometricState();

    BoundingBox box = (BoundingBox) missile.getWorldBound();
    final Vector3f extent = box.getExtent(null);

    BoxCollisionShape boxShape = new BoxCollisionShape(extent);

    missile.setName("Missile");
    missile.rotate(rot);
    missile.setLocalTranslation(pos.addLocal(0, extent.y * 4.5f, 0));
    missile.setLocalRotation(hoverControl.getPhysicsRotation());
    missile.setShadowMode(ShadowMode.Cast);
    RigidBodyControl control = new BombControl(assetManager, boxShape, 20);
    control.setLinearVelocity(dir.mult(100));
    control.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_03);
    missile.addControl(control);


    rootNode.attachChild(missile);
    getPhysicsSpace().add(missile);
}
 
Example 8
Source File: RigidBodyMotionState.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
     * If the motion state has been updated, apply the new transform to the
     * specified spatial.
     *
     * @param spatial where to apply the physics transform (not null, modified)
     * @return true if changed
     */
    public boolean applyTransform(Spatial spatial) {
        Vector3f localLocation = spatial.getLocalTranslation();
        Quaternion localRotationQuat = spatial.getLocalRotation();
        boolean physicsLocationDirty = applyTransform(motionStateId, localLocation, localRotationQuat);
        if (!physicsLocationDirty) {
            return false;
        }
        if (!applyPhysicsLocal && spatial.getParent() != null) {
            localLocation.subtractLocal(spatial.getParent().getWorldTranslation());
            localLocation.divideLocal(spatial.getParent().getWorldScale());
            tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);

//            localRotationQuat.set(worldRotationQuat);
            tmp_inverseWorldRotation.mult(localRotationQuat, localRotationQuat);

            spatial.setLocalTranslation(localLocation);
            spatial.setLocalRotation(localRotationQuat);
        } else {
            spatial.setLocalTranslation(localLocation);
            spatial.setLocalRotation(localRotationQuat);
//            spatial.setLocalTranslation(worldLocation);
//            spatial.setLocalRotation(worldRotationQuat);
        }
        if (vehicle != null) {
            vehicle.updateWheels();
        }
        return true;
    }
 
Example 9
Source File: TestHoveringTank.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void makeMissile() {
    Vector3f pos = spaceCraft.getWorldTranslation().clone();
    Quaternion rot = spaceCraft.getWorldRotation();
    Vector3f dir = rot.getRotationColumn(2);

    Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml");
    missile.scale(0.5f);
    missile.rotate(0, FastMath.PI, 0);
    missile.updateGeometricState();

    BoundingBox box = (BoundingBox) missile.getWorldBound();
    final Vector3f extent = box.getExtent(null);

    BoxCollisionShape boxShape = new BoxCollisionShape(extent);

    missile.setName("Missile");
    missile.rotate(rot);
    missile.setLocalTranslation(pos.addLocal(0, extent.y * 4.5f, 0));
    missile.setLocalRotation(hoverControl.getPhysicsRotation());
    missile.setShadowMode(ShadowMode.Cast);
    RigidBodyControl control = new BombControl(assetManager, boxShape, 20);
    control.setLinearVelocity(dir.mult(100));
    control.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_03);
    missile.addControl(control);


    rootNode.attachChild(missile);
    getPhysicsSpace().add(missile);
}
 
Example 10
Source File: CollisionTester.java    From OpenRTS with MIT License 5 votes vote down vote up
private static Spatial getSpatialFromAsset(Asset asset){
	if (!models.containsKey(asset.modelPath))
		models.put(asset.modelPath, am.loadModel("models/" + asset.modelPath));
	Spatial res = models.get(asset.modelPath).clone();
	
	res.setLocalScale((float)asset.scale);
	res.setLocalTranslation(TranslateUtil.toVector3f(asset.pos));
	res.setLocalRotation(new Quaternion().fromAngles(0, 0, (float)asset.yaw));
	return res;
}
 
Example 11
Source File: RigidBodyMotionState.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
     * applies the current transform to the given jme Node if the location has been updated on the physics side
     * @param spatial
     */
    public synchronized boolean applyTransform(Spatial spatial) {
        Vector3f localLocation = spatial.getLocalTranslation();
        Quaternion localRotationQuat = spatial.getLocalRotation();
        boolean physicsLocationDirty = applyTransform(motionStateId, localLocation, localRotationQuat);
        if (!physicsLocationDirty) {
            return false;
        }
        if (!applyPhysicsLocal && spatial.getParent() != null) {
            localLocation.subtractLocal(spatial.getParent().getWorldTranslation());
            localLocation.divideLocal(spatial.getParent().getWorldScale());
            tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);

//            localRotationQuat.set(worldRotationQuat);
            tmp_inverseWorldRotation.mult(localRotationQuat, localRotationQuat);

            spatial.setLocalTranslation(localLocation);
            spatial.setLocalRotation(localRotationQuat);
        } else {
            spatial.setLocalTranslation(localLocation);
            spatial.setLocalRotation(localRotationQuat);
//            spatial.setLocalTranslation(worldLocation);
//            spatial.setLocalRotation(worldRotationQuat);
        }
        if (vehicle != null) {
            vehicle.updateWheels();
        }
        return true;
    }
 
Example 12
Source File: SpatialTrack.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * 
 * Modify the spatial which this track modifies.
 * 
 * @param time
 *            the current time of the animation
 */
public void setTime(float time, float weight, AnimControl control, AnimChannel channel, TempVars vars) {
    Spatial spatial = control.getSpatial();
    
    Vector3f tempV = vars.vect1;
    Vector3f tempS = vars.vect2;
    Quaternion tempQ = vars.quat1;
    Vector3f tempV2 = vars.vect3;
    Vector3f tempS2 = vars.vect4;
    Quaternion tempQ2 = vars.quat2;
    
    int lastFrame = times.length - 1;
    if (time < 0 || lastFrame == 0) {
        if (rotations != null)
            rotations.get(0, tempQ);
        if (translations != null)
            translations.get(0, tempV);
        if (scales != null) {
            scales.get(0, tempS);
        }
    } else if (time >= times[lastFrame]) {
        if (rotations != null)
            rotations.get(lastFrame, tempQ);
        if (translations != null)
            translations.get(lastFrame, tempV);
        if (scales != null) {
            scales.get(lastFrame, tempS);
        }
    } else {
        int startFrame = 0;
        int endFrame = 1;
        // use lastFrame so we never overflow the array
        for (int i = 0; i < lastFrame && times[i] < time; ++i) {
            startFrame = i;
            endFrame = i + 1;
        }

        float blend = (time - times[startFrame]) / (times[endFrame] - times[startFrame]);

        if (rotations != null)
            rotations.get(startFrame, tempQ);
        if (translations != null)
            translations.get(startFrame, tempV);
        if (scales != null) {
            scales.get(startFrame, tempS);
        }
        if (rotations != null)
            rotations.get(endFrame, tempQ2);
        if (translations != null)
            translations.get(endFrame, tempV2);
        if (scales != null) {
            scales.get(endFrame, tempS2);
        }
        tempQ.nlerp(tempQ2, blend);
        tempV.interpolate(tempV2, blend);
        tempS.interpolate(tempS2, blend);
    }
    
    if (translations != null)
        spatial.setLocalTranslation(tempV);
    if (rotations != null)
        spatial.setLocalRotation(tempQ);
    if (scales != null) {
        spatial.setLocalScale(tempS);
    }
}
 
Example 13
Source File: RotationToolControl.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
@JmeThread
public void processTransform() {

    final LocalObjects local = LocalObjects.get();
    final EditorTransformSupport editorControl = getEditorControl();
    final InputManager inputManager = EditorUtil.getInputManager();
    final Camera camera = editorControl.getCamera();

    final Transform transform = notNull(editorControl.getTransformCenter());

    // cursor position and selected position vectors
    final Vector2f cursorPos = inputManager.getCursorPosition();
    final Vector3f transformOnScreen = camera.getScreenCoordinates(transform.getTranslation());
    final Vector2f selectedCoords = local.nextVector(transformOnScreen.getX(), transformOnScreen.getY());

    //set new deltaVector if it's not set
    if (Float.isNaN(editorControl.getTransformDeltaX())) {
        editorControl.setTransformDeltaX(selectedCoords.getX() - cursorPos.getX());
        editorControl.setTransformDeltaY(selectedCoords.getY() - cursorPos.getY());
    }

    // Picked vector
    final TransformationMode transformationMode = editorControl.getTransformationMode();
    final Vector3f pickedVector = transformationMode.getPickedVector(transform, editorControl.getPickedAxis(), camera);
    final Vector3f deltaVector = local.nextVector(editorControl.getTransformDeltaX(), editorControl.getTransformDeltaY(), 0F);

    // rotate according to angle
    final Vector2f cursorDirection = selectedCoords.subtractLocal(cursorPos).normalizeLocal();
    float angle = cursorDirection.angleBetween(local.nextVector(deltaVector.getX(), deltaVector.getY()));
    angle = FastMath.RAD_TO_DEG * angle * FastMath.DEG_TO_RAD;

    final Node parentNode = getParentNode();
    final Node childNode = getChildNode();

    transformationMode.prepareToRotate(parentNode, childNode, transform, camera);

    final Quaternion rotation = parentNode.getLocalRotation();
    final Vector3f axisToRotate = rotation.mult(pickedVector, local.nextVector());

    float angleCheck = axisToRotate.angleBetween(camera.getDirection(local.nextVector()));

    if (angleCheck > FastMath.HALF_PI) {
        angle = -angle;
    }

    final Quaternion difference = local.nextRotation().fromAngleAxis(angle, pickedVector);
    final Quaternion newRotation = rotation.mult(difference, local.nextRotation());

    parentNode.setLocalRotation(newRotation);

    final Spatial toTransform = notNull(editorControl.getToTransform());
    toTransform.setLocalRotation(childNode.getWorldRotation());

    editorControl.notifyTransformed(toTransform);
}
 
Example 14
Source File: KinematicRagdollControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setSpatial(Spatial model) {
    if (model == null) {
        removeFromPhysicsSpace();
        clearData();
        return;
    }
    targetModel = model;
    Node parent = model.getParent();


    Vector3f initPosition = model.getLocalTranslation().clone();
    Quaternion initRotation = model.getLocalRotation().clone();
    initScale = model.getLocalScale().clone();

    model.removeFromParent();
    model.setLocalTranslation(Vector3f.ZERO);
    model.setLocalRotation(Quaternion.IDENTITY);
    model.setLocalScale(1);
    //HACK ALERT change this
    //I remove the skeletonControl and readd it to the spatial to make sure it's after the ragdollControl in the stack
    //Find a proper way to order the controls.
    SkeletonControl sc = model.getControl(SkeletonControl.class);
    model.removeControl(sc);
    model.addControl(sc);
    //---- 

    removeFromPhysicsSpace();
    clearData();
    // put into bind pose and compute bone transforms in model space
    // maybe dont reset to ragdoll out of animations?
    scanSpatial(model);


    if (parent != null) {
        parent.attachChild(model);

    }
    model.setLocalTranslation(initPosition);
    model.setLocalRotation(initRotation);
    model.setLocalScale(initScale);

    logger.log(Level.INFO, "Created physics ragdoll for skeleton {0}", skeleton);
}
 
Example 15
Source File: KinematicRagdollControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setSpatial(Spatial model) {
    if (model == null) {
        removeFromPhysicsSpace();
        clearData();
        return;
    }
    targetModel = model;
    Node parent = model.getParent();


    Vector3f initPosition = model.getLocalTranslation().clone();
    Quaternion initRotation = model.getLocalRotation().clone();
    initScale = model.getLocalScale().clone();

    model.removeFromParent();
    model.setLocalTranslation(Vector3f.ZERO);
    model.setLocalRotation(Quaternion.IDENTITY);
    model.setLocalScale(1);
    //HACK ALERT change this
    //I remove the skeletonControl and readd it to the spatial to make sure it's after the ragdollControl in the stack
    //Find a proper way to order the controls.
    SkeletonControl sc = model.getControl(SkeletonControl.class);
    model.removeControl(sc);
    model.addControl(sc);
    //---- 

    removeFromPhysicsSpace();
    clearData();
    // put into bind pose and compute bone transforms in model space
    // maybe dont reset to ragdoll out of animations?
    scanSpatial(model);


    if (parent != null) {
        parent.attachChild(model);

    }
    model.setLocalTranslation(initPosition);
    model.setLocalRotation(initRotation);
    model.setLocalScale(initScale);

    logger.log(Level.INFO, "Created physics ragdoll for skeleton {0}", skeleton);
}
 
Example 16
Source File: SpatialTrack.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * 
 * Modify the spatial which this track modifies.
 * 
 * @param time
 *            the current time of the animation
 */
@Override
public void setTime(float time, float weight, AnimControl control, AnimChannel channel, TempVars vars) {
    Spatial spatial = trackSpatial;
    if (spatial == null) {
        spatial = control.getSpatial();
    }

    Vector3f tempV = vars.vect1;
    Vector3f tempS = vars.vect2;
    Quaternion tempQ = vars.quat1;
    Vector3f tempV2 = vars.vect3;
    Vector3f tempS2 = vars.vect4;
    Quaternion tempQ2 = vars.quat2;
    
    int lastFrame = times.length - 1;
    if (time < 0 || lastFrame == 0) {
        if (rotations != null)
            rotations.get(0, tempQ);
        if (translations != null)
            translations.get(0, tempV);
        if (scales != null) {
            scales.get(0, tempS);
        }
    } else if (time >= times[lastFrame]) {
        if (rotations != null)
            rotations.get(lastFrame, tempQ);
        if (translations != null)
            translations.get(lastFrame, tempV);
        if (scales != null) {
            scales.get(lastFrame, tempS);
        }
    } else {
        int startFrame = 0;
        int endFrame = 1;
        // use lastFrame so we never overflow the array
        for (int i = 0; i < lastFrame && times[i] < time; ++i) {
            startFrame = i;
            endFrame = i + 1;
        }

        float blend = (time - times[startFrame]) / (times[endFrame] - times[startFrame]);

        if (rotations != null)
            rotations.get(startFrame, tempQ);
        if (translations != null)
            translations.get(startFrame, tempV);
        if (scales != null) {
            scales.get(startFrame, tempS);
        }
        if (rotations != null)
            rotations.get(endFrame, tempQ2);
        if (translations != null)
            translations.get(endFrame, tempV2);
        if (scales != null) {
            scales.get(endFrame, tempS2);
        }
        tempQ.nlerp(tempQ2, blend);
        tempV.interpolateLocal(tempV2, blend);
        tempS.interpolateLocal(tempS2, blend);
    }

    if (translations != null) {
        spatial.setLocalTranslation(tempV);
    }
    if (rotations != null) {
        spatial.setLocalRotation(tempQ);
    }
    if (scales != null) {
        spatial.setLocalScale(tempS);
    }
}
 
Example 17
Source File: KinematicRagdollControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Create spatial-dependent data. Invoked when this control is added to a
 * scene.
 *
 * @param model the controlled spatial (not null)
 */
@Override
protected void createSpatialData(Spatial model) {
    targetModel = model;
    Node parent = model.getParent();


    Vector3f initPosition = model.getLocalTranslation().clone();
    Quaternion initRotation = model.getLocalRotation().clone();
    initScale = model.getLocalScale().clone();

    model.removeFromParent();
    model.setLocalTranslation(Vector3f.ZERO);
    model.setLocalRotation(Quaternion.IDENTITY);
    model.setLocalScale(1);
    //HACK ALERT change this
    //I remove the skeletonControl and readd it to the spatial to make sure it's after the ragdollControl in the stack
    //Find a proper way to order the controls.
    SkeletonControl sc = model.getControl(SkeletonControl.class);
    if(sc == null){
        throw new IllegalArgumentException("The root node of the model should have a SkeletonControl. Make sure the control is there and that it's not on a sub node.");
    }
    model.removeControl(sc);
    model.addControl(sc);

    if (boneList.isEmpty()) {
        // add all bones to the list
        skeleton = sc.getSkeleton();
        for (int boneI = 0; boneI < skeleton.getBoneCount(); boneI++) {
            String boneName = skeleton.getBone(boneI).getName();
            boneList.add(boneName);
        }
    }
    // filter out bones without vertices
    filterBoneList(sc);

    if (boneList.isEmpty()) {
        throw new IllegalArgumentException(
                "No suitable bones were found in the model's skeleton.");
    }

    // put into bind pose and compute bone transforms in model space
    // maybe don't reset to ragdoll out of animations?
    scanSpatial(model);


    if (parent != null) {
        parent.attachChild(model);

    }
    model.setLocalTranslation(initPosition);
    model.setLocalRotation(initRotation);
    model.setLocalScale(initScale);

    if (added) {
        addPhysics(space);
    }
    logger.log(Level.FINE, "Created physics ragdoll for skeleton {0}", skeleton);
}