[java] Cameras and viewports and so on

Started by
12 comments, last by d000hg 16 years, 9 months ago
I'm quite experienced with the theory of simple 3D graphics, and also the way it's done through D3D. I started looking at Java3D today, with the task of rendering a bunch of primitives at particular locations, with a camera. I'm finding it pretty confusing. I got my primitives in the universe at the right place, and got a simple light. I kind of got the camera view point to move, but when it gets more than about 30 from the objects they stop being rendered. Is there a "crossover" tutorial showing a D3D guy how to use all the classes in J3D to control viewports, transformations and so on?
Advertisement
These links should help.

Killer Game Programming in Java
Pro Java 6 3D Game Development
This space for rent.
I'm still not getting anything useful. Every tutorial I can find does things in apparently a totally different way. Some just have a main method which somehow sets up a 3D scene which is rendered with no painting or canvas being used. Others do all kinds of wierd things. Not to mention that most seem to be applet based and I want to write a Java application.

What I want is the skeleton of an app which has an update and render loop (or renders when a repaint is required), and allows me to create a scene graph and update it. So I could create say a moving cube or something like that. I think I've got the basics of using the scene graph but not how I'm supposed to integrate this within an app.
Java3d is (IMHO) a horrible API, and hideously overcomplicated for what little it does. If you're already familiar with D3D, you might want to consider using lwjgl, which gives you direct OpenGL access and should be somewhat more familiar (and flexible) than your current route.
Wee I decided to try it, using this tutorial: http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/opengl/basicopengl

I'm using net-beans so I got the jars and added them to my project in exactly the same way I for for Java3D, it compiles just fine but when I run it I get
Exception in thread "main" java.lang.NoClassDefFoundError        at graphinterceptors.Game.cleanup(Game.java:107)        at graphinterceptors.Game.main(Game.java:42)Java Result: 1


The exception is thrown when the Display class is used. I googled and found a bunch of people with the exact same problemon this same tutorial, but no solution. Is there anything special about lwjgl which explains why adding the jars as normal doesn't work?
There's some .dll's you need to add to your "c:\program files\jreX.X.X\bin folder". They should be located in the LWJGL zip file

It also couldn't hurt to move the LWJGL jars into "c:\program files\jreX.X.X\lib\ext". It might not be necessary, though I don't know how Netbeans adds external libraries. In Eclipse you don't have to move the jars.

(psst! Eclipse > Netbeans! :)
The lwjgl jar files need to be available on the classpath, usually you specify that on the command line with the "-cp" argument, however I've no idea how you actually do that in NetBeans, sorry. While you're at it, make sure you set the "-Djava.library.path" flag to point to the location of the native files (eg. the .dlls on windows).

Don't just dump the files into the /lib/ext or /bin dirs, as then you'll have that version of lwjgl for every app you run, so a lwjgl game with a different/newer version included in it will break. You'll also confuse the heck out of yourself should you ever need to upgrade version.

You might find some netbeans-specific help on the forum.
I'll have a look. But I find it odd that for Java3D I just stuck the jar somewhere and added it as a dependency/external jar to the project, and it worked. I didn't think one had to mess around with the claspath within the IDE, apart from adding jars so it would compile.

And I use Eclipse at work, but for playing around I prefer netbeans, although I don't really know why, they seem pretty much the same. And that's even when taking into account that I have MyEclipse plugin at work.
Last time I used it, J3D was distributed in a slightly odd way with an installer. Did you run a J3d installer? If so it probably setup the global classpath to point to the newly installed jars. IIRC this is a pain because you have to get your *users* to run the install procedure themselves, whereas most java libraries you just distribute whichever version you're using along with the app.

You're right though, adding the jar to the project should add it to the classpath, and in Eclipse it does exactly that. However I don't know NetBeans so you'll have to poke around manually and see how it handles things. This might be useful.
No there was no J3D installer. I just copied the jars to an arbitrary location on c: which is exactly what I did for lwjgl. I had added the jar to the classpath as described in that link - before doing this the IDE had errors for all the classes, afterwards compilation is fine. So I've done everything right, I think.

It's not an actual OpenGL issue is it? Or a Java version issue? I'm on Java 1.5.something with lwjgl 1.1.

This topic is closed to new replies.

Advertisement