Android Open Source - gameengine Prismatic Joint






From Project

Back to project page gameengine.

License

The source code is released under:

Apache License

If you think the Android project gameengine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*******************************************************************************
 * Copyright 2011 See AUTHORS file.//from w  w w  .  ja v  a  2  s  .  co  m
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package com.badlogic.gdx.physics.box2d.joints;

import com.badlogic.gdx.physics.box2d.Joint;
import com.badlogic.gdx.physics.box2d.World;

/**
 * A prismatic joint. This joint provides one degree of freedom: translation
 * along an axis fixed in body1. Relative rotation is prevented. You can use a
 * joint limit to restrict the range of motion and a joint motor to drive the
 * motion or to model joint friction.
 */
public class PrismaticJoint extends Joint {
    /*
     * JNI #include <Box2D/Box2D.h>
     */

    public PrismaticJoint(World world, long addr) {
        super(world, addr);
    }

    /** Get the current joint translation, usually in meters. */
    public float getJointTranslation() {
        return jniGetJointTranslation(addr);
    }

    private native float jniGetJointTranslation(long addr); /*
                                                             * b2PrismaticJoint*
                                                             * joint =
                                                             * (b2PrismaticJoint
                                                             * *)addr; return
                                                             * joint
                                                             * ->GetJointTranslation
                                                             * ();
                                                             */

    /** Get the current joint translation speed, usually in meters per second. */
    public float getJointSpeed() {
        return jniGetJointSpeed(addr);
    }

    private native float jniGetJointSpeed(long addr); /*
                                                       * b2PrismaticJoint* joint
                                                       * =
                                                       * (b2PrismaticJoint*)addr
                                                       * ; return
                                                       * joint->GetJointSpeed();
                                                       */

    /** Is the joint limit enabled? */
    public boolean isLimitEnabled() {
        return jniIsLimitEnabled(addr);
    }

    private native boolean jniIsLimitEnabled(long addr); /*
                                                          * b2PrismaticJoint*
                                                          * joint =
                                                          * (b2PrismaticJoint
                                                          * *)addr; return
                                                          * joint-
                                                          * >IsLimitEnabled();
                                                          */

    /** Enable/disable the joint limit. */
    public void enableLimit(boolean flag) {
        jniEnableLimit(addr, flag);
    }

    private native void jniEnableLimit(long addr, boolean flag); /*
                                                                  * b2PrismaticJoint
                                                                  * * joint = (
                                                                  * b2PrismaticJoint
                                                                  * *)addr;
                                                                  * joint
                                                                  * ->EnableLimit
                                                                  * (flag);
                                                                  */

    /** Get the lower joint limit, usually in meters. */
    public float getLowerLimit() {
        return jniGetLowerLimit(addr);
    }

    private native float jniGetLowerLimit(long addr); /*
                                                       * b2PrismaticJoint* joint
                                                       * =
                                                       * (b2PrismaticJoint*)addr
                                                       * ; return
                                                       * joint->GetLowerLimit();
                                                       */

    /** Get the upper joint limit, usually in meters. */
    public float getUpperLimit() {
        return jniGetUpperLimit(addr);
    }

    private native float jniGetUpperLimit(long addr); /*
                                                       * b2PrismaticJoint* joint
                                                       * =
                                                       * (b2PrismaticJoint*)addr
                                                       * ; return
                                                       * joint->GetUpperLimit();
                                                       */

    /** Set the joint limits, usually in meters. */
    public void setLimits(float lower, float upper) {
        jniSetLimits(addr, lower, upper);
    }

    private native void jniSetLimits(long addr, float lower, float upper); /*
                                                                            * b2PrismaticJoint
                                                                            * *
                                                                            * joint
                                                                            * =
                                                                            * (
                                                                            * b2PrismaticJoint
                                                                            * *
                                                                            * )addr
                                                                            * ;
                                                                            * joint
                                                                            * ->
                                                                            * SetLimits
                                                                            * (
                                                                            * lower
                                                                            * ,
                                                                            * upper
                                                                            * );
                                                                            */

    /** Is the joint motor enabled? */
    public boolean isMotorEnabled() {
        return jniIsMotorEnabled(addr);
    }

