/** * <code>update</code> moves a spatial along the given curve for along a time period. * * @see com.jme.scene.Controller#update(float) */ public void update(float time) { if (mover == null || curve == null || up == null) { return; } currentTime += time * getSpeed(); if (currentTime >= getMinTime() && currentTime <= getMaxTime()) { if (getRepeatType() == RT_CLAMP) { deltaTime = currentTime - getMinTime(); mover.setLocalTranslation(curve.getPoint(deltaTime, mover.getLocalTranslation())); if (autoRotation) { mover.setLocalRotation(curve.getOrientation(deltaTime, orientationPrecision, up)); } } else if (getRepeatType() == RT_WRAP) { deltaTime = (currentTime - getMinTime()) % 1.0f; if (deltaTime > 1) { currentTime = 0; deltaTime = 0; } mover.setLocalTranslation(curve.getPoint(deltaTime, mover.getLocalTranslation())); if (autoRotation) { mover.setLocalRotation(curve.getOrientation(deltaTime, orientationPrecision, up)); } } else if (getRepeatType() == RT_CYCLE) { float prevTime = deltaTime; deltaTime = (currentTime - getMinTime()) % 1.0f; if (prevTime > deltaTime) { cycleForward = !cycleForward; } if (cycleForward) { mover.setLocalTranslation(curve.getPoint(deltaTime, mover.getLocalTranslation())); if (autoRotation) { mover.setLocalRotation(curve.getOrientation(deltaTime, orientationPrecision, up)); } } else { mover.setLocalTranslation(curve.getPoint(1.0f - deltaTime, mover.getLocalTranslation())); if (autoRotation) { mover.setLocalRotation( curve.getOrientation(1.0f - deltaTime, orientationPrecision, up)); } } } else { return; } } }
public static void deepRotate(Spatial s, int x, int y, int z) { Quaternion q = s.getLocalRotation(); // only transform objects with non-zero rotation if (q.x != 0 || q.y != 0 || q.z != 0 || q.w != 1) { s.setLocalRotation(q.addLocal(Rotator.fromThreeAngles(x, y, z))); } if (s instanceof Node) { if (((Node) s).getChildren() != null) { for (Spatial child : ((Node) s).getChildren()) { deepRotate(child, x, y, z); } } } }
public void setNode3Quat(Quaternion newQuat) { node3theSpatial.setLocalRotation(newQuat); ClientContextJME.getWorldManager().addToUpdateList(node3theSpatial); }