You are right that it works when called from an operator. But I'm trying to make it work outside the operator, thus I need to define my own matrixes.
That said I found the fix :) Your example did help to make me explore it further, thanks. Basically instead of: glOrtho(-1, 1, -1, 1, -20, 20) (...) coordinates = [(size, size), (-size, size), (-size, -size), ( size, -size)] I'm now doing: glOrtho(0, 1, 0, 1, -15, 15) coordinates = [(size, size), (0, size), (0, 0), ( size, 0)] Final sample file: http://www.pasteall.org/46298/python Cheers, Dalai -- blendernetwork.org/dalai-felinto www.dalaifelinto.com 2013/10/9 CoDEmanX <[email protected]> > 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 >
_______________________________________________ Bf-python mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-python
