Package com.ardor3d.util

Examples of com.ardor3d.util.Ardor3dException


    public static IndexBufferData<?> createIndexBufferData(final int size,
            final Class<? extends IndexBufferData<?>> clazz) {
        try {
            return clazz.getConstructor(int.class).newInstance(size);
        } catch (final Exception ex) {
            throw new Ardor3dException(ex.getMessage(), ex);
        }
    }
View Full Code Here


     * @return generated Image object
     */
    public static Image generateColorMipMap(final int size, final ColorRGBA[] topColors, final ColorRGBA defaultColor) {

        if (!MathUtils.isPowerOfTwo(size)) {
            throw new Ardor3dException("size must be power of two!");
        }

        final int mips = (int) (MathUtils.log(size, 2)) + 1;

        int bufLength = size * size * 4;
 
View Full Code Here

     */
    public IntersectionRecord(final double[] distances, final Vector3[] points, final Vector3[] normals,
            final List<PrimitiveKey> primitives) {
        if (distances.length != points.length || (primitives != null && points.length != primitives.size())
                || (normals != null && points.length != normals.length)) {
            throw new Ardor3dException("All arguments must have an equal number of elements.");
        }
        _isSorted = distances.length < 2;
        _intersections = new Intersection[distances.length];
        for (int i = 0; i < distances.length; i++) {
            _intersections[i] = new Intersection(distances[i], points[i], normals != null ? normals[i] : null,
View Full Code Here

                        rawData[rawDataIndex++] = blue;
                        rawData[rawDataIndex++] = alpha;
                    }
                }
            } else {
                throw new Ardor3dException("Unsupported TGA true color depth: " + pixelDepth);
            }
        } else if (imageType == TYPE_TRUECOLOR_RLE) {
            byte red = 0;
            byte green = 0;
            byte blue = 0;
            byte alpha = 0;

            // Faster than doing a 16-or-24-or-32 check on each individual pixel,
            // just make a separate loop for each.
            if (pixelDepth == 32) {
                for (int i = 0; i <= (height - 1); ++i) {
                    if (!flip) {
                        rawDataIndex = (height - 1 - i) * width * dl;
                    }

                    for (int j = 0; j < width; ++j) {
                        // Get the number of pixels the next chunk covers (either packed or unpacked)
                        int count = dis.readByte();
                        if ((count & 0x80) != 0) {
                            // Its an RLE packed block - use the following 1 pixel for the next <count> pixels
                            count &= 0x07f;
                            j += count;
                            blue = dis.readByte();
                            green = dis.readByte();
                            red = dis.readByte();
                            alpha = dis.readByte();
                            while (count-- >= 0) {
                                rawData[rawDataIndex++] = red;
                                rawData[rawDataIndex++] = green;
                                rawData[rawDataIndex++] = blue;
                                rawData[rawDataIndex++] = alpha;
                            }
                        } else {
                            // Its not RLE packed, but the next <count> pixels are raw.
                            j += count;
                            while (count-- >= 0) {
                                blue = dis.readByte();
                                green = dis.readByte();
                                red = dis.readByte();
                                alpha = dis.readByte();
                                rawData[rawDataIndex++] = red;
                                rawData[rawDataIndex++] = green;
                                rawData[rawDataIndex++] = blue;
                                rawData[rawDataIndex++] = alpha;
                            }
                        }
                    }
                }

            } else if (pixelDepth == 24) {
                for (int i = 0; i <= (height - 1); i++) {
                    if (!flip) {
                        rawDataIndex = (height - 1 - i) * width * dl;
                    }
                    for (int j = 0; j < width; ++j) {
                        // Get the number of pixels the next chunk covers (either packed or unpacked)
                        int count = dis.readByte();
                        if ((count & 0x80) != 0) {
                            // Its an RLE packed block - use the following 1 pixel for the next <count> pixels
                            count &= 0x07f;
                            j += count;
                            blue = dis.readByte();
                            green = dis.readByte();
                            red = dis.readByte();
                            while (count-- >= 0) {
                                rawData[rawDataIndex++] = red;
                                rawData[rawDataIndex++] = green;
                                rawData[rawDataIndex++] = blue;
                                if (createAlpha) {
                                    rawData[rawDataIndex++] = (byte) 255;
                                }
                            }
                        } else {
                            // Its not RLE packed, but the next <count> pixels are raw.
                            j += count;
                            while (count-- >= 0) {
                                blue = dis.readByte();
                                green = dis.readByte();
                                red = dis.readByte();
                                rawData[rawDataIndex++] = red;
                                rawData[rawDataIndex++] = green;
                                rawData[rawDataIndex++] = blue;
                                if (createAlpha) {
                                    rawData[rawDataIndex++] = (byte) 255;
                                }
                            }
                        }
                    }
                }

            } else if (pixelDepth == 16) {
                final byte[] data = new byte[2];
                final float scalar = 255f / 31f;
                for (int i = 0; i <= (height - 1); i++) {
                    if (!flip) {
                        rawDataIndex = (height - 1 - i) * width * dl;
                    }
                    for (int j = 0; j < width; j++) {
                        // Get the number of pixels the next chunk covers (either packed or unpacked)
                        int count = dis.readByte();
                        if ((count & 0x80) != 0) {
                            // Its an RLE packed block - use the following 1 pixel for the next <count> pixels
                            count &= 0x07f;
                            j += count;
                            data[1] = dis.readByte();
                            data[0] = dis.readByte();
                            blue = (byte) (int) (getBitsAsByte(data, 1, 5) * scalar);
                            green = (byte) (int) (getBitsAsByte(data, 6, 5) * scalar);
                            red = (byte) (int) (getBitsAsByte(data, 11, 5) * scalar);
                            while (count-- >= 0) {
                                rawData[rawDataIndex++] = red;
                                rawData[rawDataIndex++] = green;
                                rawData[rawDataIndex++] = blue;
                                if (createAlpha) {
                                    rawData[rawDataIndex++] = (byte) 255;
                                }
                            }
                        } else {
                            // Its not RLE packed, but the next <count> pixels are raw.
                            j += count;
                            while (count-- >= 0) {
                                data[1] = dis.readByte();
                                data[0] = dis.readByte();
                                blue = (byte) (int) (getBitsAsByte(data, 1, 5) * scalar);
                                green = (byte) (int) (getBitsAsByte(data, 6, 5) * scalar);
                                red = (byte) (int) (getBitsAsByte(data, 11, 5) * scalar);
                                rawData[rawDataIndex++] = red;
                                rawData[rawDataIndex++] = green;
                                rawData[rawDataIndex++] = blue;
                                if (createAlpha) {
                                    rawData[rawDataIndex++] = (byte) 255;
                                }
                            }
                        }
                    }
                }

            } else {
                throw new Ardor3dException("Unsupported TGA true color depth: " + pixelDepth);
            }

        } else if (imageType == TYPE_COLORMAPPED) {
            final int bytesPerIndex = pixelDepth / 8;

            if (bytesPerIndex == 1) {
                for (int i = 0; i <= (height - 1); i++) {
                    if (!flip) {
                        rawDataIndex = (height - 1 - i) * width * dl;
                    }
                    for (int j = 0; j < width; j++) {
                        final int index = dis.readUnsignedByte();
                        if (index >= cMapEntries.length || index < 0) {
                            throw new Ardor3dException("TGA: Invalid color map entry referenced: " + index);
                        }
                        final ColorMapEntry entry = cMapEntries[index];
                        rawData[rawDataIndex++] = entry.red;
                        rawData[rawDataIndex++] = entry.green;
                        rawData[rawDataIndex++] = entry.blue;
                        if (dl == 4) {
                            rawData[rawDataIndex++] = entry.alpha;
                        }

                    }
                }
            } else if (bytesPerIndex == 2) {
                for (int i = 0; i <= (height - 1); i++) {
                    if (!flip) {
                        rawDataIndex = (height - 1 - i) * width * dl;
                    }
                    for (int j = 0; j < width; j++) {
                        final int index = flipEndian(dis.readShort());
                        if (index >= cMapEntries.length || index < 0) {
                            throw new Ardor3dException("TGA: Invalid color map entry referenced: " + index);
                        }
                        final ColorMapEntry entry = cMapEntries[index];
                        rawData[rawDataIndex++] = entry.red;
                        rawData[rawDataIndex++] = entry.green;
                        rawData[rawDataIndex++] = entry.blue;
                        if (dl == 4) {
                            rawData[rawDataIndex++] = entry.alpha;
                        }
                    }
                }
            } else {
                throw new Ardor3dException("TGA: unknown colormap indexing size used: " + bytesPerIndex);
            }
        }

        // Get a pointer to the image memory
        final ByteBuffer scratch = BufferUtils.createByteBuffer(rawData.length);
