Search in sources :

Example 1 with ValuePerVertex

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);
        }
    }
}
Also used : ShaderFieldType(com.gempukku.libgdx.graph.shader.field.ShaderFieldType) ValuePerVertex(com.gempukku.libgdx.graph.util.ValuePerVertex)

Example 2 with ValuePerVertex

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);
}
Also used : ShaderFieldType(com.gempukku.libgdx.graph.shader.field.ShaderFieldType) ValuePerVertex(com.gempukku.libgdx.graph.util.ValuePerVertex) PropertySource(com.gempukku.libgdx.graph.shader.property.PropertySource)

Aggregations

ShaderFieldType (com.gempukku.libgdx.graph.shader.field.ShaderFieldType)2 ValuePerVertex (com.gempukku.libgdx.graph.util.ValuePerVertex)2 PropertySource (com.gempukku.libgdx.graph.shader.property.PropertySource)1