c# - Translate coordinates to another plane -
my main plane rectangle(0,0,10000,10000) example.
my screen plane (ie virtual position) rectangle(1000,1000,1920,1080).
my texture2d rectangle(1500,1200,200,100) in main plane.
i need translate texture2d coordinates screen plane. tried matrix.translate without success. must texture2d = rectangle(500,200,200,100) in screen plane.
in order texture2d (1500, 1200) (500, 200) have use translation of (-1000, -1000) inverse numbers screen plane's coordinates. in code translation this
matrix transform = matrix.createtranslation(-screenplane.x, -screenplane.y, 0);
the theory want move texture if camera on (0, 0) instead of (1000, 1000). have move texture (-1000, -1000) in order so.
check web 2d camera classes, usefull know how cameras work :) 1 example: http://www.david-amador.com/2009/10/xna-camera-2d-with-zoom-and-rotation/
Comments
Post a Comment