亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? viewerbehavior.java

?? 包括了JAVA3D(全世界都能看到的網絡三維動畫)的源代碼部分! 很多基礎但是卻很精彩的例子!有什么不明白的也可以和我交流MSN:guorui0728@hotmail.com
?? JAVA
字號:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.media.j3d.*;
import javax.vecmath.*;


/**
 * ViewerBehavior
 *
 * @version		1.0, 98/04/16
 **/

/**
 * Wakeup on mouse button presses, releases, and mouse movements and
 * generate transforms for a transform group.  Classes that extend this
 * class impose specific symantics, such as "Examine" or "Walk" viewing,
 * similar to the navigation types used by VRML browsers.
 *
 * To support systems with 2 or 1 mouse buttons, the following
 * alternate mappings are supported while dragging with any mouse
 * button held down and zero or more keyboard modifiers held down:
 *
 *   No modifiers = Button 1
 *   ALT = Button 2
 *   Meta = Button 3
 *   Control = Button 3
 *
 * The behavior automatically modifies a TransformGroup provided
 * to the constructor.  The TransformGroup's transform can be set
 * at any time by the application or other behaviors to cause the
 * viewer's rotation and translation to be reset.
 */

// This class is inspired by the MouseBehavior, MouseRotate,
// MouseTranslate, and MouseZoom utility behaviors provided with
// Java 3D.  This class differs from those utilities in that it:
//
//    (a) encapsulates all three behaviors into one in order to
//        enforce a specific viewing symantic
//
//    (b) supports set/get of the rotation and translation factors
//        that control the speed of movement.
//
//    (c) supports the "Control" modifier as an alternative to the
//        "Meta" modifier not present on PC, Mac, and most non-Sun
//        keyboards.  This makes button3 behavior usable on PCs,
//        Macs, and other systems with fewer than 3 mouse buttons.

