Trying to project a 2d drawing in 3D space ...

… is jogl the right hammer?

Basically, I have a 2D renderer written in Java2D for all kinds of schematics and maps (not quite GIS) that we use a lot. One of the features we’d like to play with is the following;

Say we have a small map rendered in 2D of a geographical area. Scattered across this maps we have “values” we track that are defined at different levels across the map.

What I’d like to do is rotate the map a bit, (or let users rotate the map) say like an isometric version of it. Then have the values that are contained in the map be represented by 3d lines (maybe normalized) that graphically show what values are higher than the others. At one point, I might even want to create a mesh with these values, but for now imagine they are just cylinders that project from the 2d map.

So if I understand jogl well enough, the apporach should be to somehow grab the rendered image from my JComponent that draws maps (this is easy) and then load that image as a texture on a square surface.

When I redraw the image, I update the texture.

Does this make sense or am I making my life more complicated? I seem to remember some library out there, maybe for Java3D that would let you project the drawing of a JComponent onto a 3D surface. I may have imagined this :slight_smile:

Is jogl the right technology for this, or should I look at something more high level. For this functionality, which seems fairly simple, it seems jogl is a good fit.

Any ideas, opions? Thanks!

Yes it is definitely possible to get a Java2D
rendered image across to JOGL as a texture.
I’ve done quite a bit of this in fact. The way
I’m doing it requires a custom BufferedImage
that wraps an int[] supplied by me.
This is for 2 reasons:

  1. JOGL can update a texture directly from an int[].
    Not the fastest approach, but good enough for
    many purposes.

  2. I can perform a swizzle from Java2D’s native
    pixel format (ARGB) to OpenGL’s fast pixel format
    (BGRA) by operating directly on the int[]. If you
    get Java2D to render in BGRA, you’re gonna get
    horrendous speeds; if you wanna get OpenGL to
    update the texture in ARGB, there’s a problem
    because ARGB is not supported, only RGBA :slight_smile:

Also note that most OpenGL drivers support
a max of 2048x2048 texture size. If your image
is bigger than this, you either have to scale
it down or split it into tiles that you manage
yourself.

.rex

Don’t you want to render the map in 3D to get the proper isometric perspective? If you map schematics are made of lines with heights (like in the SOSI geographical format used in norway :)) you could simply render it as 3D lines and get a rough 3D representation of your map.

Just mapping the image as a texture will allow you to rotate it, but you’ll get no 3D effect.

you can get 3D-effect with bumpmapping :wink:

Don’t you want to render the map in 3D to get the proper isometric perspective?

That would be nice, but the information we have is very flat, is has no z information, so it’s practically impossible. That would be very neat, but it’s really 2D drawings.

The reason I want to do this is just to experiment to see how 3D visualizations can help you analyse this type of information. When you add the values (what I want to project from the map) to the coordinates, then you get a quick view of problem areas.

Thanks for the suggestions, I have a lot of stuff to learn, I just wanted to make sure I’m using the right tool. This is not for a game, but it seems like a perfect fit.

Maybe you should look into Java3D if it’s for visualization. It might be easier to use a scenegraph instead of an immediate mode API like OpenGL.

I dunno, all he’s after sounds like a textured quad and some gluCylinders.
I would have thought that a full-blown scenegraph was a bit of overkill.