61
Support / Re: Vertex colouring from last jPCT-AE version
« on: October 13, 2014, 12:40:04 pm »Thanks for your answer.
I wrote the following code:
int vertices = object3D.getMesh().getUniqueVertexCount();
Log.d(TAG," vertices = " + vertices);
float[] data = new float[4*vertices];
for(int i = 0; i < data.length; i++){
data = 0.0f;
if(i%3 == 1)
data = 1f;
}
VertexAttributes vattrs = new VertexAttributes("colorinfo",data,VertexAttributes.TYPE_FOUR_FLOATS);
object3D.getMesh().addVertexAttributes(vattrs);
GLSLShader shader = new GLSLShader( Loader.loadTextFile(mActivity.getResources().openRawResource(R.raw.vertexshader)),Loader.loadTextFile(mActivity.getResources().openRawResource(R.raw.fragmentshader)));
object3D.setShader(shader);
object3D.strip();
object3D.build();
world.addObject(object3D);
The vertex shader is:
attribute vec4 colorinfo;
uniform mat4 modelViewProjectionMatrix;
attribute vec4 position;
varying vec4 vertexColor;
void main(void)
{
vertexColor = colorinfo;
gl_Position = modelViewProjectionMatrix * position;
}
And the fragment shader is:
varying vec4 theColor;
varying vec4 vertexColor;
void main(void)
{
gl_FragColor = vertexColor;
}
I think that works . Am i correct?
Also I have a question about the method:
Object3D obj = Object3D(float[] coordinates, float[] uvs, int[] indices, int textureId)
How can I apply material info in this case to Object3D obj?
Thanks in advance.