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


Java Quaternion.lookAt方法代碼示例

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


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

示例1: initAudioApp

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public void initAudioApp(){
    assetManager.registerLocator("C:\\", FileLocator.class);
    
    Quaternion q = new Quaternion();
    q.lookAt(new Vector3f(0, 0, -1f), Vector3f.UNIT_Y);
    listener.setRotation(q);
    
    audioRenderer.setEnvironment(Environment.Dungeon);
    AL10.alDistanceModel(AL11.AL_EXPONENT_DISTANCE);
    
    ufo  = new AudioNode(audioRenderer, assetManager, "test.ogg", false);
    ufo.setPositional(true);
    ufo.setLooping(true);
    ufo.setReverbEnabled(true);
    ufo.setRefDistance(100000000);
    ufo.setMaxDistance(100000000);
    audioRenderer.playSource(ufo);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:20,代碼來源:TestDoppler.java

示例2: update

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
public void update(float tpf) {
    if (enabled && spatial != null) {
        Quaternion localRotationQuat = spatial.getLocalRotation();
        Vector3f localLocation = spatial.getLocalTranslation();
        if (!applyLocal && spatial.getParent() != null) {
            getPhysicsLocation(localLocation);
            localLocation.subtractLocal(spatial.getParent().getWorldTranslation());
            localLocation.divideLocal(spatial.getParent().getWorldScale());
            tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
            spatial.setLocalTranslation(localLocation);

            if (useViewDirection) {
                localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y);
                spatial.setLocalRotation(localRotationQuat);
            }
        } else {
            spatial.setLocalTranslation(getPhysicsLocation());
            localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y);
            spatial.setLocalRotation(localRotationQuat);
        }
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:23,代碼來源:CharacterControl.java

示例3: 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

示例4: onEntityEachTick

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected void onEntityEachTick(Entity e) {
	Spatial s = SpatialPool.models.get(e.getId());
	if(s == null) {
		return;
	}

	PlanarStance stance = e.get(PlanarStance.class);

	// translation
	s.setLocalTranslation(TranslateUtil.toVector3f(stance.getCoord().get3D(stance.getElevation())));
	// rotation
	Quaternion r = new Quaternion();
	Point3D pu = stance.getUpVector();
	Point3D pv = Point3D.UNIT_X.getRotationAroundZ(stance.getOrientation().getValue());
	Vector3f u = TranslateUtil.toVector3f(pu).normalize();
	Vector3f v = TranslateUtil.toVector3f(pv).normalize();
	r.lookAt(v, u);
	double angle = Math.acos(pu.getDotProduct(pv) / (pu.getNorm() * pv.getNorm()));
	r = r.mult(new Quaternion().fromAngles((float) (-angle), 0, 0));

	s.setLocalRotation(r);
}
 
開發者ID:meltzow,項目名稱:supernovae,代碼行數:24,代碼來源:SpritePlacingProc.java

示例5: sync

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
 * Synchronize this node with audio node.
 */
@JMEThread
public void sync() {

    final AudioNode audioNode = getAudioNode();
    if (audioNode == null) return;

    final LocalObjects local = LocalObjects.get();
    final Quaternion rotation = local.nextRotation();
    rotation.lookAt(audioNode.getDirection(), camera.getUp(local.nextVector()));

    final Node editedNode = getEditedNode();
    editedNode.setLocalRotation(rotation);
    editedNode.setLocalTranslation(audioNode.getLocalTranslation());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:18,代碼來源:EditorAudioNode.java

示例6: simpleUpdate

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
    public void simpleUpdate(float tpf){
        Vector3f origin    = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.0f);
        Vector3f direction = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.3f);
        direction.subtractLocal(origin).normalizeLocal();

        Ray ray = new Ray(origin, direction);
        CollisionResults results = new CollisionResults();
        shootables.collideWith(ray, results);
//        System.out.println("----- Collisions? " + results.size() + "-----");
//        for (int i = 0; i < results.size(); i++) {
//            // For each hit, we know distance, impact point, name of geometry.
//            float dist = results.getCollision(i).getDistance();
//            Vector3f pt = results.getCollision(i).getWorldContactPoint();
//            String hit = results.getCollision(i).getGeometry().getName();
//            System.out.println("* Collision #" + i);
//            System.out.println("  You shot " + hit + " at " + pt + ", " + dist + " wu away.");
//        }
        if (results.size() > 0) {
            CollisionResult closest = results.getClosestCollision();
            mark.setLocalTranslation(closest.getContactPoint());

            Quaternion q = new Quaternion();
            q.lookAt(closest.getContactNormal(), Vector3f.UNIT_Y);
            mark.setLocalRotation(q);

            rootNode.attachChild(mark);
        } else {
            rootNode.detachChild(mark);
        }
    }
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:32,代碼來源:TestMousePick.java

