Cooper in 3D with JMonkeyEngine3

One of the great things about Cooper is that it gives you access to the whole wide world of Java libraries. So besides now being able to build Android applications with Oxygene (Objects Pascal), you can now access any of the wide range of Java libraries with your favorite language.

JMonkeyEngine3 is an Open Source, Open GL game engine for Java. It has quite an impressive collection of features, and all those features are accessible via Cooper. I translated one of the JME3 demos to Cooper, and then enhanced it some. I published a video showing it in action.

Because Cooper talks directly to the JME3 engine, the API calls are all the same, which makes translating really easy. There is no indirection between your code and the API.

When Cooper – aka Oxygene for Java – ships, it will include a Java-to-Oxygene converter. Since that isn’t included yet, I tried the C#-to-Oxygene converter that is included in the Delphi Prism product (Oxygene for .NET). It was able to handle a lot of the simple stuff, but I still needed to clean it up some. Once the Java translator comes, it will do a much better job.

Besides being able to work in your favorite language, Cooper also brings a number of advantages over Java. A small and obvious one is automatic properties.

So this code . . .

bulletg.setLocalTranslation(cam.getLocation());

. . . becomes this code . . .

bulletg.LocalTranslation:= cam.Location;

The Cooper compiler recognizes the “set” and “get” prefix on methods (when the set method only takes a single parameter) and it becomes a property. This simplifies the code and also allows for code compatibility with Oxygene for .NET.

The bottom line is that accessing 3rd party Java APIs is really easy and opens a whole new world up to your application development, while still using your favorite language.

jim

0