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


Java Vector3f.multLocal方法代码示例

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


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

示例1: run

import com.jme3.math.Vector3f; //导入方法依赖的package包/类
@Override
public void run() {
    float mass = get(RigidBody.class).getMass();
    if (mass == 0) {
        return;
    }
    Vector3f pos = get(PhysicsPosition.class).getLocation();
    Vector3f force = new Vector3f();
    //sum up all force producers to create the final force
    producers.forEach(entity -> {
        Vector3f prodPos = entity.get(PhysicsPosition.class).getLocation();
        force.addLocal(entity.get(ForceProducer.class).getForceDefinition().apply(pos.subtract(prodPos)));
    });
    force.multLocal(mass);
    //TODO remove if = (0,0,0)
    set(new Force(force));
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:18,代码来源:ForceProducerLogic.java

示例2: moveDirectionCamera

import com.jme3.math.Vector3f; //导入方法依赖的package包/类
/**
 * Move a camera to direction.
 *
 * @param value the value to move.
 */
@JMEThread
private void moveDirectionCamera(final float value, final boolean isAction, final boolean isPressed, final int key) {
    if (!canCameraMove()) return;
    if (isAction && isPressed) startCameraMoving(key);
    else if (isAction) finishCameraMoving(key, false);
    if (!isCameraMoving() || isAction) return;

    final EditorCamera editorCamera = getEditorCamera();
    if (editorCamera == null) return;

    final Camera camera = EDITOR.getCamera();
    final Node nodeForCamera = getNodeForCamera();

    final LocalObjects local = LocalObjects.get();
    final Vector3f direction = camera.getDirection(local.nextVector());
    direction.multLocal(value * cameraSpeed);
    direction.addLocal(nodeForCamera.getLocalTranslation());

    nodeForCamera.setLocalTranslation(direction);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:AdvancedAbstractEditor3DState.java

示例3: moveSideCamera

import com.jme3.math.Vector3f; //导入方法依赖的package包/类
/**
 * Move a camera to side.
 *
 * @param value the value to move.
 */
@JMEThread
private void moveSideCamera(final float value, final boolean isAction, final boolean isPressed, final int key) {
    if (!canCameraMove()) return;
    if (isAction && isPressed) startCameraMoving(key);
    else if (isAction) finishCameraMoving(key, false);
    if (!isCameraMoving() || isAction) return;

    final EditorCamera editorCamera = getEditorCamera();
    if (editorCamera == null) return;

    final Camera camera = EDITOR.getCamera();
    final Node nodeForCamera = getNodeForCamera();

    final LocalObjects local = LocalObjects.get();
    final Vector3f left = camera.getLeft(local.nextVector());
    left.multLocal(value * cameraSpeed);
    left.addLocal(nodeForCamera.getLocalTranslation());

    nodeForCamera.setLocalTranslation(left);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:AdvancedAbstractEditor3DState.java

示例4: updateModel

import com.jme3.math.Vector3f; //导入方法依赖的package包/类
/**
 * Update position and rotation of a model.
 */
@JMEThread
public void updateModel() {

    final AudioNode audioNode = getAudioNode();
    final Node model = getModel();
    if (model == null || audioNode == null) return;

    final Node parent = audioNode.getParent();

    if (parent != null) {
        setLocalTranslation(parent.getWorldTranslation());
        setLocalRotation(parent.getWorldRotation());
        setLocalScale(parent.getWorldScale());
    }

    final Node editedNode = getEditedNode();
    final LocalObjects local = LocalObjects.get();
    final Vector3f positionOnCamera = local.nextVector();
    positionOnCamera.set(editedNode.getWorldTranslation()).subtractLocal(camera.getLocation());
    positionOnCamera.normalizeLocal();
    positionOnCamera.multLocal(camera.getFrustumNear() + 0.4f);
    positionOnCamera.addLocal(camera.getLocation());

    model.setLocalTranslation(positionOnCamera);
    model.setLocalRotation(editedNode.getLocalRotation());
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:30,代码来源:EditorAudioNode.java

示例5: checkAndUpdateVehicle

import com.jme3.math.Vector3f; //导入方法依赖的package包/类
private void checkAndUpdateVehicle() {

        final int numWheels = body.getNumWheels();

        suspensionNode.detachAllChildren();

        for (int i = 0; i < numWheels; i++) {

            final VehicleWheel physicsVehicleWheel = body.getWheel(i);

            final Vector3f location = new Vector3f(physicsVehicleWheel.getLocation());
            final Vector3f direction = new Vector3f(physicsVehicleWheel.getDirection());
            direction.normalizeLocal();

            final Vector3f axle = new Vector3f(physicsVehicleWheel.getAxle());
            axle.normalizeLocal();
            axle.multLocal(0.3f);

            final float restLength = physicsVehicleWheel.getRestLength();
            final float radius = physicsVehicleWheel.getRadius();

            final Arrow locArrow = new Arrow(location);
            final Arrow axleArrow = new Arrow(axle);
            final Arrow wheelArrow = new Arrow(direction.multLocal(radius));
            final Arrow dirArrow = new Arrow(direction.multLocal(restLength));

            final Geometry locGeom = new Geometry("WheelLocationDebugShape" + i, locArrow);
            final Geometry dirGeom = new Geometry("WheelDirectionDebugShape" + i, dirArrow);
            final Geometry axleGeom = new Geometry("WheelAxleDebugShape" + i, axleArrow);
            final Geometry wheelGeom = new Geometry("WheelRadiusDebugShape" + i, wheelArrow);

            dirGeom.setLocalTranslation(location);
            axleGeom.setLocalTranslation(location.add(direction));
            wheelGeom.setLocalTranslation(location.add(direction));

            locGeom.setMaterial(debugAppState.getDebugMagenta());
            dirGeom.setMaterial(debugAppState.getDebugMagenta());
            axleGeom.setMaterial(debugAppState.getDebugMagenta());
            wheelGeom.setMaterial(debugAppState.getDebugMagenta());

            suspensionNode.attachChild(locGeom);
            suspensionNode.attachChild(dirGeom);
            suspensionNode.attachChild(axleGeom);
            suspensionNode.attachChild(wheelGeom);
        }
    }
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:47,代码来源:BulletVehicleDebugControl.java

示例6: controlUpdate

import com.jme3.math.Vector3f; //导入方法依赖的package包/类
@Override
protected void controlUpdate(final float tpf) {
    checkAndUpdateVehicle();

    for (int i = 0; i < body.getNumWheels(); i++) {

        final VehicleWheel physicsVehicleWheel = body.getWheel(i);

        final Vector3f location = new Vector3f(physicsVehicleWheel.getLocation());
        final Vector3f direction = new Vector3f(physicsVehicleWheel.getDirection());
        direction.normalizeLocal();

        final Vector3f axle = new Vector3f(physicsVehicleWheel.getAxle());
        axle.normalizeLocal();
        axle.multLocal(0.3f);

        final float restLength = physicsVehicleWheel.getRestLength();
        final float radius = physicsVehicleWheel.getRadius();

        final Geometry locGeom = (Geometry) suspensionNode.getChild("WheelLocationDebugShape" + i);
        final Geometry dirGeom = (Geometry) suspensionNode.getChild("WheelDirectionDebugShape" + i);
        final Geometry axleGeom = (Geometry) suspensionNode.getChild("WheelAxleDebugShape" + i);
        final Geometry wheelGeom = (Geometry) suspensionNode.getChild("WheelRadiusDebugShape" + i);

        final Arrow locArrow = (Arrow) locGeom.getMesh();
        locArrow.setArrowExtent(location);

        final Arrow axleArrow = (Arrow) axleGeom.getMesh();
        axleArrow.setArrowExtent(axle);

        final Arrow wheelArrow = (Arrow) wheelGeom.getMesh();
        wheelArrow.setArrowExtent(direction.multLocal(radius));

        final Arrow dirArrow = (Arrow) dirGeom.getMesh();
        dirArrow.setArrowExtent(direction.multLocal(restLength));

        dirGeom.setLocalTranslation(location);
        axleGeom.setLocalTranslation(location.addLocal(direction));
        wheelGeom.setLocalTranslation(location);
    }

    final Vector3f physicsLocation = body.getPhysicsLocation(physicalLocation);
    final Quaternion physicsRotation = body.getPhysicsRotation(physicalRotation);

    applyPhysicsTransform(physicsLocation, physicsRotation);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:47,代码来源:BulletVehicleDebugControl.java


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