本文整理汇总了Java中javax.vecmath.Quat4f.mul方法的典型用法代码示例。如果您正苦于以下问题:Java Quat4f.mul方法的具体用法?Java Quat4f.mul怎么用?Java Quat4f.mul使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.vecmath.Quat4f
的用法示例。
在下文中一共展示了Quat4f.mul方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseRotation
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public static Quat4f parseRotation(JsonElement e)
{
if (e.isJsonArray())
{
if (e.getAsJsonArray().get(0).isJsonObject())
{
Quat4f ret = new Quat4f(0, 0, 0, 1);
for (JsonElement a : e.getAsJsonArray())
{
ret.mul(parseAxisRotation(a));
}
return ret;
}
else
{
// quaternion
return new Quat4f(parseFloatArray(e, 4, "Rotation"));
}
}
else if (e.isJsonObject())
{
return parseAxisRotation(e);
}
else throw new JsonParseException("Rotation: expected array or object, got: " + e);
}
示例2: applyInitTransform
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public void applyInitTransform(List<Vector3f> helperPoints) {
float shiftX = shift.getX() + initialShift.getX();
float shiftY = shift.getY() + initialShift.getY();
float shiftZ = shift.getZ() + initialShift.getZ();
Quat4f rotationQuat = new Quat4f(0,0,0,1) ;
rotationQuat.mul(rotQuat,initRotQuat);
for (int i = 0; i < helperPoints.size(); i++) {
Vector3f vert = new Vector3f();
vert.setX(helperPoints.get(i).getX());
vert.setY(helperPoints.get(i).getY());
vert.setZ(helperPoints.get(i).getZ());
vert = rotate(vert,rotationQuat);
helperPoints.get(i).setX(vert.getX() * scale.getX() + shiftX);
helperPoints.get(i).setY(vert.getY() * scale.getY() + shiftY);
helperPoints.get(i).setZ(vert.getZ() * scale.getZ() + shiftZ);
}
}
示例3: move
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public void move( float right , float up , float back )
{
q1.conjugate( orientation );
Quat4f qright = new Quat4f( 1 , 0 , 0 , 0 );
Quat4f qup = new Quat4f( 0 , 1 , 0 , 0 );
Quat4f qback = new Quat4f( 0 , 0 , 1 , 0 );
qright.mul( q1 );
qright.mul( orientation , qright );
qup.mul( q1 );
qup.mul( orientation , qup );
qback.mul( q1 );
qback.mul( orientation , qback );
position.x += qright.x * right + qup.x * up + qback.x * back;
position.y += qright.y * right + qup.y * up + qback.y * back;
position.z += qright.z * right + qup.z * up + qback.z * back;
}
示例4: initRotation
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
/**
*Sets initial rotation for the model and transforms it.
*/
public void initRotation() {
float rotationX = 0.0f;
float rotationY = 0.0f;
float rotationZ = 0.0f;
switch (part) {
case LEFT_EAR:
rotationY = 40.0f;
break;
case RIGHT_EAR:
rotationY = -40.0f;
break;
}
initialRotation = new Vector3f(rotationX, rotationY, rotationZ);
initRotQuat = new Quat4f(0, 0, 0, 1);
if (initialRotation.x != 0) {
Quat4f xRot = new Quat4f();
xRot.set(new AxisAngle4f(1f,0f,0f, (float) Math.toRadians(initialRotation.x)));
initRotQuat.mul(xRot,initRotQuat);
}
if (initialRotation.y != 0) {
Quat4f yRot = new Quat4f();
yRot.set(new AxisAngle4f(0f, 1f, 0f, (float) Math.toRadians(initialRotation.y)));
initRotQuat.mul(yRot,initRotQuat);
}
if (initialRotation.z != 0) {
Quat4f zRot = new Quat4f();
zRot.set(new AxisAngle4f(0f, 0f, 1f, (float) Math.toRadians(initialRotation.z)));
initRotQuat.mul(zRot,initRotQuat);
}/* */
transform();
}
示例5: rotate
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
private Vector3f rotate(Vector3f vert, Quat4f rotQuat) {
if(rotQuat.x != 0 || rotQuat.y != 0 || rotQuat.z != 0){
float size = vert.length();
Quat4f vertQuat = new Quat4f(vert.x,vert.y,vert.z,0);
Quat4f conjungQuat = new Quat4f(0,0,0,1);
conjungQuat.conjugate(rotQuat);
vertQuat.mul(rotQuat, vertQuat);
vertQuat.mul(vertQuat,conjungQuat);
vert.x = vertQuat.x*size;
vert.y = vertQuat.y*size;
vert.z = vertQuat.z*size;
}
return vert;
}
示例6: setInitialRotation
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
/**
* Sets the initial rotation (basic position) of model.
*
* @param initialRotation initial rotation
*/
public void setInitialRotation(Vector3f initialRotation) {
Quat4f xRot = new Quat4f();
xRot.set(new AxisAngle4f(1f, 0f, 0f, (float) Math.toRadians(initialRotation.x)));
Quat4f yRot = new Quat4f();
yRot.set(new AxisAngle4f(0f, 1f, 0f, (float) Math.toRadians(initialRotation.y)));
Quat4f zRot = new Quat4f();
zRot.set(new AxisAngle4f(0f, 0f, 1f, (float) Math.toRadians(initialRotation.z)));
initRotQuat = new Quat4f(0, 0, 0, 1);
initRotQuat.mul(xRot,initRotQuat);
initRotQuat.mul(yRot,initRotQuat);
initRotQuat.mul(zRot,initRotQuat);
this.initialRotation = initialRotation;
}
示例7: quat
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
static void quat() {
final AxisAngle4f angle1 = new AxisAngle4f(0, 1, 0, RotationMath.toRadians(360+90));
Log.log.info(angle1+":"+RotationMath.toDegrees(angle1.angle));
final Quat4f quat1 = RotationMath.toQuat(angle1);
final AxisAngle4f angle2 = RotationMath.toAxis(quat1);
Log.log.info(angle2+":"+RotationMath.toDegrees(angle2.angle));
final Quat4f quat2 = new Quat4f(0, 0, 0, 1);
quat2.mul(quat1);
final AxisAngle4f angle3 = RotationMath.toAxis(quat2);
Log.log.info(angle3+":"+RotationMath.toDegrees(angle3.angle));
}
示例8: getRotate
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
@Override
public @Nonnull Quat4f getRotate(final float scale) {
final Quat4f quat = new Quat4f(this.base.getRotate(1f));
quat.mul(getDiffAngleQuat(scale));
quat.mul(getDiffGlobalQuat(scale));
return quat;
}
示例9: update
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public void update(CSModelRenderer parts, IAnimated animated) {
if (animated instanceof EntityLiving)
if (parts.boxName.equals(this.headPart)) {
EntityLiving entityL = (EntityLiving) animated;
float diff = entityL.getRotationYawHead() - entityL.renderYawOffset;
Quat4f quat = MathHelper.quatFromEuler(entityL.rotationPitch, 0.0F, diff);
Quat4f quat2 = new Quat4f(parts.getDefaultRotationAsQuaternion());
quat.mul(quat2);
parts.getRotationMatrix().set(quat);
parts.getRotationMatrix().transpose();
}
}
示例10: integrateTransform
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
@StaticAlloc
public static void integrateTransform(Transform curTrans, Vector3f linvel, Vector3f angvel, float timeStep, Transform predictedTransform) {
predictedTransform.origin.scaleAdd(timeStep, linvel, curTrans.origin);
// //#define QUATERNION_DERIVATIVE
// #ifdef QUATERNION_DERIVATIVE
// btQuaternion predictedOrn = curTrans.getRotation();
// predictedOrn += (angvel * predictedOrn) * (timeStep * btScalar(0.5));
// predictedOrn.normalize();
// #else
// Exponential map
// google for "Practical Parameterization of Rotations Using the Exponential Map", F. Sebastian Grassia
Vector3f axis = Stack.alloc(Vector3f.class);
float fAngle = angvel.length();
// limit the angular motion
if (fAngle * timeStep > ANGULAR_MOTION_THRESHOLD) {
fAngle = ANGULAR_MOTION_THRESHOLD / timeStep;
}
if (fAngle < 0.001f) {
// use Taylor's expansions of sync function
axis.scale(0.5f * timeStep - (timeStep * timeStep * timeStep) * (0.020833333333f) * fAngle * fAngle, angvel);
}
else {
// sync(fAngle) = sin(c*fAngle)/t
axis.scale((float) Math.sin(0.5f * fAngle * timeStep) / fAngle, angvel);
}
Quat4f dorn = Stack.alloc(Quat4f.class);
dorn.set(axis.x, axis.y, axis.z, (float) Math.cos(fAngle * timeStep * 0.5f));
Quat4f orn0 = curTrans.getRotation(Stack.alloc(Quat4f.class));
Quat4f predictedOrn = Stack.alloc(Quat4f.class);
predictedOrn.mul(dorn, orn0);
predictedOrn.normalize();
// #endif
predictedTransform.setRotation(predictedOrn);
}
示例11: quatRotate
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public static Vector3f quatRotate(Quat4f rotation, Vector3f v, Vector3f out) {
Quat4f q = Stack.alloc(rotation);
QuaternionUtil.mul(q, v);
Quat4f tmp = Stack.alloc(Quat4f.class);
inverse(tmp, rotation);
q.mul(tmp);
out.set(q.x, q.y, q.z);
return out;
}
示例12: getLocalRotation
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public Quat4f getLocalRotation() {
Quat4f rot = new Quat4f(rotation);
if (parent != null) {
Quat4f inverseParentRot = new Quat4f();
inverseParentRot.inverse(parent.getObjectRotation());
rot.mul(inverseParentRot, rot);
}
return rot;
}
示例13: getWorldRotation
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public Quat4f getWorldRotation(Quat4f output) {
output.set(rotation);
LocationComponent parentLoc = parent.getComponent(LocationComponent.class);
while (parentLoc != null) {
output.mul(parentLoc.rotation, output);
parentLoc = parentLoc.parent.getComponent(LocationComponent.class);
}
return output;
}
示例14: calculateXyzRotations
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
private static Multimap<Orientation, XYZRotation> calculateXyzRotations(Map<Matrix3f, Orientation> fromMatrix) {
final Multimap<Orientation, XYZRotation> toXYZRotation = HashMultimap.create();
for (Rotation x : Rotation.values())
for (Rotation y : Rotation.values())
for (Rotation z : Rotation.values()) {
final XYZRotation rotation = new XYZRotation(x, y, z);
Quat4f q = new Quat4f(0, 0, 0, 1);
Quat4f tmp = new Quat4f();
tmp.set(new AxisAngle4f(0, 0, 1, z.angle));
q.mul(tmp);
tmp.set(new AxisAngle4f(0, 1, 0, y.angle));
q.mul(tmp);
tmp.set(new AxisAngle4f(1, 0, 0, x.angle));
q.mul(tmp);
Matrix3f m = new Matrix3f();
m.set(q);
roundMatrixElements(m);
final Orientation orientation = fromMatrix.get(m);
Preconditions.checkNotNull(orientation, rotation);
toXYZRotation.put(orientation, rotation);
}
return toXYZRotation;
}
示例15: handlePerspective
import javax.vecmath.Quat4f; //导入方法依赖的package包/类
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
Pair<? extends IBakedModel, Matrix4f> perspective = parent.handlePerspective(cameraTransformType);
double r = (EnderIO.proxy.getTickCount() % 360) + Minecraft.getMinecraft().getRenderPartialTicks();
TRSRTransformation transformOrig = new TRSRTransformation(perspective.getRight());
Quat4f leftRot = transformOrig.getLeftRot();
Quat4f yRotation = new Quat4f();
yRotation.set(new AxisAngle4d(0, 1, 0, Math.toRadians(r * speed)));
leftRot.mul(yRotation);
TRSRTransformation transformNew = new TRSRTransformation(transformOrig.getTranslation(), leftRot, transformOrig.getScale(), transformOrig.getRightRot());
return Pair.of(perspective.getLeft(), transformNew.getMatrix());
}