I am using the OpenGL library Rajawali3D to display my models. What I would like to know is how can I load a texture from my server based on the logged in user? I've searched all over the internet trying to figure this out for months with no success. I found this website that explains how to load a texture from a non-local source but when I tried it, it didn't work with Rajawali. Any suggestions or examples would be much appreciated.
Here's the website I attempted to use: texture from web
I'm not familiar with Rajawali, however as I just checked it out, it seems fairly easy to load a remote texture and apply it to a model.
I presume that you've loaded your 3D model and can show it fine. If so, you should take the following basic steps (which apply generally to all 3D modeling apps):
There's a class called Texture
in Rajawali, which creates a texture object from a bitmap image. So, you should first download that image from your server. Downloading process is apart from Rajawali concepts, so you can get it done via many existing libraries.
Once you're finished downloading the image, you can feed it to the Texture
class.
Texture mytexture = new Texture("texture", /*address to the downloaded image*/);
Then, you should add it to a material
try {
material.addTexture(mytexture);
} catch (ATexture.TextureException error){
Log.d(TAG, "Error Occurred");
}
Now, you can apply this material to a model
model.setMaterial(material);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With