Hai, i have to change texture when user click a button. How to change texture in runtime? i try add texture to texture manager and setTexture in onDrawFrame, but it not working, have error out of memory. Thank you.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
public void onDrawFrame(GL10 gl) {
if (_wikitudeRenderExtension != null) {
_wikitudeRenderExtension.onDrawFrame(gl);
}
if (_currentlyRecognizedTarget != null) {
world.removeAllObjects();
float[] projectionCamera = _currentlyRecognizedTarget.getProjectionMatrix();
projMatrix.setIdentity();
projMatrix.setDump(projectionCamera);
projMatrix.transformToGL();
SimpleVector translation=projMatrix.getTranslation();
SimpleVector dir=projMatrix.getZAxis();
SimpleVector up = projMatrix.getXAxis();
cam.setPosition(translation);
cam.setOrientation(dir, up);
markerMatrix.setIdentity();
float[] marker1Transformation= _currentlyRecognizedTarget.getViewMatrix();
markerMatrix.setDump(marker1Transformation);
markerMatrix.transformToGL();
cube.clearTranslation();
cube.setRotationMatrix(markerMatrix);
cube.setTranslationMatrix(markerMatrix);
// cam.setBack(markerMatrix);
world.addObject(cube);
world.renderScene(fb);
world.draw(fb);
fb.display();
world = new World();
world.setAmbientLight(30, 30, 30);
sun = new Light(world);
sun.setIntensity(255, 255, 255);
// Create a texture out of the icon...:-)
TextureManager txtMgr = TextureManager.getInstance();
if (!txtMgr.containsTexture("BURJ_AL_.JPG")) {
Texture texture = new Texture(BitmapHelper.rescale(
BitmapHelper.convert(mActivity.getResources().getDrawable(R.drawable.burj_al_arab_map)), 512, 512));
txtMgr.addTexture("BURJ_AL_.JPG", texture);
}
Context mContext =mActivity.getApplicationContext();
InputStream stream = null;
try {
stream = mContext.getAssets().open("burj_al_arab.3DS");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//cube = Primitives.getCylinder(20, 80);
cube=Loader.load3DS(stream, 1f)[0];
cube.setCulling(false);
cube.strip();
cube.build();
world.addObject(cube);
Page created in 0.020 seconds with 12 queries.