本文整理匯總了Java中com.jme3.math.Quaternion.fromAngleAxis方法的典型用法代碼示例。如果您正苦於以下問題:Java Quaternion.fromAngleAxis方法的具體用法?Java Quaternion.fromAngleAxis怎麽用?Java Quaternion.fromAngleAxis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.math.Quaternion
的用法示例。
在下文中一共展示了Quaternion.fromAngleAxis方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateDraw
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
void updateDraw(float tpf) {
Vector2 vector2 = body.getTransform().getTranslation();
this.spatial.setLocalTranslation(
new Float(vector2.x),
new Float(vector2.y), 0f);
Transform transform = body.getTransform();
if (transform.getTranslation().x == lastTransform.getTranslation().x &&
transform.getTranslation().y == lastTransform.getTranslation().y) {
this.spatial.setLocalTranslation(
new Vector3f(
new Float(transform.getTranslation().x),
new Float(transform.getTranslation().y),
0f));
lastTransform=transform;
}
Double angle = body.getTransform().getRotation();
if (angle != lastAngle) {
Quaternion roll = new Quaternion();
roll.fromAngleAxis( new Float(angle) , Vector3f.UNIT_Z);
this.spatial.setLocalRotation(roll);
lastAngle = angle;
}
}
示例2: update
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
public void update() {
Vector3f targetTranslation = followTarget.getWorldTranslation();
Vector3f distanceTranslation = followTarget.getLocalRotation().
mult(Vector3f.UNIT_Z).mult(distance);
camera.setLocation(targetTranslation.add(distanceTranslation));
Quaternion rotation = new Quaternion();
rotation.fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y);
rotation = followTarget.getWorldRotation().mult(rotation);
camera.setRotation(rotation);
}
示例3: simpleUpdate
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public void simpleUpdate(float tpf){
// Rotate around X axis
Quaternion rotate = new Quaternion();
rotate.fromAngleAxis(tpf, Vector3f.UNIT_X);
// Combine rotation with previous
rotation.multLocal(rotate);
// Set new rotation into bone
bone.setUserTransforms(Vector3f.ZERO, rotation, Vector3f.UNIT_XYZ);
// After changing skeleton transforms, must update world data
skeleton.updateWorldVectors();
}
示例4: am2jme_rotation
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
Quaternion am2jme_rotation(Rotation r) {
if (r == null)
return null;
Quaternion q = new Quaternion();
q.fromAngleAxis((float) r.getAngle(), am2jme_vector(r.getAxis()));
return q;
}
示例5: loadAnimModel
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
private Spatial loadAnimModel() {
// 生成路徑點
if (fixedPoints == null) {
fixedPoints = new Vector3f[randomPoints.length];
for (int i = 0; i < randomPoints.length; i++) {
Vector3f point = new Vector3f();
((Position)Loader.load(randomPoints[i])).getPoint(point);
fixedPoints[i] = point;
}
}
MySpline spline = createSpline(fixedPoints, tension, cycle);
if(dimension > 1) {
// 計算出實際的維度旋轉軸
TempVars tv = TempVars.get();
Vector3f nextPoint = tv.vect1;
Vector3f forward = tv.vect2;
Vector3f left = tv.vect3;
Vector3f rotAxis = tv.vect4;
spline.getSplinePoint(spline.getTotalLength() / segments, nextPoint);
nextPoint.subtract(spline.getControlPoints().get(0), forward).normalizeLocal();
up.cross(forward, left).normalizeLocal();
left.cross(up, rotAxis).normalizeLocal();
Quaternion qua = new Quaternion();
Vector3f tempUp = tv.vect5;
float angle = FastMath.PI / dimension;
Node animNode = new Node();
for (int i = 0; i < dimension; i++) {
qua.fromAngleAxis(angle * i, rotAxis);
qua.mult(up, tempUp);
animNode.attachChild(createSurface(spline, tempUp));
}
tv.release();
return animNode;
} else {
return createSurface(spline, up);
}
}
示例6: postInitialize
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected final void postInitialize() {
flyCamera = app.getFlyByCamera().isEnabled();
mouseManager = parent.getMouseManager();
stateManager.attach(gameKeysState = new GameKeysAppState());
// Player
playerEntity = parent.getPlayerEntity();
// Camera
Quaternion rot = new Quaternion();
rot.fromAngleAxis(0, Vector3f.UNIT_X);
rot.fromAngleAxis(0, Vector3f.UNIT_Y);
rot.fromAngleAxis(0, Vector3f.UNIT_Z);
this.app.getCamera().setRotation(rot);
camNode = new CameraNode("CamNode", this.app.getCamera());
camNode.setControlDir(CameraControl.ControlDirection.CameraToSpatial);
camNode.setEnabled(true);
camNode.lookAt(playerEntity.getSpatial().getLocalTranslation(), Vector3f.UNIT_Y);
chaseCam = new DetachableChaseCam(camNode.getCamera(), playerEntity.getSpatial(), inputManager) {
@Override
protected void followView(float rotation) {
}
};
chaseCam.setPushZoom(true);
chaseCam.setHeightAdjust(-5f);
chaseCam.setLookAtOffset(new Vector3f(0, 20, 0));
chaseCam.setSmoothMotion(false);
chaseCam.setDownRotateOnCloseViewOnly(true);
chaseCam.setInvertVerticalAxis(true);
chaseCam.setChasingSensitivity(5f);
chaseCam.setDragToRotate(true);
chaseCam.setTrailingEnabled(true);
chaseCam.setDefaultDistance(56);
chaseCam.setMaxDistance(200);
chaseCam.setRotationSpeed(Constants.CAMERA_ROTATE_SPEED);
chaseCam.setZoomSensitivity(Constants.CAMERA_ZOOM_SENSITIVITY);
chaseCam.setDefaultHorizontalRotation(-FastMath.DEG_TO_RAD * 90);
chaseCam.setDefaultVerticalRotation(FastMath.DEG_TO_RAD * 10);
app.getFlyByCamera().setEnabled(false);
// NOTE - This is important, the camera needs to be added once the
// player spatial is actually fully
// loaded or we'll get this weird flickering in physics. This took AGES
// to find
if (playerEntity.isLoadedScene()) {
playerEntity.getSpatial().addControl(chaseCam);
} else {
playerEntity.invoke(AbstractLoadableEntity.When.AFTER_SCENE_LOADED, new Callable<Void>() {
public Void call() throws Exception {
playerEntity.getSpatial().addControl(chaseCam);
return null;
}
});
}
}
示例7: loadAnimModel
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected final Spatial loadAnimModel() {
fixedPoints = data.getAsVector3fArray("fixedPoints");
randomPoints = data.getAsArray("randomPoints");
width = data.getAsFloat("width", width);
segments = data.getAsInteger("segments", segments);
tension = data.getAsFloat("tension", tension);
cycle = data.getAsBoolean("cycle", cycle);
up = data.getAsVector3f("up", up).normalizeLocal();
dimension = data.getAsInteger("dimension", dimension);
if (fixedPoints == null && randomPoints == null)
throw new NullPointerException("need fixedPoints or randomPoints");
// 生成路徑點
if (fixedPoints == null) {
fixedPoints = new Vector3f[randomPoints.length];
for (int i = 0; i < randomPoints.length; i++) {
Vector3f point = new Vector3f();
((Position)Loader.load(randomPoints[i])).getPoint(point);
fixedPoints[i] = point;
}
}
MySpline spline = createSpline(fixedPoints, tension, cycle);
if(dimension > 1) {
// 計算出實際的維度旋轉軸
TempVars tv = TempVars.get();
Vector3f nextPoint = tv.vect1;
Vector3f forward = tv.vect2;
Vector3f left = tv.vect3;
Vector3f rotAxis = tv.vect4;
spline.getSplinePoint(spline.getTotalLength() / segments, nextPoint);
nextPoint.subtract(spline.getControlPoints().get(0), forward).normalizeLocal();
up.cross(forward, left).normalizeLocal();
left.cross(up, rotAxis).normalizeLocal();
Quaternion qua = new Quaternion();
Vector3f tempUp = tv.vect5;
float angle = FastMath.PI / dimension;
Node animObject = new Node();
for (int i = 0; i < dimension; i++) {
qua.fromAngleAxis(angle * i, rotAxis);
qua.mult(up, tempUp);
animObject.attachChild(createSurface(spline, tempUp));
}
tv.release();
return animObject;
} else {
return createSurface(spline, up);
}
}
示例8: initialize
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public void initialize() {
super.initialize();
skillModule = actor.getModule(SkillModule.class);
// 初始化巡邏點坐標,如果沒有指別設置角色的出生地點則將當前世界位置作為巡邏
// 的原點,並在這個原點上向四周生成幾個巡邏坐標點。
if (idlePositions == null) {
if (bornPlace == null) {
bornPlace = new Vector3f(actor.getSpatial().getWorldTranslation());
}
patrolOrgin.set(bornPlace);
// 生成可用idle坐標點.
// 邏輯:隨機在角色原始坐標的周圍生成幾個idle坐標點.
idlePositions = new ArrayList<Vector3f>(walkPosTotal);
int angle = 360 / walkPosTotal;
int startAngle = FastMath.nextRandomInt(0, 180);
Vector3f startPoint = new Vector3f(0, 0, walkRadius);
Quaternion quater = new Quaternion();
idlePositions.add(patrolOrgin.clone());
for (int i = 0; i < walkPosTotal; i++) {
quater.fromAngleAxis((startAngle + angle * i) * FastMath.DEG_TO_RAD
, Vector3f.UNIT_Y.clone());
Vector3f pos = quater.mult(startPoint);
idlePositions.add(pos.addLocal(patrolOrgin));
}
currentPos = idlePositions.get(FastMath.nextRandomInt(0, idlePositions.size() - 1));
// debug
// DebugUtils.debugPoints(idlePositions, actor.getActor().getParent());
}
rayDetour.setActor(actor);
rayDetour.setAutoFacing(true);
rayDetour.setUseRun(false);
List<Skill> waitSkills = skillModule.getSkillWait(null);
if (waitSkills != null && !waitSkills.isEmpty()) {
waitSkill = waitSkills.get(0);
}
List<Skill> walkSkills = skillModule.getSkillWalk(null);
if (walkSkills != null && !walkSkills.isEmpty()) {
walkSkill = walkSkills.get(0);
}
List<Skill> runSkills = skillModule.getSkillRun(null);
if (runSkills != null && !runSkills.isEmpty()) {
runSkill = runSkills.get(0);
}
// 緩存IDLE技能並添加偵聽器
recacheIdleSkill();
actor.addDataListener(this);
}