Suitable platform for a 2D simulator using java - java

I have to do my final year project and I'm planning to use a visual simulator to simulate it. So I have to create a basic simulator and the program would be run in java. But I have a problem as to what to use to create the simulator. Should I use jmonkey or java2D or java 3D. What I would want is a basic 2d simulator. Please help me out. It would be better if it's java based as I do all my development using java
thanks,
ps :- Im planning to do a simulation on human movement within a building in a panic situation. so what i would need is a 2D view of maybe a 2 room building with a door and a few dots to be represented as people. So when the simulation starts the people(dots) must go out of the building accordingly. What i need is how to create the UI/simulator. Like some kind of an API.

If I understand correctly what you need is a way to paint 2D content. I would guess that the painting capabilities from java (swing) would be sufficient for you, an OpenGL wrapper or something like that may be overkill.
Look for "Graphics2D, Swing, Animation" ...
Here are some starting links:
http://www.apl.jhu.edu/~hall/java/Java2D-Tutorial.html
http://download.oracle.com/javase/6/docs/api/java/awt/Graphics2D.html

By "visual simulator" you mean graphics/drawing engine?
It may or may not fit the bill, but I'm one of the developers of Greenfoot:
http://greenfoot.org/
... which is really an IDE, but it also includes a 2D graphics framework suitable for simple games and simulations. It's open source so if necessary you could rip out the parts you need (as long as you abide by the license terms of course!).

Related

JOGL or LWJGL pre-existing project

