📄 colli_view_entry.java
字号:
package cn.bz.collision;
import java.util.Enumeration;
import javax.media.j3d.Behavior;
import javax.media.j3d.Bounds;
import javax.media.j3d.WakeupCondition;
import javax.media.j3d.WakeupCriterion;
import javax.media.j3d.WakeupOnViewPlatformEntry;
import javax.media.j3d.WakeupOnViewPlatformExit;
import javax.media.j3d.WakeupOr;
/**
* 此类你可以添加在任何一个TG上,当然也可以是包含obj文件或者其它外部文件的TG上,
* 使用此类,首先你必须声明一个KeyNavi对象,此类必须放在一个与视野碰撞的物体上,
* 此类是用来检查视野是否与添加了此行为的结点碰撞
*
* 此类终于封装好了.可是还是觉得不太好..效果不太好..从来没有这么认真的写过这样的类
* 不能使用组合键,,速度调整的不好.以后有时间再继续写
*
* @author 李光
*
*/
public class Colli_View_Entry extends Behavior {
// 碰撞检测参数
WakeupOnViewPlatformExit exitEvent ;
WakeupCondition wakeupCondition = null;
public static KeyNavi theView;
private Bounds bounds;
public Colli_View_Entry(Bounds bounds) {
this.bounds = bounds ;
initCollisionBounds();
}
private void initCollisionBounds() {
WakeupOnViewPlatformEntry wakeupEntry = null;
WakeupCriterion[] wakeupArray = new WakeupCriterion[1];
wakeupEntry = new WakeupOnViewPlatformEntry(bounds);
wakeupArray[0] = wakeupEntry;
wakeupCondition = new WakeupOr(wakeupArray);
}
public void initialize() {
// TODO Auto-generated method stub
wakeupOn(wakeupCondition);
}
public void processStimulus(Enumeration criteria) {
WakeupCriterion genericEvt;
while (criteria.hasMoreElements()) {
genericEvt = (WakeupCriterion) criteria.nextElement();
if (genericEvt instanceof WakeupOnViewPlatformEntry) {
System.out.println("entry");
int flag = theView.getFlag();
if(flag == 1){
theView.FTRANSLATE = 0.0 ;
theView.BTRANSLATE = theView.suduD ;
}
if(flag == 2){
theView.FTRANSLATE = theView.suduD ;
theView.BTRANSLATE = 0.0 ;
}
}
}
wakeupOn(wakeupCondition);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -