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

📄 behavior.html

📁 JAVA多媒体开发类库说明
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_06) on Wed Dec 13 16:19:59 PST 2006 --><TITLE>Behavior (Java 3D 1.5.0)</TITLE><META NAME="keywords" CONTENT="javax.media.j3d.Behavior class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="Behavior (Java 3D 1.5.0)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../../javax/media/j3d/BadTransformException.html" title="class in javax.media.j3d"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../../javax/media/j3d/Billboard.html" title="class in javax.media.j3d"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../index.html?javax/media/j3d/Behavior.html" target="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="Behavior.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#fields_inherited_from_class_javax.media.j3d.Node">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.media.j3d</FONT><BR>Class Behavior</H2><PRE>java.lang.Object  <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><A HREF="../../../javax/media/j3d/SceneGraphObject.html" title="class in javax.media.j3d">javax.media.j3d.SceneGraphObject</A>      <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><A HREF="../../../javax/media/j3d/Node.html" title="class in javax.media.j3d">javax.media.j3d.Node</A>          <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><A HREF="../../../javax/media/j3d/Leaf.html" title="class in javax.media.j3d">javax.media.j3d.Leaf</A>              <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>javax.media.j3d.Behavior</B></PRE><DL><DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../javax/media/j3d/Billboard.html" title="class in javax.media.j3d">Billboard</A>, <A HREF="../../../javax/media/j3d/Interpolator.html" title="class in javax.media.j3d">Interpolator</A>, <A HREF="../../../com/sun/j3d/utils/behaviors/keyboard/KeyNavigatorBehavior.html" title="class in com.sun.j3d.utils.behaviors.keyboard">KeyNavigatorBehavior</A>, <A HREF="../../../javax/media/j3d/LOD.html" title="class in javax.media.j3d">LOD</A>, <A HREF="../../../com/sun/j3d/utils/behaviors/sensor/Mouse6DPointerBehavior.html" title="class in com.sun.j3d.utils.behaviors.sensor">Mouse6DPointerBehavior</A>, <A HREF="../../../com/sun/j3d/utils/behaviors/mouse/MouseBehavior.html" title="class in com.sun.j3d.utils.behaviors.mouse">MouseBehavior</A>, <A HREF="../../../com/sun/j3d/utils/behaviors/picking/PickMouseBehavior.html" title="class in com.sun.j3d.utils.behaviors.picking">PickMouseBehavior</A>, <A HREF="../../../com/sun/j3d/utils/pickfast/behaviors/PickMouseBehavior.html" title="class in com.sun.j3d.utils.pickfast.behaviors">PickMouseBehavior</A>, <A HREF="../../../com/sun/j3d/utils/picking/behaviors/PickMouseBehavior.html" title="class in com.sun.j3d.utils.picking.behaviors">PickMouseBehavior</A>, <A HREF="../../../com/sun/j3d/utils/scenegraph/io/UnresolvedBehavior.html" title="class in com.sun.j3d.utils.scenegraph.io">UnresolvedBehavior</A>, <A HREF="../../../com/sun/j3d/utils/behaviors/vp/ViewPlatformBehavior.html" title="class in com.sun.j3d.utils.behaviors.vp">ViewPlatformBehavior</A></DD></DL><HR><DL><DT><PRE>public abstract class <B>Behavior</B><DT>extends <A HREF="../../../javax/media/j3d/Leaf.html" title="class in javax.media.j3d">Leaf</A></DL></PRE><P>The Behavior leaf node provides a framework for adding user-defined actions into the scene graph.  Behavior is an abstract class that defines two methods that must be overridden by a subclass: An <code>initialization</code> method, called once when the behavior becomes "live," and a <code>processStimulus</code> method called whenever appropriate by the Java 3D behavior scheduler. The Behavior node also contains an enable flag, a scheduling region, a scheduling interval, and a wakeup condition. <P> The <i>scheduling region</i> defines a spatial volume that serves to enable the scheduling of Behavior nodes. A Behavior node is <i>active</i> (can receive stimuli) whenever an active ViewPlatform's activation volume intersects a Behavior object's scheduling region. Only active behaviors can receive stimuli. <P> The <i>scheduling interval</i> defines a partial order of execution for behaviors that wake up in response to the same wakeup condition (that is, those behaviors that are processed at the same "time"). Given a set of behaviors whose wakeup conditions are satisfied at the same time, the behavior scheduler will execute all behaviors in a lower scheduling interval before executing any behavior in a higher scheduling interval.  Within a scheduling interval, behaviors can be executed in any order, or in parallel.  Note that this partial ordering is only guaranteed for those behaviors that wake up at the same time in response to the same wakeup condition, for example, the set of behaviors that wake up every frame in response to a WakeupOnElapsedFrames(0) wakeup condition. <P> The <code>initialize</code> method allows a Behavior object to initialize its internal state and specify its initial wakeup condition(s). Java 3D invokes a behavior's initialize code when the behavior's containing BranchGroup node is added to the virtual universe. Java 3D does not invoke the initialize method in a new thread.  Thus, for Java 3D to regain control, the initialize method must not execute an infinite loop; it must return. Furthermore, a wakeup condition must be set or else the behavior's processStimulus method is never executed. <P> The <code>processStimulus</code> method receives and processes a behavior's ongoing messages. The Java 3D behavior scheduler invokes a Behavior node's processStimulus method when an active ViewPlatform's activation volume intersects a Behavior object's scheduling region and all of that behavior's wakeup criteria are satisfied. The processStimulus method performs its computations and actions (possibly including the registration of state change information that could cause Java 3D to wake other Behavior objects), establishes its next wakeup condition, and finally exits. A typical behavior will modify one or more nodes or node components in the scene graph.  These modifications can happen in parallel with rendering.  In general, applications cannot count on behavior execution being synchronized with rendering.  There are two exceptions to this general rule: <ol> <li>All modifications to scene graph objects (not including geometry by-reference or texture by-reference) made from the <code>processStimulus</code> method of a single behavior instance are guaranteed to take effect in the same rendering frame.</li> <li>All modifications to scene graph objects (not including geometry by-reference or texture by-reference) made from the <code>processStimulus</code> methods of the set of behaviors that wake up in response to a WakeupOnElapsedFrames(0) wakeup condition are guaranteed to take effect in the same rendering frame.</li> </ol> Note that modifications to geometry by-reference or texture by-reference are not guaranteed to show up in the same frame as other scene graph changes. <P> <b>Code Structure</b> <P> When the Java 3D behavior scheduler invokes a Behavior object's processStimulus method, that method may perform any computation it wishes.  Usually, it will change its internal state and specify its new wakeup conditions.  Most probably, it will manipulate scene graph elements. However, the behavior code can only change those aspects of a scene graph element permitted by the capabilities associated with that scene graph element. A scene graph's capabilities restrict behavioral manipulation to those manipulations explicitly allowed. <P> The application must provide the Behavior object with references to those scene graph elements that the Behavior object will manipulate. The application provides those references as arguments to the behavior's constructor when it creates the Behavior object. Alternatively, the Behavior object itself can obtain access to the relevant scene graph elements either when Java 3D invokes its initialize method or each time Java 3D invokes its processStimulus method. <P> Behavior methods have a very rigid structure. Java 3D assumes that they always run to completion (if needed, they can spawn threads). Each method's basic structure consists of the following: <P> <UL> <LI>Code to decode and extract references from the WakeupCondition enumeration that caused the object's awakening.</LI> <LI>Code to perform the manipulations associated with the WakeupCondition</LI> <LI>Code to establish this behavior's new WakeupCondition</LI> <LI>A path to Exit (so that execution returns to the Java 3D behavior scheduler)</LI> </UL> <P> <b>WakeupCondition Object</b> <P> A WakeupCondition object is an abstract class specialized to fourteen different WakeupCriterion objects and to four combining objects containing multiple WakeupCriterion objects.  A Behavior node provides the Java 3D behavior scheduler with a WakeupCondition object. When that object's WakeupCondition has been satisfied, the behavior scheduler hands that same WakeupCondition back to the Behavior via an enumeration. <P> <b>WakeupCriterion Object</b> <P> Java 3D provides a rich set of wakeup criteria that Behavior objects can use in specifying a complex WakeupCondition. These wakeup criteria can cause Java 3D's behavior scheduler to invoke a behavior's processStimulus method whenever <UL> <LI>The center of a ViewPlatform enters a specified region</LI> <LI>The center of a ViewPlatform exits a specified region</LI> <LI>A behavior is activated</LI> <LI>A behavior is deactivated</LI> <LI>A specified TransformGroup node's transform changes</LI> <LI>Collision is detected between a specified Shape3D node's Geometry object and any other object</LI> <LI>Movement occurs between a specified Shape3D node's Geometry object and any other object with which it collides</LI> <LI>A specified Shape3D node's Geometry object no longer collides with any other object</LI> <LI>A specified Behavior object posts a specific event</LI> <LI>A specified AWT event occurs</LI> <LI>A specified time interval elapses</LI> <LI>A specified number of frames have been drawn</LI> <LI>The center of a specified Sensor enters a specified region</LI> <LI>The center of a specified Sensor exits a specified region</LI> </UL> <p> A Behavior object constructs a WakeupCriterion by constructing the appropriate criterion object. The Behavior object must provide the appropriate arguments (usually a reference to some scene graph object and possibly a region of interest). Thus, to specify a WakeupOnViewPlatformEntry, a behavior would specify the region that will cause the behavior to execute if an active ViewPlatform enters it. <p> Note that a unique WakeupCriterion object must be used with each instance of a Behavior. Sharing wakeup criteria among different instances of a Behavior is illegal. <p> <b>Additional Information</b> <p> For more information, see the <a href="doc-files/intro.html">Introduction to the Java 3D API</a> and <a href="doc-files/Behaviors.html">Behaviors and Interpolators</a> documents.<P><P><DL><DT><B>See Also:</B><DD><A HREF="../../../javax/media/j3d/WakeupCondition.html" title="class in javax.media.j3d"><CODE>WakeupCondition</CODE></A></DL><HR><P><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Field Summary</B></FONT></TH></TR></TABLE>&nbsp;<A NAME="fields_inherited_from_class_javax.media.j3d.Node"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TH ALIGN="left"><B>Fields inherited from class javax.media.j3d.<A HREF="../../../javax/media/j3d/Node.html" title="class in javax.media.j3d">Node</A></B></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../javax/media/j3d/Node.html#ALLOW_AUTO_COMPUTE_BOUNDS_READ">ALLOW_AUTO_COMPUTE_BOUNDS_READ</A>, <A HREF="../../../javax/media/j3d/Node.html#ALLOW_AUTO_COMPUTE_BOUNDS_WRITE">ALLOW_AUTO_COMPUTE_BOUNDS_WRITE</A>, <A HREF="../../../javax/media/j3d/Node.html#ALLOW_BOUNDS_READ">ALLOW_BOUNDS_READ</A>, <A HREF="../../../javax/media/j3d/Node.html#ALLOW_BOUNDS_WRITE">ALLOW_BOUNDS_WRITE</A>, <A HREF="../../../javax/media/j3d/Node.html#ALLOW_COLLIDABLE_READ">ALLOW_COLLIDABLE_READ</A>, <A HREF="../../../javax/media/j3d/Node.html#ALLOW_COLLIDABLE_WRITE">ALLOW_COLLIDABLE_WRITE</A>, <A HREF="../../../javax/media/j3d/Node.html#ALLOW_LOCAL_TO_VWORLD_READ">ALLOW_LOCAL_TO_VWORLD_READ</A>, <A HREF="../../../javax/media/j3d/Node.html#ALLOW_LOCALE_READ">ALLOW_LOCALE_READ</A>, <A HREF="../../../javax/media/j3d/Node.html#ALLOW_PARENT_READ">ALLOW_PARENT_READ</A>, <A HREF="../../../javax/media/j3d/Node.html#ALLOW_PICKABLE_READ">ALLOW_PICKABLE_READ</A>, <A HREF="../../../javax/media/j3d/Node.html#ALLOW_PICKABLE_WRITE">ALLOW_PICKABLE_WRITE</A>, <A HREF="../../../javax/media/j3d/Node.html#ENABLE_COLLISION_REPORTING">ENABLE_COLLISION_REPORTING</A>, <A HREF="../../../javax/media/j3d/Node.html#ENABLE_PICK_REPORTING">ENABLE_PICK_REPORTING</A></CODE></TD></TR></TABLE>&nbsp;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -