Comments (15)
Hmmm.
It seems that this is not the right function to change the texture on a model. Now I'm setting the material instead of adding a texture, and it works.
Danny
from rajawali.
Sorry to bring this up again, but is this really the right method to change the texture on a model? What is the normal workflow for that?
I change the material in the onDrawFrame method to change it rapiditly but it only changes once.
Danny
from rajawali.
This is the right way to do this:
mTextureManager.updateTexture(texInfo.getTextureId(), myNewBitmap);
from rajawali.
I had the same question as DD above. I apologize for having a discussion in a bug log--I'm new to GitHub (and Rajawali and OpenGL). If there's a better place to talk about this, please direct me there.
I am able to overlay a world image on a sphere using addTexture, with a fine result:
http://i1254.photobucket.com/albums/hh618/CatCarson84/sphere-imagery.png
Or I can overlay a different image instead, in the same way, with a fine result:
http://i1254.photobucket.com/albums/hh618/CatCarson84/sphere-gray.png
But if I add the first image, then call updateTexture with the second image, I get a weird mishmash of the two:
http://i1254.photobucket.com/albums/hh618/CatCarson84/sphere-hybrid.png
My renderer code (snippet from initScene()) is:
mLight = new DirectionalLight(1f, 0.2f, 1.0f); // set the direction
mLight.setColor(1.0f, 1.0f, 1.0f);
mLight.setPower(1.0f);
// createBasemapSpheres();
mBasemapSphere = new Sphere(1.0f, 40, 40);
mBasemapSphere.setTransparent(false);
DiffuseMaterial dm = new DiffuseMaterial();
mBasemapSphere.setMaterial(dm);
mBasemapSphere.addLight(mLight);
Bitmap bg = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.world_imagery_2048);
TextureInfo mBasemapTextureInfo = mTextureManager.addTexture(bg);
mBasemapSphere.addTexture(mBasemapTextureInfo);
addChild(mBasemapSphere);
Bitmap bg2 = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.canvas_gray_2048);
mTextureManager.updateTexture(mBasemapTextureInfo.getTextureId(), bg2);
from rajawali.
Thanks Dennis for your response.
Ive added
mTextureManager.updateTexture(texInfo[i].getTextureId(), tex[i]);
to my onDrawFrame fkt. and now it cycles through the images mapped on the cube.
@markdeaton
Try using a material and map the material to your object.
Danny
from rajawali.
Sorry again if this is the wrong place for a follow-up; it doesn't seem right to open a new issue for it. I attempted to set up multiple materials, each with its own texture; but there's something strange going on in the addTexture() routines that causes the textures to trample on one another and ultimately crash the app after about 7 material changes.
But I revisited my original approach (above), and found that everything works, providing I pass in the mipmap=false flag when I call mTextureManager.addTexture() on the one material I'm now using.
from rajawali.
mTextureManager.updateTexture(Models[0].model.getTextureInfoList().get(0).getTextureId(), mTextureBrown);
I tried this but not working.
from rajawali.
I've just committed a fix for this. Updating texture didn't work for mipmapped textures. I've deprecated the old method. The new method has a slightly different signature:
public void updateTexture(TextureInfo textureInfo, Bitmap texture) { ...
from rajawali.
Thanks, Dennis!
from rajawali.
its now working, but the textureCoords not the some..the texture just slipping on the object...why?
from rajawali.
public void updateTexture(TextureInfo textureInfo, Bitmap texture) {
int bitmapFormat = texture.getConfig() == Config.ARGB_8888 ? GLES20.GL_RGBA : GLES20.GL_RGB;
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureInfo.getTextureId());
if (textureInfo.isMipmap())
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_LINEAR);
else
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmapFormat, texture, 0);
if (textureInfo.isMipmap()) GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);
textureInfo.setTexture(texture);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
}
here is the working code, BUT when I have 4-5 objects (clones), and when I am just change one's tetxure, then the all object's texture changes
i am using this code
mTextureManager.updateTexture(model.getTextureInfoList().get(0), mTextureGreen)
0 is the BASE texture
1 is the BUMP right?
from rajawali.
maybe need a function to update only the DIFFUSE or only the BUMP texture on the modell.
at the moment the textures are mixing away
from rajawali.
Well, it uses the texture id, so there's no need to distinguish between diffuse or bump.
from rajawali.
Yes, cloned objects share materials. If you don't want a cloned material then you'll have to manually create new materials. Using shaders & textures on mobile devices is a costly operation. That's why materials aren't cloned automatically.
from rajawali.
I've run in the same problem.
This is the right way to do this:
mTextureManager.updateTexture(texInfo.getTextureId(), myNewBitmap);
What whould be the way to update a Etc1 texture?
There is addEtc1Texture
methods but no suitable updateTexture
.
from rajawali.
Related Issues (20)
- build issue com.github.ben-manes.versions not found HOT 3
- jcenter repository has been depracated
- Seeking Luminance based desaturation
- Seeking Lighten and Darken Blend Modes
- Seeking point texture plugin
- improving SpriteSheetMaterialPlugin efficiency HOT 1
- Seeking Flexible Sprite Sheet Animation
- Seeking runtime adjustment of AlphaMask threshold
- Please restore AnimatedSpritesFragment to example app
- Stencil Buffer is not initializing corrrectly,
- Some `ScreenQuad` materials spew error messages at frame rate
- Objects starts to render with delay when camera if far from them HOT 1
- How to translate object with touch screen?
- anyway to implement ray in the library?
- Create Sphere with phiStart, phiLength, thetaStart, thetaLength HOT 1
- LoaderFBX.java:347 ArrayIndexOutOfBoundsException
- display obj model in AR
- Examples are broken
- When will the new version be released?
- load obj file fail,NumberFormatException: For input string: "nan"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rajawali.