Java
I'm not a huge fan of Java. I can't get excited about a language that's essentially dead but offers no low level functionality like C. No pointers. No passing by Ref. No decent general IDE (akin to VS 2005). However, I have tinkered with it inasmuch as JOGL in order to put some OpenGL applets on HTML pages.
Below is a simple bouncing ball Java applet. Fully elastic collisions in 2 dimensions without friction or gravity. Each object is given a random velocity in x,y, the iterations are based on a small delta time increment (.1) compared to low value velocities (3, or 4 initial units per dt). Obviously, this is a very basic graphics object.
|
MSFT J++ versus Sun. Maybe MSFT did run with the ball a bit with their version of MSJVM, creating Windows specific API optimizations and additional features thereby weakening Sun's insistence on any platform, anytime. Sun sued, and J++ was discontinued. There is no applet equivalent or alternative to Java Applets, and I'd like to see what MSFT can do with the idea, but it is not meant to be. Sun's insistence on keeping with the "write once, run anywhere" in the end has turned out to be well worth it though. Although of course, it complicate things for developers. Since I can write code using OpenGL, I'm satisfied. I'd rather use DirectX because I've used it much more than OpenGL in the last couple of years, but OpenGL is plenty powerful for my purposes. |
Non-3d API (non-JOGL, non-OpenGL, non-DirectX, non-Java3d) cheesoid (applet) graphics part I(omitted)
11/2006
Non-3d API (non-JOGL, non-OpenGL, non-DirectX, non-Java3d) cheesoid (applet) graphics part I
|
<= Variable mass and crudely proportional (but not cube rooted) radii. With elastic collisions, some of the objects may collide at low speeds, and it's possible for a pair to get sort of hung up on one another due to the asymmetry in their positions pre-detection versus their positions the iteration after the collision. They may end up on the next iteration, 'colliding' again even though they are moving away from one another because their positions + radii still overlap, and another set of collision calculations will move them back toward one another as though they were colliding juxtaposed (because the collision equations simply reverse the component vector velocities). Basically two objects colliding with one another cannot collide again without one of them colliding with another object first (1) Assuming the collisions are in a Euclidean space 2) Assuming no other forces like gravity are acting on them. This smoothes out the simulation. If ballX's last computation cycle included a collision with ballY, and it detects they're colliding again without either ball having collided with something else in the mean time, then do not register another collision. This will allow the balls that have collided and are moving away from one another but are still overlapping not to collide again until there's a legitimate reason to do so. Quick and dirty.
|
OpenGL version:(JOGL--OpenGL port to Java) ==> Download Source
You must first install Java Web Start in order to use the demo below. JWS, to which Microsoft has answered with ClickOnce will simply launch the application from your browser (but it will not run in your browser).
|
|
<=Jogl collider Sun has created a graphics API called Java3d which is based on OpenGL and DirectX (you can choose, apparently, which to use based on the OS). I spent a week or so going through J3D, reading the documentation and trying to work out how to write for it because I was having trouble getting JOGL off the ground (until I found Kiet Le's redbook site). But, while it's easy to get something on the screen, it's too restrictive for the average OpenGL hack who wants (and knows how to) get into the nuts and bolts of transformations. Java3d is different (although logical) from OpenGL or DirectX. It's a middleware API a level higher than OpenGL/DirectX (where higher means, it takes care of more details behind the scenes than a language less high), and the entire scene is class-based. You create a universe, a branch, and group objects, then you generate leaves, or primitive objects; you can add mouse rotation classes to move objects in the scene around, but it handles all of the functionality itself, and there's no easy way to get in and manipulate things the way I'm used to. So, for me it was back to JOGL, and I was finally able to get it working. Once you have it up and running, it's just a matter of putting your C++ OpenGL code in the render function. Here's a great tutorial for JOGL that covers most of the lighting you'd ever want in a basic physics program. If you know OpenGL, then there isn't that much you need to do in going from C++ OpenGL to Java JOGL; there's a little difference in the way you get a GL context and loop through the render function, but this is very nicely taken care of with the JOGL animator class. The NeHe ports are also good, but I prefer Le's tutorials because he compresses at least the basic lessons into very basic 1 file classes you can easily modify, test, and deploy. The NeHe tutorials have help overlays, keyboard overlays, a "common" directory and other extraneous stuff that make it too difficult for me to track down issues; and also, I don't want a bunch of overlays floating around that I didn't specifically create for a reason, and I don't create things unless I use them. I will add what I need later.
|
Unfortunately, getting Java Web Start to work with a JOGL program is confusing, mostly unsupported, and requires a lot of google searching and tinkering. The GUI representations of Java don't really work very well (in my experience w/ NetBeans), so you can't just design a form the way you'd design a windows form, just dragging and dropping things visually and moving them around. With Java, typing explicit XML or executing commands from a DOS prompt are standard fare, and coming from .Net where you only code your new stuff (your new classes, methods, properties, handlers, delegates), it takes some getting used to.
If you d/l NetBeans, you can readily deploy an application that uses the standard JDK library without much effort. After you have written your program and built it, a jar file is created with appropriate directories for distributing the application. Furthermore, enabling Java Web Start creates the jnlp XML file required to launch the application, and NetBeans will even launch a tomcat servlet so you can simulate the final online version. However, with JOGL, this didn't work for me. At all. Finally, after many hours of futzing around, it does work, thanks primarily to Kiet Le's site once again.
I will now venture in a couple of different directions with Java (and .net)
Convert my VB6 and .net apps to Java and deploy them with JWS
Attempt to create a JOGL applet that runs in-browser (rather than simply launched via browser).
Do the same with ClickOnce if I can find a reasonable way to authenticate my applications (which may include getting vs2005). I don't understand why clickonce doesn't offer a sandbox wherein packages can be deployed without authentication because they're limited to a sandbox.
(Unable to get Mozilla to view localhost for testing--in Mozilla, type about:config. Filter with ntlm. For network.automatic-ntlm-auth.trusted-uris add localhost; brought you to by lobo, here)
Converting a Gravity Plane demo from vb 6.0 to Java has brought up a few issues with Java. One minor problem w/ Java is the inability to pass variables by reference. The motto seems to be if an object has more than one variable or property element to it, create a class for it.
For this, you must have the Java Runtime Environment 6 (JRE 6)
Gravity Plane Prog = Download Source
Overall however, I'm happy with the performance of the Gravity Plane mini-prog in Java.
kurt bingham
KB 2006
Kurt Bingham 1/07