public void reconstruct(final Vector3 top, final Vector3 bottom, final double radius) { // our temp vars final Vector3 localTranslation = Vector3.fetchTempInstance(); final Vector3 capsuleUp = Vector3.fetchTempInstance(); // first make the capsule the right shape height = top.distance(bottom); this.radius = radius; setGeometryData(); // now orient it in space. localTranslation.set(_localTransform.getTranslation()); top.add(bottom, localTranslation).multiplyLocal(.5); // rotation that takes us from 0,1,0 to the unit vector described by top/center. top.subtract(localTranslation, capsuleUp).normalizeLocal(); final Matrix3 rotation = Matrix3.fetchTempInstance(); rotation.fromStartEndLocal(Vector3.UNIT_Y, capsuleUp); _localTransform.setRotation(rotation); Vector3.releaseTempInstance(localTranslation); Vector3.releaseTempInstance(capsuleUp); Matrix3.releaseTempInstance(rotation); updateWorldTransform(false); }
public void reconstruct(final Vector3 top, final Vector3 bottom, final double radius) { // our temp vars final Vector3 localTranslation = Vector3.fetchTempInstance(); final Vector3 capsuleUp = Vector3.fetchTempInstance(); // first make the capsule the right shape height = top.distance(bottom); this.radius = radius; setGeometryData(); // now orient it in space. localTranslation.set(_localTransform.getTranslation()); top.add(bottom, localTranslation).multiplyLocal(.5); // rotation that takes us from 0,1,0 to the unit vector described by top/center. top.subtract(localTranslation, capsuleUp).normalizeLocal(); final Matrix3 rotation = Matrix3.fetchTempInstance(); rotation.fromStartEndLocal(Vector3.UNIT_Y, capsuleUp); _localTransform.setRotation(rotation); Vector3.releaseTempInstance(localTranslation); Vector3.releaseTempInstance(capsuleUp); Matrix3.releaseTempInstance(rotation); updateWorldTransform(false); }