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


Java Quaternion类代码示例

本文整理汇总了Java中com.badlogic.gdx.math.Quaternion的典型用法代码示例。如果您正苦于以下问题:Java Quaternion类的具体用法?Java Quaternion怎么用?Java Quaternion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Basic

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
public Basic(Matrix4 transform, double speeed, int hp, int health, int range, float coolDown, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionWorld world, IntMap<Entity> entities, List<Vector3> path, Map<String, Sound> sounds) {
    super(transform, speeed, hp, health, range, coolDown, types, effects, instance, new btCompoundShape(), world, entities, ATTACK_ANIMATION, ATTACK_OFFSET, path, sounds);
    ((btCompoundShape)shape).addChildShape(new Matrix4(new Vector3(0, 30, 0), new Quaternion().setEulerAngles(0, 0, 0), new Vector3(1, 1, 1)), new btBoxShape(new Vector3(75, 30, 90)));
    //System.out.println(getModelInstance().getAnimation("Spider_Armature|walk_ani_vor").id);
    listener = new AnimationController.AnimationListener() {
        @Override
        public void onEnd(AnimationController.AnimationDesc animationDesc) {

        }

        @Override
        public void onLoop(AnimationController.AnimationDesc animationDesc) {

        }
    };
    //animation.setAnimation("Spider_Armature|walk_ani_vor");
    //animation.animate("Spider_Armature|walk_ani_vor", -1);
    //animation.action("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
    //animation.animate("Spider_Armature|Attack", 0, 1000, 1, 1, listener, 0);
    //animation.queue("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
}
 
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:22,代码来源:Basic.java

