简体   繁体   中英

How to calculate whether the point in cube is Visibility in WPF 3D

I want to show a Perspective cube, so I should calculate whether the point in cube is Visibility.

Like the picture, the red vertex should be invisible, while the others should be visible.

Can anyone give me a formula to calculate it?

The cube may be Rotated that I have no way to do it.

I try use HitTest to do it but it have a Poor performance.

I want to know a formula to calculate whether the point and face and line is visibility.

Edit:

The point is any point on the line.

I build it with Media3D.

If any of the faces connected to the vertex has a normal facing the camera (see back face culling), the vertex is visible. This should be pretty quick to calculate.

Try taking the dot product of the "camera vector" (this is usually (0,0,1)) and all of the normal vectors of the cube faces that the vertex in question touches.
If any of the dot products return a negative value, then the angle between the camera vector and the normal vector of the respective cube face is greater that 90 degrees and is therefore "facing" the camera.
If the point of interest is a vertex, you'll be running three dot products. If the point of interest is along a line between vertices, you will only calculate two.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM