0

when i having a vertex 1.0,1.0,0.0 whit a matrix applied to it how can i calculate the viewmatrix so that this vertex is rendered at a given screen coordinate

LIBS.translateX(VertexMatrix, 5);
var PROJMATRIX=LIBS.get_projection(45, my_Widht/my_Height, 1, 300);
var VIEWMATRIX=LIBS.get_I4();
LIBS.translateZ(VIEWMATRIX, ???);

now i would like this vertex to by rendered at 768 pixels (x value) on the screen how to calculate the corresponding y value most of all how to find the Z translation for the viewmatrix

Ino
  • 41
  • 1
  • 7
  • [Unproject](http://stackoverflow.com/questions/7364693/how-to-get-object-in-webgl-3d-space-from-a-mouse-click-coordinate?rq=1) – LJᛃ Sep 07 '16 at 01:53
  • What are you actually trying to accomplish? As in what do you want to display where? I'm asking because maybe you don't need to do it by changing the view matrix (as in maybe you don't even need a view matrix). – gman Sep 07 '16 at 02:32
  • well i divide the screen in to a grid of squares if you hover over one of them they turn and show the back side which is a different part of an image i want this as a sort of background so lets say i have a grid of 20X10 (this depends on the aspect ratio of the screen) squares they need to fill the screen so i need to know what viewmatrix i need to use so the outer most square is at the border of the screen i also use a simple equitation screenToGrid for mouse tracking instead of some raytracking later i may add 3d buttons and such for navigation – Ino Sep 07 '16 at 03:02
  • https://ino1.eu/ this is what i currently having mouse tracking isnt working or it is just the grid isnt in place and there is no back side in the moment – Ino Sep 07 '16 at 03:33
  • Is this what you need? http://stackoverflow.com/a/29362951/128511 ? Basically if you know the number of units you want to display vertically then you can plug that into the stuff in that answer and get a view matrix that exactly fits that many units vertically for a given field of view – gman Sep 07 '16 at 17:57
  • yes it is but for some reason the value i get is of by .6 per unit not sure why i also would need to know how to get it by horizontal display value but this i probably can figure out by the side ration – Ino Sep 07 '16 at 20:22

0 Answers0