當前位置: 首頁>>代碼示例>>Java>>正文


Java Quaternion類代碼示例

本文整理匯總了Java中com.jme3.math.Quaternion的典型用法代碼示例。如果您正苦於以下問題:Java Quaternion類的具體用法?Java Quaternion怎麽用?Java Quaternion使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Quaternion類屬於com.jme3.math包,在下文中一共展示了Quaternion類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initWorld

import com.jme3.math.Quaternion; //導入依賴的package包/類
private void initWorld(){
    EntityId centerFloor = entityData.createEntity();
    entityData.setComponents(centerFloor,
            new BoxShape(new Vector3f(5f, 0.2f, 5f)),
            new BoxView(new Vector3f(5f, 0.2f, 5f)),
            new ShadedColor(ColorRGBA.Green),
            new PhysicsToViewLocation(),
            new PhysicsToViewRotation(),
            new RigidBody(false, 0)
    );
    EntityId forceFieldFloor = entityData.createEntity();
    entityData.setComponents(forceFieldFloor,
            new BoxShape(new Vector3f(5f, 0.2f, 5f)),
            new BoxView(new Vector3f(5f, 0.2f, 5f)),
            new ShadedColor(ColorRGBA.Red),
            new PhysicsToViewLocation(),
            new PhysicsToViewRotation(),
            new RigidBody(false, 0),
            new WarpPosition(new Vector3f(10, 0,0), new Quaternion())
    );
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:22,代碼來源:ForceFieldExample.java

示例2: simpleInitApp

import com.jme3.math.Quaternion; //導入依賴的package包/類
@Override
public void simpleInitApp() {
    //Add some entities
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))),
            new Name("floor"));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape(),
            new Name("box1"));

    EntityId box2 = entityData.createEntity();
    entityData.setComponents(box2,
            new RigidBody(false, 0),
            new BoxShape(),
            new Name("box2"));

    entityData.setComponent(box, new Force(new Vector3f(100,100,100), new Vector3f()));

    colliding = entityData.getEntities(Collision.class, Name.class);
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:27,代碼來源:CollisionExample.java

示例3: simpleInitApp

import com.jme3.math.Quaternion; //導入依賴的package包/類
@Override
public void simpleInitApp() {
    //create a new debug view state
    //you have to add the same CustomShapeFactory which you have added to the BulletSystem
    //if no factory is given to the constructor the default factory will be used (CollisionShapeFactory)
    ESDebugViewState debugView = new ESDebugViewState(entityData, getRootNode());
    getStateManager().attach(debugView);

    EntityId sphere = entityData.createEntity();
    entityData.setComponents(sphere,
            new CustomShape(new SphereCollisionShape(0.5f)),
            new RigidBody(false, 10),
            new WarpPosition(new Vector3f(0, 15, 0), Quaternion.DIRECTION_Z.clone()));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new BoxShape(new Vector3f(5f, 0.1f, 5f)),
            new RigidBody(false, 0));
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:20,代碼來源:DebugViewExample.java

示例4: simpleInitApp

import com.jme3.math.Quaternion; //導入依賴的package包/類
@Override
public void simpleInitApp() {
    //Same setup as in BasicExample
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,0,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());


    //Add two custom impulses. They are only applied once. You could play with the values..
    entityData.setComponent(box, new CombinedImpulses(new Vector3f(100, 0,0), new Vector3f()));
    //for the second one we have to update the CombinedImpulses component.
    entityData.setComponent(box, entityData.getComponent(box, CombinedImpulses.class).addImpulse(new Vector3f(-150, 0, 0), new Vector3f()));

    ESBulletState esBulletState = stateManager.getState(ESBulletState.class);
    esBulletState.onInitialize(() -> {
        BulletDebugAppState debugAppState = new BulletDebugAppState(esBulletState.getPhysicsSpace());
        getStateManager().attach(debugAppState);
    });
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:27,代碼來源:CombinedImpulsesExample.java

示例5: controlUpdate

