如何将人脸存储在内存中
我一直在试图解决这个问题,但找不到一种看起来合理的方法,似乎没有什么可以真正解释它,我可以找到无数关于如何进行建模以及如何处理面部的东西,但没有任何关于他们可以存储在内存中以供使用。我主要关注的是 obj,剩下的很简单,主要只是用数组来存储所有内容,但是对于面,我能想到的使用它们的唯一方法是存储对象中哪些顶点的详细信息,或者每次从文件中读取它们,但这肯定是正确的吗?对每张脸都使用一个对象似乎很疯狂,但我想不出任何其他方法! 即使只是一本可以看的书或任何能指引我正确方向的东西,因为一切似乎都跳过了这些东西。谢谢。
Ive been trying to figure this out but cant find a way to do it which seems reasonable, and nothing seems to actually explain it, I can find a myriad of stuff on how to do modelling, and how to work withthe faces, but nothing on whow they can be stored in memory to work with. Ive been looking at obj mainly, and the rest is easy it's mainly just arrays to store it all, but faces, the only way Ive been able to think of to work with them is to store the details on which vertices in an object, or to read them from file each time, but that can't be right surely? It seems crazy to be using an object for every face, but I cant think of any other way!
Even just a book to look at or anything to just point me in the right direction, because everything just seems to skip over this stuff. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
面通常由三个或更多顶点连接而成。这意味着您可以将每个面存储为其所组成的顶点(或顶点索引)列表。
或者,如果每个面的顶点数量是预先确定的(我打赌这是常见的),您可以将其折叠成单个列表/向量/数组:
维基百科可能比我传达得更好。
A face is usually three or more vertices connected. This means you can store each face as a list of the vertices (or indices to the vertices) it consists of.
Or if the amount of vertices for each face is predetermined (which I would wager is common), you could collapse it into a single list/vector/array:
Wikipedia may convey it better than I do.
您正在寻找的是顶点数组。它的工作原理是每个对象都包含一组顶点和一种颜色。顶点的法线存储在同一个数组中(vertexX、vertexY、vertexZ、normalX、normalY、normalZ)。当您想要渲染对象时,您可以循环遍历对象数组并渲染每个对象,如下所示:
这应该绘制一个红色平面。唯一的区别是您希望从对象定义中向其提供数组。您还可以包含每个顶点的颜色信息,只需在上面的代码中包含一个 glColorPointer 和一个 glEnableClientState(GL_COLOR_ARRAY)。
What you are looking for is arrays of vertices. How it works is each object contains an array of vertices and a color. The normals for the vertices are stored in this same array, (vertexX, vertexY, vertexZ, normalX, normalY, normalZ). When you want to render your objects, you loop through your array of objects and render each object as shown below:
And that should draw a red plane. Only difference is you would want to feed it your array from your object definition. You can also include color information per vertex and just include a glColorPointer in the above code and a glEnableClientState(GL_COLOR_ARRAY).