コード例 #1
0
            protected int replaceNaN(FloatBuffer floatBuffer, float value)
            {
                int length    = floatBuffer.remaining();
                int numValues = 0;

                if (this.tmpBuffer == null || this.tmpBuffer.length < floatBuffer.remaining())
                {
                    this.tmpBuffer = new float[length];
                }

                floatBuffer.get(this.tmpBuffer, 0, length);
                floatBuffer.flip();

                for (int i = 0; i < length; i++)
                {
                    if (isNoValueFloat(this.tmpBuffer[i]))
                    {
                        this.tmpBuffer[i] = value;
                    }
                    else
                    {
                        numValues++;
                    }
                }

                floatBuffer.put(this.tmpBuffer, 0, length);
                floatBuffer.flip();

                return(numValues);
            }
コード例 #2
0
        /**
         * Copies a specified array of vertices to a specified vertex buffer. This method calls {@link
         * java.nio.FloatBuffer#flip()} prior to returning.
         *
         * @param array  the vertices to copy.
         * @param buffer the buffer to copy the vertices to. Must have enough remaining space to hold the vertices.
         *
         * @return the buffer specified as input, with its limit incremented by the number of vertices copied, and its
         *         position set to 0.
         */
        public static FloatBuffer copyArrayToBuffer(Vec4[] array, FloatBuffer buffer)
        {
            if (array == null)
            {
                String message = Logging.getMessage("nullValue.ArrayIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (buffer == null)
            {
                String message = Logging.getMessage("nullValue.BufferIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            foreach (Vec4 v in array)
            {
                buffer.put((float)v.x).put((float)v.y).put((float)v.z);
            }

            buffer.flip(); // sets the limit to the position and then the position to 0.

            return(buffer);
        }