Hide a face of a 3D shape behind another,Android c

2019-08-25 13:25发布

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?

2条回答
叼着烟拽天下
2楼-- · 2019-08-25 14:17

Do you looking for 3D Flipping?
If so, then I suggest you look at this link and this one.
Also there is some other related questions on StackOverFlow and other blogs. Just search "3D Flip on Android" on Google.

Good luck!

查看更多
不美不萌又怎样
3楼-- · 2019-08-25 14:19

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.

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

查看更多
登录 后发表回答