简体   繁体   English

使用Rajawali3D从非本地源获取Android OpenGL纹理?

[英]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建模应用程序):

  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. 在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.

相关问题 射线广播-将屏幕上的触摸转换为OpenGL ES(Rajawali3D)中的球体上的点 - Raycasting - Convert touch on screen to point on sphere in OpenGL ES (Rajawali3D) Google Tango Java API:使用Rajawali3D更新场景 - Google Tango Java API: Scene update with Rajawali3D 使用Android和OpenGL ES / Rajawali标记3D模型的各个部分 - Labeling parts of 3D model with Android and OpenGL ES/Rajawali 从Google相册应用中获取视频(非本地) - Getting videos(non-local) from the Google Photos App 使用 min3d/Rajawali 框架 (android) 在触摸时围绕 3d 对象旋转 - Rotation around 3d object on touch using min3d/Rajawali framework (android) 如何在非本地网络上以编程方式通过 Internet 连接 windows 和 android 设备 - How to connect windows and android device over internet programmatically on Non-Local network 在OpenGL,Android中从字节数组创建纹理 - Create texture from byte array in OpenGL, Android 从0,0坐标在OpenGL Android中绘制纹理 - draw texture in OpenGL Android from 0,0 coordinates 使用OpenGL矩阵转换将纹理从“ 1D”映射到“ 2D” - Mapping a texture from “1D” to “2D” with OpenGL matrix transformations 如何在Android中使用OpenGL按角度裁剪纹理? - How to crop texture by angle using OpenGL in Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM