Hm your code looks quite complex, don't think you need to calculate all that things, this works for me:
http://www.pasteall.org/46288/python view2d.view_to_region() with 0,0 and 1,1 should give you the border coordinates of the clip in region coordinates. Am 09.10.2013 09:43, schrieb Dalai Felinto: > Hi, > > I'm trying to write an addon where I'll need to draw a quad connecting > four markers. > For that I need to be able to map the markers coordinates to > 'screenspace' glVertex2f coordinates. > > I can't match the drawn shape with the image though. > This is a test drawing a quad that was suppose to match the image 1:1 > > http://www.pasteall.org/pic/show.php?id=60483 > Not only there is an 'offset', but the offset changes if I pan around > the region. > > Here is a sample script with the bare minimum to illustrate the problem: > http://www.pasteall.org/46273/python > (draw_rectangle is where the transformation is happening). > > If anyone has any suggestion it would be much appreciated. > Thanks, > Dalai > > > > > -- > blendernetwork.org/dalai-felinto <http://blendernetwork.org/dalai-felinto> > www.dalaifelinto.com <http://www.dalaifelinto.com> > > > _______________________________________________ > Bf-python mailing list > [email protected] > http://lists.blender.org/mailman/listinfo/bf-python > _______________________________________________ Bf-python mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-python
