Mix 2D and 3D in games

I’m just thinking to start a game project and I want some advices. I want to use pre-rendered 2d backgrounds but 3d characters. Is it possible to do this using Java3D or should I have to find a way to display my 3D characters using Java2D ?

Do you know some engine that could help me with that kind of stuff ?

Any advice are welcome since I’m a beginner in 3D environnements.

are the 3d characters only moving in the x and y planes or do they move in the z as well? If only x and y then why not pre-render them as well and go fully 2d?

Also possible with Java3D. Look out for classes around Raster, OrientedShape, Background…

Yes, the 3D characters must be able to move on the z axis and get smaller or bigger when moving on this axis.

I would definitely look to use Java3D for this- it is not so easy to get started, but you will be able to get exactly the kind of effect you are looking for. I’m thinking something along the FF7 or Resident Evil avenue?

FF7 is exactly what I had in mind. Is anybody aware of some good tutorials to begin with Java3D ?

Also, do you think that GL4Java is a better alternative that Java3D (for performance) ?

[quote]Is anybody aware of some good tutorials to begin with Java3D ?
[/quote]
Start with the samples, research the code at j3d.org.

As long as your app is simple, GL4Java might be faster for it’s a low-level API. The more complex it gets, the more code you’ll have to write yourself and the more the initial benefit will vanish.
(Depending on what you intend to do, this does not have to be true, but it’s likely to be)

What are you saying here? GL4Java works on lower level than Java3d always and I can’t see how the complexity of code will affect the speed of GL4Java, which initially is the benefit along with the immediate mode, unless you have other justification for GL4Java’s speed, that is.

Does not compute, please explain better.

Also, due the fact that OpenGL has generally bigger fanbase than Java3d, which initially is dependent on OpenGL has helped me to generate code many times faster. Also the fact that OpenGL has big communities unlike java3d helps since you can go ask around there.

I don’t want to turn this into flamefest, but Herkules is Java purist, which in my opinion makes him little bit blind. It is not a bad thing of course, but I suggest you try both before judging which one is better.

Of course, the speed of gl4java itself doesn’t change.

But the more complex the overall engine gets, the more stuff will be necessary to do all the approp. sortings (material, spatial, …), implement the approp. culling mechanisms, implement things like transparency sorts CORRECTLY and efficiently, allow for efficient collision detection/picking, make effects not stall the pipeline, integrate the sound into the spatial structure …

There a real lot of things to do getting from a rendering API to a true 3D engine. Most of them are not that much needed my simple games, more are needed for more complex games.

For myself I can say I know quite good about 3D technology from my days when I was young, but I am very sure that the Sun guys are far ahead of myself!

No, I’m neither blind nor a purist. I just know that if I felt I’d better use naked OpenGL, I’d do it in C or C++. Just for the reason you mention: then I could use all the things around for OpenGL.

I just see it the other way round. I don’t start with wanting to use Java, then look for a 3D API. It’s more that I see the great Java3D API (together with a great network API, a good GUI API, a good memory management system) and then feel comfortable that I can use Java with it.

For me, exploiting a well-behaved, powerful system where I feel that real experts built it is just pure fun. Implementing bounds determination and frustrum culling is NO fun. Did it before. Sucked.

I fall on the J3d side here too- I would say that if you don’t already understand OpenGL then there is probably not a lot to gain by using one of the java-ogl interfaces. You can do all the same stuff with J3d and if your world is not immensely complex I can’t see there being any noticeable difference at all. If it is, j3d may well be better.

I would definitely look at Selman’s java3d book and the sun tutorials to start with. There is also some good stuff at j3d.org for specific areas, and people here are always willing to give advice.

Unfortunately there is something of a dearth of basic tutorials to follow those up but people here and on the java3d-interest mailing list are helpful and very well informed, even if half of them will tell you you were wrong to use that API (whichever you choose) and you should have burn everything you own, forget everything you thought you knew and move to the mountains to be a hermit. Or at least change to GL4/lwgl/j3d/etc :slight_smile:

I would agree with herkules that if you use Java3D you will be able to get into the interesting bit a whole lot sooner, unless you find really complex maths really interesting.

Actually I found learning the maths really very interesting indeed, and I felt a great sense of achievement in getting things to work as expected when, honestly, I don’t really know anything about 3D graphics.

It’s also led to that deep understanding of things that you only get by looking under the hood and doing it yourself.

Cas :slight_smile:

I noticed the same excact thing as Cas, the deeper understanding.

At first I was like wtf give me back transform3d, but once I got into it I never wanted to look back. There is just… so much potential in openGL, which I fail to see when I look at java3d. It is not that java3d is just restricted, but also that you can’t do everything yourself.

Besides the math isn’t that hard. Doing 4x4 transform matrices should be a cake for anyone who has taken math in the university/college. Trigonometry, matrices, little transformations of functions, which you will see in 2d anyway. Not that hard at all.

In fact when I started with java3d it took me longer to get to this stage than with opengl. I admit that I’m not still fluent with opengl, but I’m going strong.

[quote]Besides the math isn’t that hard. Doing 4x4 transform matrices should be a cake for anyone who has taken math in the university/college.
[/quote]
What about those of us who did Philosophy? :’(

[quote]What about those of us who did Philosophy?
[/quote]
I’m afraid there is no hope for you. :smiley:

Captain-Goatse, I have the feeling that you are not really aware of whats lying in front of you…

You can mix Java 2D and 3D anyway you like (with java3D).
I do this for a space game.
The starfield background is simply a picture drawn in Java2D before the 3D.

If you want your 2D to be behind the 3D stuff, use
Canvas3D.preRender()

if you want 2D to be in front of 3D, use
Canvas3D.postRender().

Hope this helps.
Gérard