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?
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!
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 yourface
, and check if it faces towards or away from the camera.You do this using the
dot product
of thenormal
and theview vector
of your camera. Depending on thesign
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).