android - How to dynamically change the image rendered using RajawaliVR -


public class myrenderer extends rajawalicardboardrenderer  {     public myrenderer(context context)      {         super(context);     }      @override     public void initscene() {     log.d("debug1","initscene()");     sphere sphere = createphotospherewithtexture(new texture("photo",r.drawable.image));     getcurrentscene().addchild(sphere);     getcurrentcamera().setposition(vector3.zero);     getcurrentcamera().setfieldofview(75); }  private static sphere createphotospherewithtexture(atexture texture) {      material material = new material();     material.setcolor(0);      try {         material.addtexture(texture);     } catch (atexture.textureexception e) {         throw new runtimeexception(e);     }      sphere sphere = new sphere(50, 64, 32);     sphere.setscalex(-1);     sphere.setmaterial(material);     return sphere;   } } 

currently there fixed image preloaded in rajawalivr library. method used set image in called once @ beginning. want change image on will. familiar using rajawalivr library know asking ,thanks in advance.

got solution, can dynamically change image texture of object on external trigger can use code sample.
can call changeimage method whenever triggered fired. dont forget declare method changeimage in rajawalicardboardrenderer. call changeimage method on myrenderer object.

public class myrenderer extends rajawalicardboardrenderer      {        public myrenderer(context context)         {           super(context);        }        @override     public void initscene() {     log.d("debug1","initscene()");     sphere sphere = createphotospherewithtexture(new texture("photo",r.drawable.image));     getcurrentscene().addchild(sphere);     getcurrentcamera().setposition(vector3.zero);     getcurrentcamera().setfieldofview(75);     }      private static sphere createphotospherewithtexture(atexture texture) {      material material = new material();     material.setcolor(0);      try {         material.addtexture(texture);     } catch (atexture.textureexception e) {         throw new runtimeexception(e);     }      sphere sphere = new sphere(50, 64, 32);     sphere.setscalex(-1);     sphere.setmaterial(material);     return sphere;     }      public void changeimage()     {        log.d("debug1", "" + getcurrentscene().getnumchildren());         arraylist<object3d> objectlist = getcurrentscene().getchildrencopy();         material material = objectlist.get(0).getmaterial();         (atexture texture : material.gettexturelist())         {             material.removetexture(texture);             texture = null;         }          texture t = new texture("spheretexture",r.drawable.newimage);         t.shouldrecycle(true);               try {                   material.addtexture(t);               }               catch (exception e){e.printstacktrace();}      }      } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -