本文整理汇总了Java中com.jme3.math.Quaternion.mult方法的典型用法代码示例。如果您正苦于以下问题:Java Quaternion.mult方法的具体用法?Java Quaternion.mult怎么用?Java Quaternion.mult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.math.Quaternion
的用法示例。
在下文中一共展示了Quaternion.mult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rotateUpTo
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
/**
* <code>rotateUpTo</code> is a utility function that alters the
* local rotation to point the Y axis in the direction given by newUp.
*
* @param newUp
* the up vector to use - assumed to be a unit vector.
*/
public void rotateUpTo(Vector3f newUp) {
TempVars vars = TempVars.get();
Vector3f compVecA = vars.vect1;
Quaternion q = vars.quat1;
// First figure out the current up vector.
Vector3f upY = compVecA.set(Vector3f.UNIT_Y);
Quaternion rot = localTransform.getRotation();
rot.multLocal(upY);
// get angle between vectors
float angle = upY.angleBetween(newUp);
// figure out rotation axis by taking cross product
Vector3f rotAxis = upY.crossLocal(newUp).normalizeLocal();
// Build a rotation quat and apply current local rotation.
q.fromAngleNormalAxis(angle, rotAxis);
q.mult(rot, rot);
vars.release();
setTransformRefresh();
}
示例2: getRotation
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
/**
* Get the Rotation into a specific custom space.
*
* @param transform the rotation to the custom space (World to Custom
* space)
* @return the Rotation in the custom space
*/
public Quaternion getRotation(Quaternion transform) {
if (startPickLoc == null) {
Logger.getLogger(this.getClass().getSimpleName()).warning("startPickLoc null in PickManager#getRotation()");
return transform;
} else if (finalPickLoc == null) {
Logger.getLogger(this.getClass().getSimpleName()).warning("finalPickLoc null in PickManager#getRotation()");
return transform;
}
Vector3f v1, v2;
v1 = transform.mult(startPickLoc.subtract(startSpatialLocation).normalize());
v2 = transform.mult(finalPickLoc.subtract(startSpatialLocation).normalize());
Vector3f axis = v1.cross(v2);
float angle = v1.angleBetween(v2);
return new Quaternion().fromAngleAxis(angle, axis);
}
示例3: create
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
private void create() {
if (haloRoot != null) {
haloRoot.removeFromParent();
}
// -- 初始化创建所有光晕
haloRoot = new Node("CircleHalo_root");
float angle = FastMath.TWO_PI / haloTotal;
TempVars tv = TempVars.get();
Vector3f lookAt = tv.vect1.set(0, incline, 0);
Vector3f pos = tv.vect2;
Vector3f size = tv.vect3.set(1,1,1).multLocal(haloSize);
Quaternion rot = tv.quat1;
for (int i = 0; i < haloTotal; i++) {
pos.zero().setX(radius);
if (i == 0) {
haloRoot.attachChild(createHaloOne(texture, pos, size, lookAt));
} else {
MathUtils.createRotation(angle * i, Vector3f.UNIT_Y, rot);
rot.mult(pos, pos);
haloRoot.attachChild(createHaloOne(texture, pos, size, lookAt));
}
}
tv.release();
this.animNode.attachChild(haloRoot);
}
示例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: onEntityEachTick
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
@Override
protected void onEntityEachTick(Entity e) {
Spatial s = SpatialPool.models.get(e.getId());
if(s == null) {
return;
}
PlanarStance stance = e.get(PlanarStance.class);
// translation
s.setLocalTranslation(TranslateUtil.toVector3f(stance.getCoord().get3D(stance.getElevation())));
// rotation
Quaternion r = new Quaternion();
Point3D pu = stance.getUpVector();
Point3D pv = Point3D.UNIT_X.getRotationAroundZ(stance.getOrientation().getValue());
Vector3f u = TranslateUtil.toVector3f(pu).normalize();
Vector3f v = TranslateUtil.toVector3f(pv).normalize();
r.lookAt(v, u);
double angle = Math.acos(pu.getDotProduct(pv) / (pu.getNorm() * pv.getNorm()));
r = r.mult(new Quaternion().fromAngles((float) (-angle), 0, 0));
s.setLocalRotation(r);
}
示例6: tick
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
@Override
public AirfoilResponse tick(float airDensity, Vector3f flow, Vector3f angV) {
Quaternion damp = damp(angV);
flow = damp.mult(flow);
float aoa = calcAoa(flow);
Vector3f lift = lift(airDensity, flow,aoa);
Vector3f inducedDrag = inducedDrag(airDensity, flow,lift);
Vector3f linear = lift.add(inducedDrag);
Vector3f torque = cog.cross(linear);
return new AirfoilResponse(damp, aoa, lift, inducedDrag, linear, torque);
}
示例7: setPhysicsRotation
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
@Override
public void setPhysicsRotation(Quaternion rotation) {
super.setPhysicsRotation(rotation);
TempVars tv = TempVars.get();
rotation.mult(localForward, tv.vect1);
setViewDirection(tv.vect1);
tv.release();
}
示例8: convertWaypointToWorld
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
/**
* 将本地中间路径点转化为Bullet坐标系下的世界坐标点.
* @param startPos
* @param endPos
* @param localWaypoint
* @return
*/
private void convertWaypointToWorld(Vector3f startPos, Vector3f endPos, Vector3f localWaypoint) {
TempVars tv = TempVars.get();
Vector3f dir = tv.vect1;
Quaternion rot = tv.quat1;
endPos.subtract(startPos, dir).normalizeLocal();
rot.lookAt(dir, up);
rot.mult(localWaypoint, localWaypoint);
localWaypoint.addLocal(startPos);
tv.release();
}
示例9: 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);
}
}
示例10: onRotationUpdated
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
@Override
protected void onRotationUpdated(Quaternion rotation) {
Vector3f dir = target.getLight().getDirection().set(Vector3f.UNIT_Z);
rotation.mult(dir, dir);
target.getLight().setDirection(dir);
target.updateDatas();
notifyPropertyChanged("direction", dir);
}
示例11: onRotationUpdated
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
@Override
protected void onRotationUpdated(Quaternion rotation) {
Vector3f dir = target.getDirection().set(Vector3f.UNIT_Z);
rotation.mult(dir, dir);
target.setDirection(dir);
target.updateDatas();
notifyPropertyChanged("direction", dir);
}
示例12: getRotation
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
/**
* Get the Rotation into a specific custom space.
* @param transforme the rotation to the custom space (World to Custom space)
* @return the Rotation in the custom space
*/
public Quaternion getRotation(Quaternion transforme) {
Vector3f v1, v2;
v1 = transforme.mult(startPickLoc.subtract(startSpatialLocation).normalize());
v2 = transforme.mult(endPickLoc.subtract(startSpatialLocation).normalize());
Vector3f axis = v1.cross(v2);
float angle = v1.angleBetween(v2);
return new Quaternion().fromAngleAxis(angle, axis);
}
示例13: getRotation
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
/**
* Get the Rotation into a specific custom space.
*
* @param transforme the rotation to the custom space (World to Custom
* space)
* @return the Rotation in the custom space
*/
public Quaternion getRotation(Quaternion transforme) {
Vector3f v1, v2;
v1 = transforme.mult(startPickLoc.subtract(startSpatialLocation).normalize());
v2 = transforme.mult(finalPickLoc.subtract(startSpatialLocation).normalize());
Vector3f axis = v1.cross(v2);
float angle = v1.angleBetween(v2);
return new Quaternion().fromAngleAxis(angle, axis);
}
示例14: onEntityUpdated
import com.jme3.math.Quaternion; //导入方法依赖的package包/类
@Override
protected void onEntityUpdated(Entity e) {
Model model = e.get(Model.class);
Spatial s = SpatialPool.models.get(e.getId());
if(s == null) {
return;
}
PlanarStance stance = e.get(PlanarStance.class);
// translation
s.setLocalTranslation(TranslateUtil.toVector3f(stance.getCoord().get3D(stance.getElevation())));
// rotation
Quaternion r = new Quaternion();
Point3D pu = stance.getUpVector();
Point3D pv = Point3D.UNIT_X.getRotationAroundZ(stance.getOrientation().getValue());
Vector3f u = TranslateUtil.toVector3f(pu).normalize();
Vector3f v = TranslateUtil.toVector3f(pv).normalize();
r.lookAt(v, u);
// we correct the pitch of the unit because the direction is always flatten
// this is only to follow the terrain relief
double angle = Math.acos(pu.getDotProduct(pv) / (pu.getNorm() * pv.getNorm()));
r = r.mult(new Quaternion().fromAngles((float) (-angle+AngleUtil.RIGHT+model.pitchFix.getValue()), (float) (model.rollFix.getValue()), (float) (model.yawFix.getValue())));
s.setLocalRotation(r);
}
示例15: 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);
}
}