本文整理汇总了Java中com.jme3.animation.AnimChannel类的典型用法代码示例。如果您正苦于以下问题:Java AnimChannel类的具体用法?Java AnimChannel怎么用?Java AnimChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnimChannel类属于com.jme3.animation包,在下文中一共展示了AnimChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
@Override
@FXThread
protected void process() {
super.process();
final AnimationTreeNode modelNode = (AnimationTreeNode) getNode();
if (modelNode.getChannel() < 0) return;
final AnimControl control = modelNode.getControl();
if (control == null || control.getNumChannels() <= 0) return;
final AnimChannel channel = control.getChannel(modelNode.getChannel());
channel.setLoopMode(LoopMode.DontLoop);
EXECUTOR_MANAGER.addJMETask(control::clearChannels);
final NodeTree<ModelChangeConsumer> nodeTree = getNodeTree();
nodeTree.update(modelNode);
}
示例2: process
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
@Override
@FXThread
protected void process() {
super.process();
final AnimationTreeNode modelNode = (AnimationTreeNode) getNode();
if (modelNode.getChannel() < 0) return;
final AnimControl control = modelNode.getControl();
if (control == null || control.getNumChannels() <= 0) return;
final AnimChannel channel = control.getChannel(modelNode.getChannel());
channel.setSpeed(0);
modelNode.setSpeed(0);
final NodeTree<ModelChangeConsumer> nodeTree = getNodeTree();
nodeTree.update(modelNode);
}
示例3: initEvent
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
@Override
public void initEvent(Application app, Cinematic cinematic) {
if (channel == null) {
Object s = cinematic.getEventData("modelChannels", modelName);
if (s != null && s instanceof AnimChannel) {
this.channel = (AnimChannel) s;
} else if (s == null) {
Spatial model = cinematic.getScene().getChild(modelName);
if (model != null) {
channel = model.getControl(AnimControl.class).createChannel();
cinematic.putEventData("modelChannels", modelName, channel);
} else {
log.log(Level.WARNING, "spatial {0} not found in the scene, cannot perform animation", modelName);
}
}
}
}
示例4: getPrototype
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
protected AnimChannel getPrototype(String soundPath) {
if(soundPath.isEmpty()) {
return null;
}
// if (!animationPrototypes.containsKey(soundPath)) {
// find node/mesh
// try {
// AudioNode audio = new AudioNode(RendererPlatform.getAssetManager(), "sounds/" + soundPath);
// animationPrototypes.put(soundPath, audio);
// } catch (Exception e) {
// LogUtil.warning("Sound not found : sounds/" + soundPath + " ("+ e + ")");
// return null;
// }
// }
// return (AnimChannel) ((AnimChannel) animationPrototypes.get(soundPath)).clone();
return null;
}
示例5: animate
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
protected void animate(AnimationSource source, Entity e) {
Spatial spatial = RendererPlatform.getMainSceneNode().getChild(source.getMesh());
if (spatial == null) {
System.err.println("spatial [" + source.getMesh() + "] not found");
return;
}
AnimControl playerControl = spatial.getControl(AnimControl.class);
AnimChannel channel = SpatialPool.getPlayinganimations().get(e.getId());
if (channel == null) {
channel = playerControl.createChannel();
SpatialPool.getPlayinganimations().put(e.getId(), channel);
}
channel.setAnim(source.getAnimName(), (float) source.getSpeed());
channel.setLoopMode(source.getLoopMode());
}
示例6: registerAction_PlayAnimation
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void registerAction_PlayAnimation(AnimationExplorer exp, SimpleApplication app) {
exp.treeItemActions.add(new Action("play", (evt) -> {
TreeItem<Object> treeItem = ((TreeItem<Object>)evt.getSource());
Object target = treeItem.getValue();
if (target instanceof Animation) {
AnimControl ac = ((Spatial)treeItem.getParent().getValue()).getControl(AnimControl.class);
ac.clearChannels();
Animation ani = ((Animation)target);
AnimChannel channel = ac.createChannel();
channel.setAnim(ani.getName());
channel.setLoopMode(LoopMode.DontLoop);
channel.setSpeed(1f);
}
}));
}
示例7: setTime
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
/**
* Modify the spatial which this track modifies.
*
* @param time the current time of the animation
*/
@Override
public void setTime(float time, float weight, AnimControl control, AnimChannel channel, TempVars vars) {
try {
if (points != null) {
float value = points.valueAt(time);
if (lastValue == Float.MIN_VALUE || time <= 0) {
lastValue = value;
}
apply(value, value - lastValue, weight, control, channel, vars);
lastValue = value;
}
} catch(Exception exc) {
exc.printStackTrace();
}
}
示例8: onAnimCycleDone
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
@Override
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
if(animName.compareTo("Precast") == 0) {
//System.out.println("Start waiting for cast!");
waitingForCast = true;
waitingForPrecast = false;
setPlayerShootControl(spatial.getControl(PlayerShootControl.class));
if (getPlayerShootControl() == null && target != null) {
setPlayerShootControl(new PlayerShootControl());
getPlayerShootControl().setTarget(target);
spatial.addControl(getPlayerShootControl());
attackTime = getTimeCounter();
}
} else if(animName.compareTo("Cast")==0) {
waitingForPrecast = true;
waitingForCast = false;
attackTime = getTimeCounter();
} else if(animName.compareTo("Die")==0) {
deathTime = getTimeCounter();
}
}
示例9: setPlay
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
/**
* Activate the defined animation in the AnimationComponent, on the main
* channel (Currently only one channel is used).
*
* @param channel to use for the animation.
* @param anim animation to play.
*/
private void setPlay(AnimChannel channel, Animation anim) {
if (channel.getControl().getAnimationNames().contains(anim.name())) {
switch (anim) {
case IDLE:
channel.setAnim(anim.toString(), 0.50f);
channel.setLoopMode(LoopMode.Loop);
channel.setSpeed(1f);
break;
case SUMMON:
channel.setAnim(anim.toString());
channel.setLoopMode(LoopMode.DontLoop);
break;
case WALK:
channel.setAnim(anim.toString(), 0.50f);
channel.setLoopMode(LoopMode.Loop);
break;
default:
System.err.println(anim.name() + " Is not a supported animation type.");
}
} else if (anim.equals(Animation.SUMMON)) {
setPlay(channel, Animation.IDLE);
}
}
示例10: perform
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
@Override
public void perform(Actor a) {
AnimationActor actor = (AnimationActor)a;
if(actor.launched) {
return;
}
actor.launched = true;
Spatial s = actor.getParentModelActor().getViewElements().spatial;
AnimChannel channel = s.getControl(AnimControl.class).getChannel(0);
channel.setAnim(actor.animName);
switch (actor.cycle){
case Once : channel.setLoopMode(LoopMode.DontLoop); break;
case Loop : channel.setLoopMode(LoopMode.Loop); break;
case Cycle : channel.setLoopMode(LoopMode.Cycle); break;
}
channel.setSpeed((float)actor.speed);
}
示例11: initEvent
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
@Override
public void initEvent(Application app, Cinematic cinematic) {
super.initEvent(app, cinematic);
if (channel == null) {
Object s = cinematic.getEventData("modelChannels", modelName);
if (s != null && s instanceof AnimChannel) {
this.channel = (AnimChannel) s;
} else if (s == null) {
Spatial model = cinematic.getScene().getChild(modelName);
if (model != null) {
channel = model.getControl(AnimControl.class).createChannel();
cinematic.putEventData("modelChannels", modelName, channel);
} else {
log.log(Level.WARNING, "spatial {0} not found in the scene, cannot perform animation", modelName);
}
}
}
}
示例12: onAnimCycleDone
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
/** Use this listener to trigger something after an animation is done. */
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
if (animName.equals("Walk")) {
/** After "walk", reset to "stand". */
channel.setAnim("stand", 0.50f);
channel.setLoopMode(LoopMode.DontLoop);
channel.setSpeed(1f);
}
}
示例13: onAnimCycleDone
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
if (animName.equals("Dodge")){
channel.setAnim("stand", 0.50f);
channel.setLoopMode(LoopMode.DontLoop);
channel.setSpeed(1f);
}
}
示例14: onAnimCycleDone
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
// if(channel.getAnimationName().equals("StandUpFront")){
// channel.setAnim("Dance");
// }
if (channel.getAnimationName().equals("StandUpBack") || channel.getAnimationName().equals("StandUpFront")) {
channel.setLoopMode(LoopMode.DontLoop);
channel.setAnim("IdleTop", 5);
channel.setLoopMode(LoopMode.Loop);
}
// if(channel.getAnimationName().equals("IdleTop")){
// channel.setAnim("StandUpFront");
// }
}
示例15: simpleInitApp
import com.jme3.animation.AnimChannel; //导入依赖的package包/类
@Override
public void simpleInitApp() {
Spatial ogreModel = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.White);
dl.setDirection(new Vector3f(0,-1,-1).normalizeLocal());
rootNode.addLight(dl);
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryExporter exp = new BinaryExporter();
exp.save(ogreModel, baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
BinaryImporter imp = new BinaryImporter();
imp.setAssetManager(assetManager);
Node ogreModelReloaded = (Node) imp.load(bais, null, null);
AnimControl control = ogreModelReloaded.getControl(AnimControl.class);
AnimChannel chan = control.createChannel();
chan.setAnim("Walk");
rootNode.attachChild(ogreModelReloaded);
} catch (IOException ex){
ex.printStackTrace();
}
}