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);
}
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;
}
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;
}
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);
}
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;
}
Aggregations