⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colli_view_entry.java

📁 本项目是用JAVA3D开发的一款图形界面的3D漫游的类似引擎.至所以这么说.是因为它的部分功能还不完全.说它是引擎是因为它可以完全脱离模型文件.本引擎实现了虚拟漫游,碰撞检测,动态添加模型,以及部分纹
💻 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 + -