开发者

How to get position of object in plane

开发者 https://www.devze.com 2023-02-21 04:58 出处:网络
At my game screen console one triangle a开发者_Python百科nd one circle is moving randomly. I want to get present position of triangle and circle.How will i do it ? I have to check distance between the

At my game screen console one triangle a开发者_Python百科nd one circle is moving randomly. I want to get present position of triangle and circle.How will i do it ? I have to check distance between them.


This highly depends on how you move the triangle and the circle. I suppose you at least have the circle's local center already, since that's needed to define a circle. For the triangle's local center, try google or any decent math book.

I assume you issue a bunch of glTranslate calls with random parameters. You could get the current modelview matrix and extract the translation component, but I'd advice against that. It should be easier for you to track the parameters manually, since if you only have glTranslate it would be a simple addition. In conjunction with glRotate this would be somewhat more complicated, but since those functions are deprecated already, you'd need to do the tracking yourself anyway (roll your own matrix math or preferably use a library).

0

精彩评论

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

关注公众号