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


Java QuaternionUtil.quatRotate方法代码示例

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


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

示例1: renderBoneOrientation

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
private void renderBoneOrientation(EntityRef boneEntity) {
    LocationComponent loc = boneEntity.getComponent(LocationComponent.class);
    if (loc == null) {
        return;
    }
    glPushMatrix();
    Vector3f worldPosA = loc.getWorldPosition();
    Quat4f worldRot = loc.getWorldRotation();
    Vector3f offset = new Vector3f(0, 0, 0.1f);
    QuaternionUtil.quatRotate(worldRot, offset, offset);
    offset.add(worldPosA);

    glBegin(GL11.GL_LINES);
    glVertex3f(worldPosA.x, worldPosA.y, worldPosA.z);
    glVertex3f(offset.x, offset.y, offset.z);
    glEnd();

    for (EntityRef child : loc.getChildren()) {
        renderBoneOrientation(child);
    }
    glPopMatrix();
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:23,代码来源:SkeletonRenderer.java

示例2: getVertexPositions

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public List<Vector3f> getVertexPositions(List<Vector3f> bonePositions, List<Quat4f> boneRotations) {
    List<Vector3f> results = Lists.newArrayListWithCapacity(getVertexCount());
    for (int i = 0; i < vertexStartWeights.size(); ++i) {
        Vector3f vertexPos = new Vector3f();
        for (int weightIndexOffset = 0; weightIndexOffset < vertexWeightCounts.get(i); ++weightIndexOffset) {
            int weightIndex = vertexStartWeights.get(i) + weightIndexOffset;
            BoneWeight weight = weights.get(weightIndex);

            Vector3f current = QuaternionUtil.quatRotate(boneRotations.get(weight.getBoneIndex()), weight.getPosition(), new Vector3f());
            current.add(bonePositions.get(weight.getBoneIndex()));
            current.scale(weight.getBias());
            vertexPos.add(current);
        }
        results.add(vertexPos);
    }
    return results;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:18,代码来源:SkeletalMesh.java

示例3: getVertexNormals

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public List<Vector3f> getVertexNormals(List<Vector3f> bonePositions, List<Quat4f> boneRotations) {
    List<Vector3f> results = Lists.newArrayListWithCapacity(getVertexCount());
    for (int i = 0; i < vertexStartWeights.size(); ++i) {
        Vector3f vertexNorm = new Vector3f();
        for (int weightIndexOffset = 0; weightIndexOffset < vertexWeightCounts.get(i); ++weightIndexOffset) {
            int weightIndex = vertexStartWeights.get(i) + weightIndexOffset;
            BoneWeight weight = weights.get(weightIndex);

            Vector3f current = QuaternionUtil.quatRotate(boneRotations.get(weight.getBoneIndex()), weight.getNormal(), new Vector3f());
            current.scale(weight.getBias());
            vertexNorm.add(current);
        }
        results.add(vertexNorm);
    }
    return results;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:17,代码来源:SkeletalMesh.java

示例4: processAABBShape

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
private ColliderInfo processAABBShape(JsonDeserializationContext context, JsonObject colliderDef, Rotation rot) {
    Vector3f offset = context.deserialize(colliderDef.get("position"), Vector3f.class);
    Vector3f extent = context.deserialize(colliderDef.get("extents"), Vector3f.class);
    if (offset == null) throw new JsonParseException("AABB Collider missing position");
    if (extent == null) throw new JsonParseException("AABB Collider missing extents");

    QuaternionUtil.quatRotate(rot.getQuat4f(), extent, extent);
    extent.absolute();

    return new ColliderInfo(QuaternionUtil.quatRotate(rot.getQuat4f(), offset, offset), new BoxShape(extent));
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:12,代码来源:JsonBlockShapeLoader.java

示例5: processSphereShape

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
private ColliderInfo processSphereShape(JsonDeserializationContext context, JsonObject colliderDef, Rotation rot) {
    Vector3f offset = context.deserialize(colliderDef.get("position"), Vector3f.class);
    float radius = colliderDef.get("radius").getAsFloat();
    if (offset == null) throw new JsonParseException("Sphere Collider missing position");

    return new ColliderInfo(QuaternionUtil.quatRotate(rot.getQuat4f(), offset, offset), new SphereShape(radius));
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:8,代码来源:JsonBlockShapeLoader.java

示例6: rotate

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public BlockMeshPart rotate(Quat4f rotation) {
    Vector3f[] newVertices = new Vector3f[vertices.length];
    Vector3f[] newNormals = new Vector3f[normals.length];

    for (int i = 0; i < newVertices.length; ++i) {
        newVertices[i] = QuaternionUtil.quatRotate(rotation, vertices[i], new Vector3f());
        newNormals[i] = QuaternionUtil.quatRotate(rotation, normals[i], new Vector3f());
        newNormals[i].normalize();
    }

    return new BlockMeshPart(newVertices, newNormals, texCoords, indices);
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:13,代码来源:BlockMeshPart.java

示例7: updateCamera

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
private void updateCamera(CharacterMovementComponent charMovementComp, Vector3f position, Quat4f rotation) {
    // The camera position is the player's position plus the eye offset
    Vector3d cameraPosition = new Vector3d();
    // TODO: don't hardset eye position
    cameraPosition.add(new Vector3d(position), new Vector3d(0, 0.6f, 0));

    playerCamera.getPosition().set(cameraPosition);
    Vector3f viewDir = new Vector3f(0, 0, 1);
    QuaternionUtil.quatRotate(rotation, viewDir, playerCamera.getViewingDirection());

    float stepDelta = charMovementComp.footstepDelta - lastStepDelta;
    if (stepDelta < 0) stepDelta += charMovementComp.distanceBetweenFootsteps;
    bobFactor += stepDelta;
    lastStepDelta = charMovementComp.footstepDelta;

    if (playerCamera.getClass() == PerspectiveCamera.class) {
        if (config.getRendering().isCameraBobbing()) {
            ((PerspectiveCamera) playerCamera).setBobbingRotationOffsetFactor(calcBobbingOffset(0.0f, 0.01f, 2.5f));
            ((PerspectiveCamera) playerCamera).setBobbingVerticalOffsetFactor(calcBobbingOffset((float) java.lang.Math.PI / 4f, 0.025f, 3f));
        } else {
            ((PerspectiveCamera) playerCamera).setBobbingRotationOffsetFactor(0.0f);
            ((PerspectiveCamera) playerCamera).setBobbingVerticalOffsetFactor(0.0f);
        }
    }

    if (charMovementComp.isGhosting) {
        playerCamera.extendFov(24);
    } else {
        playerCamera.resetFov();
    }
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:32,代码来源:LocalPlayerSystem.java

示例8: getLocalPosition

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public Vector3f getLocalPosition() {
    Vector3f pos = new Vector3f(objectSpacePos);
    if (parent != null) {
        pos.sub(parent.getObjectPosition());
        Quat4f inverseParentRot = new Quat4f();
        inverseParentRot.inverse(parent.getObjectRotation());
        QuaternionUtil.quatRotate(inverseParentRot, pos, pos);
    }
    return pos;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:11,代码来源:Bone.java

示例9: getViewDirection

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public Vector3f getViewDirection() {
    LocalPlayerComponent localPlayer = entity.getComponent(LocalPlayerComponent.class);
    if (localPlayer == null) {
        return Direction.FORWARD.getVector3f();
    }
    Quat4f rot = new Quat4f();
    QuaternionUtil.setEuler(rot, TeraMath.DEG_TO_RAD * localPlayer.viewYaw, TeraMath.DEG_TO_RAD * localPlayer.viewPitch, 0);
    // TODO: Put a generator for direction vectors in a util class somewhere
    // And just put quaternion -> vector somewhere too
    Vector3f dir = Direction.FORWARD.getVector3f();
    return QuaternionUtil.quatRotate(rot, dir, dir);
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:13,代码来源:LocalPlayer.java

示例10: getWorldPosition

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public Vector3f getWorldPosition(Vector3f output) {
    output.set(position);
    LocationComponent parentLoc = parent.getComponent(LocationComponent.class);
    while (parentLoc != null) {
        output.scale(parentLoc.scale);
        QuaternionUtil.quatRotate(parentLoc.getLocalRotation(), output, output);
        output.add(parentLoc.position);
        parentLoc = parentLoc.parent.getComponent(LocationComponent.class);
    }
    return output;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:12,代码来源:LocationComponent.java

示例11: setWorldPosition

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public void setWorldPosition(Vector3f position) {
    this.position.set(position);
    LocationComponent parentLoc = parent.getComponent(LocationComponent.class);
    if (parentLoc != null) {
        this.position.sub(parentLoc.getWorldPosition());
        this.position.scale(1f / parentLoc.getWorldScale());
        Quat4f rot = new Quat4f(0, 0, 0, 1);
        rot.inverse(parentLoc.getWorldRotation());
        QuaternionUtil.quatRotate(rot, this.position, this.position);
    }
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:12,代码来源:LocationComponent.java

示例12: HingeConstraint

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public HingeConstraint (RigidBody rbA, RigidBody rbB, Vector3 pivotInA, Vector3 pivotInB, Vector3 axisInA, Vector3 axisInB) {
	super(TypedConstraintType.HINGE_CONSTRAINT_TYPE, rbA, rbB);
	Stack stack = Stack.enter();
	angularOnly = false;
	enableAngularMotor = false;

	rbAFrame.origin.set(pivotInA);

	// since no frame is given, assume this to be zero angle and just pick rb transform axis
	Vector3 rbAxisA1 = stack.allocVector3();
	Vector3 rbAxisA2 = stack.allocVector3();

	Transform centerOfMassA = rbA.getCenterOfMassTransform(stack.allocTransform());
	MatrixUtil.getColumn(centerOfMassA.basis, 0, rbAxisA1);
	float projection = axisInA.dot(rbAxisA1);

	if (projection >= 1.0f - BulletGlobals.SIMD_EPSILON) {
		MatrixUtil.getColumn(centerOfMassA.basis, 2, rbAxisA1);
		rbAxisA1.scl(-1);
		MatrixUtil.getColumn(centerOfMassA.basis, 1, rbAxisA2);
	} else if (projection <= -1.0f + BulletGlobals.SIMD_EPSILON) {
		MatrixUtil.getColumn(centerOfMassA.basis, 2, rbAxisA1);
		MatrixUtil.getColumn(centerOfMassA.basis, 1, rbAxisA2);
	} else {
		rbAxisA2.set(axisInA).crs(rbAxisA1);
		rbAxisA1.set(rbAxisA2).crs(axisInA);
	}

	MatrixUtil.setRow(rbAFrame.basis, 0, rbAxisA1.x, rbAxisA2.x, axisInA.x);
	MatrixUtil.setRow(rbAFrame.basis, 1, rbAxisA1.y, rbAxisA2.y, axisInA.y);
	MatrixUtil.setRow(rbAFrame.basis, 2, rbAxisA1.z, rbAxisA2.z, axisInA.z);

	Quaternion rotationArc = QuaternionUtil.shortestArcQuat(axisInA, axisInB, stack.allocQuaternion());
	Vector3 rbAxisB1 = QuaternionUtil.quatRotate(rotationArc, rbAxisA1, stack.allocVector3());
	Vector3 rbAxisB2 = stack.allocVector3();
	rbAxisB2.set(axisInB).crs(rbAxisB1);

	rbBFrame.origin.set(pivotInB);
	MatrixUtil.setRow(rbBFrame.basis, 0, rbAxisB1.x, rbAxisB2.x, -axisInB.x);
	MatrixUtil.setRow(rbBFrame.basis, 1, rbAxisB1.y, rbAxisB2.y, -axisInB.y);
	MatrixUtil.setRow(rbBFrame.basis, 2, rbAxisB1.z, rbAxisB2.z, -axisInB.z);

	// start with free
	lowerLimit = 1e30f;
	upperLimit = -1e30f;
	biasFactor = 0.3f;
	relaxationFactor = 1.0f;
	limitSoftness = 0.9f;
	solveLimit = false;
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:52,代码来源:HingeConstraint.java

示例13: HingeConstraint

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public HingeConstraint(RigidBody rbA, RigidBody rbB, Vector3f pivotInA, Vector3f pivotInB, Vector3f axisInA, Vector3f axisInB) {
	super(TypedConstraintType.HINGE_CONSTRAINT_TYPE, rbA, rbB);
	angularOnly = false;
	enableAngularMotor = false;

	rbAFrame.origin.set(pivotInA);

	// since no frame is given, assume this to be zero angle and just pick rb transform axis
	Vector3f rbAxisA1 = Stack.alloc(Vector3f.class);
	Vector3f rbAxisA2 = Stack.alloc(Vector3f.class);
	
	Transform centerOfMassA = rbA.getCenterOfMassTransform(Stack.alloc(Transform.class));
	centerOfMassA.basis.getColumn(0, rbAxisA1);
	float projection = axisInA.dot(rbAxisA1);

	if (projection >= 1.0f - BulletGlobals.SIMD_EPSILON) {
		centerOfMassA.basis.getColumn(2, rbAxisA1);
		rbAxisA1.negate();
		centerOfMassA.basis.getColumn(1, rbAxisA2);
	} else if (projection <= -1.0f + BulletGlobals.SIMD_EPSILON) {           
		centerOfMassA.basis.getColumn(2, rbAxisA1);                            
		centerOfMassA.basis.getColumn(1, rbAxisA2);
	} else {
		rbAxisA2.cross(axisInA, rbAxisA1);                                                                
		rbAxisA1.cross(rbAxisA2, axisInA);                                                                                            
	}

	rbAFrame.basis.setRow(0, rbAxisA1.x, rbAxisA2.x, axisInA.x);
	rbAFrame.basis.setRow(1, rbAxisA1.y, rbAxisA2.y, axisInA.y);
	rbAFrame.basis.setRow(2, rbAxisA1.z, rbAxisA2.z, axisInA.z);

	Quat4f rotationArc = QuaternionUtil.shortestArcQuat(axisInA, axisInB, Stack.alloc(Quat4f.class));
	Vector3f rbAxisB1 = QuaternionUtil.quatRotate(rotationArc, rbAxisA1, Stack.alloc(Vector3f.class));
	Vector3f rbAxisB2 = Stack.alloc(Vector3f.class);
	rbAxisB2.cross(axisInB, rbAxisB1);

	rbBFrame.origin.set(pivotInB);
	rbBFrame.basis.setRow(0, rbAxisB1.x, rbAxisB2.x, -axisInB.x);
	rbBFrame.basis.setRow(1, rbAxisB1.y, rbAxisB2.y, -axisInB.y);
	rbBFrame.basis.setRow(2, rbAxisB1.z, rbAxisB2.z, -axisInB.z);			

	// start with free
	lowerLimit = 1e30f;
	upperLimit = -1e30f;
	biasFactor = 0.3f;
	relaxationFactor = 1.0f;
	limitSoftness = 0.9f;
	solveLimit = false;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:50,代码来源:HingeConstraint.java

示例14: renderOpaque

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
@Override
public void renderOpaque() {
    Vector3f cameraPosition = worldRenderer.getActiveCamera().getPosition();

    Quat4f worldRot = new Quat4f();
    Vector3f worldPos = new Vector3f();
    Matrix4f matrix = new Matrix4f();
    Transform trans = new Transform();
    Quat4f inverseWorldRot = new Quat4f();

    glPushMatrix();
    glTranslated(-cameraPosition.x, -cameraPosition.y, -cameraPosition.z);

    for (EntityRef entity : entityManager.iteratorEntities(SkeletalMeshComponent.class, LocationComponent.class)) {
        SkeletalMeshComponent skeletalMesh = entity.getComponent(SkeletalMeshComponent.class);
        if (skeletalMesh.mesh == null || skeletalMesh.material == null) {
            continue;
        }
        skeletalMesh.material.enable();
        skeletalMesh.material.setFloat("light", 1);
        skeletalMesh.material.bindTextures();

        float[] openglMat = new float[16];
        FloatBuffer mBuffer = BufferUtils.createFloatBuffer(16);
        LocationComponent location = entity.getComponent(LocationComponent.class);

        location.getWorldRotation(worldRot);
        inverseWorldRot.inverse(worldRot);
        location.getWorldPosition(worldPos);
        float worldScale = location.getWorldScale();
        matrix.set(worldRot, worldPos, worldScale);
        trans.set(matrix);

        glPushMatrix();
        trans.getOpenGLMatrix(openglMat);
        mBuffer.put(openglMat);
        mBuffer.flip();
        glMultMatrix(mBuffer);

        skeletalMesh.material.setFloat("light", worldRenderer.getRenderingLightValueAt(worldPos));
        List<Vector3f> bonePositions = Lists.newArrayListWithCapacity(skeletalMesh.mesh.getVertexCount());
        List<Quat4f> boneRotations = Lists.newArrayListWithCapacity(skeletalMesh.mesh.getVertexCount());
        for (Bone bone : skeletalMesh.mesh.bones()) {
            EntityRef boneEntity = skeletalMesh.boneEntities.get(bone.getName());
            if (boneEntity == null) {
                boneEntity = EntityRef.NULL;
            }
            LocationComponent boneLocation = boneEntity.getComponent(LocationComponent.class);
            if (boneLocation != null) {
                Vector3f pos = boneLocation.getWorldPosition();
                pos.sub(worldPos);
                QuaternionUtil.quatRotate(inverseWorldRot, pos, pos);
                bonePositions.add(pos);
                Quat4f rot = new Quat4f();
                rot.mul(inverseWorldRot, boneLocation.getWorldRotation());
                boneRotations.add(rot);
            } else {
                logger.warn("Unable to resolve bone \"{}\"", bone.getName());
                bonePositions.add(new Vector3f());
                boneRotations.add(new Quat4f());
            }
        }
        skeletalMesh.mesh.render(bonePositions, boneRotations);
        glPopMatrix();
    }

    glPopMatrix();
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:69,代码来源:SkeletonRenderer.java

示例15: updateListener

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
@Override
public void updateListener(Vector3f position, Quat4f orientation, Vector3f velocity) {

    AL10.alListener3f(AL10.AL_VELOCITY, velocity.x, velocity.y, velocity.z);

    OpenALException.checkState("Setting listener velocity");

    Vector3f dir = QuaternionUtil.quatRotate(orientation, Direction.FORWARD.getVector3f(), new Vector3f());
    Vector3f up = QuaternionUtil.quatRotate(orientation, Direction.UP.getVector3f(), new Vector3f());

    FloatBuffer listenerOri = BufferUtils.createFloatBuffer(6).put(new float[]{dir.x, dir.y, dir.z, up.x, up.y, up.z});
    listenerOri.flip();
    AL10.alListener(AL10.AL_ORIENTATION, listenerOri);

    OpenALException.checkState("Setting listener orientation");
    this.listenerPosition.set(position);

    AL10.alListener3f(AL10.AL_POSITION, position.x, position.y, position.z);

    OpenALException.checkState("Setting listener position");
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:22,代码来源:OpenALManager.java


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