| /* |
| * Copyright (c) 2009-2010 jMonkeyEngine |
| * All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions are |
| * met: |
| * |
| * * Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * |
| * * Redistributions in binary form must reproduce the above copyright |
| * notice, this list of conditions and the following disclaimer in the |
| * documentation and/or other materials provided with the distribution. |
| * |
| * * Neither the name of 'jMonkeyEngine' nor the names of its contributors |
| * may be used to endorse or promote products derived from this software |
| * without specific prior written permission. |
| * |
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| package com.jme3.bullet.joints; |
| |
| import com.jme3.bullet.objects.PhysicsRigidBody; |
| import com.jme3.math.Matrix3f; |
| import com.jme3.math.Vector3f; |
| |
| /** |
| * <i>From bullet manual:</i><br> |
| * This generic constraint can emulate a variety of standard constraints, |
| * by configuring each of the 6 degrees of freedom (dof). |
| * The first 3 dof axis are linear axis, which represent translation of rigidbodies, |
| * and the latter 3 dof axis represent the angular motion. Each axis can be either locked, |
| * free or limited. On construction of a new btGeneric6DofConstraint, all axis are locked. |
| * Afterwards the axis can be reconfigured. Note that several combinations that |
| * include free and/or limited angular degrees of freedom are undefined. |
| * @author normenhansen |
| */ |
| public class SixDofSpringJoint extends SixDofJoint { |
| |
| final boolean springEnabled[] = new boolean[6]; |
| final float equilibriumPoint[] = new float[6]; |
| final float springStiffness[] = new float[6]; |
| final float springDamping[] = new float[6]; // between 0 and 1 (1 == no damping) |
| |
| public SixDofSpringJoint() { |
| } |
| |
| /** |
| * @param pivotA local translation of the joint connection point in node A |
| * @param pivotB local translation of the joint connection point in node B |
| */ |
| public SixDofSpringJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Matrix3f rotA, Matrix3f rotB, boolean useLinearReferenceFrameA) { |
| super(nodeA, nodeB, pivotA, pivotB, rotA, rotB, useLinearReferenceFrameA); |
| } |
| public void enableSpring(int index, boolean onOff) { |
| enableSpring(objectId, index, onOff); |
| } |
| native void enableSpring(long objctId, int index, boolean onOff); |
| |
| public void setStiffness(int index, float stiffness) { |
| setStiffness(objectId, index, stiffness); |
| } |
| native void setStiffness(long objctId, int index, float stiffness); |
| |
| public void setDamping(int index, float damping) { |
| setDamping(objectId, index, damping); |
| |
| } |
| native void setDamping(long objctId, int index, float damping); |
| public void setEquilibriumPoint() { // set the current constraint position/orientation as an equilibrium point for all DOF |
| setEquilibriumPoint(objectId); |
| } |
| native void setEquilibriumPoint(long objctId); |
| public void setEquilibriumPoint(int index){ // set the current constraint position/orientation as an equilibrium point for given DOF |
| setEquilibriumPoint(objectId, index); |
| } |
| native void setEquilibriumPoint(long objctId, int index); |
| @Override |
| native long createJoint(long objectIdA, long objectIdB, Vector3f pivotA, Matrix3f rotA, Vector3f pivotB, Matrix3f rotB, boolean useLinearReferenceFrameA); |
| |
| } |