    private native boolean jniIsMotorEnabled(long addr); /*
                                                          * b2PrismaticJoint*
                                                          * joint =
                                                          * (b2PrismaticJoint
                                                          * *)addr; return
                                                          * joint-
                                                          * >IsMotorEnabled();
                                                          */

    /** Enable/disable the joint motor. */
    public void enableMotor(boolean flag) {
        jniEnableMotor(addr, flag);
    }

    private native void jniEnableMotor(long addr, boolean flag); /*
                                                                  * b2PrismaticJoint
                                                                  * * joint = (
                                                                  * b2PrismaticJoint
                                                                  * *)addr;
                                                                  * joint
                                                                  * ->EnableMotor
                                                                  * (flag);
                                                                  */

    /** Set the motor speed, usually in meters per second. */
    public void setMotorSpeed(float speed) {
        jniSetMotorSpeed(addr, speed);
    }

    private native void jniSetMotorSpeed(long addr, float speed); /*
                                                                   * b2PrismaticJoint
                                                                   * * joint = (
                                                                   * b2PrismaticJoint
                                                                   * *)addr;
                                                                   * joint
                                                                   * ->SetMotorSpeed
                                                                   * (speed);
                                                                   */

    /** Get the motor speed, usually in meters per second. */
    public float getMotorSpeed() {
        return jniGetMotorSpeed(addr);
    }

    private native float jniGetMotorSpeed(long addr); /*
                                                       * b2PrismaticJoint* joint
                                                       * =
                                                       * (b2PrismaticJoint*)addr
                                                       * ; return
                                                       * joint->GetMotorSpeed();
                                                       */

    /** Set the maximum motor force, usually in N. */
    public void setMaxMotorForce(float force) {
        jniSetMaxMotorForce(addr, force);
    }

    private native void jniSetMaxMotorForce(long addr, float force); /*
                                                                      * b2PrismaticJoint
                                                                      * * joint
                                                                      * = (
                                                                      * b2PrismaticJoint
                                                                      * *)addr;
                                                                      * joint->
                                                                      * SetMaxMotorForce
                                                                      * (force);
                                                                      */

    /** Get the current motor force given the inverse time step, usually in N. */
    public float getMotorForce(float invDt) {
        return jniGetMotorForce(addr, invDt);
    }

    private native float jniGetMotorForce(long addr, float invDt); /*
                                                                    * b2PrismaticJoint
                                                                    * * joint =
                                                                    * (
                                                                    * b2PrismaticJoint
                                                                    * *)addr;
                                                                    * return
                                                                    * joint->
                                                                    * GetMotorForce
                                                                    * (invDt);
                                                                    */
}




Java Source Code List

