Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Mapping mouse x,y to local world x,y equivalents  (Read 1223 times)
0 Members and 1 Guest are viewing this topic.
Offline jleone

Junior Newbie

« Posted 2006-02-10 16:59:47 »

I am capturing x,y mouseclicks on a Canvas3D and I want to see how they translate to x,y coordinates based on the coordinate system of  a specific shape in the scene.  I am able to convert the mouse coords to virtual world coords using a previously posted approach (pasted below), but I need the coords relative to the shape (which may be rotated,
translated, or zoomed in relation to the main virtual world). 

Is this clearly described?  Any ideas?

     * determines a corresponding virtual world point given a canvas point.
     * @param Point3d  the point on the canvas
     * @return Point3d  a virtual world point corresponding to thecanvas point
     *                  provided.
    public Point3d getCanvasPtToVworldPt(int x, int y) {
         // convert the canvas point to ImagePlate coords
        Point3d VworldPt = new Point3d();
        this.canvas.getPixelLocationInImagePlate(x, y, VworldPt);

        // transform the point from an imageplate coordinate to a
        // coordinate
        Transform3D imagePlateToVworld = new Transform3D();

        Point3d centerEyePt = new Point3d();

        //now compute the z=0 value  in the centereye to VworldPt pt
        //centerEyePt_VworldPt = alpha *centerEyePt_planePt with
        double alpha = 0.0;

        if ( VworldPt.z != centerEyePt.z ) {
            alpha = centerEyePt.z /(VworldPt.z - centerEyePt.z);

        Point3d planePt =  new Point3d(
                        centerEyePt.x- alpha *(VworldPt.x - centerEyePt.x),
                        centerEyePt.y - alpha *(VworldPt.y - centerEyePt.y),

      return planePt;
Offline Jeff

JGO Coder

Got any cats?

« Reply #1 - Posted 2006-02-11 01:55:18 »


If I am understanding you correctly I would getLocalToVWorld on the shape node and take the inverse.

But I dont knwo how you plan to map 2d coordinates into a 3D coordinate system.  Your missing one coord.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!
Pages: [1]
  ignore  |  Print  

EgonOlsen (74 views)
2018-06-10 19:43:48

EgonOlsen (55 views)
2018-06-10 19:43:44

EgonOlsen (74 views)
2018-06-10 19:43:20

DesertCoockie (254 views)
2018-05-13 18:23:11

nelsongames (154 views)
2018-04-24 18:15:36

nelsongames (154 views)
2018-04-24 18:14:32

ivj94 (895 views)
2018-03-24 14:47:39

ivj94 (156 views)
2018-03-24 14:46:31

ivj94 (808 views)
2018-03-24 14:43:53

Solater (172 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!