opengles显示在iPhone的人脸的人、opengles、iPhone

2023-09-07 17:48:57 作者:老子最可爱

我需要一个人面对的2D到3D的脸。 我用此链接加载.OBJ文件和地图纹理。本实施例是仅用于立方体和金字塔。我装人脸的.obj文件。

I need to make a human 2D face to 3D face. I used this link to load an ".obj" file and map the textures. This example is only for cube and pyramid. I loaded a human face ".obj" file.

这加载obj文件,并可以得到人脸正确如下。

This loads the .obj file and can get the human face properly as below.

但在这里我的问题是我需要在不改变.OBJ文件,以显示不同的人脸。只是纹理映射。

But my problem here is I need to display different human faces without changing the ".obj" file. just by texture mapping.

但质地没有得到映射正确,因为OBJ文件是不同的模型。我只是想改变它用作质地和下面是结果,其中纹理映射,但不完全是我所料,如下图所示的png格式文件。

But the texture is not getting mapped properly, as the obj file is of different model. I just tried changing the ".png" file which is used as texture and the below is the result, where the texture is mapped but not exactly what I expected, as shown below.

下面是我的几个问题就可以了:

The below are my few questions on it :

1)我需要加载纹理相同型号(相同obj文件)具有不同的图像。是否有可能在opengles?

1) I need to load texture on same model( with same .obj file ) with different images. Is it possible in opengles?

2)如果上述问题的解决方案是形状匹配,我该怎么办用opengles?

2) If the solution for above problem is "shape matching", how can I do it with opengles?

3)最后一个基本的问题,我需要显示在大面积的图像,如何使显示面积更大一些?

3) And finally a basic question, I need to display the image in large area, how to make the display area bigger?

推荐答案

mtl2opengl 实际上是我的项目,所以感谢使用它!

mtl2opengl is actually my project, so thanks for using it!

1)的唯一方式可以达到完美的纹理交换无失真是如果两个纹理映射到紫外线顶点以完全相同的方式。看看下面的图片:

1) The only way you can achieve perfect texture swapping without distortion is if both textures are mapped onto the UV vertices in exactly the same way. Have a look at the images below:

A型:金发女孩 B型:阿什利头 Model A: Blonde Girl Model B: Ashley Head

正如你所看到的,纹理做适合的模式。所以任何交换到不同的几何形状的目标将导致失真。简体,人头/面有两个组成部分:内部(骨/几何)和外观(皮肤/纹理)。内饰方面显然定义了外观,让完美质感交换在同一个obj文件将无法正常工作,除非你改变模型与交换的几何形状。

As you can see, textures are made to fit the model. So any swapping to a different geometry target will result in distortion. Simplified, human heads/faces have two components: Interior (Bone/Geometry) and Exterior (Skin/Texture). The interior aspect obviously defines the exterior, so perfect texture swapping on the same .obj file will not work unless you change the geometry of the model with the swap.

2),这是可能与被叫技术displacement映射可以在OpenGL ES的实施,虽与预期的难度多头/面。这就需要你的目标.OBJ几何体开始与pretty的通用模式,就像一个人体模型,然后使用每个纹理转移模型顶点的位置。我想你需要非常舒服建模,图形,着色器,和数学来完成这件事!

2) This is possible with a technique called displacement mapping that can be implemented in OpenGL ES, although with anticipated difficulty for multiple heads/faces. This would require your target .obj geometry to start with a pretty generic model, like a mannequin, and then use each texture to shift the position of the model vertices. I think you need to be very comfortable with Modeling, Graphics, Shaders, and Math to pull this one off!

通过维基百科

3)我会添加更多变换的选择(规模和放大器;翻译)在下次更新。在X code项目实际作出炫耀的PERL脚本,而不是作为底漆的OpenGL ES在iOS。现在,找到 modelViewMatrix 和小提琴与这一点点:

3) I will add more transform options (scale & translate) in the next update. The Xcode project was actually made to show off the PERL script, not as a primer for OpenGL ES on iOS. For now, find the modelViewMatrix and fiddle with this little bit:

GLKMatrix4Scale(_modelViewMatrix, 0.30, 0.33, 0.30);

希望这能回答你所有的问题!

Hope that answers all your questions!