本文整理汇总了Java中com.jme.math.Vector3f.cross方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3f.cross方法的具体用法?Java Vector3f.cross怎么用?Java Vector3f.cross使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme.math.Vector3f
的用法示例。
在下文中一共展示了Vector3f.cross方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentPlacemark
import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
* Returns a Placemark that represents the current position of the avatar.
*/
private Placemark getCurrentPlacemark(ServerSessionManager sessionManager) {
// Fetch the current translation of the avatar and the (x, y, z) of its
// position
ViewManager manager = ViewManager.getViewManager();
ViewCell viewCell = manager.getPrimaryViewCell();
CellTransform viewTransform = viewCell.getWorldTransform();
Vector3f location = viewTransform.getTranslation(null);
float x = location.x;
float y = location.y;
float z = location.z;
// Find out what the URL to the server is
String url = sessionManager.getServerURL();
// Compute the current look angle, as degrees from the +x axis, ignoring
// any look in the y-axis.
Quaternion viewRotation = viewTransform.getRotation(null);
Vector3f v1 = new Vector3f(0, 0, 1);
Vector3f normal = new Vector3f(0, 1, 0);
Vector3f v2 = viewRotation.mult(v1);
v2.normalizeLocal();
// Compute the signed angle between v1 and v2. We do this with the
// following formula: angle = atan2(normal dot (v1 cross v2), v1 dot v2)
float dotProduct = v1.dot(v2);
Vector3f crossProduct = v1.cross(v2);
float lookAngle = (float) Math.atan2(normal.dot(crossProduct), dotProduct);
lookAngle = (float) Math.toDegrees(lookAngle);
return new Placemark("", url, x, y, z, lookAngle);
}
示例2: computeViewPlatformTransform
import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
* Compute and return the View Platform Transform3D give the users position, direction and up
*/
public static Matrix4f computeViewPlatformTransform(Vector3f userPosition, Vector3f direction, Vector3f up) {
Matrix4f mat = new Matrix4f();
Vector3f axisX = new Vector3f();
Vector3f axisY = new Vector3f();
Vector3f axisZ = new Vector3f(direction);
axisZ.negate();
axisZ.normalize();
axisX.cross(up, axisZ);
axisX.normalize();
axisY.cross(axisZ, axisX);
axisY.normalize();
mat.m00 = axisX.x;
mat.m10 = axisX.y;
mat.m20 = axisX.z;
mat.m30 = 0.0f;
mat.m01 = axisY.x;
mat.m11 = axisY.y;
mat.m21 = axisY.z;
mat.m31 = 0.0f;
mat.m02 = axisZ.x;
mat.m12 = axisZ.y;
mat.m22 = axisZ.z;
mat.m32 = 0.0f;
mat.m03 = userPosition.x;
mat.m13 = userPosition.y;
mat.m23 = userPosition.z;
mat.m33 = 1.0f;
return mat;
}
示例3: project
import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
* Project a vector onto a plane (define by the normal Normal)
* Inputs are assumed to be normalized. If the normal equals the vector (or very nearly does), return false, and set store to zero.
* @param vector
* @param normal
* @param store The (normalized) projection
* @return
*/
private boolean project(Vector3f vector, Vector3f normal, Vector3f store) {
//take the zero vector, project it into the plane, and normalize
//A || B = B x (AxB / |B|) / |B| projection of a vector A onto a plane with normal B. NOTE: division happens AFTER crossing
//See: http://www.euclideanspace.com/maths/geometry/elements/plane/lineOnPlane/index.htm
//assuming normalized inputs, we can skip some steps...
if(normal.distanceSquared(vector)<FastMath.FLT_EPSILON)
{
store.zero();
return false;
}
else
{
store.set(vector);
store.crossLocal(normal);
normal.cross(store,store);
if(store.lengthSquared()<=FastMath.FLT_EPSILON)
{
store.zero();
return false;
}
store.normalizeLocal();
return true;
}
// worldZeroVector =(orientation.getDirection().cross( worldZeroVector));//.cross(orientation.getDirection()));
// worldZeroVector.set( orientation.getDirection().cross(worldZeroVector.cross(orientation.getDirection()))).normalizeLocal();
}
示例4: performAction
import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
* <code>performAction</code> rotates the camera a certain angle.
*
* @see com.jme.input.action.KeyInputAction#performAction(InputActionEvent)
*/
public void performAction(InputActionEvent evt) {
float x_l,y_l,z_l;
float xo,zo;
DisplaySystem display = DisplaySystem.getDisplaySystem();
// Detecta centro deslocado do foco de aten�ao
Vector2f mouse_xy = new Vector2f(512,384);
Vector3f worldCoords = display.getWorldCoordinates(mouse_xy, 0);
Vector3f worldCoords2 = display.getWorldCoordinates(mouse_xy, 1);
Vector3f direction = worldCoords2.subtractLocal(worldCoords).normalizeLocal();
Ray mouseRay = new Ray(worldCoords, direction);
float planeY = 0;
float startY = mouseRay.origin.y;
float endY = mouseRay.direction.y;
float coef = (planeY - startY) / endY;
y_l = camera.getLocation().y;
if (y_l != 0) {
xo = mouseRay.origin.x + (coef * mouseRay.direction.x);
zo = mouseRay.origin.z + (coef * mouseRay.direction.z);
}
else {
xo = xoo;
zo = zoo;
}
xoo = xo;
zoo = zo;
// Detecta circunferencia sobre o centro deslocado
x_l = camera.getLocation().x-xo;
z_l = camera.getLocation().z-zo;
float L = (float) Math.sqrt( x_l * x_l + z_l * z_l);
float ang = (float)Math.atan2(z_l, x_l);
//ang += 1f/180f * Math.PI;
if (y_l < -10 || y_l > 10)
y_l -= 0.5;
else y_l -= 0.1;
//System.out.println("y:"+y_l+" L:"+L);
x_l = (float)(L*Math.cos(ang))+xo;
z_l = (float)(L*Math.sin(ang))+zo;
//System.out.println("xo:"+xo+" zo:"+zo+" x:"+x_l+" z:"+z_l);
Vector3f newlocation = new Vector3f(x_l,y_l,z_l);
camera.setLocation(newlocation);
//System.out.println("newlocation:"+newlocation.toString());
//camera.lookAt(new Vector3f(planeX,0,planeZ), new Vector3f(0,1f,0));
Vector3f focusofattention = new Vector3f(xo,0,zo);
//System.out.println("focusofattention:"+focusofattention.toString());
Vector3f newdirection = focusofattention.subtract(newlocation);
//System.out.println("newdirection(antes de normalizar):"+newdirection);
newdirection = newdirection.normalize();
//System.out.println("newdirection:"+newdirection);
camera.setDirection(newdirection);
Vector3f tangent = new Vector3f((float)(L*Math.cos(ang+Math.PI/2)+xo),y_l,(float)(L*Math.sin(ang+Math.PI/2)+zo));
//System.out.println("tangent:"+tangent);
Vector3f centerhigh = new Vector3f(xo,y_l,zo);
Vector3f newleft = tangent.subtract(centerhigh);
//System.out.println("newleft(antes de normalizar:"+newleft);
newleft = newleft.normalize();
//System.out.println("newleft:"+newleft);
camera.setLeft(newleft);
Vector3f newup = newdirection.cross(newleft);
newup = newup.normalize();
//System.out.println("newup:"+newup);
camera.setUp(newup);
//System.out.println("xd:"+camera.getLocation().x+" yd:"+camera.getLocation().y+" zd:"+camera.getLocation().z);
camera.normalize();
camera.update();
}
示例5: performAction
import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
* <code>performAction</code> rotates the camera a certain angle.
*
* @see com.jme.input.action.KeyInputAction#performAction(InputActionEvent)
*/
public void performAction(InputActionEvent evt) {
// if (lockAxis == null) {
// incr.fromAngleNormalAxis(-speed * evt.getTime(), camera.getUp());
// } else {
// incr.fromAngleNormalAxis(-speed * evt.getTime(), lockAxis);
// }
// incr.mult(camera.getUp(), camera.getUp());
// incr.mult(camera.getLeft(), camera.getLeft());
// incr.mult(camera.getDirection(), camera.getDirection());
// camera.normalize();
float x_l,y_l,z_l;
DisplaySystem display = DisplaySystem.getDisplaySystem();
// Detecta centro deslocado do foco de aten�ao
Vector2f mouse_xy = new Vector2f(512,384);
Vector3f worldCoords = display.getWorldCoordinates(mouse_xy, 0);
Vector3f worldCoords2 = display.getWorldCoordinates(mouse_xy, 1);
Vector3f direction = worldCoords2.subtractLocal(worldCoords).normalizeLocal();
Ray mouseRay = new Ray(worldCoords, direction);
float planeY = 0;
float startY = mouseRay.origin.y;
float endY = mouseRay.direction.y;
float coef = (planeY - startY) / endY;
float xo = mouseRay.origin.x + (coef * mouseRay.direction.x);
float zo = mouseRay.origin.z + (coef * mouseRay.direction.z);
// Detecta circunferencia sobre o centro deslocado
x_l = camera.getLocation().x-xo;
y_l = camera.getLocation().y;
z_l = camera.getLocation().z-zo;
float L = (float) Math.sqrt( x_l * x_l + z_l * z_l);
float ang = (float)Math.atan2(z_l, x_l);
ang -= 1f/180f * Math.PI;
//System.out.println("y:"+y_l+" L:"+L);
x_l = (float)(L*Math.cos(ang))+xo;
z_l = (float)(L*Math.sin(ang))+zo;
//System.out.println("xo:"+xo+" zo:"+zo+" x:"+x_l+" z:"+z_l);
Vector3f newlocation2 = new Vector3f(x_l,y_l,z_l);
camera.setLocation(newlocation2);
//System.out.println("newlocation:"+newlocation.toString());
//camera.lookAt(new Vector3f(planeX,0,planeZ), new Vector3f(0,1f,0));
Vector3f focusofattention = new Vector3f(xo,0,zo);
//System.out.println("focusofattention:"+focusofattention.toString());
Vector3f newdirection = focusofattention.subtract(newlocation2);
//System.out.println("newdirection(antes de normalizar):"+newdirection);
newdirection = newdirection.normalize();
//System.out.println("newdirection:"+newdirection);
camera.setDirection(newdirection);
Vector3f tangent = new Vector3f((float)(L*Math.cos(ang+Math.PI/2)+xo),y_l,(float)(L*Math.sin(ang+Math.PI/2)+zo));
//System.out.println("tangent:"+tangent);
Vector3f centerhigh = new Vector3f(xo,y_l,zo);
Vector3f newleft = tangent.subtract(centerhigh);
//System.out.println("newleft(antes de normalizar:"+newleft);
newleft = newleft.normalize();
//System.out.println("newleft:"+newleft);
camera.setLeft(newleft);
Vector3f newup = newdirection.cross(newleft);
newup = newup.normalize();
//System.out.println("newup:"+newup);
camera.setUp(newup);
//System.out.println("xd:"+camera.getLocation().x+" yd:"+camera.getLocation().y+" zd:"+camera.getLocation().z);
camera.normalize();
camera.update();
}
示例6: performAction
import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
* <code>performAction</code> rotates the camera a certain angle.
*
* @see com.jme.input.action.KeyInputAction#performAction(InputActionEvent)
*/
public void performAction(InputActionEvent evt) {
// if (lockAxis == null) {
// incr.fromAngleNormalAxis(-speed * evt.getTime(), camera.getUp());
// } else {
// incr.fromAngleNormalAxis(-speed * evt.getTime(), lockAxis);
// }
// incr.mult(camera.getUp(), camera.getUp());
// incr.mult(camera.getLeft(), camera.getLeft());
// incr.mult(camera.getDirection(), camera.getDirection());
// camera.normalize();
float x_l,y_l,z_l;
DisplaySystem display = DisplaySystem.getDisplaySystem();
// Detecta centro deslocado do foco de aten�ao
Vector2f mouse_xy = new Vector2f(512,384);
Vector3f worldCoords = display.getWorldCoordinates(mouse_xy, 0);
Vector3f worldCoords2 = display.getWorldCoordinates(mouse_xy, 1);
Vector3f direction = worldCoords2.subtractLocal(worldCoords).normalizeLocal();
Ray mouseRay = new Ray(worldCoords, direction);
float planeY = 0;
float startY = mouseRay.origin.y;
float endY = mouseRay.direction.y;
float coef = (planeY - startY) / endY;
float xo = mouseRay.origin.x + (coef * mouseRay.direction.x);
float zo = mouseRay.origin.z + (coef * mouseRay.direction.z);
// Detecta circunferencia sobre o centro deslocado
x_l = camera.getLocation().x-xo;
y_l = camera.getLocation().y;
z_l = camera.getLocation().z-zo;
float L = (float) Math.sqrt( x_l * x_l + z_l * z_l);
float ang = (float)Math.atan2(z_l, x_l);
ang -= 1f/180f * Math.PI;
//System.out.println("y:"+y_l+" L:"+L);
x_l = (float)(L*Math.cos(ang))+xo;
z_l = (float)(L*Math.sin(ang))+zo;
//System.out.println("xo:"+xo+" zo:"+zo+" x:"+x_l+" z:"+z_l);
Vector3f newlocation2 = new Vector3f(x_l,y_l,z_l);
camera.setLocation(newlocation2);
//System.out.println("newlocation:"+newlocation.toString());
//camera.lookAt(new Vector3f(planeX,0,planeZ), new Vector3f(0,1f,0));
Vector3f focusofattention = new Vector3f(xo,0,zo);
//System.out.println("focusofattention:"+focusofattention.toString());
Vector3f newdirection = focusofattention.subtract(newlocation2);
//System.out.println("newdirection(antes de normalizar):"+newdirection);
newdirection = newdirection.normalize();
//System.out.println("newdirection:"+newdirection);
camera.setDirection(newdirection);
Vector3f tangent = new Vector3f((float)(L*Math.cos(ang+Math.PI/2)+xo),y_l,(float)(L*Math.sin(ang+Math.PI/2)+zo));
//System.out.println("tangent:"+tangent);
Vector3f centerhigh = new Vector3f(xo,y_l,zo);
Vector3f newleft = tangent.subtract(centerhigh);
//System.out.println("newleft(antes de normalizar:"+newleft);
newleft = newleft.normalize();
//System.out.println("newleft:"+newleft);
camera.setLeft(newleft);
Vector3f newup = newdirection.cross(newleft);
newup = newup.normalize();
//System.out.println("newup:"+newup);
camera.setUp(newup);
//System.out.println("xd:"+camera.getLocation().x+" yd:"+camera.getLocation().y+" zd:"+camera.getLocation().z);
camera.normalize();
camera.update();
}
示例7: performAction
import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
* <code>performAction</code> rotates the camera a certain angle.
*
* @see com.jme.input.action.KeyInputAction#performAction(InputActionEvent)
*/
public void performAction(InputActionEvent evt) {
float x_l,y_l,z_l;
float xo,zo;
DisplaySystem display = DisplaySystem.getDisplaySystem();
// Detecta centro deslocado do foco de aten�ao
Vector2f mouse_xy = new Vector2f(512,384);
Vector3f worldCoords = display.getWorldCoordinates(mouse_xy, 0);
Vector3f worldCoords2 = display.getWorldCoordinates(mouse_xy, 1);
Vector3f direction = worldCoords2.subtractLocal(worldCoords).normalizeLocal();
Ray mouseRay = new Ray(worldCoords, direction);
float planeY = 0;
float startY = mouseRay.origin.y;
float endY = mouseRay.direction.y;
float coef = (planeY - startY) / endY;
y_l = camera.getLocation().y;
if (y_l != 0) {
xo = mouseRay.origin.x + (coef * mouseRay.direction.x);
zo = mouseRay.origin.z + (coef * mouseRay.direction.z);
}
else {
xo = xoo;
zo = zoo;
}
xoo = xo;
zoo = zo;
// Detecta circunferencia sobre o centro deslocado
x_l = camera.getLocation().x-xo;
z_l = camera.getLocation().z-zo;
float L = (float) Math.sqrt( x_l * x_l + z_l * z_l);
float ang = (float)Math.atan2(z_l, x_l);
//ang += 1f/180f * Math.PI;
//System.out.println("y:"+y_l+" L:"+L);
x_l = (float)(L*Math.cos(ang))+xo;
z_l = (float)(L*Math.sin(ang))+zo;
if (y_l < -10 || y_l > 10)
y_l += 0.5;
else y_l += 0.1;
//System.out.println("xo:"+xo+" zo:"+zo+" x:"+x_l+" z:"+z_l);
Vector3f newlocation = new Vector3f(x_l,y_l,z_l);
camera.setLocation(newlocation);
//System.out.println("newlocation:"+newlocation.toString());
//camera.lookAt(new Vector3f(planeX,0,planeZ), new Vector3f(0,1f,0));
Vector3f focusofattention = new Vector3f(xo,0,zo);
//System.out.println("focusofattention:"+focusofattention.toString());
Vector3f newdirection = focusofattention.subtract(newlocation);
//System.out.println("newdirection(antes de normalizar):"+newdirection);
newdirection = newdirection.normalize();
//System.out.println("newdirection:"+newdirection);
camera.setDirection(newdirection);
Vector3f tangent = new Vector3f((float)(L*Math.cos(ang+Math.PI/2)+xo),y_l,(float)(L*Math.sin(ang+Math.PI/2)+zo));
//System.out.println("tangent:"+tangent);
Vector3f centerhigh = new Vector3f(xo,y_l,zo);
Vector3f newleft = tangent.subtract(centerhigh);
//System.out.println("newleft(antes de normalizar:"+newleft);
newleft = newleft.normalize();
//System.out.println("newleft:"+newleft);
camera.setLeft(newleft);
Vector3f newup = newdirection.cross(newleft);
newup = newup.normalize();
//System.out.println("newup:"+newup);
camera.setUp(newup);
//System.out.println("xd:"+camera.getLocation().x+" yd:"+camera.getLocation().y+" zd:"+camera.getLocation().z);
camera.normalize();
camera.update();
}
示例8: performAction
import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
* <code>performAction</code> rotates the camera a certain angle.
*
* @see com.jme.input.action.KeyInputAction#performAction(InputActionEvent)
*/
public void performAction(InputActionEvent evt) {
// if (lockAxis == null) {
// incr.fromAngleNormalAxis(speed * evt.getTime(), camera.getUp());
// } else {
// incr.fromAngleNormalAxis(speed * evt.getTime(), lockAxis);
// }
// incr.mult(camera.getUp(), camera.getUp());
// incr.mult(camera.getLeft(), camera.getLeft());
// incr.mult(camera.getDirection(), camera.getDirection());
// camera.normalize();
float x_l,y_l,z_l;
DisplaySystem display = DisplaySystem.getDisplaySystem();
// Detecta centro deslocado do foco de aten�ao
Vector2f mouse_xy = new Vector2f(512,384);
Vector3f worldCoords = display.getWorldCoordinates(mouse_xy, 0);
Vector3f worldCoords2 = display.getWorldCoordinates(mouse_xy, 1);
Vector3f direction = worldCoords2.subtractLocal(worldCoords).normalizeLocal();
Ray mouseRay = new Ray(worldCoords, direction);
float planeY = 0;
float startY = mouseRay.origin.y;
float endY = mouseRay.direction.y;
float coef = (planeY - startY) / endY;
float xo = mouseRay.origin.x + (coef * mouseRay.direction.x);
float zo = mouseRay.origin.z + (coef * mouseRay.direction.z);
// Detecta circunferencia sobre o centro deslocado
x_l = camera.getLocation().x-xo;
y_l = camera.getLocation().y;
z_l = camera.getLocation().z-zo;
float L = (float) Math.sqrt( x_l * x_l + z_l * z_l);
float ang = (float)Math.atan2(z_l, x_l);
ang += 1f/180f * Math.PI;
//System.out.println("y:"+y_l+" L:"+L);
x_l = (float)(L*Math.cos(ang))+xo;
z_l = (float)(L*Math.sin(ang))+zo;
//System.out.println("xo:"+xo+" zo:"+zo+" x:"+x_l+" z:"+z_l);
Vector3f newlocation = new Vector3f(x_l,y_l,z_l);
camera.setLocation(newlocation);
//System.out.println("newlocation:"+newlocation.toString());
//camera.lookAt(new Vector3f(planeX,0,planeZ), new Vector3f(0,1f,0));
Vector3f focusofattention = new Vector3f(xo,0,zo);
//System.out.println("focusofattention:"+focusofattention.toString());
Vector3f newdirection = focusofattention.subtract(newlocation);
//System.out.println("newdirection(antes de normalizar):"+newdirection);
newdirection = newdirection.normalize();
//System.out.println("newdirection:"+newdirection);
camera.setDirection(newdirection);
Vector3f tangent = new Vector3f((float)(L*Math.cos(ang+Math.PI/2)+xo),y_l,(float)(L*Math.sin(ang+Math.PI/2)+zo));
//System.out.println("tangent:"+tangent);
Vector3f centerhigh = new Vector3f(xo,y_l,zo);
Vector3f newleft = tangent.subtract(centerhigh);
//System.out.println("newleft(antes de normalizar:"+newleft);
newleft = newleft.normalize();
//System.out.println("newleft:"+newleft);
camera.setLeft(newleft);
Vector3f newup = newdirection.cross(newleft);
newup = newup.normalize();
//System.out.println("newup:"+newup);
camera.setUp(newup);
//System.out.println("xd:"+camera.getLocation().x+" yd:"+camera.getLocation().y+" zd:"+camera.getLocation().z);
camera.normalize();
camera.update();
}
示例9: performAction
import com.jme.math.Vector3f; //导入方法依赖的package包/类
public void performAction(InputActionEvent evt) {
float x_l,y_l,z_l;
DisplaySystem display = DisplaySystem.getDisplaySystem();
// Detecta centro deslocado do foco de aten�ao
Vector2f mouse_xy = new Vector2f(512,384);
Vector3f worldCoords = display.getWorldCoordinates(mouse_xy, 0);
Vector3f worldCoords2 = display.getWorldCoordinates(mouse_xy, 1);
Vector3f direction = worldCoords2.subtractLocal(worldCoords).normalizeLocal();
Ray mouseRay = new Ray(worldCoords, direction);
float planeY = 0;
float startY = mouseRay.origin.y;
float endY = mouseRay.direction.y;
float coef = (planeY - startY) / endY;
float xo = mouseRay.origin.x + (coef * mouseRay.direction.x);
float zo = mouseRay.origin.z + (coef * mouseRay.direction.z);
// Detecta circunferencia sobre o centro deslocado
x_l = camera.getLocation().x-xo;
y_l = camera.getLocation().y;
z_l = camera.getLocation().z-zo;
float L = (float) Math.sqrt( x_l * x_l + z_l * z_l);
float ang = (float)Math.atan2(z_l, x_l);
ang += 1f/180f * Math.PI;
//System.out.println("y:"+y_l+" L:"+L);
x_l = (float)(L*Math.cos(ang))+xo;
z_l = (float)(L*Math.sin(ang))+zo;
//System.out.println("xo:"+xo+" zo:"+zo+" x:"+x_l+" z:"+z_l);
Vector3f newlocation = new Vector3f(x_l,y_l,z_l);
camera.setLocation(newlocation);
//System.out.println("newlocation:"+newlocation.toString());
//camera.lookAt(new Vector3f(planeX,0,planeZ), new Vector3f(0,1f,0));
Vector3f focusofattention = new Vector3f(xo,0,zo);
//System.out.println("focusofattention:"+focusofattention.toString());
Vector3f newdirection = focusofattention.subtract(newlocation);
//System.out.println("newdirection(antes de normalizar):"+newdirection);
newdirection = newdirection.normalize();
//System.out.println("newdirection:"+newdirection);
camera.setDirection(newdirection);
Vector3f tangent = new Vector3f((float)(L*Math.cos(ang+Math.PI/2)+xo),y_l,(float)(L*Math.sin(ang+Math.PI/2)+zo));
//System.out.println("tangent:"+tangent);
Vector3f centerhigh = new Vector3f(xo,y_l,zo);
Vector3f newleft = tangent.subtract(centerhigh);
//System.out.println("newleft(antes de normalizar:"+newleft);
newleft = newleft.normalize();
//System.out.println("newleft:"+newleft);
camera.setLeft(newleft);
Vector3f newup = newdirection.cross(newleft);
newup = newup.normalize();
//System.out.println("newup:"+newup);
camera.setUp(newup);
//System.out.println("xd:"+camera.getLocation().x+" yd:"+camera.getLocation().y+" zd:"+camera.getLocation().z);
camera.normalize();
camera.update();
}
示例10: Orientation
import com.jme.math.Vector3f; //导入方法依赖的package包/类
public Orientation(Vector3f direction, Vector3f horizontal)
{
this.direction = direction;
this.horizontal = horizontal;
this.vertical = direction.cross(horizontal);
}
示例11: pointLineDistance
import com.jme.math.Vector3f; //导入方法依赖的package包/类
/**
* Calculates the distance of a point from a line.
* <p><code>
* x1----------------------------x2 <br>
* | <br>
* | distance <br>
* | <br>
* point <br>
* </code>
* <p>
* The formula is <br>
* <code>
* d = |(x2-x1) x (x1-p)| <br>
* ------------------ <br>
* |x2-x1| <br>
* </code>
*
* Where p=point, lineStart=x1, lineEnd=x2
*
*/
public static float pointLineDistance( final Vector3f lineStart,
final Vector3f lineEnd,
final Vector3f point ) {
Vector3f a = new Vector3f(lineEnd);
a.subtract(lineStart);
Vector3f b = new Vector3f(lineStart);
b.subtract(point);
Vector3f cross = new Vector3f();
cross.cross(a,b);
return cross.length()/a.length();
}