use of com.gempukku.libgdx.graph.util.ValuePerVertex in project gdx-graph by MarcinSc.
the class ParticlesUtil method setParticleAttribute.
public static void setParticleAttribute(float[] particlesData, int particleOffset, int vertexCount, int vertexLength, int attributeOffset, PropertySource propertySource, Object attributeValue) {
ShaderFieldType shaderFieldType = propertySource.getShaderFieldType();
if (attributeValue instanceof ValuePerVertex) {
for (int i = 0; i < vertexCount; i++) {
int vertexIndex = particleOffset + i * vertexLength;
Object vertexValue = ((ValuePerVertex) attributeValue).getValue(i);
shaderFieldType.setValueInAttributesArray(particlesData, vertexIndex + attributeOffset, propertySource.getValueToUse(vertexValue));
}
} else {
Object value = propertySource.getValueToUse(attributeValue);
for (int i = 0; i < vertexCount; i++) {
int vertexIndex = particleOffset + i * vertexLength;
shaderFieldType.setValueInAttributesArray(particlesData, vertexIndex + attributeOffset, value);
}
}
}
use of com.gempukku.libgdx.graph.util.ValuePerVertex in project gdx-graph by MarcinSc.
the class LimitedCapacitySpriteBatchModel method updateSpriteData.
private void updateSpriteData(RenderableSprite sprite, int spriteIndex) {
int spriteDataStart = getSpriteDataStart(spriteIndex);
for (VertexAttribute vertexAttribute : vertexAttributes) {
PropertySource propertySource = vertexPropertySources.get(vertexAttribute);
int attributeOffset = vertexAttribute.offset / 4;
ShaderFieldType shaderFieldType = propertySource.getShaderFieldType();
Object attributeValue = sprite.getPropertyContainer().getValue(propertySource.getPropertyName());
if (attributeValue instanceof ValuePerVertex) {
for (int vertexIndex = 0; vertexIndex < 4; vertexIndex++) {
int vertexOffset = spriteDataStart + vertexIndex * floatCountPerVertex;
Object vertexValue = ((ValuePerVertex) attributeValue).getValue(vertexIndex);
shaderFieldType.setValueInAttributesArray(vertexData, vertexOffset + attributeOffset, propertySource.getValueToUse(vertexValue));
}
} else {
attributeValue = propertySource.getValueToUse(attributeValue);
for (int vertexIndex = 0; vertexIndex < 4; vertexIndex++) {
int vertexOffset = spriteDataStart + vertexIndex * floatCountPerVertex;
shaderFieldType.setValueInAttributesArray(vertexData, vertexOffset + attributeOffset, attributeValue);
}
}
}
markSpriteUpdated(spriteIndex);
}
Aggregations