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


Java Quaternionf类代码示例

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


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

示例1: Cone

import org.joml.Quaternionf; //导入依赖的package包/类
/**
 * Creates a new cone at the specified position
 * using the specified rotation and scale.
 * 
 * @param position - Position of the cone.
 * @param rotation - Rotation of the cone.
 * @param scale - Scale of the cone.
 */
public Cone(Vector3f position, Quaternionf rotation, float scale) {
	super();

	height = 1;
	radius = 1;
	sides = 10;
	
	generateVertices();
	generateNormals();
	generateTextureCoordinates();
	
	Mesh mesh = new Mesh(cone_positions, cone_texture_coordinates, cone_normals, cone_indices);
	Material mat = new Material();
	
	mesh.setMaterial(mat);
	setMesh(mesh);
	
	setPosition(position.x, position.y, position.z);
	setRotation(rotation);
	setScale(scale);
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:30,代码来源:Cone.java

示例2: Sphere

import org.joml.Quaternionf; //导入依赖的package包/类
/**
 * Creates a new sphere at the specified position
 * using the specified rotation and scale. Then 
 * subdivides the sphere with the specified amount of iterations.
 * 
 * @param position - Position of the sphere.
 * @param rotation - Rotation of the sphere.
 * @param scale - Scale of the sphere.
 * @param iterations - Number of subdivisions.
 */
public Sphere(Vector3f position, Quaternionf rotation, float scale, int iterations) {
	super();
	
	generateVertices();
	subdivide(iterations);
	generateNormals();
	generateTextureCoordinates();
	
	Mesh mesh = new Mesh(sphere_positions, sphere_texture_coordinates, sphere_normals, sphere_indices);
	Material mat = new Material();
	
	mesh.setMaterial(mat);
	setMesh(mesh);
	
	setPosition(position.x, position.y, position.z);
       setRotation(rotation);
       setScale(scale);
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:29,代码来源:Sphere.java

示例3: Cylinder

import org.joml.Quaternionf; //导入依赖的package包/类
/**
 * Creates a new cylinder at the specified position
 * using the specified rotation and scale.
 * 
 * @param position - Position of the cylinder.
 * @param rotation - Rotation of the cylinder.
 * @param scale - Scale of the cylinder.
 */
public Cylinder(Vector3f position, Quaternionf rotation, float scale) {
	super();
	
	height = 1;
	radius = 1;
	sides = 10;
	
	generateVertices();
	generateNormals();
	generateTextureCoordinates();
	
	Mesh mesh = new Mesh(cylinder_positions, cylinder_texture_coordinates, cylinder_normals, cylinder_indices);
	Material mat = new Material();
	
	mesh.setMaterial(mat);
	setMesh(mesh);
	
	setPosition(position.x, position.y, position.z);
	setRotation(rotation);
	setScale(scale);
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:30,代码来源:Cylinder.java

示例4: Cube

import org.joml.Quaternionf; //导入依赖的package包/类
/**
 * Creates a new cube at the specified position
 * using the specified rotation, scale and color.
 *
 * @param position - Position of the cube.
 * @param rotation - Rotation of the cube.
 * @param scale - Scale of the cube.
 * @param color - Color of the cube.
 */
public Cube(Vector3f position, Quaternionf rotation, float scale, Color color) {
    super();

    Mesh mesh = new Mesh(CUBE_POSITIONS, CUBE_TEXTURE_COORDINATES, CUBE_NORMALS, CUBE_INDICES);
    Material mat = new Material();

    mat.setAmbientColor(color.toVector4f());
    mat.setDiffuseColor(color.toVector4f());
    mat.setSpecularColor(color.toVector4f());

    mesh.setMaterial(mat);
    setMesh(mesh);

    setPosition(position.x, position.y, position.z);
    setRotation(rotation);
    setScale(scale);
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:27,代码来源:Cube.java

示例5: toQuat

import org.joml.Quaternionf; //导入依赖的package包/类
/**
 * 
 * @param pitch
 * @param yaw
 * @param roll
 * @return
 */
public static Quaternionf toQuat(float pitch, float yaw, float roll) {
	Quaternionf quat = new Quaternionf();
	
	float t0 = (float) Math.cos(yaw * 0.5f);
	float t1 = (float) Math.sin(yaw * 0.5f);
	float t2 = (float) Math.cos(roll * 0.5f);
	float t3 = (float) Math.sin(roll * 0.5f);
	float t4 = (float) Math.cos(pitch * 0.5f);
	float t5 = (float) Math.sin(pitch * 0.5f);
	
	quat.w = t0 * t2 * t4 + t1 * t3 * t5;
	quat.x = t0 * t3 * t4 - t1 * t2 * t5;
	quat.y = t0 * t2 * t5 + t1 * t3 * t4;
	quat.z = t1 * t2 * t4 - t0 * t3 * t5;
	
	return quat;
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:25,代码来源:QuatHelper.java

示例6: move

import org.joml.Quaternionf; //导入依赖的package包/类
private void move(int delta) {
    movementVector.zero();

    if (input.isForwardPressed()) {
        movementVector.add(-1, 0, 0);
    }
    if (input.isBackwardsPressed())
        movementVector.add(1, 0, 0);
    if (input.isLeftPressed())
        movementVector.add(0, 0, 1);
    if (input.isRightPressed())
        movementVector.add(0, 0, -1);
    Quaternionf rotation = Transforms.getAbsoluteRotation(getOwner(), new Quaternionf());
    if (movementVector.lengthSquared() >= 1.0f) {
        movementVector.normalize();
        movementVector.rotate(rotation);
        movementVector.mul(MOV_SPEED * delta);
        physicsProperty.applyCentralForce(movementVector);
    }
}
 
开发者ID:WarpOrganization,项目名称:warp,代码行数:21,代码来源:MovementScript.java

示例7: move

import org.joml.Quaternionf; //导入依赖的package包/类
private void move(int delta) {
        if (input.isKeyDown(VK_SHIFT))
            cameraSpeed = CAMERA_SPEED * 3;
        else cameraSpeed = CAMERA_SPEED;

        movementVector.zero();
        if (input.isKeyDown(VK_W)) {
            movementVector.add(0, 0, -1);
//            getOwner().triggerEvent(new Envelope(new InputEvent(VK_W)));
        }
        if (input.isKeyDown(VK_S))
            movementVector.add(0, 0, 1);
        if (input.isKeyDown(VK_A))
            movementVector.add(-1, 0, 0);
        if (input.isKeyDown(VK_D))
            movementVector.add(1, 0, 0);
        Quaternionf rotation = Transforms.getAbsoluteRotation(getOwner(), new Quaternionf());
        if (movementVector.lengthSquared() >= 1.0f) {
            movementVector.normalize();
            movementVector.rotate(rotation);
            movementVector.mul(cameraSpeed * delta);
            transformProperty.move(movementVector);
        }
    }
 
开发者ID:WarpOrganization,项目名称:warp,代码行数:25,代码来源:SimpleControlScript.java

示例8: SmoothToComponent

import org.joml.Quaternionf; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param worldSpace True if the target position and rotation are in world space, false if they are local.
 * @param targetPosition Target position to smooth to.
 * @param targetRotation Target rotation to smooth to.
 * @param positionDamping Amount of positional damping while smoothing.
 * @param rotationDamping Amount of rotational damping while smoothing.
 */
public SmoothToComponent(boolean worldSpace, Vector3f targetPosition, Quaternionf targetRotation, float positionDamping, float rotationDamping) {
    // Set the world space mode
    this.worldSpace = worldSpace;

    // Copy the target position and rotation if set
    if(targetPosition != null)
        this.targetPosition.set(targetPosition);
    if(targetRotation != null)
        this.targetRotation.set(targetRotation);

    // Set whether to use the target position and rotation
    this.useTargetPosition = targetPosition != null;
    this.useTargetRotation = targetRotation != null;

    // Set the positional and rotational damping
    this.positionDamping = positionDamping;
    this.rotationDamping = rotationDamping;
}
 
开发者ID:timvisee,项目名称:key-barricade,代码行数:28,代码来源:SmoothToComponent.java

示例9: CameraInternal

import org.joml.Quaternionf; //导入依赖的package包/类
public CameraInternal(Rect viewport, float fieldOfView, float zNear, float zFar, int depth)
{
	Events.onWindowResize.addListener(windowResizeEvent = () -> updateProjection());
	
	// TODO; Change skybox to default skybox
	Skybox.setTexture(Assets2.load(Cubemap.class, "skybox/skybox.jpg"));
	
	this.clearFlags = CameraClearFlags.SolidColor;
	this.clearColor = Color.BLACK;
	
	this.position = new Vector3f();
	this.rotation = new Quaternionf();
	
	this.viewport = viewport;
	this.fieldOfView = fieldOfView;
	this.zNear = zNear;
	this.zFar = zFar;
	this.depth = depth;
	
	updateProjection();
	
	main = main == null ? this : main;
	cameras.add(this);
}
 
开发者ID:Snakybo,项目名称:TorchEngine,代码行数:25,代码来源:CameraInternal.java

示例10: buildTransFormationMatrices

import org.joml.Quaternionf; //导入依赖的package包/类
private static void buildTransFormationMatrices(AINodeAnim aiNodeAnim, Node node) {
    int numFrames = aiNodeAnim.mNumPositionKeys();
    AIVectorKey.Buffer positionKeys = aiNodeAnim.mPositionKeys();
    AIVectorKey.Buffer scalingKeys = aiNodeAnim.mScalingKeys();
    AIQuatKey.Buffer rotationKeys = aiNodeAnim.mRotationKeys();

    for (int i = 0; i < numFrames; i++) {
        AIVectorKey aiVecKey = positionKeys.get(i);
        AIVector3D vec = aiVecKey.mValue();

        Matrix4f transfMat = new Matrix4f().translate(vec.x(), vec.y(), vec.z());

        AIQuatKey quatKey = rotationKeys.get(i);
        AIQuaternion aiQuat = quatKey.mValue();
        Quaternionf quat = new Quaternionf(aiQuat.x(), aiQuat.y(), aiQuat.z(), aiQuat.w());
        transfMat.rotate(quat);

        if (i < aiNodeAnim.mNumScalingKeys()) {
            aiVecKey = scalingKeys.get(i);
            vec = aiVecKey.mValue();
            transfMat.scale(vec.x(), vec.y(), vec.z());
        }

        node.addTransformation(transfMat);
    }
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:27,代码来源:AnimMeshesLoader.java

示例11: Entity

import org.joml.Quaternionf; //导入依赖的package包/类
/**
 * Default constructor for the Entity class.
 * Sets the mesh to null, position and rotation to vectors of 0s
 * and scale to 1.
 */
protected  Entity() {
	selected = false;
	
    position = new Vector3f(0, 0, 0);
    rotation =  new Quaternionf();
    
    scale = 1;
    
    texturePosition = 0;
    insideFrustrumCulling = true;
    disableFrustrumCulling = false;
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:18,代码来源:Entity.java

示例12: buildModelMatrix

import org.joml.Quaternionf; //导入依赖的package包/类
public Matrix4f buildModelMatrix(Entity entity) {
	Quaternionf rotation = entity.getRotation();
	Vector3f position = entity.getPosition();
	
	return modelMatrix.translationRotateScale(position.x, position.y, position.z, 
			rotation.x, rotation.y, rotation.z, rotation.w, 
			entity.getScale(), entity.getScale(), entity.getScale());
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:9,代码来源:Transformation.java

示例13: getRotation

import org.joml.Quaternionf; //导入依赖的package包/类
@Override
public Quaternionf getRotation(Quaternionf dst)
{
	this.parent.getRotation(dst);
	dst.mul(super.rotation);
	return dst;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:8,代码来源:DerivedTransform3.java

示例14: getRotation

import org.joml.Quaternionf; //导入依赖的package包/类
@Override
public Quaternionf getRotation(Quaternionf dst)
{
	this.parent.getRotation(dst);
	dst.mul(super.quaternion());
	return dst;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:8,代码来源:DerivedTransform2.java

示例15: calculateQuaternion

import org.joml.Quaternionf; //导入依赖的package包/类
public static Quaternionf calculateQuaternion(float x, float y, float z) {
    Quaternionf orientation = new Quaternionf(x, y, z, 0);
    float temp = 1.0f - (orientation.x * orientation.x) - (orientation.y * orientation.y) -
            (orientation.z * orientation.z);
    if (temp < 0.0f) {
        orientation.w = 0.0f;
    } else {
        orientation.w = -(float) (Math.sqrt(temp));
    }
    return orientation;
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:12,代码来源:MD5Utils.java


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