隐藏的脸背后另有3D形状,Android的画布?画布、另有、形状、Android

2023-09-08 10:51:44 作者:千雪半花碧落黄泉

假设我要画一个三维形状的两副面孔在canvas.In OpenGL中,我们使用的顶点顺时针和非顺时针顺序来检测一下脸是正面,什么是落后的脸,但是的我可以不使用OpenGL 的,我会用canvas.It看来,如果我们画背后的脸,然后得出的前脸,它背后隐藏的脸,但我的3D形状旋转,每一个面临一些时间必须是正面和一些时间必须在后面。

Suppose that I have to draw two faces of a 3D shape in a canvas.In OpenGL,we use clockwise and non clockwise ordering of vertices to detect what face is front face and what is behind face,but I can not use OpenGL and I would to use canvas.It seems that if we draw behind face and then draw front face,it hides behind face,but my 3D shape rotates and each face some times must be front and some times must be behind.

我的问题是:??在形状旋转,我怎么可以检测到女巫的脸是正面或隐藏当前的背后脸,前脸的任何其他方式

My question is : When shape is rotating,how I can detect witch face is front?Or any other way to hide current behind face with front face?

推荐答案

您所描述的过程被称为的背面剔除的(这将大大提高在话题您的谷歌的实力)。

The process you describe is called back-face culling (this will greatly improve your google prowess on the topic).

要实现的直接的方法是采取法线面对,并检查它是否面临朝向或远离相机

The straight forward way to implement is to take the normal vector of your face, and check if it faces towards or away from the camera.

您做到这一点使用的正常视图矢量。根据标志的点积,多边形从相机朝向或离开。

You do this using the dot product of the normal and the view vector of your camera. Depending on the sign of the dot product, the polygon is facing towards or away from the camera.

如果你没有真正有一个摄像头,在这一点上,替换为载体到屏幕(即 [0,0,1] [0,0,-1] 根据您的轴系统)。

If you don't actually have a camera at this point, substitute a vector into the screen (i.e. [0, 0, 1] or [0, 0, -1] depending on your axis system).