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


Java Geometry.setLocalTranslation方法代碼示例

本文整理匯總了Java中com.jme3.scene.Geometry.setLocalTranslation方法的典型用法代碼示例。如果您正苦於以下問題:Java Geometry.setLocalTranslation方法的具體用法?Java Geometry.setLocalTranslation怎麽用?Java Geometry.setLocalTranslation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jme3.scene.Geometry的用法示例。


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

示例1: addObject

import com.jme3.scene.Geometry; //導入方法依賴的package包/類
@Override
protected Spatial addObject(Entity e) {
    Vector3f loc = e.get(PhysicsPosition.class).getLocation();
    Mesh mesh = MeshFactory.createSphere(0.25f);
    Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    material.setColor("Color", ColorRGBA.Orange);
    TextureKey key = new TextureKey("Interface/grid-shaded.png");
    key.setGenerateMips(true);
    Texture texture = assetManager.loadTexture(key);
    texture.setWrap(Texture.WrapMode.Repeat);
    material.setTexture("ColorMap", texture);
    Geometry geometry = new Geometry("PhysicsPosition: "+e.getId(), mesh);
    geometry.setMaterial(material);
    geometry.setLocalTranslation(loc);
    rootNode.attachChild(geometry);
    return geometry;
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:18,代碼來源:ESDebugViewState.java

示例2: updateModel

import com.jme3.scene.Geometry; //導入方法依賴的package包/類
/**
 * Update position and rotation of a model.
 */
@JMEThread
public void updateModel() {

    final ScenePresentable object = getObject();
    final Geometry model = getModel();
    if (model == null || object == null) return;

    // TODO implement getting parent
    /*final Node parent = object.getParent();

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

    final Node editedNode = getEditedNode();
    model.setLocalTranslation(editedNode.getWorldTranslation());
    model.setLocalRotation(editedNode.getWorldRotation());
    model.setLocalScale(editedNode.getWorldScale());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:25,代碼來源:EditorPresentableNode.java

示例3: onAttached

import com.jme3.scene.Geometry; //導入方法依賴的package包/類
@Override
protected void onAttached(@NotNull final Node node) {
    super.onAttached(node);

    final Spatial editedModel = notNull(getEditedModel());
    final Geometry baseMarker = getBaseMarker();
    final Geometry targetMarker = getTargetMarker();
    final Geometry line = getLine();

    final Node markersNode = component.getMarkersNode();
    markersNode.attachChild(baseMarker);
    markersNode.attachChild(targetMarker);
    markersNode.attachChild(line);

    baseMarker.setLocalTranslation(editedModel.getWorldTranslation());
    targetMarker.setLocalTranslation(editedModel.getWorldTranslation());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:18,代碼來源:SlopeTerrainToolControl.java

示例4: refreshMesh

import com.jme3.scene.Geometry; //導入方法依賴的package包/類
private void refreshMesh(Node node, Entity e){
    float r = e.get(CapsuleView.class).getRadius();
    float h = e.get(CapsuleView.class).getHeight();
    Geometry cylinder = new Geometry("cylinder", new Cylinder(16, 16, r, h));
    Geometry top = new Geometry("top sphere", new Sphere(16,16, r));
    Geometry bottom = new Geometry("bottom sphere", new Sphere(16, 16, r));
    cylinder.rotate(FastMath.HALF_PI, 0, 0);
    bottom.setLocalTranslation(0, -h/2, 0);
    top.setLocalTranslation(0, h/2,0);
    node.attachChild(cylinder);
    node.attachChild(bottom);
    node.attachChild(top);
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:14,代碼來源:CapsuleView.java

示例5: addObject

import com.jme3.scene.Geometry; //導入方法依賴的package包/類
@Override
protected Spatial addObject(Entity e) {
    PhysicsPosition pos = e.get(PhysicsPosition.class);
    Vector3f size = e.get(BoxComponent.class).getSize();
    Geometry reBoxg = new Geometry("brick", new Box(size.x, size.y, size.z));
    reBoxg.setMaterial(e.get(MaterialComponent.class).getMat());
    reBoxg.setLocalTranslation(pos.getLocation());
    reBoxg.setLocalRotation(pos.getRotation());
    reBoxg.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
    TestBrickWall.this.rootNode.attachChild(reBoxg);
    return reBoxg;
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:13,代碼來源:TestBrickWall.java

示例6: onAttached

import com.jme3.scene.Geometry; //導入方法依賴的package包/類
@Override
protected void onAttached(@NotNull final Node node) {
    super.onAttached(node);

    final Spatial editedModel = notNull(getEditedModel());
    final Geometry levelMarker = getLevelMarker();

    final Node markersNode = component.getMarkersNode();
    markersNode.attachChild(levelMarker);

    levelMarker.setLocalTranslation(editedModel.getWorldTranslation());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:13,代碼來源:LevelTerrainToolControl.java

示例7: checkAndUpdateVehicle

import com.jme3.scene.Geometry; //導入方法依賴的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

示例8: controlUpdate

import com.jme3.scene.Geometry; //導入方法依賴的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.scene.Geometry.setLocalTranslation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。