当前位置: 首页>>代码示例>>Java>>正文


Java Quat4f.set方法代码示例

本文整理汇总了Java中javax.vecmath.Quat4f.set方法的典型用法代码示例。如果您正苦于以下问题:Java Quat4f.set方法的具体用法?Java Quat4f.set怎么用?Java Quat4f.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.vecmath.Quat4f的用法示例。


在下文中一共展示了Quat4f.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shortestArcQuat

import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public static Quat4f shortestArcQuat(Vector3f v0, Vector3f v1, Quat4f out) {
	Vector3f c = Stack.alloc(Vector3f.class);
	c.cross(v0, v1);
	float d = v0.dot(v1);

	if (d < -1.0 + BulletGlobals.FLT_EPSILON) {
		// just pick any vector
		out.set(0.0f, 1.0f, 0.0f, 0.0f);
		return out;
	}

	float s = (float) Math.sqrt((1.0f + d) * 2.0f);
	float rs = 1.0f / s;

	out.set(c.x * rs, c.y * rs, c.z * rs, s * 0.5f);
	return out;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:18,代码来源:QuaternionUtil.java

示例2: rotationForAxis

import javax.vecmath.Quat4f; //导入方法依赖的package包/类
/**
 * Builds the appropriate quaternion to rotate around the given orthogonalAxis.
 */
public static Quat4f rotationForAxis(EnumFacing.Axis axis, double degrees)
{
	Quat4f retVal = new Quat4f();
	switch (axis) {
	case X:
		retVal.set(new AxisAngle4d(1, 0, 0, Math.toRadians(degrees)));
		break;
	case Y:
		retVal.set(new AxisAngle4d(0, 1, 0, Math.toRadians(degrees)));
		break;
	case Z:
		retVal.set(new AxisAngle4d(0, 0, 1, Math.toRadians(degrees)));
		break;
	}
	return retVal;
}
 
开发者ID:grondag,项目名称:Hard-Science,代码行数:20,代码来源:QuadHelper.java

示例3: MBJoint

import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public MBJoint(String name, BlockPart part)
{
    this.name = name;
    if(part.partRotation != null)
    {
        float x = 0, y = 0, z = 0;
        switch(part.partRotation.axis)
        {
            case X:
                x = 1;
            case Y:
                y = 1;
            case Z:
                z = 1;
        }
        Quat4f rotation = new Quat4f();
        rotation.set(new AxisAngle4f(x, y, z, 0));
        Matrix4f m = new TRSRTransformation(
            TRSRTransformation.toVecmath(part.partRotation.origin),
            rotation,
            null,
            null).getMatrix();
        m.invert();
        invBindPose = new TRSRTransformation(m);
    }
    else
    {
        invBindPose = TRSRTransformation.identity();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:31,代码来源:ModelBlockAnimation.java

示例4: parseAxisRotation

import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public static Quat4f parseAxisRotation(JsonElement e)
{
    if (!e.isJsonObject()) throw new JsonParseException("Axis rotation: object expected, got: " + e);
    JsonObject obj  = e.getAsJsonObject();
    if (obj.entrySet().size() != 1) throw new JsonParseException("Axis rotation: expected single axis object, got: " + e);
    Map.Entry<String, JsonElement> entry = obj.entrySet().iterator().next();
    Quat4f ret = new Quat4f();
    try
    {
        if (entry.getKey().equals("x"))
        {
            ret.set(new AxisAngle4d(1, 0, 0, Math.toRadians(entry.getValue().getAsNumber().floatValue())));
        }
        else if (entry.getKey().equals("y"))
        {
            ret.set(new AxisAngle4d(0, 1, 0, Math.toRadians(entry.getValue().getAsNumber().floatValue())));
        }
        else if (entry.getKey().equals("z"))
        {
            ret.set(new AxisAngle4d(0, 0, 1, Math.toRadians(entry.getValue().getAsNumber().floatValue())));
        }
        else throw new JsonParseException("Axis rotation: expected single axis key, got: " + entry.getKey());
    }
    catch(ClassCastException ex)
    {
        throw new JsonParseException("Axis rotation value: expected number, got: " + entry.getValue());
    }
    return ret;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:30,代码来源:ForgeBlockStateV1.java

示例5: 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();
}
 
开发者ID:Fidentis,项目名称:Analyst,代码行数:37,代码来源:CompositeModel.java

示例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;
}
 
开发者ID:Fidentis,项目名称:Analyst,代码行数:19,代码来源:CompositeModel.java

示例7: toQuat

import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public static @Nonnull Quat4f toQuat(final @Nonnull AxisAngle4f axis) {
	if (axis.angle==0f)
		return newQuat();
	final Quat4f q = new Quat4f();
	q.set(axis);
	return q;
}
 
开发者ID:Team-Fruit,项目名称:SignPicture,代码行数:8,代码来源:RotationData.java

示例8: 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);
	}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:39,代码来源:TransformUtil.java

示例9: mul

