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

📄 sensor.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
       }    }    /**     * Returns the type of predictor used by this sensor.     * @return the predictor type.     *     * @deprecated As of Java 3D version 1.4, prediction is not a     * supported feature.     */     public int getPredictor(){	return predictorType;    }    /**     * Sets the prediction policy use by this sensor.     * Since prediction is not implemented (and never has been), this     * attribute has no effect.     * @param policy prediction policy one of NO_PREDICTOR, HEAD_PREDICTOR,     * or HAND_PREDICTOR     * @exception IllegalArgumentException if an invalid prediction policy     *  is specified.     *     * @deprecated As of Java 3D version 1.4, prediction is not a     * supported feature.     */    public void setPredictionPolicy(int policy){	if (policy != NO_PREDICTOR && policy != HEAD_PREDICTOR &&                 policy != HAND_PREDICTOR)	    throw new IllegalArgumentException(J3dI18N.getString("Sensor1"));	else	    predictionPolicy = policy;    }    /**     * Returns the prediction policy used by this sensor.     * @return the prediction policy.     *     * @deprecated As of Java 3D version 1.4, prediction is not a     * supported feature.     */     public int getPredictionPolicy(){	return predictionPolicy;    }    /**     * Set the sensor's hotspot in this sensor's coordinate system.     * @param hotspot the sensor's new hotspot     */    public void setHotspot(Point3d hotspot){	this.hotspot.set(hotspot);    }    /**     * Get the sensor's hotspot in this sensor's coordinate system.     * @param hotspot the variable to receive the sensor's hotspot     */    public void getHotspot(Point3d hotspot){	hotspot.set(this.hotspot);    }    /**     * Set the sensor's associated input device.     * @param device the sensor's new device     */    public void setDevice(InputDevice device){	this.device = device;    }    /**     * Retrieves the sensor's associated input device.     * @return the sensor's device     */    public InputDevice getDevice(){	return device;    }    /**     * Retrieves the last sensor reading and copies that value into     * the specified argument.     *     * @param read the matrix that will receive the sensor reading     */    public void getRead(Transform3D read) {        if(demand_driven == true)             device.pollAndProcessInput();	read.set(readings[currentIndex].read);    }    /**     * Retrieves the last sensor reading and copies that value into     * the specified argument.     *     * @param read the matrix that will receive the sensor reading     * @param deltaT this parameter is ignored     *     * @deprecated As of Java 3D version 1.4, prediction is not a     * supported feature; use <code>getRead(Transform3D)</code> instead.     */    public void getRead(Transform3D read, long deltaT){	getRead(read);    }    /**     * Extracts the most recent sensor reading and copies that value into     * the specified argument.     * @param read the matrix that will receive the most recent sensor reading     */    public void lastRead(Transform3D read){	read.set(readings[currentIndex].read);    }    /**     * Extracts the kth-most recent sensor reading and copies that value into     * the specified argument; where 0 is the most recent sensor reading, 1 is      * the next most recent sensor reading, etc.       * @param read the matrix that will receive the most recent sensor reading     * @param kth  the kth previous sensor reading     */    public void lastRead(Transform3D read, int kth){        if(kth >= sensorReadCount) {   throw new IllegalArgumentException(J3dI18N.getString("Sensor3"));        }	read.set(readings[previousIndex(kth)].read);    }    /**     * Returns the time associated with the most recent sensor reading.     * @return the time associated with the most recent sensor reading.     */    public long lastTime(){	return readings[currentIndex].time;    }    /**     * Returns the time associated with the kth-most recent sensor reading;     * where 0 is the most recent sensor reading, 1 is the next most recent     * sensor reading, etc.     * @return the time associated with the kth-most recent sensor reading.     */    public long lastTime(int k){        if(k >= sensorReadCount) {           throw new IllegalArgumentException(J3dI18N.getString("Sensor4"));        }	return readings[previousIndex(k)].time;    }    /**     *  Places the most recent sensor reading value for each button into     *  the array parameter; will throw an ArrayIndexOutOfBoundsException     *  if values.length is less than the number of buttons.     *  @param values the array into which the button values will be     *  placed     */    public void lastButtons(int[] values) {       System.arraycopy(readings[currentIndex].buttonValues, 0, values,                              0, sensorButtonCount);    }    /**     *  Places the kth-most recent sensor reading value for each button into     *  the array parameter; where k=0 is the most recent sensor reading, k=1      *  is the next most recent sensor reading, etc.;  will throw an      *  ArrayIndexOutOfBoundsException if values.length is less than     *  the number of buttons.     *  @param k  the time associated with the most recent sensor reading     *  @param values the array into which the button values will be     *  placed.     */    public void lastButtons(int k, int[] values) {        if(k >= sensorReadCount) {       throw new IllegalArgumentException(J3dI18N.getString("Sensor5"));        }       System.arraycopy(readings[previousIndex(k)].buttonValues, 0, values,                            0, sensorButtonCount);    }    /**     * Returns the number of SensorRead objects associated with     * this sensor.     * @return the number of SensorReadObjects associated with this sensor     */    public int getSensorReadCount() {	return this.sensorReadCount;    }    /**     * Set the number of sensor read objects per Sensor. This is a      * calibration parameter that should normally be set in this      * object's constructor.  Calling this method resets all of this     * sensor's values that are already in the buffer.     * It is illegal to change this value after the device has been     * added to the scheduler.     * @param count the new sensor read count     */    public void setSensorReadCount(int count) {        sensorReadCount = count;        MaxSensorReadIndex = sensorReadCount + SENSOR_READ_COUNT_BUFFER - 1;        readings = new SensorRead[MaxSensorReadIndex + 1];        for(int i = 0; i < MaxSensorReadIndex + 1; i++){            readings[i] = new SensorRead(sensorButtonCount);        }        currentIndex = 0;    }        /**     * Returns the number of buttons associated with this sensor.     * @return the number of buttons associated with this sensor.     */    public int getSensorButtonCount() {	return sensorButtonCount;    }    /**     * Gets the current sensor read.     * @return the current sensor read object     */    public SensorRead getCurrentSensorRead() {        // not sure if this should return a reference or a copy         SensorRead read = new SensorRead(sensorButtonCount);        read.set(readings[currentIndex]);	return read;    }    /**      *  Sets the next sensor read to the specified values; once these      *  values are set via this method they become the current values      *  returned by methods such as lastRead(), lastTime(), and       *  lastButtons(); note that if there are no buttons associated with      *  this sensor, values can just be an empty array.      *  @param time  the next SensorRead's associated time      *  @param transform  the next SensorRead's transformation      *  @param values the next SensorRead's buttons' states      */    public void setNextSensorRead(long time, Transform3D transform,				  int[] values) {        int temp = currentIndex + 1;        if (temp > MaxSensorReadIndex) temp = 0;         readings[temp].setTime(time);        readings[temp].set(transform);        if(sensorButtonCount > 0)           readings[temp].setButtons(values);        currentIndex = temp;    }    /**      *  Sets the next sensor read to the specified values; once these      *  values are set via this method they become the current values      *  returned by methods such as lastRead(), lastTime(), and      *  lastButtons().      *  @param read  the next SensorRead's values      */    public void setNextSensorRead(SensorRead read) {        int temp = currentIndex + 1;         if (temp > MaxSensorReadIndex) temp = 0;         readings[temp].set(read);        currentIndex = temp;   }}

⌨️ 快捷键说明

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