本文整理匯總了Java中com.jme3.math.Vector2f.subtract方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector2f.subtract方法的具體用法?Java Vector2f.subtract怎麽用?Java Vector2f.subtract使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.math.Vector2f
的用法示例。
在下文中一共展示了Vector2f.subtract方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: finishDrop
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
private void finishDrop(BaseElement dropEl, boolean events) {
Vector2f absDropLoc = getAbsolute();
handleSuccess(dropEl);
if (useLockToDropElementEffect) {
animating = true;
Vector2f dest = absDropLoc.subtract(getParentContainer().getAbsolute());
screen.getEffectManager()
.applyEffect(new EffectList(new SlideFromEffect(.15f, dest).setElement(this), new RunEffect(() -> {
animating = false;
handleSuccess(dropEl);
cleanUpDrop();
if (dragSupport != null && events)
dragSupport.fireEvent(new DragEvent<BaseElement>(DragElement.this, DragEventType.complete));
})));
return;
}
cleanUpDrop();
if (dragSupport != null && events)
dragSupport.fireEvent(new DragEvent<BaseElement>(this, DragEventType.complete));
}
示例2: abortDrop
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
private void abortDrop() {
if (useSpringBack) {
Vector2f absDropLoc = getPosition().clone();
if (wasParentedBy != null) {
screen.removeElement(this);
wasParentedBy.insertChild(this, null, originalIndex);
wasParentedBy = null;
}
if (useSpringBackEffect) {
animating = true;
Vector2f dest = absDropLoc.subtract(getParentContainer().getAbsolute());
screen.getEffectManager().applyEffect(
new EffectList(new SlideFromEffect(.25f, dest).setElement(this), new RunEffect(() -> {
animating = false;
if (dragSupport != null)
dragSupport.fireEvent(new DragEvent<BaseElement>(DragElement.this, DragEventType.aborted));
cleanUpDrop();
})));
return;
}
}
cleanUpDrop();
if (dragSupport != null)
dragSupport.fireEvent(new DragEvent<BaseElement>(this, DragEventType.aborted));
}
示例3: LineElement
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
public LineElement(BaseScreen screen, Vector2f p1, Vector2f p2, ColorRGBA color, float lineWidth) {
super(screen, p1, new Size(p2.subtract(p1)));
Line l1 = new Line(new Vector3f(0, 0, 0), new Vector3f(p2.x - p1.x, p2.y - p1.y, 0));
l1.setLineWidth(lineWidth);
Geometry geom = new Geometry("A shape", l1);
meshMaterial.setColor("Color", color);
geom.setMaterial(meshMaterial);
attachChild(geom);
}
示例4: onLayoutBackground
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
protected void onLayoutBackground(C container) {
BaseElement element = (BaseElement) container;
Material mat = element.getElementMaterial();
Geometry geom = element.getGeometry();
Vector2f elsz = element.getDimensions();
if (mat != null && geom != null) {
Vector4f margin = element.getMargin();
Vector2f sz = calcBackgroundSize(container);
if (sz == null)
sz = elsz.subtract(margin.x + margin.y, margin.z + margin.w);
Vector2f esz = container.getDimensions().clone();
esz.subtractLocal(margin.x + margin.y, margin.z + margin.w);
sz.x -= element.borderOffset.x + element.borderOffset.y;
sz.y -= element.borderOffset.z + element.borderOffset.w;
Vector2f fac = new Vector2f(esz.x / sz.x, esz.y / sz.y);
ElementQuadGrid model = element.getModel();
if (!element.calcBorders().equals(model.getBorders())) {
element.recreateElementQuadGrid();
}
float tcW, tcH;
switch (element.getTileMode()) {
case REPEAT:
model.updateDimensions(esz.x, esz.y);
tcW = sz.x / (element.isAtlasTextureInUse() ? element.getAtlasCoords().z : model.getImageWidth())
* fac.x;
tcH = sz.y / (element.isAtlasTextureInUse() ? element.getAtlasCoords().w : model.getImageHeight())
* fac.y;
model.updateTiledTexCoords(0, -tcH, tcW, 0);
break;
case REPEAT_X:
model.updateDimensions(esz.x, sz.y);
tcW = sz.x / (element.isAtlasTextureInUse() ? element.getAtlasCoords().z : model.getImageWidth())
* fac.x;
tcH = sz.y / (element.isAtlasTextureInUse() ? element.getAtlasCoords().w : model.getImageHeight());
model.updateTiledTexCoords(0, -tcH, tcW, 0);
break;
case REPEAT_Y:
model.updateDimensions(sz.x, esz.y);
tcW = sz.x / (element.isAtlasTextureInUse() ? element.getAtlasCoords().z : model.getImageWidth());
tcH = sz.y / (element.isAtlasTextureInUse() ? element.getAtlasCoords().w : model.getImageHeight())
* fac.y;
model.updateTiledTexCoords(0, -tcH, tcW, 0);
break;
default:
model.updateDimensions(sz.x, sz.y);
break;
}
Position bp = element.getBackgroundPosition();
Vector2f pos = new Vector2f(0, 0);
if (bp != null)
if (bp.xUnit == Unit.PERCENT)
pos.x = ((elsz.x - margin.y - sz.x - margin.x) * (bp.x / 100f)) + margin.x;
else
pos.x = bp.x + margin.x;
else
pos.x = margin.x;
if (bp != null)
if (bp.yUnit == Unit.PERCENT) {
pos.y = ((elsz.y - margin.z - sz.y - margin.w) * ((100 - bp.y) / 100f)) + margin.w;
} else
pos.y = elsz.y - sz.y - bp.y + margin.w - margin.z;
else
pos.y = elsz.y - sz.y - margin.z;
geom.setLocalTranslation(pos.x + element.borderOffset.x, pos.y + element.borderOffset.z,
geom.getLocalTranslation().z);
geom.updateModelBound();
}
}
示例5: endDragPaletteTool
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
private void endDragPaletteTool(DragEvent evt, PaletteTool tool) {
canvasStack.removeElement(dragLayer);
BaseElement el = tool.createElement();
el.onElementEvent(e -> {
/* When moved, take the element out of it's current parent and
* put it back in the drag layer
*/
List<BaseElement> els = screen.getElementsAt(el.getAbsoluteX() + ( el.getWidth() / 2f ), el.getAbsoluteY() + (el.getHeight() / 2f ) );
/* Remove the element we are moving */
els.remove(e.getSource());
/* Find the canvas layer in the list and remove it from the list and any preceeding elements */
int idx = els.indexOf(canvas);
if(idx != -1) {
for(int i = 0 ; i < idx + 1 ; i++) {
els.remove(0);
}
}
/* Go through the rest of the elements and look for the tool that created it */
for(BaseElement bel : els) {
PaletteTool t = elementTools.get(bel);
if(t != null) {
t.handle(e, bel);
}
}
System.out.println(els);
}, Type.MOVED);
el.sizeToContent();
Vector2f pos = new Vector2f(evt.getX(), evt.getY());
pos.subtract(canvas.getAbsolute());
el.setMovable(true);
el.setBringToFrontOnClick(true);
el.setLockToParentBounds(true);
el.setPosition(pos);
if (evt.getTarget() == dragLayer) {
}
elementTools.put(el, tool);
canvas.addElement(el);
}