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

📄 soundretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * devices associated with a given view.     * @param viewRef view to test sound playing silently state for     * @return number of channels used by this sound on a particular device     */    int getNumberOfChannelsUsed(View viewRef)  {       // retrieves the number of channels used by the atom that is:       //     loaded, and       //     playing either audibily or silently        // on the device associated with the given view.       if (viewRef == null)           return 0;       SoundSchedulerAtom atom;       for (int i=0; i<atomCount; i++) {            atom = loadedAtoms[i];            if (atom == null || atom.soundScheduler == null)               continue;           if (atom.soundScheduler.view == viewRef) {                   return atom.numberChannels;           }       }          return 0; // atom associated with primary view not found    }    /**     * Set mute state flag.  If the sound is playing it will be set to     * play silently     * @param state flag     * @since Java 3D 1.3     */    void setMute(boolean state) {        this.mute = state;        dispatchAttribChange(MUTE_DIRTY_BIT, (state ? Boolean.TRUE: Boolean.FALSE));                 if (source != null && source.isLive()) {            notifySceneGraphChanged(false);        }    }             /**       * Retrieves sound Mute state.     * A return value of true does not imply that the sound has       * been started playing or is still playing silently.      * @return mute state flag     * @since Java 3D 1.3     */      boolean getMute() {        return (boolean) this.mute;    }     /**     * Set pause state flag.  If the sound is playing it will be paused     * @param state flag     * @since Java 3D 1.3     */    void setPause(boolean state) {        this.pause = state;        dispatchAttribChange(PAUSE_DIRTY_BIT, (state ? Boolean.TRUE: Boolean.FALSE));                 if (source != null && source.isLive()) {            notifySceneGraphChanged(false);        }    }             /**       * Retrieves sound Pause state.     * A return value of true does not imply that the sound has       * been started playing auditibly or silently.     * @return mute state flag     * @since Java 3D 1.3     */      boolean getPause() {        return (boolean) this.pause;    }    /**     * This sets the immedate mode context flag     */      void setInImmCtx(boolean inCtx) {        inImmCtx = inCtx;    }    /**     * This gets the immedate mode context flag     */      boolean getInImmCtx() {        return (inImmCtx);    }    /**     * This gets the mirror sound for this sound given the key.     */    SoundRetained getMirrorSound(HashKey key) {	int i;	SoundRetained[] newSounds;	if (inSharedGroup) {	    for (i=0; i<numMirrorSounds; i++) {		if (mirrorSounds[i].key.equals(key)) {		    return(mirrorSounds[i]);		}	    }	    if (numMirrorSounds == mirrorSounds.length) {		newSounds = new SoundRetained[numMirrorSounds*2];		for (i=0; i<numMirrorSounds; i++) {		    newSounds[i] = mirrorSounds[i];		}		mirrorSounds = newSounds;	    } 	    //	    mirrorSounds[numMirrorSounds] = (SoundRetained) this.clone();	    mirrorSounds[numMirrorSounds] = (SoundRetained) this.clone();	    	    //mirrorSounds[numMirrorSounds].key = new HashKey(key);	    mirrorSounds[numMirrorSounds].key = key;	    mirrorSounds[numMirrorSounds].sgSound = this;	    return(mirrorSounds[numMirrorSounds++]);	} else {	    if (mirrorSounds[0] == null) {	      //  mirrorSounds[0] = (SoundRetained) this.clone(true);		mirrorSounds[0] = (SoundRetained) this.clone();		mirrorSounds[0].sgSound = this;	    }	    return(mirrorSounds[0]);	}    }    synchronized void initMirrorObject(SoundRetained ms) {        GroupRetained group;        Transform3D trans;        Bounds region = null;        ms.setSchedulingBounds(getSchedulingBounds());        ms.setSchedulingBoundingLeaf(getSchedulingBoundingLeaf());        ms.sgSound = sgSound;/*// QUESTION: these are not set in LightRetained???        ms.key = null;        ms.mirrorSounds = new SoundRetained[1];        ms.numMirrorSounds = 0;*/        ms.inImmCtx = inImmCtx;        ms.setSoundData(getSoundData());// XXXX: copy ms.atoms array from this.atoms        ms.parent = parent;        ms.inSharedGroup = false;        ms.locale = locale;        ms.parent = parent;        ms.localBounds = (Bounds)localBounds.clone();        ms.transformedRegion = null;        if (boundingLeaf != null) {            if (ms.boundingLeaf != null)                ms.boundingLeaf.removeUser(ms);            ms.boundingLeaf = boundingLeaf.mirrorBoundingLeaf;            // Add this mirror object as user            ms.boundingLeaf.addUser(ms);            ms.transformedRegion = ms.boundingLeaf.transformedRegion;        }        else {            ms.boundingLeaf = null;        }         if (schedulingRegion != null) {            ms.schedulingRegion = (Bounds) schedulingRegion.clone();            // Assign region only if bounding leaf is null            if (ms.transformedRegion == null) {                ms.transformedRegion = (Bounds) ms.schedulingRegion.clone();                ms.transformedRegion.transform(ms.schedulingRegion,                                    ms.getLastLocalToVworld());            }                         }        else {            ms.schedulingRegion = null;        }    }    void setLive(SetLiveState s) {        SoundRetained ms;        int i, j;        if (debugFlag)            debugPrint("Sound.setLive");		if (inImmCtx) {            throw new                IllegalSharingException(J3dI18N.getString("SoundRetained2"));        }        super.setLive(s);        if (inBackgroundGroup) {             throw new                IllegalSceneGraphException(J3dI18N.getString("SoundRetained3"));        }        if (this.loadStatus == LOAD_PENDING) {            if (debugFlag)                debugPrint("Sound.setLive load Sound");            dispatchStateChange(LOAD_SOUND_DIRTY_BIT, soundData);        }	if (this.soundData != null) {	    ((MediaContainerRetained)this.soundData.retained).setLive(inBackgroundGroup, s.refCount);	}        if (s.inSharedGroup) {            for (i=0; i<s.keys.length; i++) {                ms = this.getMirrorSound(s.keys[i]);                ms.localToVworld = new Transform3D[1][];                ms.localToVworldIndex = new int[1][];				j = s.keys[i].equals(localToVworldKeys, 0,				     localToVworldKeys.length);		if(j < 0) {		    System.err.println("SoundRetained : Can't find hashKey"); 		}                ms.localToVworld[0] = localToVworld[j];                ms.localToVworldIndex[0] = localToVworldIndex[j];		// If its view Scoped, then add this list		// to be sent to Sound Structure		if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {		    s.viewScopedNodeList.add(ms);		    s.scopedNodesViewList.add(s.viewLists.get(i));		} else {		    s.nodeList.add(ms);		}                // Initialization of the mirror object during the INSERT_NODE                // message (in updateMirrorObject)                if (s.switchTargets != null && s.switchTargets[i] != null) {                    s.switchTargets[i].addNode(ms, Targets.SND_TARGETS);                }                ms.switchState = (SwitchState)s.switchStates.get(j);                if (s.transformTargets != null &&		    s.transformTargets[i] != null) {                    s.transformTargets[i].addNode(ms, Targets.SND_TARGETS);		    s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;                }            }        } else {            ms = this.getMirrorSound(null);            ms.localToVworld = new Transform3D[1][];            ms.localToVworldIndex = new int[1][];            ms.localToVworld[0] = this.localToVworld[0];            ms.localToVworldIndex[0] = this.localToVworldIndex[0];	    // If its view Scoped, then add this list	    // to be sent to Sound Structure	    if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {		s.viewScopedNodeList.add(ms);		s.scopedNodesViewList.add(s.viewLists.get(0));	    } else {		s.nodeList.add(ms);	    }	    // Initialization of the mirror object during the INSERT_NODE            // message (in updateMirrorObject)            if (s.switchTargets != null && s.switchTargets[0] != null) {                s.switchTargets[0].addNode(ms, Targets.SND_TARGETS);            }            ms.switchState = (SwitchState)s.switchStates.get(0);            if (s.transformTargets != null &&		s.transformTargets[0] != null) {                s.transformTargets[0].addNode(ms, Targets.SND_TARGETS);		s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;	    }        }        dispatchStateChange(LIVE_DIRTY_BIT, soundData);        s.notifyThreads |= targetThreads;    }    void clearLive(SetLiveState s) {	SoundRetained ms;	super.clearLive(s);// XXXX: if (inSharedGroup)        if (s.inSharedGroup) {            for (int i=0; i<s.keys.length; i++) {                ms = this.getMirrorSound(s.keys[i]);                if (s.switchTargets != null &&		    s.switchTargets[i] != null) {                    s.switchTargets[i].addNode(ms, Targets.SND_TARGETS);                }                if (s.transformTargets != null && s.transformTargets[i] != null) {                    s.transformTargets[i].addNode(ms, Targets.SND_TARGETS);		    s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;		}		// If its view Scoped, then add this list		// to be sent to Sound Structure		if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {		    s.viewScopedNodeList.add(ms);		    s.scopedNodesViewList.add(s.viewLists.get(i));		} else {		    s.nodeList.add(ms);		}            }        } else {            ms = this.getMirrorSound(null);            if (s.switchTargets != null &&                        s.switchTargets[0] != null) {                s.switchTargets[0].addNode(ms, Targets.SND_TARGETS);            }            if (s.transformTargets != null &&		s.transformTargets[0] != null) {                s.transformTargets[0].addNode(ms, Targets.SND_TARGETS);		s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;            }	    // If its view Scoped, then add this list	    // to be sent to Sound Structure	    if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {		s.viewScopedNodeList.add(ms);		s.scopedNodesViewList.add(s.viewLists.get(0));	    } else {		s.nodeList.add(ms);	    }	}        s.notifyThreads |= targetThreads;	if (this.soundData != null) {	    ((MediaContainerRetained)this.soundData.retained).clearLive(s.refCount);	}    }    void mergeTransform(TransformGroupRetained xform) {        super.mergeTransform(xform);        if (schedulingRegion != null) {            schedulingRegion.transform(xform.transform);        }    }/*    // This makes passed in sound look just like this sound// QUESTION: DOesn't appread to be called// XXXX:      ...if so, remove...    synchronized void update(SoundRetained sound) {        if (debugFlag)            debugPrint("Sound.update ******** entered ***** this = " + this +                 ", and sound param = " + sound);        sound.soundData = soundData;        sound.initialGain = initialGain;        sound.loopCount = loopCount;        sound.release = release;        sound.continuous = continuous;        sound.enable = enable;  // used to be 'on'        sound.inImmCtx = inImmCtx;// QUESTION://     This line removed from 1.1.1 version; why ???        sound.currentSwitchOn = currentSwitchOn;// NEW:        sound.priority = priority;// QUESTION: With code below, no sound schedulingRegion found//        sound.schedulingRegion = schedulingRegion;//        sound.boundingLeaf = boundingLeaf;// XXXX: clone of region used in Traverse code, why not here???//        if (schedulingRegion != null)//            sound.schedulingRegion = (Bounds)schedulingRegion.clone();// XXXX:  BoundingLeafRetained boundingLeaf ...//        WHAT ABOUT transformedRegion??// XXXX: Update ALL fields// ALL THE BELOW USED TO COMMENTED OUT vvvvvvvvvvvvvvvvvvvvvvvvvvvvv        sound.sampleLength = sampleLength;        sound.loopStartOffset = loopStartOffset;        sound.loopLength = loopLength;        sound.attackLength = attackLength;        sound.releaseLength = releaseLength;        sound.sgSound = sgSound;        sound.key = key;        sound.numMirrorSounds = numMirrorSounds;        for (int index=0; index<numMirrorSounds; index++)              sound.mirrorSounds = mirrorSounds;        sound.universe = universe;        if (universe.sounds.contains(sound) == false) {             universe.sounds.addElement(sound);        }        if (debugFlag)            debugPrint("update****************************** exited");^^^^^^^^^^^ COMMENTED OUT    }*/    // Called on mirror object// QUESTION: doesn't transformed region need to be saved???    void updateTransformChange() {        // If bounding leaf is null, tranform the bounds object        if (debugFlag)            debugPrint("SoundRetained.updateTransformChange()");        if (boundingLeaf == null) {            if (schedulingRegion != null) {                transformedRegion = schedulingRegion.copy(transformedRegion);                transformedRegion.transform(schedulingRegion,						getLastLocalToVworld());            }        }        dispatchStateChange(XFORM_DIRTY_BIT, null);    }    // QUESTION://     Clone method (from 1.1.1 version) removed!?!?!? yet LightRetained has it    // Debug print mechanism for Sound nodes    static final boolean debugFlag = false;    static final boolean internalErrors = false;    void debugPrint(String message) {        if (debugFlag) {            System.err.println(message);	}    }    void getMirrorObjects(ArrayList leafList, HashKey key) {	if (key == null) {	    leafList.add(mirrorSounds[0]);	}	else {	    for (int i=0; i<numMirrorSounds; i++) {		if (mirrorSounds[i].key.equals(key)) {		    leafList.add(mirrorSounds[i]);		    break;		}	    }	    	}    }    }

⌨️ 快捷键说明

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