jPCT-AE - a 3d engine for Android > Support

Vertex colouring from last jPCT-AE version

<< < (2/5) > >>

mxar:

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.

EgonOlsen:
Looks ok at first glace, except for the definition of the "theColor" variant in the fragment shader. I don't see where this is supposed to be filled or used.

That special constructor is for a very special case...i'm not sure, if you really need it. If you do, what exactly do you mean by material info? TextureInfo instances? If that's the case, you can't use them in this constructor but a simple array of texture ids instead (which limits you to one texture layer of course). You can of course anything you like after creating the object but that will influence the object as a whole.

mxar:
Thanks for the answer.

I forgot to remove the unused vec4 theColor from fragment shader.

My current project is an Augmented Reality project.

I need to read the Augmented Object3D models from a data buffer not from a file.

This means that i dont know the format (.3ds, .obj,. md2 ..)  of the Object3D model stored in the data buffer.

The Object3D obj = Object3D(float[] coordinates, float[] uvs, int[] indices, int textureId)   method could be a good candidate in this case.

One part of the data buffer can store the float[] coordinates,
other parts the float[] uvs, int[] indices  and textureID.

But  some Object3D formats like .obj provide the material info in a separate .mtl file.

For example a .mtl file can have a content like this:
 
newmtl policecar.png
Ns 0
Kd 0.8 0.8 0.8
Ks 0.0 0.0 0.0
Ka 0.2 0.2 0.2
d 1
illum 2
map_Kd policecar.png


I think that the previews Object3D constructor doesn't provide this kind of info.

What do you think about this issue?


Thanks in advance







EgonOlsen:
No, it doesn't but actually, it doesn't have to. All that jPCT uses from this file (when using it's own loader) is newmtl (as an indicator that something new comes after) and the name, Kd, map_Kd/map_Ka and d. If map_Kd/map_Ka is present, it uses that as a texture name. If not, it creates a texture with the colors of Kd and uses that one. Plus is uses d for transparency. If you want to support file of that kind in the same way that the default loaders do it, just mimic that behaviour.

mxar:
Thanks for your answer,

I want to ask you if other type of Object3D models (like .3ds,.obj ..) are planned to be supported in the near future.

Also i found some 3D models with non square textures and having not power of 2 width and size.

I know that these kind of textures are not supported by jPCT-ae, but do you know any way to be used by jPCT-ae? (scaling?,some tranformation? ..).

Thanks in advance

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version