how to use image instead of custom box in Augment Reality android -


i new in android in augmented reality , facing problem in ar .

that using example of andar , in example can see simple cube box on markers.

but want use own image on marker instead of in build cube.

and want use different image different markers.

this code:- cube generated.

public class customobject extends arobject {   public customobject(string name, string patternname,         double markerwidth, double[] markercenter) {     super(name, patternname, markerwidth, markercenter);     float   mat_ambientf[]     = {0f, 1.0f, 0f, 1.0f};     float   mat_flashf[]       = {0f, 1.0f, 0f, 1.0f};     float   mat_diffusef[]       = {0f, 1.0f, 0f, 1.0f};     float   mat_flash_shinyf[] = {50.0f};      mat_ambient = graphicsutil.makefloatbuffer(mat_ambientf);     mat_flash = graphicsutil.makefloatbuffer(mat_flashf);     mat_flash_shiny = graphicsutil.makefloatbuffer(mat_flash_shinyf);     mat_diffuse = graphicsutil.makefloatbuffer(mat_diffusef);  } public customobject(string name, string patternname,         double markerwidth, double[] markercenter, float[] customcolor) {     super(name, patternname, markerwidth, markercenter);     float   mat_flash_shinyf[] = {50.0f};      mat_ambient = graphicsutil.makefloatbuffer(customcolor);     mat_flash = graphicsutil.makefloatbuffer(customcolor);     mat_flash_shiny = graphicsutil.makefloatbuffer(mat_flash_shinyf);     mat_diffuse = graphicsutil.makefloatbuffer(customcolor);  }  private simplebox box = new simplebox(); private floatbuffer mat_flash; private floatbuffer mat_ambient; private floatbuffer mat_flash_shiny; private floatbuffer mat_diffuse;  /**  * drawn here drawn directly onto marker,  * corresponding translation matrix applied.  */ @override public final void draw(gl10 gl) {     super.draw(gl);      gl.glmaterialfv(gl10.gl_front_and_back, gl10.gl_specular,mat_flash);     gl.glmaterialfv(gl10.gl_front_and_back, gl10.gl_shininess, mat_flash_shiny);         gl.glmaterialfv(gl10.gl_front_and_back, gl10.gl_diffuse, mat_diffuse);       gl.glmaterialfv(gl10.gl_front_and_back, gl10.gl_ambient, mat_ambient);      //draw cube     gl.glcolor4f(0, 1.0f, 0, 1.0f);     gl.gltranslatef( 0.0f, 0.0f, 12.5f );       box.draw(gl); } @override public void init(gl10 gl) {     // todo auto-generated method stub  } 

please me out overcome problem.

thanks.

to create new marker can use 1 of these online marker generator tools:

create marker , save preferably .patt suffix (e.g. dog.patt).

copy marker in accessible directory android application (e.g sdcard).

to load specific marker, need @ custom activity in andar repository see how it's done ( /svn/trunk/andar/src/edu/dhbw/andar/pub/customactivity.java ):

someobject = new customobject("test", "patt.hiro", 80.0, new double[]{0,0}); artoolkit.registerarobject(someobject); 

when declare 3d object (customobject, 1 drawing simplebox), can specify marker should use initialization parameters (e.g. patt.hiro).

for information initialization parameters are: marker name (arbitrary), file marker (your .patt file), size of marker (mm), marker center (by default 0,0)).


Comments