com.badlogic.gdx.math.MathUtils.java
com.badlogic.gdx.math.Matrix3.java
com.badlogic.gdx.math.Matrix4.java
com.badlogic.gdx.math.Quaternion.java
com.badlogic.gdx.math.Vector2.java
com.badlogic.gdx.math.Vector3.java
com.badlogic.gdx.physics.box2d.BodyDef.java
com.badlogic.gdx.physics.box2d.Body.java
com.badlogic.gdx.physics.box2d.ChainShape.java
com.badlogic.gdx.physics.box2d.CircleShape.java
com.badlogic.gdx.physics.box2d.ContactFilter.java
com.badlogic.gdx.physics.box2d.ContactImpulse.java
com.badlogic.gdx.physics.box2d.ContactListener.java
com.badlogic.gdx.physics.box2d.Contact.java
com.badlogic.gdx.physics.box2d.DestructionListener.java
com.badlogic.gdx.physics.box2d.EdgeShape.java
com.badlogic.gdx.physics.box2d.Filter.java
com.badlogic.gdx.physics.box2d.FixtureDef.java
com.badlogic.gdx.physics.box2d.Fixture.java
com.badlogic.gdx.physics.box2d.JointDef.java
com.badlogic.gdx.physics.box2d.JointEdge.java
com.badlogic.gdx.physics.box2d.Joint.java
com.badlogic.gdx.physics.box2d.Manifold.java
com.badlogic.gdx.physics.box2d.MassData.java
com.badlogic.gdx.physics.box2d.PolygonShape.java
com.badlogic.gdx.physics.box2d.QueryCallback.java
com.badlogic.gdx.physics.box2d.RayCastCallback.java
com.badlogic.gdx.physics.box2d.Shape.java
com.badlogic.gdx.physics.box2d.Transform.java
com.badlogic.gdx.physics.box2d.WorldManifold.java
com.badlogic.gdx.physics.box2d.World.java
com.badlogic.gdx.physics.box2d.joints.DistanceJointDef.java
com.badlogic.gdx.physics.box2d.joints.DistanceJoint.java
com.badlogic.gdx.physics.box2d.joints.FrictionJointDef.java
com.badlogic.gdx.physics.box2d.joints.FrictionJoint.java
com.badlogic.gdx.physics.box2d.joints.GearJointDef.java
com.badlogic.gdx.physics.box2d.joints.GearJoint.java
com.badlogic.gdx.physics.box2d.joints.MouseJointDef.java
com.badlogic.gdx.physics.box2d.joints.MouseJoint.java
com.badlogic.gdx.physics.box2d.joints.PrismaticJointDef.java
com.badlogic.gdx.physics.box2d.joints.PrismaticJoint.java
com.badlogic.gdx.physics.box2d.joints.PulleyJointDef.java
com.badlogic.gdx.physics.box2d.joints.PulleyJoint.java
com.badlogic.gdx.physics.box2d.joints.RevoluteJointDef.java
com.badlogic.gdx.physics.box2d.joints.RevoluteJoint.java
com.badlogic.gdx.physics.box2d.joints.RopeJointDef.java
com.badlogic.gdx.physics.box2d.joints.RopeJoint.java
com.badlogic.gdx.physics.box2d.joints.WeldJointDef.java
com.badlogic.gdx.physics.box2d.joints.WeldJoint.java
com.badlogic.gdx.physics.box2d.joints.WheelJointDef.java
com.badlogic.gdx.physics.box2d.joints.WheelJoint.java
com.badlogic.gdx.utils.Array.java
com.badlogic.gdx.utils.ComparableTimSort.java
com.badlogic.gdx.utils.Disposable.java
com.badlogic.gdx.utils.GdxRuntimeException.java
com.badlogic.gdx.utils.LongArray.java
com.badlogic.gdx.utils.LongMap.java
com.badlogic.gdx.utils.NumberUtils.java
com.badlogic.gdx.utils.Pool.java
com.badlogic.gdx.utils.Sort.java
com.badlogic.gdx.utils.StringBuilder.java
com.badlogic.gdx.utils.TimSort.java
com.garrapeta.MathUtils.java
com.garrapeta.gameengine.Actor.java
com.garrapeta.gameengine.AsyncGameMessage.java
com.garrapeta.gameengine.BitmapManager.java
com.garrapeta.gameengine.Box2DActor.java
com.garrapeta.gameengine.Box2DWorld.java
com.garrapeta.gameengine.GameMessage.java
com.garrapeta.gameengine.GameView.java
com.garrapeta.gameengine.GameWorld.java
com.garrapeta.gameengine.ShapeDrawer.java
com.garrapeta.gameengine.SyncGameMessage.java
com.garrapeta.gameengine.Viewport.java
com.garrapeta.gameengine.actor.Box2DAtomicActor.java
com.garrapeta.gameengine.actor.Box2DCircleActor.java
com.garrapeta.gameengine.actor.Box2DEdgeActor.java
com.garrapeta.gameengine.actor.Box2DLoopActor.java
com.garrapeta.gameengine.actor.Box2DOpenChainActor.java
com.garrapeta.gameengine.actor.Box2DPolygonActor.java
com.garrapeta.gameengine.actor.IAtomicActor.java
com.garrapeta.gameengine.actor.SimpleActor.java
com.garrapeta.gameengine.module.LevelActionsModule.java
com.garrapeta.gameengine.module.LoadedLevelActionsModule.java
com.garrapeta.gameengine.module.SoundModule.java
com.garrapeta.gameengine.module.VibrationModule.java
com.garrapeta.gameengine.utils.IOUtils.java
com.garrapeta.gameengine.utils.LogX.java
com.garrapeta.gameengine.utils.PhysicsUtils.java
com.garrapeta.gameengine.utils.Pool.java