示例7: computeTargetDirection

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
private void computeTargetDirection() {
    switch (directionType) {
        case Path:
            Quaternion q = new Quaternion();
            q.lookAt(direction, Vector3f.UNIT_Y);
            spatial.setLocalRotation(q);
            break;
        case LookAt:
            if (lookAt != null) {
                spatial.lookAt(lookAt, upVector);
            }
            break;
        case PathAndRotation:
            if (rotation != null) {
                Quaternion q2 = new Quaternion();
                q2.lookAt(direction, Vector3f.UNIT_Y);
                q2.multLocal(rotation);
                spatial.setLocalRotation(q2);
            }
            break;
        case Rotation:
            if (rotation != null) {
                spatial.setLocalRotation(rotation);
            }
            break;
        case None:
            break;
        default:
            break;
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:32,代碼來源:MotionTrack.java

示例8: convertWaypointToWorld

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
 * 將本地中間路徑點轉化為Bullet坐標係下的世界坐標點.
 * @param startPos
 * @param endPos
 * @param localWaypoint
 * @return 
 */
private void convertWaypointToWorld(Vector3f startPos, Vector3f endPos, Vector3f localWaypoint) {
    TempVars tv = TempVars.get();
    Vector3f dir = tv.vect1;
    Quaternion rot = tv.quat1;
    endPos.subtract(startPos, dir).normalizeLocal();
    rot.lookAt(dir, up);
    rot.mult(localWaypoint, localWaypoint);
    localWaypoint.addLocal(startPos);
    tv.release();
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:18,代碼來源:CurveBullet.java

示例9: doAnimUpdate

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected void doAnimUpdate(float interpolation) {
    
    TempVars tv = TempVars.get();
    float distance = interpolation * spline.getTotalLength();
    
    // 1.獲取spline上指定距離處的位置
    getSplinePoint(spline, distance, tv.vect1);
    
    if (interpolation >= 1) {
        // end
        target.setLocalTranslation(spline.getControlPoints().get(spline.getControlPoints().size() - 1));
    } else {
        // dir
        if (facePath) {
            tv.vect1.subtract(target.getLocalTranslation(), tv.vect2).normalizeLocal();
            Quaternion rot = target.getLocalRotation();
            rot.lookAt(tv.vect2, Vector3f.UNIT_Y);
            if (rotationOffset != null) {
                rot.multLocal(rotationOffset);
            }
            target.setLocalRotation(rot);
        }
        target.setLocalTranslation(tv.vect1);
    }
    tv.release();
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:28,代碼來源:CurveMoveAnim.java

示例10: updateState

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public void updateState() {
    super.updateState();
    controlSpatial.setLocalTranslation(target.getSpatial().getLocalTranslation());
    
    Quaternion rot = controlSpatial.getLocalRotation();
    rot.lookAt(target.getLight().getDirection(), Vector3f.UNIT_Y);
    setLocalRotation(rot);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:10,代碼來源:SpotLightEntityControlTile.java

示例11: updateState

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public void updateState() {
    super.updateState();
    controlSpatial.setLocalTranslation(target.getSpatial().getLocalTranslation());
    
    Quaternion rot = controlSpatial.getLocalRotation();
    rot.lookAt(target.getDirection(), Vector3f.UNIT_Y);
    setLocalRotation(rot);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:10,代碼來源:DirectionalLightEntityControlTile.java

示例12: onEntityUpdated

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected void onEntityUpdated(Entity e) {
	Model model = e.get(Model.class);
	Spatial s = SpatialPool.models.get(e.getId());

	if(s == null) {
		return;
	}

	PlanarStance stance = e.get(PlanarStance.class);

	// translation
	s.setLocalTranslation(TranslateUtil.toVector3f(stance.getCoord().get3D(stance.getElevation())));

	// rotation
	Quaternion r = new Quaternion();
	Point3D pu = stance.getUpVector();
	Point3D pv = Point3D.UNIT_X.getRotationAroundZ(stance.getOrientation().getValue());
	Vector3f u = TranslateUtil.toVector3f(pu).normalize();
	Vector3f v = TranslateUtil.toVector3f(pv).normalize();
	r.lookAt(v, u);

	// we correct the pitch of the unit because the direction is always flatten
	// this is only to follow the terrain relief
	double angle = Math.acos(pu.getDotProduct(pv) / (pu.getNorm() * pv.getNorm()));
	r = r.mult(new Quaternion().fromAngles((float) (-angle+AngleUtil.RIGHT+model.pitchFix.getValue()), (float) (model.rollFix.getValue()), (float) (model.yawFix.getValue())));

	s.setLocalRotation(r);
}
 
開發者ID:meltzow,項目名稱:supernovae,代碼行數:30,代碼來源:ModelPlacingProc.java


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