开发者

WPF 3D Billboards

In a 3D scene we often need to apply labels (little textelements or icons) next to 3D object that is moving around (rotation, transla开发者_高级运维tion) in the scene. These labels should always face the camera but still move with the object. This technique I believe is called billboard.

An additional cool feature would be if the label would stay always at the same size - no matter how far away the associated object is. So the label seems to live in 2D screenspace and not in the 3D scenegraph.

Does anyone figures out a clever way how to do this in WPF?


For billboarding you need to make sure that the face normal is pointing towards the camera. The algorithm is that the dot product between the face normal and the view direction should be -1 (minus one).

I have some old C code that does this, but it's probably not particularly useful.

For keeping the object the same size you'd need to work out the screen size and then apply a transform to keep it the constant size you desired.

However, if you want the object to appear as though it's in 2D space, why not draw it in a 2D overlay? This will solve both the billboarding and scaling problem at the same time. You work out the screen location of your label and then use the 2D drawing functions.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