Hide a face of a 3D shape behind another,Android canvas?

怎甘沉沦 提交于 2020-01-06 20:00:43

问题


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?


回答1:


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




回答2:


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!



来源:https://stackoverflow.com/questions/13899774/hide-a-face-of-a-3d-shape-behind-another-android-canvas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!