View Full Code Here

        setupDefaultBuckets();
    }

    public void setupBuckets(final RenderBucketType[] renderBucketTypes, final RenderBucket[] buckets) {
        if (renderBucketTypes.length != buckets.length) {
            throw new Ardor3dException("Can't setup buckets, RenderBucketType and RenderBucket counts don't match.");
        }
        removeRenderBuckets();
        for (int i = 0; i < renderBucketTypes.length; i++) {
            setRenderBucket(renderBucketTypes[i], buckets[i]);
        }
View Full Code Here

        return renderBuckets.get(type);
    }

    public void addToQueue(final Spatial spatial, final RenderBucketType type) {
        if (type == RenderBucketType.Inherit || type == RenderBucketType.Skip) {
            throw new Ardor3dException("Can't add spatial to bucket of type: " + type);
        }

        if (Constants.enableInstancedGeometrySupport && prepareForInstancing(spatial)) {
            return;
        }

        final RenderBucket renderBucket = getRenderBucket(type);
        if (renderBucket != null) {
            renderBucket.add(spatial);
        } else {
            throw new Ardor3dException("No bucket exists of type: " + type);
        }
    }
View Full Code Here

        return skipRenderQueue;
    }

    public void removeFromQueue(final Spatial spatial, final RenderBucketType type) {
        if (type == RenderBucketType.Inherit || type == RenderBucketType.Skip) {
            throw new Ardor3dException("Can't remove spatial from bucket of type: " + type);
        }

        final RenderBucket renderBucket = getRenderBucket(type);
        if (renderBucket != null) {
            renderBucket.remove(spatial);
        } else {
            throw new Ardor3dException("No bucket exists of type: " + type);
        }
    }
View Full Code Here

     * @param angle
     *            the angle (in degrees) which must be between 0 and 90 (inclusive) or the special case 180.
     */
    public void setAngle(final float angle) {
        if (angle < 0f || (angle > 90f && angle != 180f)) {
            throw new Ardor3dException("invalid angle.  Angle must be between 0 and 90, or 180");
        }
        _angle = angle;
    }
View Full Code Here

     * @param exponent
     *            the spot exponent of this light. Should be between 0-128
     */
    public void setExponent(final float exponent) {
        if (exponent < 0f || exponent > 128f) {
            throw new Ardor3dException("invalid exponent.  Exponent must be between 0 and 128");
        }
        _exponent = exponent;
    }
View Full Code Here

                    // merge current world bound with child world bound
                    worldBound.mergeLocal(child.getWorldBound());

                    // simple check to catch NaN issues
                    if (!Vector3.isValid(worldBound.getCenter())) {
                        throw new Ardor3dException("WorldBound center is invalid after merge between " + this + " and "
                                + child);
                    }
                } else {
                    // set world bound to first non-null child world bound
                    if (child.getWorldBound() != null) {
View Full Code Here

TOP

Related Classes of com.ardor3d.util.Ardor3dException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.