tag:blogger.com,1999:blog-8577130439755471155.post6228519000939617433..comments2019-03-27T12:27:19.684+01:00Comments on WebGL Factory: How to convert world to screen coordinates and vice versaDenis Tosichttp://www.blogger.com/profile/14992340631798182965noreply@blogger.comBlogger33125tag:blogger.com,1999:blog-8577130439755471155.post-45891717072929899082017-11-17T13:28:20.354+01:002017-11-17T13:28:20.354+01:00Utilize the controls in the controller window to c...Utilize the controls in the controller window to completely alter the Movement smash format. Clients can change the number, weight, gravity, thickness and effect of the smash impact to make perpetual cool looks. <a href="http://store.pixelfilmstudios.com/product-category/motion-5-products/" rel="nofollow">Motion 5 Eﬀects</a><br />seo experthttps://www.blogger.com/profile/13945775688622787774noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-81500569049500244192017-05-21T04:11:48.110+02:002017-05-21T04:11:48.110+02:00What is winx and winy in the below function? Is it...What is winx and winy in the below function? Is it just the width and height of the screen?<br /><br />function Point3D get3dPoint(Point2D point2D, int width,<br /> int height, Matrix viewMatrix, Matrix projectionMatrix) {<br /> <br /> double x = 2.0 * winX / clientWidth - 1;<br /> double y = - 2.0 * winY / clientHeight + 1;<br /> Matrix4 viewProjectionInverse = inverse(projectionMatrix *<br /> viewMatrix);<br /><br /> Point3D point3D = new Point3D(x, y, 0); <br /> return viewProjectionInverse.multiply(point3D);<br />}tobihttps://www.blogger.com/profile/15290218194320935420noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-7776592225408410162016-05-24T07:25:58.411+02:002016-05-24T07:25:58.411+02:00hi
I am working on 3d scanner.I cant understand h...hi<br /><br />I am working on 3d scanner.I cant understand how to convert pixel co-ordinates into real world co-ordinates. <br /><br />For example I have a data set containing only (x,y) co-ordinates of some points on object in terms of pixels how can i convert them into real world units(i.e.,cm or mm)?<br /><br />thnx.mandy rhttps://www.blogger.com/profile/06180419498929319231noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-61531632010208969662016-05-10T07:16:05.695+02:002016-05-10T07:16:05.695+02:00hi
i have a 4 2dlocator (animated baked)of a simp...hi<br /><br />i have a 4 2dlocator (animated baked)of a simple plane geometry rotation and movement.<br />i need:<br />is here any simple mel script command for convert my 4 2dlocator to 1 3d locator in center of 4 2dlocator.created 3d locator with scale, transform x,y and xyz rotaion .<br />is this possible in maya i need this method for place my polyplane in my 3d scene video. with rotaion scale movement in3d but front of projected video layer no need of z movement need matched with same screen space as output of render video.<br />any idea any link any method any script any software who did this<br />please help me<br /><br />thanksAnil Kumarhttps://www.blogger.com/profile/16986076462557300122noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-47168276387035798272015-07-15T16:40:01.954+02:002015-07-15T16:40:01.954+02:00Image you have a point at (100, 200) on a 2D reder...Image you have a point at (100, 200) on a 2D redering surface of size 640x480.<br /><br />We can then say:<br /><br />clientWidth == 640<br />clinetHeight == 480<br />winX == 100<br />winY == 200<br /><br />Hope it helps!Denis Tosichttps://www.blogger.com/profile/14992340631798182965noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-44370287379953126712015-07-15T16:30:23.712+02:002015-07-15T16:30:23.712+02:00What are clientWidth, clinetHeight, winX, winY in ...What are clientWidth, clinetHeight, winX, winY in the 2d to 3d conversion funciton? please help.Ramshttps://www.blogger.com/profile/05849244875249850502noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-42245219396630481802015-05-14T03:06:49.037+02:002015-05-14T03:06:49.037+02:00I finally figured it out. The issue is when you se...I finally figured it out. The issue is when you set camera Z to particular value (in article 0), then world X and Y actually calculate to fit to that Z, So when you want to calculate X,Y world coordinates, you have to know for which world Z you are finding this X a Y. Once you know that. You can calculate camera coordinate Z which u can finally use to calculate world X,Y as is described in article. So how do you find the cameraZ when you know worldZ ? You have to take a Plane which contains worldZ coordinate and has normal identical to looking direction vector( it is target - eyeCoor) Once you have that plane you, have to transform it into camera space(For example by taking thre points which the plane containc, trasform them and then make from them again). And by putting camera X,Y to plane equatian you get camera Z. And That's it!Petr Geigerhttps://www.blogger.com/profile/04340140209934081875noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-44937294623701387132014-09-23T13:52:38.804+02:002014-09-23T13:52:38.804+02:00thx OP postthx OP postAndy0n7https://www.blogger.com/profile/14361319320963265788noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-33730271713403244082013-11-08T23:35:10.702+01:002013-11-08T23:35:10.702+01:00I have problem : I cant find any algorithm or prog...I have problem : I cant find any algorithm or program describe how to do conversion point 2D to 3D <br />how did I to find Z <br />point(x,y) --> point(x,y,z) <br />please help me<br /> souissi mounirhttps://www.blogger.com/profile/05202208905023633667noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-36382105258762489772013-06-27T13:59:01.453+02:002013-06-27T13:59:01.453+02:00Please refer to http://trac.bookofhook.com/bookofh...Please refer to http://trac.bookofhook.com/bookofhook/trac.cgi/wiki/MousePicking for a detailed explanation of how x and y computed wihtout the necessity of z.<br /><br />As for glm, this is a general coding approach written with WebGL in mind, without the use of any special libraries.Denis Tosichttps://www.blogger.com/profile/14992340631798182965noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-10344208371857330292013-06-27T13:32:10.918+02:002013-06-27T13:32:10.918+02:00Should not you not divide by z to get screen coord...Should not you not divide by z to get screen coords?<br /><br />I did this using glm, and it seems to work (actual code):<br /><br />glm::vec2 getScreenCoord(glm::vec3 pos){<br /> <br /> glm::vec4 p = cameraPerspectiveMatrix*glm::vec4(pos, 1.0);<br /> glm::vec2 s;<br /> s.x = int(((p.x/p.z + 1.0)/2.0) * winWidth + .5);<br /> s.y = int(((1.0 - p.y/p.z)/2.0) * winHeight + .5);<br /> return s;<br />}<br /><br />Also, you could extract z-coord from z-buffer, something like<br /><br />GLfloat zbuf;<br />getPixelInfo(x,y, GL_COLOR_ATTACHMENT0, GL_DEPTH_COMPONENT, GL_FLOAT, &zbuf);<br />double znorm = 2.0 * zbuf - 1.0;<br />double zreal = 2.0 * clipNear * clipFar / (clipFar + clipNear - znorm * (clipFar - clipNear));<br />avocadohttps://www.blogger.com/profile/04523998532520908895noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-79759711986210411582013-06-01T13:32:47.235+02:002013-06-01T13:32:47.235+02:00Change this line
(1) double y = - 2.0 * winY / cl...Change this line<br /><br />(1) double y = - 2.0 * winY / clientHeight + 1;<br /><br />to <br /><br />(2) double y = 2.0 * winY / clientHeight - 1; <br />So, you should use the same approach as with the x-axis.<br /><br />Besides that, you will get the same result if you supstitue "winY" with "clientHeight - winY" in (1).<br /><br />Hope it helps!Denis Tosichttps://www.blogger.com/profile/14992340631798182965noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-85695169506475663982013-06-01T03:03:43.919+02:002013-06-01T03:03:43.919+02:00If the screen's origin is in the bottom left c...If the screen's origin is in the bottom left corner instead of top left, what would you need to change to convert from 2d->3d?Unknownhttps://www.blogger.com/profile/17824160784151581362noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-10133725005929695662013-01-11T12:32:32.420+01:002013-01-11T12:32:32.420+01:00Very helpful article, thanks! :) I actually wrote ...Very helpful article, thanks! :) I actually wrote a similar article for performing the same conversion, but I'm specifically working in Maya. For people who have trouble with the normalization part, maybe you will find this useful: http://www.gouvatsos.com/how-to-transform-3d-coordinates-to-2d-screenspace-and-vice-versaAlexandros Gouvatsoshttps://www.blogger.com/profile/04654009144284421358noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-37357902377915078092012-12-29T11:22:25.955+01:002012-12-29T11:22:25.955+01:00the clear and real view provided by the latest dis...the clear and real view provided by the latest display devices make our experience real... the display system can be made more living with the correct supportives.. for beautiful home curtains and many more, you can visit..<br /><a href="http://www.saaria.com" rel="nofollow"> Projection screen company</a><br /><a href="http://www.directfromwarehouse.com" rel="nofollow">Theatrical Curtain" </a>sachinhttps://www.blogger.com/profile/11031346466629624313noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-87809133672760996502012-12-15T22:27:07.441+01:002012-12-15T22:27:07.441+01:00Hi Denis,
Many thanks for the tutorial. I was won...Hi Denis,<br />Many thanks for the tutorial. I was wondering if you have a spare moment to help me work this out. I have built the example in javascript, but I am having a bit of an issue converting back from a 3d point to xy. In other words applying the viewProjectionMatrix back on the 3d point to get the normalized screen coord.<br /><br />//starting with the nomalised screen coords:<br />screen3D[0] = 0.5;<br />screen3D[1] = 0.5;<br />screen3D[2] = 0;<br />screen3D[3] = 1;<br /><br />var viewProjectionMatrix = Matrix.mult(projectionMatrix,viewMatrix);<br />var invViewProjectionMatrix =Matrix.inverse(viewProjectionMatrix);<br /><br />//apply the inverse projection view matrix get us into world space<br />var worldM = Matrix.multTranslate(invProjectionViewMatrix,screen3D);<br /><br />//I can mult this worldM matix by viewProjectionMatrix now to get back to my normalized screen coords .<br /><br />var normScreenM = Matrix.multTranslate(projectionViewMatrix,worldM);<br /><br />//However taking the worldPoint coords....<br />var worldPoint = Matrix.getTrans(worldM);<br />//...and multiplying the projectionViewMatrix to it does not work<br />var normScreenM2 = Matrix.multTranslate(projectionViewMatrix,worldPoint);<br /><br />So, I do not get the normalised screen coords from the product of (worldPoint * projectionViewMatrix). I only can get them back if I have the full matrix to multiply (worldM * projectionViewMatrix).<br />I was trying to apply the inverse ops as a sanity check make sure everything checked out. Unfortunately there is something I have missed. I can't get back to my normalised screen coords multing with the worldPoint So I'd really appreciate it if you have a moment/idea of whats wrong to help me work this brain banana out...<br /><br />Many thanks!<br />Wil handsfelloffhttps://www.blogger.com/profile/00191926171647058058noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-22992325417133668542012-04-08T13:34:58.062+02:002012-04-08T13:34:58.062+02:00Hello all
I read the conversion function get3dPoi...Hello all<br /><br />I read the conversion function get3dPoint but I didn't understand how to use it. For example I have an image of a point with coordinates (x, y) respectively (2.3) how can I find the Point3D (x, y, z).<br /><br />And thank you in advancewassimbikhttps://www.blogger.com/profile/04688623356807465424noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-37841788198342583792011-09-06T18:57:14.554+02:002011-09-06T18:57:14.554+02:00I am working on a prototype which required me to d...I am working on a prototype which required me to do picking and 3D->2D transformation. I have done both but figuring out doing normalization took significant time. I think it would be a good idea if you explain normalization step in the post.<br /><br />I also took W=1 at the first place but after multiplying [x,y,z,W] with view matrix and projection matrix, W becomes >1 and thats why there was a strict need for me to divide x,y by W. <br /><br />Thanks for the help :-)Amithttps://www.blogger.com/profile/13689089119983550295noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-63532013698384130722011-09-06T12:58:19.957+02:002011-09-06T12:58:19.957+02:00By theory it should be considered and the division...By theory it should be considered and the division should be made. In this case though I assumed that the w coordinate is 1 and consistent throughout the data (therefore no division, I should point this out in the post). <br /><br />Check this two links here, maybe they help:<br /><br />http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node23.html<br /><br />http://www.di.ubi.pt/~agomes/cg/teoricas/04e-windows.pdf<br /><br />Anyways, what is the exact issue you are having?Denis Tosichttps://www.blogger.com/profile/14992340631798182965noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-79971745469820398102011-09-06T12:40:30.672+02:002011-09-06T12:40:30.672+02:00"Once these steps are done we get a point in ..."Once these steps are done we get a point in normalized coordinate space ([-1,1], [-1,1])". How?<br /><br />I did that by diving x,y,z clipping co-ordinates by clipping co-ordinate W. (which represents scaling factor of the scene).<br /><br />Did you miss this step or it wasn't really required?Amit Agarwalhttps://www.blogger.com/profile/05320475539093579097noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-66005183772706293382011-09-05T22:40:34.096+02:002011-09-05T22:40:34.096+02:00Hy Amit, sorry for the broken link - I'll try ...Hy Amit, sorry for the broken link - I'll try to find a good substitute for it (was some pdf on the net where I first saw these calculations a few years ago, and can't remember now how it was called anymore)...<br /><br />Regardin the 3D->2D conversion... the whole proces can be divided into a few simple steps, assuming that we have a 3D point in "absolute" coordinates. First we try to move that 3D into relative camera space by multiplying it with the view matrix. After that the product is multiplied by the projection matrix to get the point into clipping coordinates. <br /><br />Since the projection and view matrix are known at the begining I multipled them first and then the result matrix with the point (not neccessary for one point, but imagine you had 50 000 points to convert for whatever reason).<br /><br />Once these steps are done we get a point in normalized coordinate space ([-1,1], [-1,1]). We transform this 2D point into the domain ([0,1], [0,1]). Now, multiplying this with the window width/height we will get the pixel coordinates of the screen. <br /><br />Minor errors have to be expected (especially due to the round off when getting the normalized coordinates). You could try to specify the round function better - maybe using this here<br />http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithmDenis Tosichttps://www.blogger.com/profile/14992340631798182965noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-23305995222299823172011-09-05T10:40:09.078+02:002011-09-05T10:40:09.078+02:00Nice tutorial Denis! Few points:
1) Can you descr...Nice tutorial Denis! Few points:<br /><br />1) Can you describe what exactly you did while doing a 3D to 2D conversion. Code is fine but for me its giving little offset errors, so to rectify that I need to understand what the code is trying to do.<br /><br />2) mouse picking tutorial link is not working.Amithttps://www.blogger.com/profile/13689089119983550295noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-12977103854249060132011-08-29T21:31:55.448+02:002011-08-29T21:31:55.448+02:00Hi Ben, thanks for the comment, appreciate it a lo...Hi Ben, thanks for the comment, appreciate it a lot! Regarding the matrix order: the multiplication order is actually a convetion thing. Depending on whatever you are interpreting points as column or row vectors, and using row or major column mode, the order can change. In this specific case here I assumed the points to be row vectors and the matrices row major (e.g. translation component in the matrix indices 12, 13 and 14). Write down on a piece of paper the operation point*world*view*projection in math notation and you'll see what I mean. <br /><br />P.S. I anyways planned to have a post or two about transformations in detail, thanks for reminding me :)Denis Tosichttps://www.blogger.com/profile/14992340631798182965noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-72927210779506833222011-08-29T14:23:16.748+02:002011-08-29T14:23:16.748+02:00Nice tutorial, clear and a good read.
The only ti...Nice tutorial, clear and a good read.<br /><br />The only tiny thing I noticed, was:<br /><br />Matrix4 viewProjectionInverse = inverse(projectionMatrix * viewMatrix);<br /><br />Order of the matrix multiplication:<br /><br />Multiplication order should be switched to be:<br /><br />viewMatrix * projectionMatrix.<br /><br />Thanx for a great tutorial.<br /><br />BenBenhttps://www.blogger.com/profile/03459849292272551987noreply@blogger.comtag:blogger.com,1999:blog-8577130439755471155.post-54860673372819399972011-06-15T10:35:29.792+02:002011-06-15T10:35:29.792+02:00The code looks fine to me - the only value that he...The code looks fine to me - the only value that here is unknown is the pvMatrix. I guess that one should be correct since you are rendering your scene, but double check if it has the correct value... I would try (if you did not already) to convert world1 back to screen space (do you get the event.offSet values again?). Otherwise it's the same math as in my codeDenis Tosichttps://www.blogger.com/profile/14992340631798182965noreply@blogger.com