本文整理匯總了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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}