Ok, as I said when I create my objects, I basically do this :
Object3D towerTop = Primitives.getSphere(1);
//choosing the texture stuff here
//..
towerTop.setTexture(topTex); //texture chosen previously
towerTop.calcTextureWrapSpherical();
//towerTop.setSpecularLighting(true);
towerTop.build();
String uniformTime = mContext.getResources().getString(R.string.global_uniform_time);
ArrayList<ShaderUniform> uniformsTop = new ArrayList<ShaderUniform>();
uniformsTop.add(new ShaderUniform("colorMap", 1));
uniformsTop.add(new ShaderUniform("noiseMap", 1));
uniformsTop.add(new ShaderUniform(uniformTime, currentTime));
uniformsTop.add(new ShaderUniform("alpha", 1.0));
uniformsTop.add(new ShaderUniform("baseSpeed", 0.005));
uniformsTop.add(new ShaderUniform("noiseScale", 0.1337));
uniformsTop.add(new ShaderUniform("invRadius", 0.0005f));
ShaderUtils.setShader(mContext, towerTop, shadersDir+"towers/"+"vertexShader.glsl", shadersDir+"towers/"+"fragmentShader.glsl", uniformsTop);
//then I add the object to the world etc
At this point, I have created wrappers and added them to the arraylist, the wrapper class looks like that :
public class ShaderUniform<T> {
private String name;
private T value;
public ShaderUniform(String name, T value) {
super();
this.name = name;
this.value = value;
}
//getters & setters...
Then I call my setShader method :
ShaderUtils.setShader(mContext, towerTop, shadersDir+"towers/"+"vertexShader.glsl", shadersDir+"towers/"+"fragmentShader.glsl", uniformsTop);
And this method does what I have posted before, it just takes the value attribute of the ShaderUniform and checks its class, if it's an integer it will call the setStaticUniform method that takes an integer parameter, if it's a float, the float method etc.
I'm not 100% sure that the line s.getValue() instanceof Float works perfectly, as I'm giving a float primitive parameter as the value when I create a ShaderUniform. I suppose that it's working as I'm getting the Log messages (UNIFORM INTEGER,FLOAT etc...).
And when I'm trying to update the uniform, I do it directly using the setUniform method of JPCT, not mine (I'm lazy ^^, this would force me to make another method that takes a single ShaderUniform parameter, check its class again and update it with setUniform, while I can directly do it in the render loop :p )