开发者

OpenGl - calculate normal in cube

i need calculate normal of 6 faces from cube. The cube is moved with keys, so, as the position of cube i need kno开发者_如何学Pythonw normal face.

There any method that help this calculation??


If you maintain the relationship between faces you can calculate one and then get all the others using transformations. Or you can just calculate all six individually.

The easiest way to do it is to use the cross-product of two edge vectors and normalize the result to get a unit vector in 3D.

Pick any cube surface that has points (1, 2, 3, 4) numbered in such a way that if you look down the unit vector normal to the face the numbers run in the counterclockwise direction.

Calculate the vectors between points 1 and 2:

OpenGl - calculate normal in cube

Same for a vector running from point 1 to point 4.

Cross the first vector into the second, normalize it, and that's your unit vector.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