I've noticed that using the Java libraries that are default built in, rendering the simplest graphics absolutely kills the FPS, and furthermore, looks ugly.
Now I was wondering if I could use JOGL or LWJGL libraries to use in my pre-existing program. (I'm making a game which renders cubes as planets, and you have to build planets.) Do I need to completely rewrite my code? Or can I just install these and render freely? And which one of the above is easier to understand, because I have limited knowledge in these libraries.
Btw, right now, I am using JFrames, does that need to go as well?
Also, what is OpenGL, is that good to use as well without rewriting code?
OpenGL is a standardized graphics interface for use between programs and your graphics card. A proprietary version of this by Microsoft is known as DirectX. LWJGL and JOGL are two different Java bindings to OpenGL libraries, both of which have native code they load in.
LWJGL is much more aimed towards gaming with OpenGL, where as JOGL is more worried about complete and perfect bindings to OpenGL/OpenCL. I would recommend LWJGL if you're just getting started.
You're going to have to rewrite your rendering code, yes. But assuming you designed your project well, you shouldn't need to rewrite the game logic. JFrames will probably also have to go, but I'm not completely sure about that.
Please don't turn this question into another "JOGL vs LWJGL" thread. Moreover, JOGL is used in several games including Poxnora and Salem (MMO). You'll have to learn OpenGL if you want to use any Java binding of this API anyway.
Finally, you can use GLG2D in order to get a better hardware acceleration with plain Swing, it would allow you to benefit of better performance only with a very few changes in your program. GLG2D relies on JOGL 2, you can find more information about it here: http://brandonborkholder.github.io/glg2d/

Designing a UI for Programmers to Use

I am doing UI design for a group of programmers who are working on building music-related software. I have created .psd files for all of the mockups, graphics, etc.
I was assuming they just needed the (many) images to put into the code, but they want me to use a GUI to spit out the necessary code. (I looked at Antetype, but it just seems so basic compared to my Photoshop mockups.)
My question: Is there a GUI tool that can build VERY UNIQUE designs, and can export the mockups in code using MatLab or Java? -- Or should I just say no and give them the images to use in the code. (we are talking guitar-pedal knobs, EQ sliders, etc.)
Netbeans has a decent swing WYSIWYG editor for Java GUIs that's certainly worth looking into. There's going to be some significant back-end work getting your graphics to look just right if you have particular/complex designs in mind, but that said customizing Java GUI's is much easier than MATLAB. . . I believe eclipse also has plug ins available for this same sort of thing.
Anyways, that is probably the closest you'll get to a nice drag-n-drop interface in Java for GUI design.
JFace is also a pretty spectacular framework that sits atop SWT for building Java GUI's. I would say that it's power lies in how it handles different windows/components, but of course the trade off is that it's more complicated to put together (no WYSIWYG that I know of)
Also consider the Microsoft route, Visual Studio is designed to take the pain out of layout designs in writing Visual Basic/C#/.net applications. If you're a student your university probably has a deal to get you a free copy (mine did) otherwise visual studio express should be free (I think? ...citation needed?)
To create a UI you can use some tools, Netbeans in first .. but i think that is better to create a consistent code using simple layout and component, so doing it by hand (Oracle interesting tutorials). If you aren't a java programmer i suggest you can simply give them your image.

Sharing a library between android and a PC application

I'm trying to design a side scroller for android and a level editor for windows. A lot of the code between the two programs will be the same. The bit I'm currently working on is drawing textures.
What I currently have is a library that includes code related to loading and drawing the texture information. The bit that I'm stuck on is how would I incorporate OpenGL (for windows) and OpenGL ES (for android) into the library?
I thought about having an interface that includes all the drawing functions and then implementing that interface separately within each program (since one will use OpenGL and one OpenGL ES) but that still produces a lot of duplicated code (and kinda defeats the purpose of trying to create this shared library).
Is there a better way to approach this problem? Am I just over complicating this by trying to make it too flexible? I have been thinking about this for a few sdays now, so any input would be greatly appreciated!
Please ask if anything doesn't make sense!
OpenGL and OpenGL-ES are similar enough, that you can share large amounts of the codebase. Since you're probably going to target OpenGL-ES-2, you will then probably use OpenGL-3 on the desktop. OpenGL-3 has a lot of what OpenGL-ES-2 has. So I suggest you develop your code primarily for OpenGL-ES-2 and then only for the small differences toward OpenGL-3 you add alternative codepaths.

2d mobile game development: OpenGL ES 2.0 or cocos2d-x?

I plan to build a game for mobile. My target platforms are iOS and Android. I hope to be able to carry out testing on windows and/or linux. I'm a bit over my head in this as aside from general game development experience, all the technologies are fairly new to me. I've done a decent amount of research and have concluded that the game should be written in/ported to C++ to ensure that most of my engine can be easily ported to multiple devices.
Another thing I'd prefer is to write the game initially in java and port to C++ since that's where I'm most comfortable and will get it done the fastest.
Now I have the issue of choosing whether to use a game engine such as cocos2d-x, or to write the engine from scratch and use OpenGL ES 2.0 for rendering. Initially I thought it would be better to use cocos2d-x since I don't have a lot of experience with OpenGL. My problem with using cocos2d-x, however, is that since I want to write the game initially in java, that I'm going to have a hard time porting the engine to conform to cocos2d-x (or I'd have to learn all about the cocos2d-x engine to begin with and then write my engine to mimic the cocos2d-x engine.. seems redundant).
Upon further consideration, I thought that writing my own engine using OpenGL would actually be the better option. I'm able to use the PowerVR SDK along with JOGL to emulate a GLES environment. Also it seemed nice since I would be able to allow GL to do most of the work for me in terms of collision detection and transformations. My only issue with this is that since the game is going to have multiplayer support as well, the GL collision detection and such is basically moot since I'm going to have to do collision checking server side anyway to prevent the game from being easily hacked. Of course for the single player game play this method is viable.
Obviously this decision is subjective and depends on my personal preference, though I hope to have given enough background for some more experienced persons to lend their opinions.
That being said, my question is: given these parameters - would it be better for me to use cocos2d-x and suffer the head trauma of building the game from the ground up in C++, or would it be better to write my own engine initially in java and struggle through the OpenGL aspect of it?
Building your own engine from scratch would be too much of a work and would attract lot's of bugs to creep into. The tried and tested engines are better choice in my view. The porting would be far more easier to do, since you would be having a working game.
I am using Marmalade engine currently and I am quite happy with it's performance. It gives you direct access to the OpenGL libraries, although I've never tried it. You should give it a try too, although it's not free, but the 90 days evaluation license is free to check it out.
I've decided to write it from the ground up in c++ using cocos2d-x. It hasn't been as bad as I expected.

What to use for writing a user interface?

I've written a series of classes to interperet data from a serial port. This data needs to be displayed on the screen. I am trying to go for straight up eye candy with a refined look.
Swing UI- Easy to program, yields mediocre results
Open GL- Hard to program, yields good results.
Are there any other options?
Give SWT a go, the API is a lot simpler than Swing. Here is a recent question outlining the differences between SWT and Swing.
I'm not aware of any alternatives, but in my opinion it is possible to write beautiful GUI with Swing. Just changing the ugly default look and feel goes a long way. Visual appeal just doesn't seem to be a top priority for most Java coders and therefore you have to make an effort to make anything pretty.
JavaFX maybe? Didn't tried it yet, it obviously offers some eye candy.
You can use NetBeans combined with JOGL (Java bindings for OpenGL) or simply with Java2D.
NetBeans has an easy GUI Builder for Swing applications -- you can make beautiful interfaces (if you get into it), easily change the Look&Feel, etc etc.., and you can use Java2D or JOGL for visualizing your data and embed it in the GUI to display it.
There's a plugin for JOGL for NetBeans so getting started is hassle free.
use html, css, javascript. Much easier to get wizz-bang UI than using Swing or related technologies.
For my projects at work, we have purchased a licence of JFormDesigner.
This is really a great tool that saved us a lot of time.
Writing Swing application by hand can be a real pain and is awful to maintain.
This tool choose the right approach : The model-view-controller.
The GUI builder creates XML files for you that represent the interface. These XML files are loaded at runtime and transformed into Swing objects. The builder also generates Java stubs that you can fill with event handlers.
It also handles Localization and nice layout goodies.
Give it a try.

Categories