Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How Do I transform 2d coordinates of the mouse into 3d?

How Do I transform 2d coordinates of the mouse into 3d?

Scheduled Pinned Locked Moved C#
question
12 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S SherKar

    i want to transform the coordinates of the mouse into 3d projection Ramez Raafat

    L Offline
    L Offline
    leppie
    wrote on last edited by
    #3

    You have to use the Isolatic Mouse cross pollenation subfrequency. leppie::AllocCPArticle("Zee blog");
    Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.

    C 1 Reply Last reply
    0
    • L leppie

      You have to use the Isolatic Mouse cross pollenation subfrequency. leppie::AllocCPArticle("Zee blog");
      Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #4

      leppie wrote: Isolatic Mouse cross pollenation subfrequency Yes, but don't forget to cross-connect it to the third phase inducer plasma manifold. Otherwise the calibration of the dilithium crystal harmonisation routine will be ineffective and cause a phase variance feedback loop that will cause the automatic ejection of the mouse core. --Colin Mackay--

      "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown) Enumerators in .NET: See how to customise foreach loops with C#

      N 1 Reply Last reply
      0
      • C Colin Angus Mackay

        leppie wrote: Isolatic Mouse cross pollenation subfrequency Yes, but don't forget to cross-connect it to the third phase inducer plasma manifold. Otherwise the calibration of the dilithium crystal harmonisation routine will be ineffective and cause a phase variance feedback loop that will cause the automatic ejection of the mouse core. --Colin Mackay--

        "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown) Enumerators in .NET: See how to customise foreach loops with C#

        N Offline
        N Offline
        Nick Parker
        wrote on last edited by
        #5

        Don't forget to engage the subatomic 3D hypogenerative mesh analyzer, otherwise all multi-axis cross pararllel calculations will be off by at least +/- 3 subneural nanometers. - Nick Parker
          My Blog

        C 1 Reply Last reply
        0
        • N Nick Parker

          Don't forget to engage the subatomic 3D hypogenerative mesh analyzer, otherwise all multi-axis cross pararllel calculations will be off by at least +/- 3 subneural nanometers. - Nick Parker
            My Blog

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #6

          Nick Parker wrote: ...will be off by at least +/- 3 subneural nanometers. True, but at that error variance it is also possible to activate the heisenberg compensator in order to mitigate any misalignment of the multi-axis cross parallel interconnectors. Thus allowing a steady stream of negatively charged subatomic particles to pass freely through the integral data coupling array. ... You know, I think we've all been watching too much Science Fiction. --Colin Mackay--

          "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown) Enumerators in .NET: See how to customise foreach loops with C#

          N 1 Reply Last reply
          0
          • C Colin Angus Mackay

            Nick Parker wrote: ...will be off by at least +/- 3 subneural nanometers. True, but at that error variance it is also possible to activate the heisenberg compensator in order to mitigate any misalignment of the multi-axis cross parallel interconnectors. Thus allowing a steady stream of negatively charged subatomic particles to pass freely through the integral data coupling array. ... You know, I think we've all been watching too much Science Fiction. --Colin Mackay--

            "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown) Enumerators in .NET: See how to customise foreach loops with C#

            N Offline
            N Offline
            Nick Parker
            wrote on last edited by
            #7

            Colin Angus Mackay wrote: Thus allowing a steady stream of negatively charged subatomic particles to pass freely through the integral data coupling array. Too true, but remember that by taking the integral of the guid generating function we can discern the total surface area of the applications UI in pixels. :) Colin Angus Mackay wrote: You know, I think we've all been watching too much Science Fiction. Says who?? :omg: - Nick Parker
              My Blog

            1 Reply Last reply
            0
            • S SherKar

              i want to transform the coordinates of the mouse into 3d projection Ramez Raafat

              B Offline
              B Offline
              Bryan White
              wrote on last edited by
              #8

              I'm uncertain whether this thread is supposed to be taken seriously or not (judging by other responses), but I have converted mouse coordinate X,Y into a ray from Point1(X,Y,Z) to Point2(X,Y,Z) in OpenGL. If that's any good to you, reply to me and I'll post the code. Regards Brewman

              C 1 Reply Last reply
              0
              • B Bryan White

                I'm uncertain whether this thread is supposed to be taken seriously or not (judging by other responses), but I have converted mouse coordinate X,Y into a ray from Point1(X,Y,Z) to Point2(X,Y,Z) in OpenGL. If that's any good to you, reply to me and I'll post the code. Regards Brewman

                C Offline
                C Offline
                Colin Angus Mackay
                wrote on last edited by
                #9

                It is a serious thread. Some of us were just having some fun. :-D --Colin Mackay--

                1 Reply Last reply
                0
                • S SherKar

                  i want to transform the coordinates of the mouse into 3d projection Ramez Raafat

                  C Offline
                  C Offline
                  Colin Angus Mackay
                  wrote on last edited by
                  #10

                  You should post your reply to me through the forum and not directly in my email. You might receive a broader response. START EMAILED REPLY ---- hi i am in virtual 3D room and i want to choose something from the wall END EMAILED REPLY ---- --Colin Mackay--

                  S 1 Reply Last reply
                  0
                  • C Colin Angus Mackay

                    You should post your reply to me through the forum and not directly in my email. You might receive a broader response. START EMAILED REPLY ---- hi i am in virtual 3D room and i want to choose something from the wall END EMAILED REPLY ---- --Colin Mackay--

                    S Offline
                    S Offline
                    SherKar
                    wrote on last edited by
                    #11

                    sorry for disturbing u colin

                    1 Reply Last reply
                    0
                    • S SherKar

                      i want to transform the coordinates of the mouse into 3d projection Ramez Raafat

                      B Offline
                      B Offline
                      Bryan White
                      wrote on last edited by
                      #12

                      This code is for CsGL, a C# wrapper for OpenGL, but I'm sure that the concept applies to other graphical 3D stuff. In a 2D representation of a 3D scene (i.e. most pictures, TV, cinema, etc), a point on the 2D surface represents a line in 3D space. In openGL, this 3D space is bounded by clipping planes. The following code takes the mouse's X-Y coordinates and calculates a line (or ray) that passes through those clipping planes. Note that the OpenGL mouse Y coordinate is 'inverted' to Windows mouse Y Coordinate. Note that the following code won't quite work 'out of the box' (I've removed some stuff to condense things), but you should be able to construct working code with little effort. - You need the ModelView, ModelPort & Projection state, saved like the following code: public class OGLMatrixState { public void Save() { GL.glGetDoublev(GL.GL_PROJECTION_MATRIX, savedProjectionMatrix); GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, savedModelviewMatrix); GL.glGetIntegerv(GL.GL_VIEWPORT, savedViewportArray); } private double[] savedProjectionMatrix = new double[16]; private double[] savedModelviewMatrix = new double[16]; private int[] savedViewportArray = new int[4]; } - You need the built-in conversion routines that OpenGL provides: public static SEG.Line ViewXYToRay(double vX, double mouseY, OGLMatrixState matrixState) { double vY = matrixState.Viewport[3] - mouseY; double pX,pY,pZ; SEG.Point nearPt = new SEG.Point(); SEG.Point farPt = new SEG.Point(); GL.gluUnProject(vX, vY, 0.0, matrixState.Modelview, matrixState.Projection, matrixState.Viewport, out pX, out pY, out pZ); nearPt.X = pX; nearPt.Y = pY; nearPt.Z = pZ; GL.gluUnProject(vX, vY, 1.0, matrixState.Modelview, matrixState.Projection, matrixState.Viewport, out pX, out pY, out pZ); farPt.X = pX; farPt.Y = pY; farPt.Z = pZ; SEG.Line rayFromNearToFar = new SEG.Line(nearPt, farPt); return rayFromNearToFar; } Hope this helps Regards Brewman

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups