Search in sources :

Example 6 with GdxRuntimeException

use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.

the class ModelCache method getRenderables.

@Override
public void getRenderables(Array<Renderable> renderables, Pool<Renderable> pool) {
    if (building)
        throw new GdxRuntimeException("Cannot render a ModelCache in between .begin() and .end()");
    for (Renderable r : this.renderables) {
        r.shader = null;
        r.environment = null;
    }
    renderables.addAll(this.renderables);
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Example 7 with GdxRuntimeException

use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.

the class Node method insertChild.

/** Insert the specified node as child of this node at the specified index. If the node is already a child of another node, then
	 * it is removed from its current parent. If the specified index is less than zero or equal or greater than
	 * {@link #getChildCount()} then the Node is added as the currently last child.
	 * @param index The zero-based index at which to add the child
	 * @param child The Node to add as child of this Node
	 * @return the zero-based index of the child */
public <T extends Node> int insertChild(int index, final T child) {
    for (Node p = this; p != null; p = p.getParent()) {
        if (p == child)
            throw new GdxRuntimeException("Cannot add a parent as a child");
    }
    Node p = child.getParent();
    if (p != null && !p.removeChild(child))
        throw new GdxRuntimeException("Could not remove child from its current parent");
    if (index < 0 || index >= children.size) {
        index = children.size;
        children.add(child);
    } else
        children.insert(index, child);
    child.parent = this;
    return index;
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Example 8 with GdxRuntimeException

use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.

the class ParallelArray method addElement.

/** Adds an element considering the values in the same order as the current channels in the array. The n_th value must have the
	 * same type and stride of the given channel at position n */
public void addElement(Object... values) {
    /* FIXME make it grow... */
    if (size == capacity)
        throw new GdxRuntimeException("Capacity reached, cannot add other elements");
    int k = 0;
    for (Channel strideArray : arrays) {
        strideArray.add(k, values);
        k += strideArray.strideSize;
    }
    ++size;
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Example 9 with GdxRuntimeException

use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.

the class G3dModelLoader method parseAttributes.

private VertexAttribute[] parseAttributes(JsonValue attributes) {
    Array<VertexAttribute> vertexAttributes = new Array<VertexAttribute>();
    int unit = 0;
    int blendWeightCount = 0;
    for (JsonValue value = attributes.child; value != null; value = value.next) {
        String attribute = value.asString();
        String attr = (String) attribute;
        if (attr.equals("POSITION")) {
            vertexAttributes.add(VertexAttribute.Position());
        } else if (attr.equals("NORMAL")) {
            vertexAttributes.add(VertexAttribute.Normal());
        } else if (attr.equals("COLOR")) {
            vertexAttributes.add(VertexAttribute.ColorUnpacked());
        } else if (attr.equals("COLORPACKED")) {
            vertexAttributes.add(VertexAttribute.ColorPacked());
        } else if (attr.equals("TANGENT")) {
            vertexAttributes.add(VertexAttribute.Tangent());
        } else if (attr.equals("BINORMAL")) {
            vertexAttributes.add(VertexAttribute.Binormal());
        } else if (attr.startsWith("TEXCOORD")) {
            vertexAttributes.add(VertexAttribute.TexCoords(unit++));
        } else if (attr.startsWith("BLENDWEIGHT")) {
            vertexAttributes.add(VertexAttribute.BoneWeight(blendWeightCount++));
        } else {
            throw new GdxRuntimeException("Unknown vertex attribute '" + attr + "', should be one of position, normal, uv, tangent or binormal");
        }
    }
    return vertexAttributes.toArray(VertexAttribute.class);
}
Also used : Array(com.badlogic.gdx.utils.Array) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) VertexAttribute(com.badlogic.gdx.graphics.VertexAttribute) JsonValue(com.badlogic.gdx.utils.JsonValue)

Example 10 with GdxRuntimeException

use of com.badlogic.gdx.utils.GdxRuntimeException in project libgdx by libgdx.

the class AnimationController method action.

/** Apply an action animation on top of the current animation. */
protected AnimationDesc action(final AnimationDesc anim, float transitionTime) {
    if (anim.loopCount < 0)
        throw new GdxRuntimeException("An action cannot be continuous");
    if (current == null || current.loopCount == 0)
        animate(anim, transitionTime);
    else {
        AnimationDesc toQueue = inAction ? null : obtain(current);
        inAction = false;
        animate(anim, transitionTime);
        inAction = true;
        if (toQueue != null)
            queue(toQueue, transitionTime);
    }
    return anim;
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Aggregations

GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)202 IOException (java.io.IOException)40 FileHandle (com.badlogic.gdx.files.FileHandle)14 Array (com.badlogic.gdx.utils.Array)13 Texture (com.badlogic.gdx.graphics.Texture)12 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)11 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)9 InputStream (java.io.InputStream)9 Pixmap (com.badlogic.gdx.graphics.Pixmap)8 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)8 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)7 AtlasSprite (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite)7 BufferedInputStream (java.io.BufferedInputStream)7 File (java.io.File)7 OutputStream (java.io.OutputStream)7 VertexAttribute (com.badlogic.gdx.graphics.VertexAttribute)6 LifecycleListener (com.badlogic.gdx.LifecycleListener)5 ByteBuffer (java.nio.ByteBuffer)5 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)4 NinePatch (com.badlogic.gdx.graphics.g2d.NinePatch)4