示例2: processBodyComponent

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
private void processBodyComponent(RigidBodyComponent bodyComponent, NodeComponent nodeComponent) {
    if (bodyComponent.state == RigidBodyComponent.State.READY) {
        if (!bodyComponent.isAdded()) {
            Matrix4 initialTransform = new Matrix4();

            Vector3 translation = nodeComponent.node.translation;
            Vector3 scale = new Vector3(1, 1, 1);
            Quaternion rotation = nodeComponent.node.rotation;

            initialTransform.set(translation, rotation, scale);
            bodyComponent.addToWorld(dynamicsWorld, initialTransform);
        } else {
            nodeComponent.setTranslation(bodyComponent.getTranslation());
            nodeComponent.setRotation(bodyComponent.getRotation());
            nodeComponent.applyTransforms();
        }
    }
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:19,代码来源:PhysicsSystem.java

示例3: processVehicleComponent

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
private void processVehicleComponent(VehicleComponent vehicleComponent, NodeComponent nodeComponent) {
    if (vehicleComponent.state == RigidBodyComponent.State.READY) {
        if (!vehicleComponent.isAdded()) {
            Matrix4 initialTransform = new Matrix4();

            Vector3 trn = nodeComponent.getTranslation();
            Vector3 scl = new Vector3(1, 1, 1);
            Quaternion rtn = nodeComponent.getRotationQuaternion();

            initialTransform.set(trn, rtn, scl);

            vehicleComponent.addToWorld(dynamicsWorld, initialTransform);
        } else {
            nodeComponent.setTranslation(vehicleComponent.getTranslation());
            nodeComponent.setRotation(vehicleComponent.getRotation());
            nodeComponent.applyTransforms();
        }
    }
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:20,代码来源:PhysicsSystem.java

示例4: NodeComponent

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
public NodeComponent() {
    node = new Node();

    tempVec = new Vector3();
    tempVec2 = new Vector3();
    tempQuat = new Quaternion();

    translation = new Vector3();
    rotation = new Vector3();
    scale = new Vector3(1, 1, 1);
    
    localTranslation = new Vector3();
    localRotation = new Vector3();
    localScale = new Vector3(1, 1, 1);

    translationDelta = new Vector3();
    rotationDelta = new Vector3();
    scaleDelta = new Vector3();

    localRotationQuaternion = new Quaternion();
    rotationQuaternion = new Quaternion();
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:23,代码来源:NodeComponent.java

示例5: maxAxis4

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
public static int maxAxis4 (Quaternion v) {
	int maxIndex = -1;
	float maxVal = -1e30f;
	if (v.x > maxVal) {
		maxIndex = 0;
		maxVal = v.x;
	}
	if (v.y > maxVal) {
		maxIndex = 1;
		maxVal = v.y;
	}
	if (v.z > maxVal) {
		maxIndex = 2;
		maxVal = v.z;
	}
	if (v.w > maxVal) {
		maxIndex = 3;
		maxVal = v.w;
	}

	return maxIndex;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:23,代码来源:VectorUtil.java

示例6: shortestArcQuat

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
public static Quaternion shortestArcQuat (Vector3 v0, Vector3 v1, Quaternion out) {
	Stack stack = Stack.enter();
	Vector3 c = stack.allocVector3();
	c.set(v0).crs(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);
		stack.leave();
		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);
	stack.leave();
	return out;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:21,代码来源:QuaternionUtil.java

示例7: setRotation

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
public static void setRotation (Matrix3 dest, Quaternion q) {
	float d = q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w;
	assert (d != 0f);
	float s = 2f / d;
	float xs = q.x * s, ys = q.y * s, zs = q.z * s;
	float wx = q.w * xs, wy = q.w * ys, wz = q.w * zs;
	float xx = q.x * xs, xy = q.x * ys, xz = q.x * zs;
	float yy = q.y * ys, yz = q.y * zs, zz = q.z * zs;
	dest.val[Matrix3.M00] = 1f - (yy + zz);
	dest.val[Matrix3.M01] = xy - wz;
	dest.val[Matrix3.M02] = xz + wy;
	dest.val[Matrix3.M10] = xy + wz;
	dest.val[Matrix3.M11] = 1f - (xx + zz);
	dest.val[Matrix3.M12] = yz - wx;
	dest.val[Matrix3.M20] = xz - wy;
	dest.val[Matrix3.M21] = yz + wx;
	dest.val[Matrix3.M22] = 1f - (xx + yy);
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:19,代码来源:MatrixUtil.java

示例8: getRotation

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
public static void getRotation (Matrix3 mat, Quaternion dest) {
	/*
	 * ArrayPool<float[]> floatArrays = ArrayPool.get(float.class);
	 * 
	 * float trace = mat.val[Matrix3.M00] + mat.val[Matrix3.M11] + mat.val[Matrix3.M22]; float[] temp = floatArrays.getFixed(4);
	 * 
	 * if (trace > 0f) { float s = (float) Math.sqrt(trace + 1f); temp[3] = (s * 0.5f); s = 0.5f / s;
	 * 
	 * temp[0] = ((mat.val[Matrix3.M21] - mat.val[Matrix3.M12]) * s); temp[1] = ((mat.val[Matrix3.M02] - mat.val[Matrix3.M20]) *
	 * s); temp[2] = ((mat.val[Matrix3.M10] - mat.val[Matrix3.M01]) * s); } else { int i = mat.val[Matrix3.M00] <
	 * mat.val[Matrix3.M11] ? (mat.val[Matrix3.M11] < mat.val[Matrix3.M22] ? 2 : 1) : (mat.val[Matrix3.M00] <
	 * mat.val[Matrix3.M22] ? 2 : 0); int j = (i + 1) % 3; int k = (i + 2) % 3;
	 * 
	 * float s = (float) Math.sqrt(mat.getElement(i, i) - mat.getElement(j, j) - mat.getElement(k, k) + 1f); temp[i] = s * 0.5f;
	 * s = 0.5f / s;
	 * 
	 * temp[3] = (mat.getElement(k, j) - mat.getElement(j, k)) * s; temp[j] = (mat.getElement(j, i) + mat.getElement(i, j)) * s;
	 * temp[k] = (mat.getElement(k, i) + mat.getElement(i, k)) * s; } dest.set(temp[0], temp[1], temp[2], temp[3]);
	 * 
	 * floatArrays.release(temp);
	 */
	// FIXME check this is correct
	dest.setFromMatrix(true, mat);
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:25,代码来源:MatrixUtil.java

示例9: plane_classify

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
public PlaneIntersectionType plane_classify (Quaternion plane) {
	Stack stack = Stack.enter();
	Vector3 tmp = stack.allocVector3();

	float[] _fmin = new float[1], _fmax = new float[1];
	tmp.set(plane.x, plane.y, plane.z);
	projection_interval(tmp, _fmin, _fmax);

	if (plane.w > _fmax[0] + BOX_PLANE_EPSILON) {
		stack.leave();
		return PlaneIntersectionType.BACK_PLANE; // 0
	}

	if (plane.w + BOX_PLANE_EPSILON >= _fmin[0]) {
		stack.leave();
		return PlaneIntersectionType.COLLIDE_PLANE; // 1
	}

	stack.leave();
	return PlaneIntersectionType.FRONT_PLANE; // 2
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:22,代码来源:BoxCollision.java

示例10: line_plane_collision

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
/** Line plane collision.
 * 
 * @return -0 if the ray never intersects, -1 if the ray collides in front, -2 if the ray collides in back */
public static int line_plane_collision (Quaternion plane, Vector3 vDir, Vector3 vPoint, Vector3 pout, float[] tparam, float tmin,
	float tmax) {
	float _dotdir = VectorUtil.dot3(vDir, plane);

	if (Math.abs(_dotdir) < PLANEDIREPSILON) {
		tparam[0] = tmax;
		return 0;
	}

	float _dis = ClipPolygon.distance_point_plane(plane, vPoint);
	int returnvalue = _dis < 0.0f ? 2 : 1;
	tparam[0] = -_dis / _dotdir;

	if (tparam[0] < tmin) {
		returnvalue = 0;
		tparam[0] = tmin;
	} else if (tparam[0] > tmax) {
		returnvalue = 0;
		tparam[0] = tmax;
	}
	pout.x = vPoint.x + tparam[0] * vDir.x;
	pout.y = vPoint.y + tparam[0] * vDir.y;
	pout.z = vPoint.z + tparam[0] * vDir.z;
	return returnvalue;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:29,代码来源:GeometryOperations.java

示例11: moveShipLeft

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
public void moveShipLeft (float delta, float scale) {
		if (ship.isExploding) return;

		float q0 = (float) Invaders.mInvaderInterface.getQ0();
		float q1 = (float) Invaders.mInvaderInterface.getQ1();
		float q2 = (float) Invaders.mInvaderInterface.getQ2();
		float q3 = (float) Invaders.mInvaderInterface.getQ3();

		ship.transform.trn(-delta * Ship.SHIP_VELOCITY * scale, 0, 0);
		ship.transform.getTranslation(tmpV1);
		if (tmpV1.x < PLAYFIELD_MIN_X) ship.transform.trn(PLAYFIELD_MIN_X - tmpV1.x, 0, 0);

		Vector3 oldTranslation = ship.transform.getTranslation(tmpV1);
		Quaternion rotateQ = new Quaternion(q0,-1*q1,q3,-1*q2); //Used if you want all 3-axis rotation
//		Quaternion rotateQ = new Quaternion(1,0,0,0); //Used if you only want the roll

        ship.transform.setToRotation(0, 0, 0, 0);
        ship.transform.set(oldTranslation, rotateQ);

//      ROLL-ONLY CODE - BETTER FOR GAME MODE
//		float roll_x = 57.29578f*((float)(Math.atan2(2*(q0*q1+q2*q3),1-2*(q1*q1+q2*q2))));//Used if you want only roll
//		ship.transform.rotate(0, 0, 1, roll_x);//Used if you want only roll
// 		ship.transform.rotate(rotateQ);
	}
 
开发者ID:Motsai,项目名称:neblina-libgdx3d,代码行数:25,代码来源:Simulation.java

示例12: moveShipRight

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
public void moveShipRight (float delta, float scale) {
		if (ship.isExploding) return;

		float q0 = (float) Invaders.mInvaderInterface.getQ0();
		float q1 = (float) Invaders.mInvaderInterface.getQ1();
		float q2 = (float) Invaders.mInvaderInterface.getQ2();
		float q3 = (float) Invaders.mInvaderInterface.getQ3();

		ship.transform.trn(+delta * Ship.SHIP_VELOCITY * scale, 0, 0);
		if (tmpV1.x > PLAYFIELD_MAX_X) ship.transform.trn(PLAYFIELD_MAX_X - tmpV1.x, 0, 0);

		Vector3 oldTranslation = ship.transform.getTranslation(tmpV1);

		Vector3 flip = new Vector3(0,0,0);

		Quaternion rotateQ = new Quaternion(q0,-1*q1,q3,-1*q2); //For 3-axis
//		Quaternion rotateQ = new Quaternion(1, 0, 0, 0); //For ROLL-ONLY
//      ship.transform.set(oldTranslation.mulAdd(flip, -1), rotateQ);//ROLL-ONLY
//		float roll_x = 57.29578f*((float)(Math.atan2(2*(q0*q1+q2*q3),1-2*(q1*q1+q2*q2))));//ROLL ONLY
//		ship.transform.rotate(0,0,1,roll_x);//ROLL ONLY


        ship.transform.setToRotation(0, 0, 0, 0);
        ship.transform.set(oldTranslation.mulAdd(flip, -1), rotateQ);
	}
 
开发者ID:Motsai,项目名称:neblina-libgdx3d,代码行数:26,代码来源:Simulation.java

示例13: initWorld

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
public static void initWorld(BulletWorld world) {
    //TreeShape
    Model model = Assets.get(Models.MODEL_TREE_PROTOTYPE, Model.class);
    model.nodes.first().translation.set(0, -1.15f, 0);
    btCompoundShape treeShape = new btCompoundShape();
    treeShape.addChildShape(new Matrix4(new Vector3(0, 0, 0), new Quaternion(), new Vector3(1, 1, 1)), new btBoxShape(new Vector3(.2f, .9f, .2f)));
    treeShape.addChildShape(new Matrix4(new Vector3(0, 1, 0), new Quaternion(), new Vector3(1, 1, 1)), new btSphereShape(1));
    //LogShape
    model = Assets.get(Models.MODEL_LOG_PROTOTYPE, Model.class);
    model.nodes.first().translation.set(0, -1.15f, 0);

    world.addConstructor("log", new BulletConstructor(Assets.get(Models.MODEL_LOG_PROTOTYPE, Model.class), 75, new btBoxShape(new Vector3(.2f, .9f, .2f))));
    world.addConstructor("stump", new BulletConstructor(Assets.get(Models.MODEL_STUMP_PROTOTYPE, Model.class), 0, new btCylinderShape(new Vector3(.2f, .22f, .2f))));
    world.addConstructor("staticTree", new BulletConstructor(Assets.get(Models.MODEL_TREE_PROTOTYPE, Model.class), 0, treeShape));
    world.addConstructor("dynamicTree", new BulletConstructor(Assets.get(Models.MODEL_TREE_PROTOTYPE, Model.class), 100, treeShape));
}
 
开发者ID:ToxSickCoder,项目名称:Skyland,代码行数:17,代码来源:TreeGenerator.java

示例14: drawArmatureNodes

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
private void drawArmatureNodes(Node currentNode, Vector3 modelPos,
							   Quaternion modelRot,
							   Vector3 parentNodePos, Vector3 currentNodePos) {
	currentNode.globalTransform.getTranslation(currentNodePos);
	modelRot.transform(currentNodePos);
	currentNodePos.add(modelPos);
	drawVertex(currentNodePos, 0.02f, Color.GREEN);
	shapeRenderer.setColor(Color.YELLOW);
	if (currentNode.hasParent()) {
		shapeRenderer.line(parentNodePos, currentNodePos);
	}
	if (currentNode.hasChildren()) {
		float x = currentNodePos.x;
		float y = currentNodePos.y;
		float z = currentNodePos.z;
		for (Node child : currentNode.getChildren()) {
			drawArmatureNodes(child, modelPos, modelRot, currentNodePos, parentNodePos);
			currentNodePos.set(x, y, z);
		}
	}
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:22,代码来源:ArmatureDebugDrawer.java

示例15: render

import com.badlogic.gdx.math.Quaternion; //导入依赖的package包/类
@Override
public void render() {
	float deltaTime = Gdx.graphics.getDeltaTime();

	if (Gdx.input.isKeyPressed(Input.Keys.W)) {
		VirtualReality.body.position.add(new Vector3(0, 0, -2).mul(VirtualReality.body.orientation).scl(deltaTime));
	}
	if (Gdx.input.isKeyPressed(Input.Keys.S)) {
		VirtualReality.body.position.add(new Vector3(0, 0, 2).mul(VirtualReality.body.orientation).scl(deltaTime));
	}
	if (Gdx.input.isKeyPressed(Input.Keys.A)) {
		VirtualReality.body.orientation.mulLeft(new Quaternion(Vector3.Y, 90f * deltaTime));
	}
	if (Gdx.input.isKeyPressed(Input.Keys.D)) {
		VirtualReality.body.orientation.mulLeft(new Quaternion(Vector3.Y, -90f * deltaTime));
	}

	VirtualReality.update(Gdx.graphics.getDeltaTime());
	VirtualReality.renderer.render();
}
 
开发者ID:nooone,项目名称:gdx-vr,代码行数:21,代码来源:SimpleRoom.java


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