本文整理汇总了Java中com.jme3.scene.control.AbstractControl类的典型用法代码示例。如果您正苦于以下问题:Java AbstractControl类的具体用法?Java AbstractControl怎么用?Java AbstractControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractControl类属于com.jme3.scene.control包,在下文中一共展示了AbstractControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
@Override
@FXThread
public void accept(@NotNull final ChangeConsumer changeConsumer, @NotNull final Object object,
final boolean isCopy) {
final T spatial = getElement();
if (object instanceof AbstractControl) {
final AbstractControl control = (AbstractControl) object;
final Spatial prevParent = control.getSpatial();
if (isCopy) {
final AbstractControl clone = (AbstractControl) control.jmeClone();
clone.setSpatial(null);
changeConsumer.execute(new AddControlOperation(clone, spatial));
} else {
changeConsumer.execute(new MoveControlOperation(control, prevParent, spatial));
}
}
super.accept(changeConsumer, object, isCopy);
}
示例2: playAudioNode
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
/**
* Plays an instance of an audio node
*
* @param key
* String The key associated with the audio node
* @param volume
* float the volume to play the instance at (effected by global
* volume)
*/
public void playAudioNode(String key, float volume) {
AudioNode audioNode = new AudioNode(getApplication().getAssetManager(), key, false);
audioNode.setPositional(false);
audioNode.setReverbEnabled(false);
audioNode.setVolume(volume * getUIAudioVolume());
getGUINode().attachChild(audioNode);
audioNode.playInstance();
audioNode.addControl(new AbstractControl() {
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
@Override
protected void controlUpdate(float tpf) {
if (audioNode.getStatus() != Status.Playing) {
audioNode.removeFromParent();
}
}
});
}
示例3: createFrustum
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
public static Geometry createFrustum(Camera cam, AssetManager assetManager){
Vector3f[] pts = new Vector3f[8];
for(int i = 0; i < pts.length; i++) pts[i] = new Vector3f();
ShadowUtil.updateFrustumPoints2(cam, pts);
WireFrustum frustum = new WireFrustum(pts);
Geometry frustumMdl = new Geometry("_frustum."+cam.getName(), frustum);
frustumMdl.setCullHint(Spatial.CullHint.Never);
frustumMdl.setShadowMode(ShadowMode.Off);
frustumMdl.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
frustumMdl.getMaterial().setColor("Color", ColorRGBA.Brown);
frustumMdl.addControl(new AbstractControl() {
@Override
protected void controlUpdate(float tpf) {
ShadowUtil.updateFrustumPoints2(cam, pts);
frustum.update(pts);
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
});
return frustumMdl;
}
示例4: buildForImpl
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
@Override
@FXThread
protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent,
@NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer) {
if (object instanceof AbstractCinematicEvent) {
build((AbstractCinematicEvent) object, container, changeConsumer);
} else if (object instanceof VehicleWheel) {
build((VehicleWheel) object, container, changeConsumer);
} else if (object instanceof Animation) {
build((Animation) object, container, changeConsumer);
}
if (!(object instanceof Control)) return;
if (object instanceof AbstractControl) {
build((AbstractControl) object, container, changeConsumer);
}
super.buildForImpl(object, parent, container, changeConsumer);
if (object instanceof SkeletonControl) {
build((SkeletonControl) object, container, changeConsumer);
} else if (object instanceof CharacterControl) {
build((CharacterControl) object, container, changeConsumer);
} else if (object instanceof RigidBodyControl) {
build((RigidBodyControl) object, container, changeConsumer);
} else if (object instanceof VehicleControl) {
build((VehicleControl) object, container, changeConsumer);
} else if (object instanceof MotionEvent) {
build((MotionEvent) object, container, changeConsumer);
}
if (object instanceof PhysicsRigidBody) {
build((PhysicsRigidBody) object, container, changeConsumer);
}
}
示例5: build
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
@FXThread
private void build(@NotNull final AbstractControl control, @NotNull final VBox container,
@NotNull final ModelChangeConsumer changeConsumer) {
final boolean enabled = control.isEnabled();
final BooleanPropertyControl<ModelChangeConsumer, AbstractControl> enabledControl =
new BooleanPropertyControl<>(enabled, Messages.MODEL_PROPERTY_IS_ENABLED, changeConsumer);
enabledControl.setApplyHandler(AbstractControl::setEnabled);
enabledControl.setSyncHandler(AbstractControl::isEnabled);
enabledControl.setEditObject(control);
FXUtils.addToPane(enabledControl, container);
}
示例6: checkState
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
protected void checkState() {
if (this.speed > 0 && spin == null) {
if (hideWhenIdle)
show();
p.addControl(spin = new AbstractControl() {
private float rot;
@Override
public Control cloneForSpatial(Spatial paramSpatial) {
return null;
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
@Override
protected void controlUpdate(float tpf) {
rot -= tpf * speed;
if (rot < 0) {
rot = FastMath.TWO_PI - tpf;
}
spatial.rotate(0, 0, tpf * speed);
spatial.setLocalTranslation(0, 0, 0);
spatial.rotate(0, 0, tpf * speed);
spatial.center();
spatial.move(getDimensions().x / 2f, getDimensions().y / 2f, 0);
}
});
} else if (speed == 0 && spin != null) {
if (hideWhenIdle)
hide();
p.removeControl(spin);
spin = null;
}
}
示例7: isEnabled
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
/**
* Returns whether this Control is enabled or disabled.
* <b>Note:</b> When the Control doesn't extend AbstractControl, FALSE is returned.
* @return -
*/
public boolean isEnabled()
{
if (isEnableable()) {
return ((AbstractControl)control).isEnabled();
} else
return false;
}
示例8: remove
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
public void remove(Spatial spatial) {
if (spatial == null || spatial.getControl(IDyn4JControl.class) == null) return;
synchronized (spatials) {
spatials.remove(spatial);
}
IDyn4JControl ctl = spatial.getControl(IDyn4JControl.class);
for (int i = spatial.getNumControls() - 1; i > -1; i--) {
//getNumControls changes for each cycle, because BGeometryBodyControl removes itself when disabled
((AbstractControl) spatial.getControl(i)).setEnabled(false);
}
ctl.removeFromWorld();
}
示例9: AbstractBullet
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
public AbstractBullet() {
bulletNode.addControl(new AbstractControl() {
@Override
protected void controlUpdate(float tpf) {
bulletControlUpdate(tpf);
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {}
});
}
示例10: initSketchPlane
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
private void initSketchPlane() {
Quad quad = new Quad(PLANE_QUAD_SIZE*2, PLANE_QUAD_SIZE*2);
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", new ColorRGBA(0.5f, 0, 0, 0.5f));
mat.setTransparent(true);
mat.getAdditionalRenderState().setAlphaTest(true);
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
Geometry geom = new Geometry("SketchPlaneQuad", quad);
geom.setMaterial(mat);
geom.setQueueBucket(RenderQueue.Bucket.Translucent);
geom.setLocalTranslation(-PLANE_QUAD_SIZE, -PLANE_QUAD_SIZE, 0);
sketchPlane = new Node("SketchPlane");
((Node) sketchPlane).attachChild(geom);
sceneNode.attachChild(sketchPlane);
sketchPlane.addControl(new AbstractControl() {
@Override
protected void controlUpdate(float tpf) {
//place the plane at the given distance from the camera
Vector3f pos = app.getCamera().getLocation().clone();
pos.addLocal(app.getCamera().getDirection().mult(planeDistance));
sketchPlane.setLocalTranslation(pos);
//face the camera
Quaternion q = sketchPlane.getLocalRotation();
q.lookAt(app.getCamera().getDirection().negate(), Vector3f.UNIT_Y);
sketchPlane.setLocalRotation(q);
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {}
});
app.getInputManager().addMapping("SketchPlaneDist-", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
app.getInputManager().addMapping("SketchPlaneDist+", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
app.getInputManager().addListener(this, "SketchPlaneDist-", "SketchPlaneDist+");
}
示例11: registerAction_ShowLocalAxis
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void registerAction_ShowLocalAxis(SpatialExplorer se, SimpleApplication app) {
//Spatial axis = app.getRootNode().getChild("axis");
Spatial axis = makeCoordinateAxes(Vector3f.ZERO, app.getAssetManager());
axis.setQueueBucket(Bucket.Translucent);
for(Spatial s : ((Node)axis).getChildren()) {
((Geometry)s).getMaterial().getAdditionalRenderState().setDepthTest(false);
}
axis.setName("localAxis");
AbstractControl axisSync = new AbstractControl() {
@Override
protected void controlUpdate(float tpf) {
if (axis.getParent() == null) {
app.getRootNode().attachChild(axis);
}
if (axis != getSpatial() && axis != getSpatial().getParent()) {
axis.setLocalTransform(getSpatial().getWorldTransform());
}
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
};
se.treeItemActions.add(new Action("Show Local Axis", (evt) -> {
app.enqueue(()->{
Spatial target = ((TreeItem<Spatial>)evt.getSource()).getValue();
if (target != axisSync.getSpatial()) {
if (axisSync.getSpatial() != null) {
axisSync.getSpatial().removeControl(axisSync);
}
target.addControl(axisSync);
}
return null;
});
}));
}
示例12: canAccept
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
@Override
@FXThread
public boolean canAccept(@NotNull final TreeNode<?> treeNode, final boolean isCopy) {
final Object element = treeNode.getElement();
return element instanceof AbstractControl || super.canAccept(treeNode, isCopy);
}
示例13: threadCall
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
@Override
protected boolean threadCall(Spatial spatial) {
if(spatial instanceof Node) {
return false;
}
final Geometry geometry = (Geometry) spatial;
if(debugContains(geometry)) {
return true;
}
if(geometry.getMesh().getBuffer(type) == null) {
return true;
}
Mesh normalsMesh;
if(useArrows) {
normalsMesh = DebugUtil.createNormalArrows(geometry, null, .3f, useTangents());
} else {
if(useTangents()) {
normalsMesh = TangentBinormalGenerator.genTbnLines(geometry.getMesh(), .3f);
} else {
normalsMesh = TangentBinormalGenerator.genNormalLines(geometry.getMesh(), .3f);
}
}
Geometry debugArrowGeom = new Geometry("Normals for: " + geometry.getName(), normalsMesh);
debugArrowGeom.addControl(new AbstractControl() {
@Override
protected void controlUpdate(float tpf) {
if(geometry.getParent() == null) {
removeFromDebug(geometry);
}
this.spatial.setLocalTransform(geometry.getWorldTransform());
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
});
debugArrowGeom.setMaterial(SpatialUtil.createMaterial(getAssetManager(), null));
// debugArrowGeom.setLocalTranslation(geometry.getWorldTranslation());
addToDebug(geometry, debugArrowGeom);
return true;
}
示例14: buildExample
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
protected void buildExample(ElementContainer<?, ?> container) {
/*
* A Horizontal Indicator displaying percentages in the normal direction
*/
Indicator indicator1 = new Indicator().setDisplayMode(DisplayMode.percentages).setMaxValue(100)
.setCurrentValue(75);
indicator1.addControl(new UpdateControl());
Panel panel1 = new Panel(new MigLayout("fill, wrap 1", "[grow]", "[][]"));
panel1.setPosition(100, 100);
panel1.addElement(indicator1, "growx");
panel1.addElement(new Label("Horizontal, Percentages, Forward"), "ax 50%");
/*
* A Horizontal Indicator displaying the value in the reverse direction
*/
Indicator indicator2 = new Indicator().setMaxValue(100).setDisplayMode(DisplayMode.value).setCurrentValue(75)
.setReverseDirection(true);
indicator2.addControl(new UpdateControl());
Panel panel2 = new Panel(new MigLayout("fill, wrap 1", "[grow]", "[][]"));
panel2.addElement(indicator2, "growx");
panel2.addElement(new Label("Horizontal, Valuue, Reverse"), "ax 50%");
panel2.setPosition(200, 200);
/*
* A Vertical Indicator displaying custom text in the forward direction
*/
Indicator indicator3 = new Indicator() {
@Override
protected void refactorText() {
getOverlayElement().setText(String.format("Custom text %.3f", getCurrentPercentage()));
super.refactorText();
}
}.setMaxValue(100).setDisplayMode(DisplayMode.none).setCurrentValue(75);
indicator3.addControl(new UpdateControl());
Panel panel3 = new Panel(new MigLayout("fill, wrap 1", "[]", "[grow][]"));
panel3.addElement(indicator3, "growx, ax 50%");
panel3.addElement(new Label("Vertical,Custom,Forward"), "ax 50%");
panel3.setPosition(300, 300);
/*
* A Vertical Indicator displaying nothing with animation (jumps every 2
* seconds)
*/
Indicator indicator4 = new Indicator().setOrientation(Orientation.VERTICAL).setDisplayMode(DisplayMode.none)
.setMaxValue(100).setCurrentValue(75).setAnimationTime(0.5f).setInterpolation(Interpolation.bounce);
indicator4.addControl(new AbstractControl() {
/* This control updates the bar to a random value every 2 seconds */
float t = 0;
@Override
protected void controlUpdate(float tpf) {
t += tpf;
if (t > 2) {
t = 0;
indicator4.setCurrentValue(FastMath.nextRandomFloat() * indicator4.getMaxValue());
}
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
});
Panel panel4 = new Panel(new MigLayout("fill, wrap 1", "[]", "[:260:,grow][]"));
panel4.setPosition(400, 400);
panel4.addElement(indicator4, "growy, ax 50%");
panel4.addElement(new Label("Vertical,Animation"), "ax 50%");
// Build the screen
container.showElement(panel1);
container.showElement(panel2);
container.showElement(panel3);
container.showElement(panel4);
}
示例15: isEnableable
import com.jme3.scene.control.AbstractControl; //导入依赖的package包/类
public boolean isEnableable() {
return control instanceof AbstractControl;
}