Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (855)
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  
  Trying to project a 2d drawing in 3D space ...  (Read 2643 times)
0 Members and 1 Guest are viewing this topic.
Offline augusto

Senior Newbie

« Posted 2005-05-12 00:13:29 »

... 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 :-)

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!
Offline rexguo

Junior Devvie

Real-Time Java

« Reply #1 - Posted 2005-05-12 02:29:30 »

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

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

.rex - Technologist + Designer
Offline ozak

Junior Devvie

Java demon has no respect for bad code!!!

« Reply #2 - Posted 2005-05-12 05:10:56 »

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 Smiley) 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.

Want to do multiplayer? Why not try my free Socky socket server?
It's scriptable through JavaScript!
Check it out at
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline devent

Junior Newbie

Java games rock!

« Reply #3 - Posted 2005-05-12 12:04:24 »

you can get 3D-effect with bumpmapping  Wink
Offline augusto

Senior Newbie

« Reply #4 - Posted 2005-05-12 19:57:41 »

> 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.
Offline cylab

JGO Kernel

Medals: 185

« Reply #5 - Posted 2005-05-13 05:50:32 »

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.

Mathias - I Know What [you] Did Last Summer!
Offline ryanm

Senior Devvie

Projects: 1
Exp: 15 years

Used to be bleb

« Reply #6 - Posted 2005-05-13 10:12:09 »

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.
Pages: [1]
  ignore  |  Print  

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

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

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

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

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

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

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

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

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

Solater (879 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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!