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./*www.java2s.com*/
*
* 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.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.JointDef;
/**
* Pulley joint definition. This requires two ground anchors, two dynamic body
* anchor points, max lengths for each side, and a pulley ratio.
*/publicclass PulleyJointDef extends JointDef {
privatefinalstaticfloat minPulleyLength = 2.0f;
public PulleyJointDef() {
type = JointType.PulleyJoint;
collideConnected = true;
}
/**
* Initialize the bodies, anchors, lengths, max lengths, and ratio using the
* world anchors.
*/publicvoid initialize(Body bodyA, Body bodyB, Vector2 groundAnchorA, Vector2 groundAnchorB, Vector2 anchorA, Vector2 anchorB, float ratio) {
this.bodyA = bodyA;
this.bodyB = bodyB;
this.groundAnchorA.set(groundAnchorA);
this.groundAnchorB.set(groundAnchorB);
this.localAnchorA.set(bodyA.getLocalPoint(anchorA));
this.localAnchorB.set(bodyB.getLocalPoint(anchorB));
lengthA = anchorA.dst(groundAnchorA);
lengthB = anchorB.dst(groundAnchorB);
this.ratio = ratio;
float C = lengthA + ratio * lengthB;
}
/** The first ground anchor in world coordinates. This point never moves. */publicfinal Vector2 groundAnchorA = new Vector2(-1, 1);
/** The second ground anchor in world coordinates. This point never moves. */publicfinal Vector2 groundAnchorB = new Vector2(1, 1);
/** The local anchor point relative to bodyA's origin. */publicfinal Vector2 localAnchorA = new Vector2(-1, 0);
/** The local anchor point relative to bodyB's origin. */publicfinal Vector2 localAnchorB = new Vector2(1, 0);
/** The a reference length for the segment attached to bodyA. */publicfloat lengthA = 0;
/** The a reference length for the segment attached to bodyB. */publicfloat lengthB = 0;
/** The pulley ratio, used to simulate a block-and-tackle. */publicfloat ratio = 1;
}