本文整理了Java中com.jme3.scene.Geometry.getWorldTranslation()
方法的一些代码示例,展示了Geometry.getWorldTranslation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.getWorldTranslation()
方法的具体详情如下:
包路径:com.jme3.scene.Geometry
类名称:Geometry
方法名:getWorldTranslation
暂无
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public int compare(Geometry o1, Geometry o2) {
float z1 = o1.getWorldTranslation().getZ();
float z2 = o2.getWorldTranslation().getZ();
if (z1 > z2)
return 1;
else if (z1 < z2)
return -1;
else
return 0;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public int pick(Vector2f cursor, CollisionResults results) {
for (Geometry g : geomToJoint.keySet()) {
if (g.getMesh() instanceof JointShape) {
camera.getScreenCoordinates(g.getWorldTranslation(), tmp);
if (cursor.x <= tmp.x + PIXEL_BOX && cursor.x >= tmp.x - PIXEL_BOX
&& cursor.y <= tmp.y + PIXEL_BOX && cursor.y >= tmp.y - PIXEL_BOX) {
CollisionResult res = new CollisionResult();
res.setGeometry(g);
results.addCollision(res);
}
}
}
return 0;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private void checkPlanetGravity() {
Vector3f planetDist = planet.getWorldTranslation().subtract(characterNode.getWorldTranslation());
if (planetDist.length() < 24) {
physicsCharacter.setGravity(planetDist.normalizeLocal().multLocal(9.81f));
} else {
physicsCharacter.setGravity(normalGravity);
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public float distanceToCam(Geometry spat){
if (spat == null)
return Float.NEGATIVE_INFINITY;
if (spat.queueDistance != Float.NEGATIVE_INFINITY)
return spat.queueDistance;
Vector3f camPosition = cam.getLocation();
Vector3f viewVector = cam.getDirection(tempVec2);
Vector3f spatPosition = null;
if (spat.getWorldBound() != null){
spatPosition = spat.getWorldBound().getCenter();
}else{
spatPosition = spat.getWorldTranslation();
}
spatPosition.subtract(camPosition, tempVec);
spat.queueDistance = tempVec.dot(viewVector);
return spat.queueDistance;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private void createDebugTangents(Geometry geom) {
Geometry debug = new Geometry(
"Debug " + geom.getName(),
TangentBinormalGenerator.genTbnLines(geom.getMesh(), 0.8f)
);
Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");
debug.setMaterial(debugMat);
debug.setCullHint(Spatial.CullHint.Never);
debug.getLocalTranslation().set(geom.getWorldTranslation());
debugNode.attachChild(debug);
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Calculates the distance from a spatial to the camera. Distance is a
* squared distance.
*
* @param spat
* Spatial to distancize.
* @return Distance from Spatial to camera.
*/
private float distanceToCam2(Geometry spat){
if (spat == null)
return Float.NEGATIVE_INFINITY;
if (spat.queueDistance != Float.NEGATIVE_INFINITY)
return spat.queueDistance;
Vector3f camPosition = cam.getLocation();
Vector3f viewVector = cam.getDirection();
Vector3f spatPosition = null;
if (spat.getWorldBound() != null){
spatPosition = spat.getWorldBound().getCenter();
}else{
spatPosition = spat.getWorldTranslation();
}
spatPosition.subtract(camPosition, tempVec);
spat.queueDistance = tempVec.dot(tempVec);
float retval = Math.abs(tempVec.dot(viewVector)
/ viewVector.dot(viewVector));
viewVector.mult(retval, tempVec);
spat.queueDistance = tempVec.length();
return spat.queueDistance;
}
代码示例来源:origin: org.jmonkeyengine/jme3-core
public int compare(Geometry o1, Geometry o2) {
float z1 = o1.getWorldTranslation().getZ();
float z2 = o2.getWorldTranslation().getZ();
if (z1 > z2)
return 1;
else if (z1 < z2)
return -1;
else
return 0;
}
代码示例来源:origin: info.projectkyoto/mms-engine
public int compare(Geometry o1, Geometry o2) {
float z1 = o1.getWorldTranslation().getZ();
float z2 = o2.getWorldTranslation().getZ();
if (z1 > z2)
return 1;
else if (z1 < z2)
return -1;
else
return 0;
}
代码示例来源:origin: info.projectkyoto/mms-engine
public float distanceToCam(Geometry spat){
if (spat == null)
return Float.NEGATIVE_INFINITY;
if (spat.queueDistance != Float.NEGATIVE_INFINITY)
return spat.queueDistance;
Vector3f camPosition = cam.getLocation();
Vector3f viewVector = cam.getDirection(tempVec2);
Vector3f spatPosition = null;
if (spat.getWorldBound() != null){
spatPosition = spat.getWorldBound().getCenter();
}else{
spatPosition = spat.getWorldTranslation();
}
spatPosition.subtract(camPosition, tempVec);
spat.queueDistance = tempVec.dot(viewVector);
return spat.queueDistance;
}
代码示例来源:origin: org.jmonkeyengine/jme3-core
public float distanceToCam(Geometry spat){
if (spat == null)
return Float.NEGATIVE_INFINITY;
if (spat.queueDistance != Float.NEGATIVE_INFINITY)
return spat.queueDistance;
Vector3f camPosition = cam.getLocation();
Vector3f viewVector = cam.getDirection(tempVec2);
Vector3f spatPosition = null;
if (spat.getWorldBound() != null){
spatPosition = spat.getWorldBound().getCenter();
}else{
spatPosition = spat.getWorldTranslation();
}
spatPosition.subtract(camPosition, tempVec);
spat.queueDistance = tempVec.dot(viewVector);
return spat.queueDistance;
}
代码示例来源:origin: net.sf.phat/phat-server
void initialPos() {
TempVars vars = TempVars.get();
Quaternion q = vars.quat1;
q.fromAngles(0f, FastMath.DEG_TO_RAD * currentAngle, 0f);
Vector3f dir = new Vector3f(0f, 0f, 1f);
q.mult(dir, dir);
vars.release();
smartphone.setLocalTranslation(screenLoc.add(dir.mult(initialDistance)));
smartphone.lookAt(screenLoc, Vector3f.UNIT_Y);
bitmapText.setText(String.valueOf(distanceToScreen())+"m");
camNode.lookAt(screenQR.getWorldTranslation(), Vector3f.UNIT_Y);
}
代码示例来源:origin: net.sf.phat/phat-server
@Override
protected void createCameras() {
flyCam.setMoveSpeed(1f);
flyCam.setDragToRotate(true);// to prevent mouse capture
//flyCam.setEnabled(false);
cam.setFrustumPerspective(45f, (float) cam.getWidth() / cam.getHeight(), 0.01f, 1000f);
Vector3f center = screenQR.getModelBound().getCenter();
center.multLocal(qrSize);
screenLoc = screenQR.getWorldTranslation().add(center);
initialPos();
}
代码示例来源:origin: net.sf.phat/phat-devices
@Override
protected void createCameras() {
flyCam.setMoveSpeed(1f);
flyCam.setDragToRotate(true);// to prevent mouse capture
//flyCam.setEnabled(false);
cam.setFrustumPerspective(45f, (float) cam.getWidth() / cam.getHeight(), 0.01f, 1000f);
Vector3f center = screen.getModelBound().getCenter();
center.multLocal(qrSize);
screenLoc = screen.getWorldTranslation().add(center);
initialPos();
}
代码示例来源:origin: org.jmonkeyengine/jme3-core
/**
* Calculates the distance from a spatial to the camera. Distance is a
* squared distance.
*
* @param spat
* Spatial to distancize.
* @return Distance from Spatial to camera.
*/
private float distanceToCam2(Geometry spat){
if (spat == null)
return Float.NEGATIVE_INFINITY;
if (spat.queueDistance != Float.NEGATIVE_INFINITY)
return spat.queueDistance;
Vector3f camPosition = cam.getLocation();
Vector3f viewVector = cam.getDirection();
Vector3f spatPosition = null;
if (spat.getWorldBound() != null){
spatPosition = spat.getWorldBound().getCenter();
}else{
spatPosition = spat.getWorldTranslation();
}
spatPosition.subtract(camPosition, tempVec);
spat.queueDistance = tempVec.dot(tempVec);
float retval = Math.abs(tempVec.dot(viewVector)
/ viewVector.dot(viewVector));
viewVector.mult(retval, tempVec);
spat.queueDistance = tempVec.length();
return spat.queueDistance;
}
代码示例来源:origin: info.projectkyoto/mms-engine
/**
* Calculates the distance from a spatial to the camera. Distance is a
* squared distance.
*
* @param spat
* Spatial to distancize.
* @return Distance from Spatial to camera.
*/
private float distanceToCam2(Geometry spat){
if (spat == null)
return Float.NEGATIVE_INFINITY;
if (spat.queueDistance != Float.NEGATIVE_INFINITY)
return spat.queueDistance;
Vector3f camPosition = cam.getLocation();
Vector3f viewVector = cam.getDirection();
Vector3f spatPosition = null;
if (spat.getWorldBound() != null){
spatPosition = spat.getWorldBound().getCenter();
}else{
spatPosition = spat.getWorldTranslation();
}
spatPosition.subtract(camPosition, tempVec);
spat.queueDistance = tempVec.dot(tempVec);
float retval = Math.abs(tempVec.dot(viewVector)
/ viewVector.dot(viewVector));
viewVector.mult(retval, tempVec);
spat.queueDistance = tempVec.length();
return spat.queueDistance;
}
代码示例来源:origin: net.sf.phat/phat-server
camNode.setControlDir(CameraControl.ControlDirection.SpatialToCamera);
camNode.setLocalTranslation(new Vector3f(0, height, distance));
camNode.lookAt(screenQR.getWorldTranslation(), Vector3f.UNIT_Y);
smartphone.attachChild(camNode);
内容来源于网络,如有侵权,请联系作者删除!