This site requires JavaScript, please enable it in your browser!
Greenfoot back
bourne
bourne wrote ...

2011/3/1

Multiplayer & 3D

bourne bourne

2011/3/1

#
There's two things I am very interested in: 1. Networking multiplayer between multiple applets, is it possible? And also highscores? 2. 3D, - everywhere I look it seems to be very confusing. It would be nice to have an example of these with very good comments. Perhaps a tutorial. Or maybe a great place to read up on them.
JL235 JL235

2011/3/1

#
Both of these certainly would be cool to have. >> 1. Networking multiplayer between multiple applets, is it possible? And also highscores? With a standalone Greenfoot scenario you can use a networking library today. With a Greenfoot scenario on the Gallery you cannot do networking. For security reasons the applets here are only allowed to community with the Gallery. This is something built into Java itself to help stop applets from performing something malicious. Building networking and highscores into the Gallery have crossed our minds several times. If you are hosting your Greenfoot applet on your own website then the applet can communicate to your site; who can then send back data. You could then have applets communicate with each other via calls to your site. It would require lots of coding and might be too much trouble for what it's worth (especially since you couldn't host the applet here); but if that interests you then that is a possible solution. >> 2. 3D, - everywhere I look it seems to be very confusing. Do you mean Raycasting (like some of the things BuilderBoy has been working on) or proper 3D using the graphics card? For raycasting there is a nice tutorial here http://www.student.kuleuven.be/~m0216922/CG/raycasting.html that you can follow. For proper 3D, using your graphics with OpenGL, you can't really use Greenfoot. You can use Java, but it would be outisde of Greenfoot.
bourne bourne

2011/3/3

#
Thank you for the answers :) Was thinking proper 3D i suppose.
dangjavageek dangjavageek

2011/3/7

#
Greenfoot is focused on 2d scenarios / simulations / games / microworlds. And it is excellent for that, much better than trying to wade through swing tutorials or Java2D tutorials with eclipse / netbeans / jdeveloper / etc. In terms of "proper" 3D, have a look at the Java Monkey Engine, one of the best 3D Java environments going. It's now bundled as it's own development environment and you can grab alpha 3 off of jmonkeyengine.org. Since you can have other windows through greenfoot, I would suppose it's possible to load the Java Monkey Engine libraries as external libraries and have Java Monkey Engine do it's thing in an external 3D view while having Greenfoot actors do their thing in the traditional 2d Greenfoot world view. But I have not tried that yet so I don't know if there are obstacles in that path that would prevent doing so.
mjrb4 mjrb4

2011/3/11

#
JMonkey is great at what it does and theoretically I suppose you should be able to get it working with Greenfoot. It uses native libraries though for the graphics (either JLWGL or JOGL) so it'd be a bit of work getting it up and running and you wouldn't be able to upload the scenarios you created to the gallery (well, you would - but they wouldn't work!). In short, if you want to use JMonkey then it's a great tool (though documentation isn't always great) but there's not an enormous amount of point I can see in getting it to run with Greenfoot.
JL235 JL235

2011/3/12

#
>> theoretically I suppose you should be able to get it working with Greenfoot. Technically you can just create a new window within your scenario where you can render 3D (using JOGL or JLWGL). But you might as well build that as a standalone Java application rather then use Greenfoot. For getting 3D on the actual world you would need to safely replace the current component of Greenfoot that does that drawing with an OpenGL context you can render 3D to. You could attempt this from one of two places. First you could download the Greenfoot source code (off greenfoot.org), apply the needed changes and then compile your own copy of Greenfoot. This would be the proper way to introduce 3D into Greenfoot, but it is not a challenge that should be taken likely. A second approach could be to attempt to apply this change from within a user scenario. You could use reflection to navigate around Greenfoot internally in order to apply your changes. This approach has the advantage that it's contained entirely within a user scenario, but this would be _FAR_ more difficult to build then the first approach (and potentially it could even be impossible). As well as changing the surface you draw to you would also need to re-write the GreenfootImage class so images still work, and there would be a handful of other places where things would need to be re-written. You'd also have to think up a way to expose the 3D functionality you need. Will you use a 3D engine (such as JMonkey) or just offer OpenGL calls? When you export a scenario it's bundled with some libraries, these would also need looking at. However even with 3D support added to Greenfoot it would still not work on the Gallery. The Gallery needs it's own changes in order to support 3D (they are quite small, but very fiddly). Again I would stress this is not trivial to build (otherwise I would have attempted this myself a long time ago). But that is a rough idea of what it would take.
MatheMagician MatheMagician

2012/7/6

#
Jmonkey really is helpful, and in my opinion is an excellent second step after greenfoot.
You need to login to post a reply.