import com.jme3.math.Quaternion; //導入依賴的package包/類
@Override
protected void controlUpdate(final float tpf) {

    final PhysicsCharacter body = getBody();
    final CollisionShape shape = body.getCollisionShape();

    if (currentShape != shape) {
        final Node node = (Node) getSpatial();
        node.detachChild(geom);
        geom = getDebugShape(shape);
        geom.setMaterial(debugAppState.getDebugPink());
        node.attachChild(geom);
        currentShape = shape;
    }

    final Vector3f physicsLocation = body.getPhysicsLocation(physicalLocation);

    applyPhysicsTransform(physicsLocation, Quaternion.IDENTITY);

    geom.setLocalScale(shape.getScale());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder-extension,代碼行數:22,代碼來源:BulletCharacterDebugControl.java

示例6: setCollisionPlane

import com.jme3.math.Quaternion; //導入依賴的package包/類
@Override
public void setCollisionPlane(@NotNull final CollisionResult collisionResult) {

    final EditorTransformSupport editorControl = getEditorControl();
    final Transform transform = editorControl.getTransformCenter();

    if (transform == null) {
        LOGGER.warning(this, "not found transform center for the " + editorControl);
        return;
    }

    detectPickedAxis(editorControl, collisionResult);

    // set the collision Plane location and rotation
    final Node collisionPlane = getCollisionPlane();
    collisionPlane.setLocalTranslation(transform.getTranslation());
    collisionPlane.setLocalRotation(Quaternion.IDENTITY);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:19,代碼來源:AbstractTransformControl.java

示例7: reload

import com.jme3.math.Quaternion; //導入依賴的package包/類
@Override
@FXThread
protected void reload() {

    final float[] angles = new float[3];

    final Quaternion element = getPropertyValue();
    notNull(element, "The property value can't be null.");

    element.toAngles(angles);

    final FloatTextField xField = getXField();
    xField.setValue(radiansToDegree(angles[0]));
    xField.positionCaret(xField.getText().length());

    final FloatTextField yFiled = getYFiled();
    yFiled.setValue(radiansToDegree(angles[1]));
    yFiled.positionCaret(yFiled.getText().length());

    final FloatTextField zField = getZField();
    zField.setValue(radiansToDegree(angles[2]));
    zField.positionCaret(zField.getText().length());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:24,代碼來源:QuaternionPropertyControl.java

示例8: updateRotation

import com.jme3.math.Quaternion; //導入依賴的package包/類
/**
 * Updating rotation.
 */
@FXThread
private void updateRotation(@Nullable final KeyEvent event) {
    if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return;

    final Quaternion oldValue = notNull(getPropertyValue());

    final FloatTextField xField = getXField();
    final float x = degreeToRadians(xField.getValue());

    final FloatTextField yFiled = getYFiled();
    final float y = degreeToRadians(yFiled.getValue());

    final FloatTextField zField = getZField();
    final float z = degreeToRadians(zField.getValue());

    final Quaternion newValue = new Quaternion();
    newValue.fromAngles(ArrayFactory.toFloatArray(x, y, z));

    changed(newValue, oldValue.clone());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:24,代碼來源:QuaternionPropertyControl.java

示例9: build

import com.jme3.math.Quaternion; //導入依賴的package包/類
@FXThread
private void build(@NotNull final ChildCollisionShape shape, @NotNull final VBox container,
                   @NotNull final ModelChangeConsumer changeConsumer) {

    final Vector3f location = shape.location;
    final Matrix3f rotation = shape.rotation;

    final DefaultSinglePropertyControl<ModelChangeConsumer, ChildCollisionShape, Vector3f> locationControl =
            new DefaultSinglePropertyControl<>(location, Messages.MODEL_PROPERTY_LOCATION, changeConsumer);

    locationControl.setSyncHandler(collisionShape -> collisionShape.location);
    locationControl.setToStringFunction(Vector3f::toString);
    locationControl.setEditObject(shape);

    final DefaultSinglePropertyControl<ModelChangeConsumer, ChildCollisionShape, Matrix3f> rotationControl =
            new DefaultSinglePropertyControl<>(rotation, Messages.MODEL_PROPERTY_ROTATION, changeConsumer);

    rotationControl.setSyncHandler(collisionShape -> collisionShape.rotation);
    rotationControl.setToStringFunction(matrix3f -> new Quaternion().fromRotationMatrix(matrix3f).toString());
    rotationControl.setEditObject(shape);
    rotationControl.reload();

    FXUtils.addToPane(locationControl, container);
    FXUtils.addToPane(rotationControl, container);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:26,代碼來源:CollisionShapePropertyBuilder.java

示例10: createControl

import com.jme3.math.Quaternion; //導入依賴的package包/類
@Override
@FXThread
protected @NotNull Control createControl(@NotNull final Spatial parent) {

    final MotionPath motionPath = new MotionPath();
    motionPath.addWayPoint(Vector3f.ZERO.clone());
    motionPath.addWayPoint(new Vector3f(0f, 1f, 0f));
    motionPath.addWayPoint(new Vector3f(1f, 0f, 1f));

    final MotionEvent control = new MotionEvent();
    control.setLookAt(Vector3f.UNIT_Z, Vector3f.UNIT_Y);
    control.setRotation(Quaternion.IDENTITY);
    control.setPath(motionPath);

    return control;
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:17,代碼來源:CreateMotionControlAction.java

示例11: applyWheelTransform

import com.jme3.math.Quaternion; //導入依賴的package包/類
public synchronized void applyWheelTransform() {
    if (wheelSpatial == null) {
        return;
    }
    Quaternion localRotationQuat = wheelSpatial.getLocalRotation();
    Vector3f localLocation = wheelSpatial.getLocalTranslation();
    if (!applyLocal && wheelSpatial.getParent() != null) {
        localLocation.set(wheelWorldLocation).subtractLocal(wheelSpatial.getParent().getWorldTranslation());
        localLocation.divideLocal(wheelSpatial.getParent().getWorldScale());
        tmp_inverseWorldRotation.set(wheelSpatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);

        localRotationQuat.set(wheelWorldRotation);
        tmp_inverseWorldRotation.set(wheelSpatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);

        wheelSpatial.setLocalTranslation(localLocation);
        wheelSpatial.setLocalRotation(localRotationQuat);
    } else {
        wheelSpatial.setLocalTranslation(wheelWorldLocation);
        wheelSpatial.setLocalRotation(wheelWorldRotation);
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:22,代碼來源:VehicleWheel.java

示例12: read

import com.jme3.math.Quaternion; //導入依賴的package包/類
public void read(JmeImporter e) throws IOException {
    InputCapsule capsule = e.getCapsule(this);
    location = (Vector3f) capsule.readSavable("location", Vector3f.ZERO.clone());
    rotation = (Quaternion) capsule.readSavable("rotation", Quaternion.DIRECTION_Z.clone());
    frustumNear = capsule.readFloat("frustumNear", 1);
    frustumFar = capsule.readFloat("frustumFar", 2);
    frustumLeft = capsule.readFloat("frustumLeft", -0.5f);
    frustumRight = capsule.readFloat("frustumRight", 0.5f);
    frustumTop = capsule.readFloat("frustumTop", 0.5f);
    frustumBottom = capsule.readFloat("frustumBottom", -0.5f);
    coeffLeft = capsule.readFloatArray("coeffLeft", new float[2]);
    coeffRight = capsule.readFloatArray("coeffRight", new float[2]);
    coeffBottom = capsule.readFloatArray("coeffBottom", new float[2]);
    coeffTop = capsule.readFloatArray("coeffTop", new float[2]);
    viewPortLeft = capsule.readFloat("viewPortLeft", 0);
    viewPortRight = capsule.readFloat("viewPortRight", 1);
    viewPortTop = capsule.readFloat("viewPortTop", 1);
    viewPortBottom = capsule.readFloat("viewPortBottom", 0);
    width = capsule.readInt("width", 1);
    height = capsule.readInt("height", 1);
    name = capsule.readString("name", null);
    onFrustumChange();
    onViewPortChange();
    onFrameChange();
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:26,代碼來源:Camera.java

示例13: getRotation

import com.jme3.math.Quaternion; //導入依賴的package包/類
/**
 * Get the Rotation into a specific custom space.
 *
 * @param transform the rotation to the custom space (World to Custom
 * space)
 * @return the Rotation in the custom space
 */
public Quaternion getRotation(Quaternion transform) {
    if (startPickLoc == null) {
        Logger.getLogger(this.getClass().getSimpleName()).warning("startPickLoc null in PickManager#getRotation()");
        return transform;
    } else if (finalPickLoc == null) {
        Logger.getLogger(this.getClass().getSimpleName()).warning("finalPickLoc null in PickManager#getRotation()");
        return transform;
    }
    
    Vector3f v1, v2;
    v1 = transform.mult(startPickLoc.subtract(startSpatialLocation).normalize());
    v2 = transform.mult(finalPickLoc.subtract(startSpatialLocation).normalize());
    Vector3f axis = v1.cross(v2);
    float angle = v1.angleBetween(v2);
    return new Quaternion().fromAngleAxis(angle, axis);
}
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:24,代碼來源:PickManager.java

示例14: updateState

import com.jme3.math.Quaternion; //導入依賴的package包/類
@Override
public void updateState() {
    super.updateState();
    Vector3f location = new Vector3f(target.getSpatial().getLocalTranslation());
    location.setY(target.getWaterHeight());
    setLocalTranslation(location);
    if (target.getCenter() != null) {
        setLocalScale(new Vector3f(target.getRadius(), target.getRadius(), target.getRadius()));
    } else {
        setLocalScale(new Vector3f(MAX_RADIUS, MAX_RADIUS, MAX_RADIUS));
    }
    Quaternion qua = new Quaternion();
    Vector3f windDir = new Vector3f(target.getWindDirection().x, 0, target.getWindDirection().y).normalizeLocal();
    qua.lookAt(windDir, Vector3f.UNIT_Y);
    setLocalRotation(qua);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:17,代碼來源:AdvanceWaterEntityControlTile.java

示例15: controlUpdate

import com.jme3.math.Quaternion; //導入依賴的package包/類
@Override
protected void controlUpdate(float f) {
    refreshLightDirection();
    if (!lightDir.equals(lastDir)) {
        lastDir.set(lightDir);

        Vector3f axis = Vector3f.UNIT_Y.cross(lastDir);
        float angle = Vector3f.UNIT_Y.angleBetween(lastDir);
        //Quaternion rotation = gizmo.getWorldRotation().inverse().mult(new Quaternion().fromAngleAxis(angle, axis));
        
        if (angle > 1f * FastMath.DEG_TO_RAD) { // Anti Flickering
            Quaternion rotation = new Quaternion().fromAngleAxis(angle, axis);
            gizmo.silentLocalRotation(rotation); /* silent, because otherwise
            the gizmo would call light.setDirection() and update the property */
        }
    }
}
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:18,代碼來源:LightDirectionUpdate.java


注:本文中的com.jme3.math.Quaternion類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。