本文整理汇总了Java中com.jme3.math.Vector3f.subtractLocal方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3f.subtractLocal方法的具体用法?Java Vector3f.subtractLocal怎么用?Java Vector3f.subtractLocal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.math.Vector3f
的用法示例。
在下文中一共展示了Vector3f.subtractLocal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAnalog
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
@Override
public void onAnalog( String name, float value, float tpf ) {
CollisionResult cr = getClicked();
Vector3f pos = null;
if (cr != null)
pos = cr.getContactPoint();
if (pos == null) {
Vector3f dir = cam.getWorldCoordinates( getInputManager().getCursorPosition(), -10 );
dir.subtractLocal( cam.getLocation() );
new Ray( cam.getLocation(), dir ).intersectsWherePlane( new Plane(Jme3z.UP, 0), pos = new Vector3f() );
}
cursorPosition = Jme3z.from( pos );
if (pos != null)
point.setPosition( pos.add ( cam.getDirection().mult( -0.3f ) ));
}
示例2: getSurfaceSelected
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
private Vector3f getSurfaceSelected(float dist) {
CollisionResult cr = getClicked();
Vector3f pos = null;
if (cr != null)
pos = cr.getContactPoint();
if (pos == null) {
Vector3f dir = cam.getWorldCoordinates( getInputManager().getCursorPosition(), -dist );
dir.subtractLocal( cam.getLocation() );
new Ray( cam.getLocation(), dir ).intersectsWherePlane( new Plane(Jme3z.UP, 0), pos = new Vector3f() );
}
return pos;
}
示例3: renderDepth
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
public BufferedImage renderDepth( File fout, float scale, Pano pano, Spatial scene, double minDepth, double maxDepth ) {
BufferedImage out = new BufferedImage( (int) ( a.distance( b ) * scale ), (int) ( ( heightMax- heightMin) * scale ), BufferedImage.TYPE_3BYTE_BGR );
Vector3f o = Jme3z.to ( pano.location );
for ( int x = 0; x < out.getWidth(); x++ ) {
for ( int y = 0; y < out.getHeight(); y++ ) {
CollisionResults results = new CollisionResults();
float[] target = uvToWorld( x / (float) out.getWidth(), 1 - ( y / (float) out.getHeight() ) );
Vector3f ray = new Vector3f (target[0], target[1], target[2]);
ray.subtractLocal( o );
scene.collideWith(new Ray( o, ray), results);
CollisionResult cr = results.getClosestCollision();
double dist = maxDepth;
if (cr != null)
dist = Math.min (maxDepth, cr.getDistance() );
dist = Mathz.clamp ( ( dist - minDepth ) / ( maxDepth - minDepth ), 0, 1);
int d = (int)(dist * 256);
double r = dist*256 - d;
int c = Colour.asInt(
Mathz.clamp ( d + (r > 0.25 ? 1 : 0), 0, 255),
Mathz.clamp ( d + (r > 0.50 ? 1 : 0), 0, 255),
Mathz.clamp ( d + (r > 0.75 ? 1 : 0), 0, 255) );
out.setRGB( x, y, c );
}
System.out.println( x + " / " + out.getWidth() );
}
if ( fout != null )
try {
ImageIO.write( out, "png", fout );
} catch ( IOException e1 ) {
e1.printStackTrace();
}
return out;
}
示例4: processTransform
import com.jme3.math.Vector3f; //导入方法依赖的package包/类
@Override
public void processTransform() {
final EditorTransformSupport editorControl = getEditorControl();
final LocalObjects local = LocalObjects.get();
final Camera camera = editorControl.getCamera();
final InputManager inputManager = EDITOR.getInputManager();
final Transform transform = notNull(editorControl.getTransformCenter());
// cursor position and selected position vectors
final Vector2f cursorPos = inputManager.getCursorPosition();
final Vector3f transformOnScreen = camera.getScreenCoordinates(transform.getTranslation(), local.nextVector());
final Vector2f selectedCoords = local.nextVector(transformOnScreen.getX(), transformOnScreen.getY());
// set new deltaVector if it's not set (scale tool stores position of a cursor)
if (Float.isNaN(editorControl.getTransformDeltaX())) {
editorControl.setTransformDeltaX(cursorPos.getX());
editorControl.setTransformDeltaY(cursorPos.getY());
}
final Node parentNode = getParentNode();
final Node childNode = getChildNode();
// Picked vector
final Spatial toTransform = notNull(editorControl.getToTransform());
final TransformationMode transformationMode = editorControl.getTransformationMode();
transformationMode.prepareToScale(parentNode, childNode, transform, camera);
// scale according to distance
final Vector3f deltaVector = local.nextVector(editorControl.getTransformDeltaX(), editorControl.getTransformDeltaY(), 0F);
final Vector2f delta2d = local.nextVector(deltaVector.getX(), deltaVector.getY());
final Vector3f baseScale = local.nextVector(transform.getScale()); // default scale
final Vector3f pickedVector = local.nextVector(transformationMode.getScaleAxis(transform, editorControl.getPickedAxis(), camera));
pickedVector.setX(abs(pickedVector.getX()));
pickedVector.setY(abs(pickedVector.getY()));
pickedVector.setZ(abs(pickedVector.getZ()));
if (Config.DEV_TRANSFORMS_DEBUG) {
System.out.println("Base scale " + baseScale + ", pickedVector " + pickedVector);
}
// scale object
float disCursor = cursorPos.distance(selectedCoords);
float disDelta = delta2d.distance(selectedCoords);
float scaleValue = (float) (cursorPos.distance(delta2d) * 0.01f * Math.sqrt(baseScale.length()));
if (disCursor > disDelta) {
baseScale.addLocal(pickedVector.mult(scaleValue, local.nextVector()));
} else {
scaleValue = Math.min(scaleValue, 0.999f); // remove negateve values
baseScale.subtractLocal(pickedVector.mult(scaleValue, local.nextVector()));
}
parentNode.setLocalScale(baseScale);
if (Config.DEV_TRANSFORMS_DEBUG) {
System.out.println("New scale " + baseScale + ", result world " + childNode.getWorldScale());
}
parentNode.setLocalScale(baseScale);
toTransform.setLocalScale(childNode.getWorldScale());
editorControl.notifyTransformed(toTransform);
}