import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public static void mul(Quat4f q, Vector3f w) {
	float rx = q.w * w.x + q.y * w.z - q.z * w.y;
	float ry = q.w * w.y + q.z * w.x - q.x * w.z;
	float rz = q.w * w.z + q.x * w.y - q.y * w.x;
	float rw = -q.x * w.x - q.y * w.y - q.z * w.z;
	q.set(rx, ry, rz, rw);
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:8,代码来源:QuaternionUtil.java

示例10: storeTransformAt

import javax.vecmath.Quat4f; //导入方法依赖的package包/类
/**
 * Stores the transformation of the bone at a specific point in the animation. This method interpolates between the
 * nearest two key-frames using the correct interpolation mode.
 *
 * @param frame
 * @param transform
 * @param subFrame
 * @return
 */
public void storeTransformAt(float frame, BoneTransformation transform) {
	Vector3f t = translationBuffer.get();
	t.set(loc_x.getValueAt(frame), loc_y.getValueAt(frame), loc_z.getValueAt(frame));
	Quat4f r = rotationBuffer.get();
	r.set(quat_x.getValueAt(frame), quat_y.getValueAt(frame), quat_z.getValueAt(frame), quat_w.getValueAt(frame));
	r.normalize();
	Vector3f s = scaleBuffer.get();
	s.set(scale_x.getValueAt(frame), scale_y.getValueAt(frame), scale_z.getValueAt(frame));
	Utils.fromRTS(r, t, s, transform.matrix);
}
 
开发者ID:WorldSEnder,项目名称:MCAnm,代码行数:20,代码来源:AnimatedTransform.java

示例11: 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;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:10,代码来源:LocationComponent.java

示例12: 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;
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:29,代码来源:OrientationInfoGenerator.java

示例13: 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());
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:16,代码来源:RotatingSmartItemModel.java

示例14: apply

import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public TRSRTransformation apply(float time)
{
    time -= Math.floor(time);
    Vector3f translation = new Vector3f(0, 0, 0);
    Vector3f scale = new Vector3f(1, 1, 1);
    AxisAngle4f rotation = new AxisAngle4f(0, 0, 0, 0);
    for(MBVariableClip var : variables)
    {
        int length = loop ? var.samples.length : (var.samples.length - 1);
        float timeScaled = time * length;
        int s1 = MathHelper.clamp_int((int)Math.round(Math.floor(timeScaled)), 0, length - 1);
        float progress = timeScaled - s1;
        int s2 = s1 + 1;
        if(s2 == length && loop) s2 = 0;
        float value = 0;
        switch(var.interpolation)
        {
            case LINEAR:
                if(var.variable == Variable.ANGLE)
                {
                    float v1 = var.samples[s1];
                    float v2 = var.samples[s2];
                    float diff = ((v2 - v1) % 360 + 540) % 360 - 180;
                    value = v1 + diff * progress;
                }
                else
                {
                    value = var.samples[s1] * (1 - progress) + var.samples[s2] * progress;
                }
                break;
            case NEAREST:
                value = var.samples[progress < .5f ? s1 : s2];
                break;
        }
        switch(var.variable)
        {
            case X:
                translation.x = value;
                break;
            case Y:
                translation.y = value;
                break;
            case Z:
                translation.z = value;
                break;
            case XROT:
                rotation.x = value;
                break;
            case YROT:
                rotation.y = value;
                break;
            case ZROT:
                rotation.z = value;
                break;
            case ANGLE:
                rotation.angle = (float)Math.toRadians(value);
                break;
            case SCALE:
                scale.x = scale.y = scale.z = value;
                break;
            case XS:
                scale.x = value;
                break;
            case YS:
                scale.y = value;
                break;
            case ZS:
                scale.z = value;
                break;
        }
    }
    Quat4f rot = new Quat4f();
    rot.set(rotation);
    return TRSRTransformation.blockCenterToCorner(new TRSRTransformation(translation, rot, scale, null));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:76,代码来源:ModelBlockAnimation.java

示例15: getRotation

import javax.vecmath.Quat4f; //导入方法依赖的package包/类
public Quat4f getRotation(int i) {

        Vector3f rotation = new Vector3f(Float.valueOf(rotationXSpinner.getValue().toString()), Float.valueOf(rotationYSpinner.getValue().toString()), Float.valueOf(rotationZSpinner.getValue().toString()));

        Quat4f rotQuat = new Quat4f(0, 0, 0, 1);

        Quat4f xRot = new Quat4f();
        xRot.set(new AxisAngle4f(1f, 0f, 0f, (float) Math.toRadians(rotation.x)));
        rotQuat.mul(xRot, rotQuat);


        Quat4f zRot = new Quat4f();
        zRot.set(new AxisAngle4f(0f, 0f, 1f, i * (float) Math.toRadians(rotation.z)));
        rotQuat.mul(zRot, rotQuat);

        Quat4f yRot = new Quat4f();
        yRot.set(new AxisAngle4f(0f, 1f, 0f, i * (float) Math.toRadians(rotation.y)));
        rotQuat.mul(yRot, rotQuat);

        return rotQuat; //
    }
 
开发者ID:Fidentis,项目名称:Analyst,代码行数:22,代码来源:CompositeConfiguration.java


注:本文中的javax.vecmath.Quat4f.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。