Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 721 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
Vworld
        // coordinate
        Transform3D imagePlateToVworld = new Transform3D();
        this.canvas.getImagePlateToVworld(imagePlateToVworld);
        imagePlateToVworld.transform(VworldPt);

        Point3d centerEyePt = new Point3d();
        this.canvas.getCenterEyeInImagePlate(centerEyePt);
        imagePlateToVworld.transform(centerEyePt);

        //now compute the z=0 value  in the centereye to VworldPt pt
        //centerEyePt_VworldPt = alpha *centerEyePt_planePt with
planePt.z=0
        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),
                0.0);

      return planePt;
Offline Jeff

JGO Coder




Got any cats?


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

hmm.

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!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (16 views)
2014-09-21 02:42:18

BurntPizza (13 views)
2014-09-21 01:30:30

moogie (13 views)
2014-09-21 00:26:15

UprightPath (24 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (71 views)
2014-09-10 13:57:51

TehJavaDev (96 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!