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

📄 pointsound.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        ((PointSoundRetained)this.retained).setDistanceGain(                        attenuationDistance, attenuationGain);    }       /**     * Construct a PointSound object accepting individual float parameters for      * the elements of the position points, and accepting separate arrays for      * the distance and gain scale factors components of distance attenuation.      * @param soundData sound data associated with this sound source node     * @param initialGain amplitude scale factor applied to sound source     * @param loopCount number of times loop is looped     * @param release flag denoting playing sound to end     * @param continuous denotes that sound silently plays when disabled     * @param enable sound switched on/off     * @param region scheduling bounds     * @param priority playback ranking value     * @param posX x coordinate of location of source     * @param posY y coordinate of location of source     * @param posZ z coordinate of location of source     * @param attenuationDistance array of distance values used for attenuation     * @param attenuationGain array of gain scale factors used for attenuation     */      public PointSound(MediaContainer soundData,                      float initialGain,                      int loopCount,                      boolean release,                      boolean continuous,                      boolean enable,                      Bounds  region,                      float   priority,                      float posX, float posY, float posZ,                       float[] attenuationDistance,                      float[] attenuationGain) {        super(soundData, initialGain, loopCount, release,              continuous, enable, region, priority );        // set default read capabilities        setDefaultReadCapabilities(readCapabilities);        ((PointSoundRetained)this.retained).setPosition(posX,posY,posZ);        ((PointSoundRetained)this.retained).setDistanceGain(                        attenuationDistance, attenuationGain);    }       /**     * Creates the retained mode PointSoundRetained object that this     * PointSound object will point to.     */    void createRetained() {	this.retained = new PointSoundRetained();	this.retained.setSource(this);    }    /**     * Sets this sound's location from the vector provided.     * @param position the new location     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public void setPosition(Point3f position) {        if (isLiveOrCompiled())            if(!this.getCapability(ALLOW_POSITION_WRITE))                throw new CapabilityNotSetException(J3dI18N.getString("PointSound0"));          ((PointSoundRetained)this.retained).setPosition(position);    }    /**     * Sets this sound's position from the three values provided.     * @param x the new x position     * @param y the new y position     * @param z the new z position     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public void setPosition(float x, float y, float z) {        if (isLiveOrCompiled())            if(!this.getCapability(ALLOW_POSITION_WRITE))                throw new CapabilityNotSetException(J3dI18N.getString("PointSound0"));          ((PointSoundRetained)this.retained).setPosition(x,y,z);    }    /**     * Retrieves this sound's direction and places it in the     * vector provided.     * @param position the variable to receive the direction vector     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public void getPosition(Point3f position) {        if (isLiveOrCompiled())            if(!this.getCapability(ALLOW_POSITION_READ))                throw new CapabilityNotSetException(J3dI18N.getString("PointSound2"));          ((PointSoundRetained)this.retained).getPosition(position);    }    /**     * Sets this sound's distance gain attenuation - where gain scale factor     * is applied to sound based on distance listener is from sound source.     * This form of setDistanceGain takes these pairs of values as an array of     * Point2f.      * @param attenuation defined by pairs of (distance,gain-scale-factor)     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */      public void setDistanceGain(Point2f[] attenuation) {        if (isLiveOrCompiled())            if(!this.getCapability(ALLOW_DISTANCE_GAIN_WRITE))                throw new CapabilityNotSetException(J3dI18N.getString("PointSound3"));          ((PointSoundRetained)this.retained).setDistanceGain(attenuation);    }    /**     * Sets this sound's distance gain attenuation as an array of Point2fs.     * This form of setDistanceGain accepts two separate arrays for these values.     * The distance and gainScale arrays should be of the same length. If the      * gainScale array length is greater than the distance array length, the      * gainScale array elements beyond the length of the distance array are      * ignored. If the gainScale array is shorter than the distance array, the     * last gainScale array value is repeated to fill an array of length equal     * to distance array.     * @param distance array of monotonically-increasing floats     * @param gain array of non-negative scale factors     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */      public void setDistanceGain(float[] distance, float[] gain) {        if (isLiveOrCompiled())            if(!this.getCapability(ALLOW_DISTANCE_GAIN_WRITE))                throw new CapabilityNotSetException(J3dI18N.getString("PointSound3"));          ((PointSoundRetained)this.retained).setDistanceGain(distance, gain);    }    /**     * Get the length of this node's distance gain attenuation arrays.     * @return distance gain attenuation array length     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */      public int getDistanceGainLength() {        if (isLiveOrCompiled())            if(!this.getCapability(ALLOW_DISTANCE_GAIN_READ))                throw new CapabilityNotSetException(J3dI18N.getString("PointSound4"));        return (((PointSoundRetained)this.retained).getDistanceGainLength());    }    /**     * Gets this sound's distance attenuation. The distance attenuation     * pairs are copied into the specified array.     * The array must be large enough to hold all of the points.      * The individual array elements must be allocated by the caller.     * @param attenuation arrays containing distance attenuation pairs     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */     public void getDistanceGain(Point2f[] attenuation) {         if (isLiveOrCompiled())            if(!this.getCapability(ALLOW_DISTANCE_GAIN_READ))                throw new CapabilityNotSetException(J3dI18N.getString("PointSound4"));          ((PointSoundRetained)this.retained).getDistanceGain(attenuation);    }    /**     * Gets this sound's distance gain attenuation values in separate arrays.     * The arrays must be large enough to hold all of the values.     * @param distance array of float distance from sound source     * @param gain array of non-negative scale factors associated with      * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */     public void getDistanceGain(float[] distance, float[] gain) {         if (isLiveOrCompiled())        if(!this.getCapability(ALLOW_DISTANCE_GAIN_READ))            throw new CapabilityNotSetException(J3dI18N.getString("PointSound4"));              ((PointSoundRetained)this.retained).getDistanceGain(distance,gain);    }    /**     * Creates a new instance of the node.  This routine is called     * by <code>cloneTree</code> to duplicate the current node.     * @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.     *     * @see Node#cloneTree     * @see Node#cloneNode     * @see Node#duplicateNode     * @see NodeComponent#setDuplicateOnCloneTree     */    public Node cloneNode(boolean forceDuplicate) {        PointSound p = new PointSound();        p.duplicateNode(this, forceDuplicate);        return p;    }    /**     * Copies all node 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>     * For any <code>NodeComponent</code> objects     * contained by the object being duplicated, each <code>NodeComponent</code>     * object's <code>duplicateOnCloneTree</code> value is used to determine     * whether the <code>NodeComponent</code> should be duplicated in the new node     * or if just a reference to the current node should be placed in the     * new node.  This flag can be overridden by setting the     * <code>forceDuplicate</code> parameter in the <code>cloneTree</code>     * method to <code>true</code>.     * <br>     * NOTE: Applications should <i>not</i> call this method directly.     * It should only be called by the cloneNode method.     *     * @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 ClassCastException if originalNode is not an instance of      *  <code>PointSound</code>     *     * @see Node#cloneTree     * @see Node#cloneNode     * @see NodeComponent#setDuplicateOnCloneTree     */    public void duplicateNode(Node originalNode, boolean forceDuplicate) {	checkDuplicateNode(originalNode, forceDuplicate);	    }   /**     * Copies all PointSound 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);	PointSoundRetained orgRetained = (PointSoundRetained)originalNode.retained;	PointSoundRetained thisRetained = (PointSoundRetained)this.retained;	Point3f p = new Point3f();	orgRetained.getPosition(p);	thisRetained.setPosition(p);	int len = orgRetained.getDistanceGainLength();	float distance[] = new float[len];	float gain[] = new float[len];	orgRetained.getDistanceGain(distance, gain);	thisRetained.setDistanceGain(distance, gain);    }   }

⌨️ 快捷键说明

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