use of com.gempukku.libgdx.graph.shader.property.PropertySource in project gdx-graph by MarcinSc.
the class MeshParticleModel method updateParticleData.
@Override
public void updateParticleData(float[] particlesData, int particleOffset, VertexAttributes vertexAttributes, ObjectMap<String, String> attributeToPropertyMap, ObjectMap<String, PropertySource> properties, ObjectMap<String, Object> attributes) {
int vertexLength = vertexAttributes.vertexSize / 4;
for (VertexAttribute vertexAttribute : vertexAttributes) {
String propertyName = attributeToPropertyMap.get(vertexAttribute.alias);
if (propertyName != null) {
int attributeOffset = vertexAttribute.offset / 4;
PropertySource propertySource = properties.get(propertyName);
Object attributeValue = attributes.get(propertyName);
ParticlesUtil.setParticleAttribute(particlesData, particleOffset, vertexCount, vertexLength, attributeOffset, propertySource, attributeValue);
}
}
}
use of com.gempukku.libgdx.graph.shader.property.PropertySource 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);
}
use of com.gempukku.libgdx.graph.shader.property.PropertySource in project gdx-graph by MarcinSc.
the class TexturePagedSpriteBatchModel method getTextureSignature.
private String getTextureSignature(RenderableSprite sprite) {
if (textureUniforms.size == 0)
return "";
StringBuilder sb = new StringBuilder();
for (PropertySource textureUniform : textureUniforms) {
Object region = sprite.getPropertyContainer().getValue(textureUniform.getPropertyName());
region = textureUniform.getValueToUse(region);
sb.append(((TextureRegion) region).getTexture().getTextureObjectHandle()).append(",");
}
sb.setLength(sb.length() - 1);
return sb.toString();
}
use of com.gempukku.libgdx.graph.shader.property.PropertySource in project gdx-graph by MarcinSc.
the class GraphModelUtil method getPropertySourceMap.
public static ObjectMap<VertexAttribute, PropertySource> getPropertySourceMap(GraphModels graphModels, String tag, VertexAttributes vertexAttributes) {
ObjectMap<String, PropertySource> shaderProperties = graphModels.getShaderProperties(tag);
if (shaderProperties == null)
throw new GdxRuntimeException("Unable to locate shader with tag: " + tag);
ObjectMap<VertexAttribute, PropertySource> result = new ObjectMap<>();
for (VertexAttribute vertexAttribute : vertexAttributes) {
String alias = vertexAttribute.alias;
PropertySource propertySource = findPropertyByAttributeName(shaderProperties, alias);
result.put(vertexAttribute, propertySource);
}
return result;
}
use of com.gempukku.libgdx.graph.shader.property.PropertySource in project gdx-graph by MarcinSc.
the class GraphModelUtil method getShaderVertexAttributes.
public static VertexAttributes getShaderVertexAttributes(GraphModels graphModels, String tag) {
ObjectMap<String, PropertySource> shaderProperties = graphModels.getShaderProperties(tag);
if (shaderProperties == null)
throw new GdxRuntimeException("Unable to locate shader with tag: " + tag);
Array<VertexAttribute> vertexAttributeArray = new Array<>(VertexAttribute.class);
for (ObjectMap.Entry<String, PropertySource> shaderProperty : shaderProperties) {
PropertySource propertySource = shaderProperty.value;
PropertyLocation propertyLocation = propertySource.getPropertyLocation();
if (propertyLocation == PropertyLocation.Attribute) {
ShaderFieldType shaderFieldType = propertySource.getShaderFieldType();
if (shaderFieldType instanceof ArrayShaderFieldType) {
int arraySize = ((ArrayShaderFieldType) shaderFieldType).getArrayLength();
for (int i = 0; i < arraySize; i++) {
vertexAttributeArray.add(new VertexAttribute(1024, shaderFieldType.getNumberOfComponents(), propertySource.getAttributeName(i)));
}
} else {
vertexAttributeArray.add(new VertexAttribute(1024, shaderFieldType.getNumberOfComponents(), propertySource.getAttributeName()));
}
}
}
return new VertexAttributes(vertexAttributeArray.toArray());
}
Aggregations