Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android OpenGL texture from non-local source using Rajawali3D?

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

like image 876
Steve C. Avatar asked Oct 24 '15 20:10

Steve C.


1 Answers

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):

  1. Prepare texture
  2. Prepare material
  3. Apply material to a model

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);
like image 176
frogatto Avatar answered Sep 22 '22 13:09

frogatto