当前位置: 首页>>代码示例>>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;未经允许,请勿转载。