@SuppressWarnings("unchecked") protected static Map<String, Object> getMap(final Object doc, final boolean verify) { if (!(doc instanceof Map<?, ?>)) { if (verify) { throw new Ardor3dException("Could not parse material. Expected Map at: " + doc); } else { return null; } } return (Map<String, Object>) doc; }
@SuppressWarnings("unchecked") protected static List<Object> getList(final Object doc, final boolean verify) { if (!(doc instanceof List<?>)) { if (verify) { throw new Ardor3dException("Could not parse material. Expected List at: " + doc); } else { return null; } } return (List<Object>) doc; } }
/** * <code>setExponent</code> sets the spot exponent of this light. This value represents how focused the light beam * is. * * @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; }
/** * <code>setAngle</code> sets the angle of focus of the spot light measured from the direction vector. Think of this * as the angle of a cone. Therefore, if you specify 10 degrees, you will get a 20 degree cone (10 degrees off * either side of the direction vector.) 180 degrees means radiate in all directions. * * @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; }
/** * <code>setRoughness</code> sets the new roughness value of the heightmap. Roughness determines how chaotic the * terrain will be. Where 1 is perfectly self-similar, > 1 early iterations have a disproportionately large effect * creating smooth terrain, and < 1 late iteraions have a disproportionately large effect creating chaotic terrain. * * @param roughness * how chaotic will the heightmap be. */ public void setRoughness(final float roughness) { if (roughness < 0) { throw new Ardor3dException("roughness must be greater than 0"); } this.roughness = roughness; }
/** * <code>setRoughness</code> sets the new roughness value of the heightmap. Roughness determines how chaotic the * terrain will be. Where 1 is perfectly self-similar, > 1 early iterations have a disproportionately large effect * creating smooth terrain, and < 1 late iteraions have a disproportionately large effect creating chaotic terrain. * * @param roughness * how chaotic will the heightmap be. */ public void setRoughness(final float roughness) { if (roughness < 0) { throw new Ardor3dException("roughness must be greater than 0"); } this.roughness = roughness; }
public static int getGLShaderType(final ShaderType type) { switch (type) { case Fragment: return GL20C.GL_FRAGMENT_SHADER; case Geometry: return GL32C.GL_GEOMETRY_SHADER; case TessellationControl: return GL40C.GL_TESS_CONTROL_SHADER; case TessellationEvaluation: return GL40C.GL_TESS_EVALUATION_SHADER; case Vertex: return GL20C.GL_VERTEX_SHADER; default: throw new Ardor3dException("Unhandled shader type: " + type); } }
protected static int getGLDataType(final Buffer buffer) { if (buffer instanceof FloatBuffer) { return GL11C.GL_FLOAT; } else if (buffer instanceof ByteBuffer) { return GL11C.GL_BYTE; } else if (buffer instanceof IntBuffer) { return GL11C.GL_INT; } else if (buffer instanceof ShortBuffer) { return GL11C.GL_SHORT; } else { throw new Ardor3dException("Unhandled buffer type: " + buffer.getClass().getName()); } }
/** * Create a new IndexBufferData of the specified size and class. * * @param size * required number of values to store. * @param clazz * The class type to instantiate. * @return the new IndexBufferData */ 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); } }
/** * Create a new IndexBufferData of the specified size and class. * * @param size * required number of values to store. * @param clazz * The class type to instantiate. * @return the new IndexBufferData */ 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); } }
/** * Constructor builds a new heightmap using the midpoint displacement algorithm. Roughness determines how chaotic * the terrain will be. Where 1 is perfectly self-similar, > 1 early iterations have a disproportionately large * effect creating smooth terrain, and < 1 late iteraions have a disproportionately large effect creating chaotic * terrain. * * @param size * the size of the terrain, must be a power of 2. * @param roughness * how chaotic to make the terrain. * * @throws Ardor3dException * if size is less than or equal to zero or roughtness is less than 0. */ public MidPointHeightMapGenerator(final int size, final float roughness) { if (!MathUtils.isPowerOfTwo(size)) { throw new Ardor3dException("Size must be (2^N) sized."); } if (roughness < 0 || size <= 0) { throw new Ardor3dException("size and roughness must be " + "greater than 0"); } this.roughness = roughness; this.size = size; }
/** * Constructor builds a new heightmap using the midpoint displacement algorithm. Roughness determines how chaotic * the terrain will be. Where 1 is perfectly self-similar, > 1 early iterations have a disproportionately large * effect creating smooth terrain, and < 1 late iteraions have a disproportionately large effect creating chaotic * terrain. * * @param size * the size of the terrain, must be a power of 2. * @param roughness * how chaotic to make the terrain. * * @throws Ardor3dException * if size is less than or equal to zero or roughtness is less than 0. */ public MidPointHeightMapGenerator(final int size, final float roughness) { if (!MathUtils.isPowerOfTwo(size)) { throw new Ardor3dException("Size must be (2^N) sized."); } if (roughness < 0 || size <= 0) { throw new Ardor3dException("size and roughness must be " + "greater than 0"); } this.roughness = roughness; this.size = size; }
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); } }
private void deactivate() { if (_active == 1) { try { giveBackContext(); } catch (final LWJGLException e) { logger.logp(Level.SEVERE, this.getClass().toString(), "deactivate()", "Exception", e); throw new Ardor3dException(); } } _active--; }
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); } }
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); } }
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); } }
@SuppressWarnings("unchecked") private static FloatBuffer getFloatBuffer(final Object doc, final int sizeM, final int sizeN) { if (doc == null) { return null; } if (!(doc instanceof ArrayList<?>)) { throw new Ardor3dException("Incorrect type. Expected ArrayList of size " + sizeM + ". Got: " + doc.getClass().getName() + " value: " + doc); } final List<Object> vals = (ArrayList<Object>) doc; if (vals.size() != sizeM) { throw new Ardor3dException("Incorrect size. Expected: " + sizeM + " value: " + doc); } final FloatBuffer buff = BufferUtils.createFloatBuffer(sizeM * sizeN); for (final Object val : vals) { buff.put(getFloatBuffer(val, sizeN)); } buff.flip(); return buff; }
public void checkCardError() throws Ardor3dException { try { org.lwjgl.opengl.Util.checkGLError(); } catch (final OpenGLException exception) { throw new Ardor3dException("Error in opengl: " + exception.getMessage(), exception); } }
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]); } }