Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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  
  Need advisement on approach  (Read 692 times)
0 Members and 1 Guest are viewing this topic.
Offline jleone

Junior Newbie





« Posted 2006-02-04 21:08:12 »

I am creating a program that generates and displays 3 dimensional graphs.  I have the basics completed and the graph gets created, rotated, zoom, etc.

I want to add a crosshair feature so that one can analyze the specific data points with more detail.  As the mouse moves across the canvas, two lines would form an intersection. One of the lines is parrallel to the X-axis, the other Z.  On the side, I would dispaly the X&Z values as well as the Y value that is the result of the function with inputs X&Z.  Hopefully this explaination is pretty straight-forward.

There are two approaches I can think of. 

1. Represent the lines as shapes in the 3D graph and create a custom behavior that translates them as the mouse moves.  I'm a bit concerned about the performance impact of constantly translating the lines.  I also want these to stretch across the entire canvas, so I guess I would need to grow them as the person zoomed out?
2. Figure out how to overlay the lines on the canvas using Java2D.  This would bring some complexity as the underly graph was rotated and zoomed, since I would need to draw the lines at the correct angles.

Please advise, and if you can point to example code that would be much appreciated.

James
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2006-02-05 00:59:32 »

If you are looking for persective in the lines Id go ahead and use real 3D objects.

If you walways want them "flat" on the screen, you coudl use one of the many HUD systems people have designe for Java3D...

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
Offline jleone

Junior Newbie





« Reply #2 - Posted 2006-02-05 02:18:14 »

Jeff,

Thanks for the quick reply, perspective is what I'm going for.  Now I'm having some difficulty mapping the mouse location to the coordinates of the transform group that contains my graph shapes.  Below is the code I found that does a good job of mapping mouse coordinates to a point in the virtual world.

    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);

        //Logging.trace(10, "Center eye pt VW " + 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;
    }


I have tested this and it works pretty well.  Unfortunately this isn't enough.  I need to get the coordinates relative to the graph shape (which I have inside a transform object that can be rotated, zoomed, etc.).  I thought it would simply be a matter of applying the Transform3D of the graph's transformgroup to the point returned from the method above.  This doesn't work out as I expected.  Any ideas on how to take that point and convert it from being relative to the overall virtual universe, to relative to the transform group that I am focused on?

This didn't work:
       
       Transform3D t = new Transform3D();
        this.transformGroup.getTransform(t);       
        t.transform(planePt);
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.

ctomni231 (34 views)
2014-07-18 06:55:21

Zero Volt (30 views)
2014-07-17 23:47:54

danieldean (25 views)
2014-07-17 23:41:23

MustardPeter (27 views)
2014-07-16 23:30:00

Cero (42 views)
2014-07-16 00:42:17

Riven (44 views)
2014-07-14 18:02:53

OpenGLShaders (32 views)
2014-07-14 16:23:47

Riven (34 views)
2014-07-14 11:51:35

quew8 (30 views)
2014-07-13 13:57:52

SHC (66 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!