本文整理匯總了Java中com.jme3.math.Quaternion.fromAngles方法的典型用法代碼示例。如果您正苦於以下問題:Java Quaternion.fromAngles方法的具體用法?Java Quaternion.fromAngles怎麽用?Java Quaternion.fromAngles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.math.Quaternion
的用法示例。
在下文中一共展示了Quaternion.fromAngles方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateRotation
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
* Updating rotation.
*/
@FXThread
private void updateRotation(@Nullable final KeyEvent event) {
if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return;
final Quaternion oldValue = notNull(getPropertyValue());
final FloatTextField xField = getXField();
final float x = degreeToRadians(xField.getValue());
final FloatTextField yFiled = getYFiled();
final float y = degreeToRadians(yFiled.getValue());
final FloatTextField zField = getZField();
final float z = degreeToRadians(zField.getValue());
final Quaternion newValue = new Quaternion();
newValue.fromAngles(ArrayFactory.toFloatArray(x, y, z));
changed(newValue, oldValue.clone());
}
示例2: simpleUpdate
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public void simpleUpdate(float tpf){
Bone b = control.getSkeleton().getBone("spinehigh");
Bone b2 = control.getSkeleton().getBone("uparm.left");
angle += tpf * rate;
if (angle > FastMath.HALF_PI / 2f){
angle = FastMath.HALF_PI / 2f;
rate = -1;
}else if (angle < -FastMath.HALF_PI / 2f){
angle = -FastMath.HALF_PI / 2f;
rate = 1;
}
Quaternion q = new Quaternion();
q.fromAngles(0, angle, 0);
b.setUserControl(true);
b.setUserTransforms(Vector3f.ZERO, q, Vector3f.UNIT_XYZ);
b2.setUserControl(true);
b2.setUserTransforms(Vector3f.ZERO, Quaternion.IDENTITY, new Vector3f(1+angle,1+ angle, 1+angle));
}
示例3: setData
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public void setData(AnimData data) {
super.setData(data);
// 路徑點
String[] positions = data.getAsArray("waypoints");
if (positions != null) {
Vector3f[] waypoints = new Vector3f[positions.length];
for (int i = 0; i < positions.length; i++) {
waypoints[i] = ((Position)Loader.load(positions[i])).getPoint(null);
}
setControlPoints(Arrays.asList(waypoints));
}
float curveTension = data.getAsFloat("curveTension", 0.5f);
spline.setCurveTension(curveTension);
this.facePath = data.getAsBoolean("facePath", facePath);
Vector3f tempRotationOffset = data.getAsVector3f("rotationOffset");
if (tempRotationOffset != null) {
rotationOffset = new Quaternion();
rotationOffset.fromAngles(tempRotationOffset.x, tempRotationOffset.y, tempRotationOffset.z);
}
}
示例4: onRotationUpdated
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected void onRotationUpdated(Quaternion rotation) {
rotation.toAngles(tempAngles);
// 去掉x和z軸的旋轉
tempAngles[0] = 0;
tempAngles[2] = 0;
TempVars tv = TempVars.get();
Quaternion qua = tv.quat1;
qua.fromAngles(tempAngles);
target.getSpatial().setLocalRotation(qua);
Vector3f windDir = tv.vect1.set(0,0,1);
qua.mult(windDir, windDir);
target.setWindDirection(new Vector2f(windDir.x, windDir.z).normalizeLocal());
tv.release();
target.updateDatas();
notifyPropertyChanged("rotation", qua);
notifyPropertyChanged("windDirection", target.getWindDirection());
}
示例5: createMiniMapViewport
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
private void createMiniMapViewport() {
// Create a new camera (cloned from current)
Camera cam = app.getCamera();
mapCamera = cam.clone();
repositionCameraViewport();
// Position camera at player position and rotate it so it points
// downwards
camLoc = parent.getParent().getPlayerEntity().getSpatial().getLocalTranslation().clone();
mapCamera.setLocation(camLoc);
Quaternion q = new Quaternion();
q.fromAngles(FastMath.DEG_TO_RAD * 90f, FastMath.DEG_TO_RAD * 180f, 0);
mapCamera.setRotation(q);
// Create the viewport
mapViewport = app.getRenderManager().createMainView("View of camera #n", mapCamera);
mapViewport.setClearFlags(true, true, true);
// Filter prost processor for masking out the circular map
fpp = new FilterPostProcessor(assetManager);
maskFilter = new MaskFilter();
maskFilter.setMaskTexture(assetManager.loadTexture("Textures/NV/BinocularsMask.png"));
fpp.addFilter(maskFilter);
mapViewport.addProcessor(fpp);
// newGuiNode = new Node();
// newGuiNode.setQueueBucket(RenderQueue.Bucket.Gui);
// newGuiNode.setCullHint(Spatial.CullHint.Never);
// mapViewport.attachScene(newGuiNode);
mapViewport.attachScene(parent.getParent().getMappableNode());
// newGuiNode.updateGeometricState();
}
示例6: simpleUpdate
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public void simpleUpdate(float tpf){
Quaternion q = new Quaternion();
angle += tpf;
angle %= FastMath.TWO_PI;
q.fromAngles(angle, 0, angle);
offBox.setLocalRotation(q);
offBox.updateLogicalState(tpf);
offBox.updateGeometricState();
}
示例7: simpleUpdate
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public void simpleUpdate(float tpf){
Quaternion q = new Quaternion();
if (offView.isEnabled()) {
angle += tpf;
angle %= FastMath.TWO_PI;
q.fromAngles(angle, 0, angle);
offBox.setLocalRotation(q);
offBox.updateLogicalState(tpf);
offBox.updateGeometricState();
}
}
示例8: rotate
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
* Rotates the spatial by the yaw, roll and pitch angles (in radians),
* in the local coordinate space.
*
* @return The spatial on which this method is called, e.g <code>this</code>.
*/
public Spatial rotate(float yaw, float roll, float pitch) {
TempVars vars = TempVars.get();
Quaternion q = vars.quat1;
q.fromAngles(yaw, roll, pitch);
rotate(q);
vars.release();
return this;
}
示例9: parseInto
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
private void parseInto(String text, Quaternion res) throws IllegalArgumentException {
text = text.replace('[', ' ');
text = text.replace(']', ' ').trim();
String[] a = text.split("\\s*(,|\\s)\\s*");
if (a.length == 1) {
if (text.trim().toLowerCase().equals("nan")) {
res.set(Float.NaN, Float.NaN, Float.NaN, Float.NaN);
return;
}
float f = Float.parseFloat(text);
f = (float) Math.toRadians(f);
res.fromAngles(f, f, f);
return;
}
if (a.length == 3) {
float[] floats = new float[3];
for (int i = 0; i < a.length; i++) {
floats[i] = (float) Math.toRadians(Float.parseFloat(a[i]));
}
res.fromAngles(floats);
return;
}
throw new IllegalArgumentException("String not correct");
}
示例10: getAsQuaternion
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
* 獲取參數值,並以Quaternion形式返回,原始格式必須如: "x,y,z"<br>
* x,y,z分別表示在各個軸上的旋轉<STRONG>弧度</STRONG>數.如果參數長度不對,將返回null.
* @param value
* @return
*/
public final static Quaternion getAsQuaternion(Object value) {
if (value instanceof String) {
String[] arr = value.toString().split(",");
if (arr.length < 3)
return null;
Quaternion qua = new Quaternion();
qua.fromAngles(Float.parseFloat(arr[0]), Float.parseFloat(arr[1]), Float.parseFloat(arr[2]));
return qua;
}
return (Quaternion) value;
}
示例11: setSpawnRotation
import com.jme3.math.Quaternion; //導入方法依賴的package包/類
private void setSpawnRotation(Spawn spawn, Sprite spawnMarker) {
Quaternion rot = new Quaternion();
rot.fromAngles(0, 0, FastMath.DEG_TO_RAD * spawn.getRotation());
spawnMarker.center().move(MARKER_WIDTH / 2f, MARKER_HEIGHT / 2f, 0);
spawnMarker.setLocalRotation(rot);
}