[英]Android OpenGL texture from non-local source using Rajawali3D?
I am using the OpenGL library Rajawali3D to display my models. 我使用OpenGL库Rajawali3D来显示我的模型。 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.
我发现这个网站解释了如何从非本地源加载纹理,但是当我尝试它时,它不适用于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. 我不熟悉Rajawali,但是当我刚检查出来时,加载远程纹理并将其应用于模型似乎相当容易。
I presume that you've loaded your 3D model and can show it fine. 我认为你已经加载了3D模型并且可以很好地显示它。 If so, you should take the following basic steps (which apply generally to all 3D modeling apps):
如果是这样,您应该采取以下基本步骤(通常适用于所有3D建模应用程序):
There's a class called Texture
in Rajawali, which creates a texture object from a bitmap image. 在Rajawali中有一个名为
Texture
的类,它从位图图像创建纹理对象。 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.
下载过程与Rajawali概念不同,因此您可以通过许多现有库完成它。
Once you're finished downloading the image, you can feed it to the Texture
class. 下载完图像后,可以将其提供给
Texture
类。
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.