public abstract class ViewerBehavior
	extends Behavior
{
	// Keep track of the transform group who's transform we modify
	// during mouse motion.
	protected TransformGroup subjectTransformGroup = null;

	// Keep a set of wakeup criterion for different mouse-generated
	// event types.
	protected WakeupCriterion[] mouseEvents = null;
	protected WakeupOr mouseCriterion = null;

	// Track which button was last pressed
	protected static final int BUTTONNONE = -1;
	protected static final int BUTTON1 = 0;
	protected static final int BUTTON2 = 1;
	protected static final int BUTTON3 = 2;
	protected int buttonPressed = BUTTONNONE;

	// Keep a few Transform3Ds for use during event processing.  This
	// avoids having to allocate new ones on each event.
	protected Transform3D currentTransform = new Transform3D( );
	protected Transform3D transform1 = new Transform3D( );
	protected Transform3D transform2 = new Transform3D( );
	protected Matrix4d matrix = new Matrix4d( );
	protected Vector3d origin = new Vector3d( 0.0, 0.0, 0.0 );
	protected Vector3d translate = new Vector3d( 0.0, 0.0, 0.0 );

	// Unusual X and Y delta limits.
	protected static final int UNUSUAL_XDELTA = 400;
	protected static final int UNUSUAL_YDELTA = 400;

	protected Component parentComponent = null;


	/**
	 * Construct a viewer behavior that listens to mouse movement
	 * and button presses to generate rotation and translation
	 * transforms written into a transform group given later
	 * with the setTransformGroup( ) method.
	 */
	public ViewerBehavior( )
	{
		super( );
	}


	/**
	 * Construct a viewer behavior that listens to mouse movement
	 * and button presses to generate rotation and translation
	 * transforms written into a transform group given later
	 * with the setTransformGroup( ) method.
	 *
	 * @param parent The AWT Component that contains the area
	 * generating mouse events.
	 */
	public ViewerBehavior( Component parent )
	{
		super( );
		parentComponent = parent;
	}


	/**
	 * Construct a viewer behavior that listens to mouse movement
	 * and button presses to generate rotation and translation
	 * transforms written into the given transform group.
	 *
	 * @param transformGroup The transform group to be modified
	 * by the behavior.
	 */
	public ViewerBehavior( TransformGroup transformGroup )
	{
		super( );
		subjectTransformGroup = transformGroup;
	}


	/**
	 * Construct a viewer behavior that listens to mouse movement
	 * and button presses to generate rotation and translation
	 * transforms written into the given transform group.
	 *
	 * @param transformGroup The transform group to be modified
	 * by the behavior.
	 * @param parent The AWT Component that contains the area
	 * generating mouse events.
	 */
	public ViewerBehavior( TransformGroup transformGroup, Component parent )
	{
		super( );
		subjectTransformGroup = transformGroup;
		parentComponent = parent;
	}


	/**
	 * Set the transform group modified by the viewer behavior.
	 * Setting the transform group to null disables the behavior
	 * until the transform group is again set to an existing group.
	 *
	 * @param transformGroup The new transform group to be modified
	 * by the behavior.
	 */
	public void setTransformGroup( TransformGroup transformGroup )
	{
		subjectTransformGroup = transformGroup;
	}


	/**
	 * Get the transform group modified by the viewer behavior.
	 */
	public TransformGroup getTransformGroup( )
	{
		return subjectTransformGroup;
	}


	/**
	 *  Sets the parent component who's cursor will be changed during
	 *  mouse drags.  If no component is given is given to the
	 *  constructor, or set via this method, no cursor changes
	 *  will be done.
	 *
	 *  @param  parent  the AWT Component, such as a Frame, within which
	 *                  cursor changes should take place during
	 *                  mouse drags
	 */
	public void setParentComponent( Component parent )
	{
		parentComponent = parent;
	}


	/*
	 *  Gets the parent frame within which the cursor changes
	 *  during mouse drags.
	 *
	 *  @return         the AWT Component, such as a Frame, within which
	 *                  cursor changes should take place during
	 *                  mouse drags.  Returns null if no parent is set.
	 */
	public Component getParentComponent( )
	{
		return parentComponent;
	}


	/**
	 * Initialize the behavior.
	 */
	public void initialize( )
	{
		// Wakeup when the mouse is dragged or when a mouse button
		// is pressed or released.
		mouseEvents = new WakeupCriterion[3];
		mouseEvents[0] = new WakeupOnAWTEvent( MouseEvent.MOUSE_DRAGGED );
		mouseEvents[1] = new WakeupOnAWTEvent( MouseEvent.MOUSE_PRESSED );
		mouseEvents[2] = new WakeupOnAWTEvent( MouseEvent.MOUSE_RELEASED );
		mouseCriterion = new WakeupOr( mouseEvents );
		wakeupOn( mouseCriterion );
	}



	/**
	 * Process a new wakeup.  Interpret mouse button presses, releases,
	 * and mouse drags.
	 *
	 * @param criteria The wakeup criteria causing the behavior wakeup.
	 */
	public void processStimulus( Enumeration criteria )
	{
		WakeupCriterion wakeup = null;
		AWTEvent[] event = null;
		int whichButton = BUTTONNONE;


		// Process all pending wakeups
		while( criteria.hasMoreElements( ) )
		{
			wakeup = (WakeupCriterion)criteria.nextElement( );
			if ( wakeup instanceof WakeupOnAWTEvent )
			{
				event = ((WakeupOnAWTEvent)wakeup).getAWTEvent( );

				// Process all pending events
				for ( int i = 0; i < event.length; i++ )
				{
					if ( event[i].getID( ) != MouseEvent.MOUSE_PRESSED &&
						event[i].getID( ) != MouseEvent.MOUSE_RELEASED &&
						event[i].getID( ) != MouseEvent.MOUSE_DRAGGED )
						// Ignore uninteresting mouse events
						continue;

					//
					// Regretably, Java event handling (or perhaps
					// underlying OS event handling) doesn't always
					// catch button bounces (redundant presses and
					// releases), or order events so that the last
					// drag event is delivered before a release.
					// This means we can get stray events that we
					// filter out here.
					//
					if ( event[i].getID( ) == MouseEvent.MOUSE_PRESSED &&
						buttonPressed != BUTTONNONE )
						// Ignore additional button presses until a release
						continue;

					if ( event[i].getID( ) == MouseEvent.MOUSE_RELEASED &&
						buttonPressed == BUTTONNONE )
						// Ignore additional button releases until a press
						continue;

					if ( event[i].getID( ) == MouseEvent.MOUSE_DRAGGED &&
						buttonPressed == BUTTONNONE )
						// Ignore drags until a press
						continue;

					MouseEvent mev = (MouseEvent)event[i];
					int modifiers = mev.getModifiers( );

					//
					// Unfortunately, the underlying event handling
					// doesn't do a "grab" operation when a mouse button
					// is pressed.  This means that once a button is
					// pressed, if another mouse button or a keyboard
					// modifier key is pressed, the delivered mouse event
					// will show that a different button is being held
					// down.  For instance:
					//
					// Action                           Event
					//  Button 1 press                  Button 1 press
					//  Drag with button 1 down         Button 1 drag
					//  ALT press                       -
					//  Drag with ALT & button 1 down   Button 2 drag
					//  Button 1 release                Button 2 release
					//
					// The upshot is that we can get a button press
					// without a matching release, and the button
					// associated with a drag can change mid-drag.
					//
					// To fix this, we watch for an initial button
					// press, and thenceforth consider that button
					// to be the one held down, even if additional
					// buttons get pressed, and despite what is
					// reported in the event.  Only when a button is
					// released, do we end such a grab.
					//

					if ( buttonPressed == BUTTONNONE )
					{
						// No button is pressed yet, figure out which
						// button is down now and how to direct events
						if ( ( (modifiers & InputEvent.BUTTON3_MASK)
								!= 0 ) ||
							( ( (modifiers & InputEvent.BUTTON1_MASK)
								!= 0 ) &&
							( (modifiers & InputEvent.CTRL_MASK)
								== InputEvent.CTRL_MASK ) ) )
						{
							// Button 3 activity (META or CTRL down)
							whichButton = BUTTON3;
						}
						else if ( (modifiers & InputEvent.BUTTON2_MASK)
							!= 0 )
						{
							// Button 2 activity (ALT down)
							whichButton = BUTTON2;
						}
						else
						{
							// Button 1 activity (no modifiers down)
							whichButton = BUTTON1;
						}

						// If the event is to press a button, then
						// record that that button is now down
						if ( event[i].getID( ) == MouseEvent.MOUSE_PRESSED )
							buttonPressed = whichButton;
					}
					else
					{
						// Otherwise a button was pressed earlier and
						// hasn't been released yet.  Assign all further
						// events to it, even if ALT, META, CTRL, or
						// another button has been pressed as well.
						whichButton = buttonPressed;
					}

					// Distribute the event
					switch( whichButton )
					{
					case BUTTON1:
						onButton1( mev );
						break;
					case BUTTON2:
						onButton2( mev );
						break;
					case BUTTON3:
						onButton3( mev );
						break;
					default:
						break;
					}

					// If the event is to release a button, then
					// record that that button is now up
					if ( event[i].getID( ) == MouseEvent.MOUSE_RELEASED )
						buttonPressed = BUTTONNONE;
				}
				continue;
			}

			if ( wakeup instanceof WakeupOnElapsedFrames )
			{
				onElapsedFrames( (WakeupOnElapsedFrames) wakeup );
				continue;
			}
		}

		// Reschedule us for another wakeup
		wakeupOn( mouseCriterion );
	}




	/**
	 * Default X and Y rotation factors, and XYZ translation factors.
	 */
	public static final double DEFAULT_XROTATION_FACTOR = 0.02;
	public static final double DEFAULT_YROTATION_FACTOR = 0.005;
	public static final double DEFAULT_XTRANSLATION_FACTOR = 0.02;
	public static final double DEFAULT_YTRANSLATION_FACTOR = 0.02;
	public static final double DEFAULT_ZTRANSLATION_FACTOR = 0.04;

	protected double XRotationFactor    = DEFAULT_XROTATION_FACTOR;
	protected double YRotationFactor    = DEFAULT_YROTATION_FACTOR;
	protected double XTranslationFactor = DEFAULT_XTRANSLATION_FACTOR;
	protected double YTranslationFactor = DEFAULT_YTRANSLATION_FACTOR;
	protected double ZTranslationFactor = DEFAULT_ZTRANSLATION_FACTOR;


	/**
	 * Set the X rotation scaling factor for X-axis rotations.
	 *
	 * @param factor The new scaling factor.
	 */
	public void setXRotationFactor( double factor )
	{
		XRotationFactor = factor;
	}

	/**
	 * Get the current X rotation scaling factor for X-axis rotations.
	 */
	public double getXRotationFactor( )
	{
		return XRotationFactor;
	}

	/**
	 * Set the Y rotation scaling factor for Y-axis rotations.
	 *
	 * @param factor The new scaling factor.
	 */
	public void setYRotationFactor( double factor )
	{
		YRotationFactor = factor;
	}

	/**
	 * Get the current Y rotation scaling factor for Y-axis rotations.
	 */
	public double getYRotationFactor( )
	{
		return YRotationFactor;
	}


	/**
	 * Set the X translation scaling factor for X-axis translations.
	 *
	 * @param factor The new scaling factor.
	 */
	public void setXTranslationFactor( double factor )
	{
		XTranslationFactor = factor;
	}

	/**
	 * Get the current X translation scaling factor for X-axis translations.
	 */
	public double getXTranslationFactor( )
	{
		return XTranslationFactor;
	}

	/**
	 * Set the Y translation scaling factor for Y-axis translations.
	 *
	 * @param factor The new scaling factor.
	 */
	public void setYTranslationFactor( double factor )
	{
		YTranslationFactor = factor;
	}

	/**
	 * Get the current Y translation scaling factor for Y-axis translations.
	 */
	public double getYTranslationFactor( )
	{
		return YTranslationFactor;
	}

	/**
	 * Set the Z translation scaling factor for Z-axis translations.
	 *
	 * @param factor The new scaling factor.
	 */
	public void setZTranslationFactor( double factor )
	{
		ZTranslationFactor = factor;
	}

	/**
	 * Get the current Z translation scaling factor for Z-axis translations.
	 */
	public double getZTranslationFactor( )
	{
		return ZTranslationFactor;
	}


	/**
	 * Respond to a button1 event (press, release, or drag).
	 *
	 * @param mouseEvent A MouseEvent to respond to.
	 */
	public abstract void onButton1( MouseEvent mouseEvent );


	/**
	 * Respond to a button2 event (press, release, or drag).
	 *
	 * @param mouseEvent A MouseEvent to respond to.
	 */
	public abstract void onButton2( MouseEvent mouseEvent );


	/**
	 * Responed to a button3 event (press, release, or drag).
	 *
	 * @param mouseEvent A MouseEvent to respond to.
	 */
	public abstract void onButton3( MouseEvent mouseEvent );


	/**
	 * Respond to an elapsed frames event (assuming subclass has set up a
	 * wakeup criterion for it).
	 *
	 * @param time A WakeupOnElapsedFrames criterion to respond to.
	 */
	public abstract void onElapsedFrames( WakeupOnElapsedFrames timeEvent );
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜臀精品一区二区三区在线观看| 国产精品久久久久久福利一牛影视 | 色悠久久久久综合欧美99| 国产一区二区三区在线看麻豆| 精品亚洲成av人在线观看| 免费成人av在线| 国内外成人在线视频| 精品无人码麻豆乱码1区2区| 国产精品影音先锋| 成人午夜视频在线观看| 99热在这里有精品免费| 色婷婷av一区| 制服丝袜在线91| 久久五月婷婷丁香社区| 中文字幕一区免费在线观看| 中文字幕一区二区三区蜜月| 一区2区3区在线看| 美女视频黄a大片欧美| 精品一二三四区| 成人app软件下载大全免费| 色综合天天性综合| 777午夜精品视频在线播放| 欧美一级片在线看| 亚洲国产精品成人综合| 青草国产精品久久久久久| 老司机免费视频一区二区| 国产精品自拍一区| 欧美专区在线观看一区| 日韩欧美一区二区视频| 国产精品区一区二区三| 亚洲综合色视频| 国产乱码精品一区二区三| 一本大道av伊人久久综合| 欧美一区二区久久| 中文字幕日韩欧美一区二区三区| 亚洲国产aⅴ天堂久久| 国产一区二区在线观看视频| 色噜噜狠狠成人中文综合| 精品日韩一区二区三区| 亚洲图片激情小说| 国产中文字幕精品| 3atv一区二区三区| 一区二区中文视频| 欧美不卡一区二区三区| 在线不卡一区二区| 中文字幕高清不卡| 日韩av中文在线观看| 不卡av免费在线观看| 日韩三区在线观看| 亚洲国产日韩综合久久精品| 国产激情视频一区二区在线观看 | 成人午夜电影小说| 这里是久久伊人| 一区二区三区毛片| 波多野结衣91| 国产午夜一区二区三区| 免费观看30秒视频久久| 欧美日韩午夜在线| 亚洲欧洲一区二区在线播放| 国产一区激情在线| 久久久久久久久伊人| 日本午夜一本久久久综合| 在线免费观看日本一区| 国产精品成人免费在线| 成人午夜在线播放| 久久久99精品久久| 国产在线精品一区在线观看麻豆| 91精品国产一区二区三区香蕉| 亚洲无线码一区二区三区| 97久久精品人人澡人人爽| 中文字幕欧美激情| 成人一区在线观看| 中文字幕精品一区二区三区精品| 国产麻豆一精品一av一免费 | 丰满放荡岳乱妇91ww| 久久久噜噜噜久久人人看 | 久久青草国产手机看片福利盒子| 亚洲观看高清完整版在线观看| 一本色道**综合亚洲精品蜜桃冫 | 在线观看欧美精品| 一个色综合av| 91精品在线麻豆| 麻豆视频观看网址久久| 精品少妇一区二区三区| 韩国在线一区二区| 国产午夜亚洲精品午夜鲁丝片 | 色综合咪咪久久| 一区二区日韩电影| 欧美久久高跟鞋激| 午夜精品福利视频网站| 日韩一区二区精品| 韩国av一区二区三区| 欧美激情综合五月色丁香小说| a级高清视频欧美日韩| 亚洲美女电影在线| 91精品国产综合久久精品| 国内成人免费视频| 亚洲天堂久久久久久久| 欧美日韩一区三区四区| 激情亚洲综合在线| 国产精品人人做人人爽人人添| 91精品91久久久中77777| 日韩福利视频网| 国产网站一区二区三区| 在线亚洲免费视频| 久久国产福利国产秒拍| 日韩美女啊v在线免费观看| 欧美日韩亚洲综合| 国产成人免费视频一区| 亚洲午夜免费电影| 久久综合久久综合亚洲| 色综合天天综合在线视频| 青娱乐精品视频| 亚洲色图视频网| 日韩欧美国产小视频| kk眼镜猥琐国模调教系列一区二区| 午夜日韩在线电影| 国产精品久久三| 精品少妇一区二区三区视频免付费 | 国产日本欧美一区二区| 欧美亚洲国产一区二区三区va| 国产一区二区在线电影| 亚洲国产综合视频在线观看| 久久先锋影音av鲁色资源网| 欧美亚洲国产bt| av午夜精品一区二区三区| 蜜桃视频在线观看一区| 亚洲国产综合91精品麻豆| 国产欧美一区二区精品性色| 538在线一区二区精品国产| 97国产一区二区| 丁香啪啪综合成人亚洲小说 | 久久综合九色欧美综合狠狠 | 欧美xfplay| 欧美日韩激情在线| 91丨九色丨蝌蚪富婆spa| www..com久久爱| 国产精品一区二区你懂的| 日本欧美一区二区在线观看| 亚洲乱码国产乱码精品精可以看 | 一本色道久久加勒比精品| 久久99国内精品| 蜜臀久久99精品久久久画质超高清 | 欧美日韩国产中文| 日本二三区不卡| 不卡一区在线观看| 不卡一区二区中文字幕| 国v精品久久久网| 国产高清亚洲一区| 国产成人综合在线播放| 精品一区二区三区不卡 | 国产亚洲欧美日韩日本| 日韩精品一区二区三区老鸭窝| 欧美日韩mp4| 日韩一级二级三级| 欧美一区二区三区在线看| 欧美一区二区在线不卡| 日韩午夜激情免费电影| 久久综合九色欧美综合狠狠| 久久久精品影视| 国产精品毛片久久久久久久| 亚洲色图在线视频| 亚洲在线视频免费观看| 亚洲第一激情av| 奇米影视在线99精品| 久久精品国产精品青草| 国产激情一区二区三区四区 | 精品日韩在线一区| 亚洲精品在线一区二区| 2014亚洲片线观看视频免费| 国产欧美一区二区精品性| 亚洲视频图片小说| 亚洲国产裸拍裸体视频在线观看乱了| 亚洲国产cao| 精品午夜久久福利影院| 成人av网址在线观看| 欧美性大战久久久久久久蜜臀| 欧美日韩小视频| 久久精品一区二区三区不卡牛牛| 国产精品久久久久久久久免费桃花 | 亚洲国产日韩在线一区模特| 日本美女视频一区二区| 成人精品电影在线观看| 欧美午夜不卡视频| 日韩精品一区二区三区在线观看 | 一区二区三区在线看| 麻豆一区二区三| 一本一本大道香蕉久在线精品 | 精品视频在线免费观看| 日韩无一区二区| 亚洲视频网在线直播| 久久99国产精品尤物| 欧洲精品一区二区| 久久人人超碰精品| 亚洲第一狼人社区| 成人激情黄色小说| 欧美成人三级在线| 亚洲成人av在线电影| 成人午夜av影视| 欧美成人综合网站|