📄 behavior.java
字号:
*/ public void setSchedulingBoundingLeaf(BoundingLeaf region) { ((BehaviorRetained)this.retained).setSchedulingBoundingLeaf(region); } /** * Retrieves the Behavior node's scheduling bounding leaf. * @return this Behavior's scheduling bounding leaf information */ public BoundingLeaf getSchedulingBoundingLeaf() { return ((BehaviorRetained)this.retained).getSchedulingBoundingLeaf(); } /** * Creates the retained mode BehaviorRetained object that this * Behavior object will point to. */ void createRetained() { this.retained = new BehaviorRetained(); this.retained.setSource(this); } /** * Defines this behavior's wakeup criteria. This method * may only be called from a Behavior object's initialize * or processStimulus methods to (re)arm the next wakeup. * It should be the last thing done by those methods. * @param criteria the wakeup criteria for this behavior * @exception IllegalStateException if this method is called by * a method <i>other than</i> initialize or processStimulus */ protected void wakeupOn(WakeupCondition criteria) { BehaviorRetained behavret = (BehaviorRetained) this.retained; synchronized (behavret) { if (!behavret.inCallback) { throw new IllegalStateException(J3dI18N.getString("Behavior0")); } } behavret.wakeupOn(criteria); } /** * Retrieves this behavior's current wakeup condition as set by * the wakeupOn method. If no wakeup condition is currently * active, null will be returned. In particular, this means that * null will be returned if Java 3D is executing this behavior's * processStimulus routine and wakeupOn has not yet been called to * re-arm the wakeup condition for next time. * * @return the current wakeup condition for this behavior * * @since Java 3D 1.3 */ protected WakeupCondition getWakeupCondition() { return ((BehaviorRetained)this.retained).getWakeupCondition(); } /** * Posts the specified postId to the Behavior Scheduler. All behaviors * that have registered WakeupOnBehaviorPost with this postId, or a postId * of 0, and with this behavior, or a null behavior, will have that wakeup * condition met. * <p> * This feature allows applications to send arbitrary events into the * behavior scheduler stream. It can be used as a notification scheme * for communicating events to behaviors in the system. * </p> * @param postId the Id being posted * * @see WakeupOnBehaviorPost */ public void postId(int postId){ ((BehaviorRetained)this.retained).postId(postId); } /** * Enables or disables this Behavior. The default state is enabled. * @param state true or false to enable or disable this Behavior */ public void setEnable(boolean state) { ((BehaviorRetained)this.retained).setEnable(state); } /** * Retrieves the state of the Behavior enable flag. * @return the Behavior enable state */ public boolean getEnable() { return ((BehaviorRetained)this.retained).getEnable(); } /** * Returns the number of scheduling intervals supported by this * implementation of Java 3D. The minimum number of supported * intervals must be at least 10. The default scheduling interval * for each behavior instance is set to * <code>numSchedulingIntervals / 2</code>. * * @return the number of supported scheduling intervals * * @since Java 3D 1.3 */ public static int getNumSchedulingIntervals() { return BehaviorRetained.NUM_SCHEDULING_INTERVALS; } /** * Sets the scheduling interval of this Behavior node to the * specified value. * * The scheduling interval 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. * * The default value is <code>numSchedulingIntervals / 2</code>. * * @param schedulingInterval the new scheduling interval * * @exception IllegalArgumentException if * <code>schedulingInterval</code> < 0 or * <code>schedulingInterval</code> >= * <code>numSchedulingIntervals</code> * * @since Java 3D 1.3 */ public void setSchedulingInterval(int schedulingInterval) { if (schedulingInterval < 0 || schedulingInterval >= getNumSchedulingIntervals()) { throw new IllegalStateException(J3dI18N.getString("Behavior1")); } ((BehaviorRetained)this.retained). setSchedulingInterval(schedulingInterval); } /** * Retrieves the current scheduling interval of this Behavior * node. * * @return the current scheduling interval * * @since Java 3D 1.3 */ public int getSchedulingInterval() { return ((BehaviorRetained)this.retained).getSchedulingInterval(); } /** * Returns the primary view associated with this behavior. This method * is useful with certain types of behaviors (e.g., Billboard, LOD) that * rely on per-View information and with behaviors in general in regards * to scheduling (the distance from the view platform determines the * active behaviors). The "primary" view is defined to be the first * View attached to a live ViewPlatform, if there is more than one active * View. So, for instance, Billboard behaviors would be oriented toward * this primary view, in the case of multiple active views into the same * scene graph. */ protected View getView() { return ((BehaviorRetained)this.retained).getView(); } /** * Copies all Behavior information from * <code>originalNode</code> into * the current node. This method is called from the * <code>cloneNode</code> method which is, in turn, called by the * <code>cloneTree</code> method.<P> * * @param originalNode the original node to duplicate * @param forceDuplicate when set to <code>true</code>, causes the * <code>duplicateOnCloneTree</code> flag to be ignored. When * <code>false</code>, the value of each node's * <code>duplicateOnCloneTree</code> variable determines whether * NodeComponent data is duplicated or copied. * * @exception RestrictedAccessException if this object is part of a live * or compiled scenegraph. * * @see Node#duplicateNode * @see Node#cloneTree * @see NodeComponent#setDuplicateOnCloneTree */ void duplicateAttributes(Node originalNode, boolean forceDuplicate) { super.duplicateAttributes(originalNode, forceDuplicate); BehaviorRetained attr = (BehaviorRetained) originalNode.retained; BehaviorRetained rt = (BehaviorRetained) retained; rt.setEnable(attr.getEnable()); rt.setSchedulingBounds(attr.getSchedulingBounds()); rt.setSchedulingInterval(attr.getSchedulingInterval()); // will set to the correct one in updateNodeReferences rt.setSchedulingBoundingLeaf(attr.getSchedulingBoundingLeaf()); } /** * Callback used to allow a node to check if any scene graph objects * referenced * by that node have been duplicated via a call to <code>cloneTree</code>. * This method is called by <code>cloneTree</code> after all nodes in * the sub-graph have been duplicated. The cloned Leaf node's method * will be called and the Leaf node can then look up any object references * by using the <code>getNewObjectReference</code> method found in the * <code>NodeReferenceTable</code> object. If a match is found, a * reference to the corresponding object in the newly cloned sub-graph * is returned. If no corresponding reference is found, either a * DanglingReferenceException is thrown or a reference to the original * object is returned depending on the value of the * <code>allowDanglingReferences</code> parameter passed in the * <code>cloneTree</code> call. * <p> * NOTE: Applications should <i>not</i> call this method directly. * It should only be called by the cloneTree method. * * @param referenceTable a NodeReferenceTableObject that contains the * <code>getNewObjectReference</code> method needed to search for * new object instances. * * @see NodeReferenceTable * @see Node#cloneTree * @see DanglingReferenceException */ public void updateNodeReferences(NodeReferenceTable referenceTable) { super.updateNodeReferences(referenceTable); BehaviorRetained rt = (BehaviorRetained) retained; BoundingLeaf bl= rt.getSchedulingBoundingLeaf(); // check for schedulingBoundingLeaf if (bl != null) { Object o = referenceTable.getNewObjectReference(bl); rt.setSchedulingBoundingLeaf((BoundingLeaf) o); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -