I am looking for a java library that can draw lines and shapes (2d) as well as be able to capture the mouse events on the drawn objects. I will also need the ability to zoom and out on the drawn objects.
I might be asking for a lot but anything close will save me some time re-inventing the wheel.
P.S. It will be even better if the library renders the shapes as objects.
Thanking you all in anticipation.
Cheers
Simple answer will be:
LWJGL .
There you have an access to OpenGL, OpenCL, and OpenAL libraries.
Related
For a school project i have made a program that can solve a rubiks cube (you know, that cube with all the colors). But now my teachers asked if i could do some research and try out 3d animation for one of the sides. But they want to see the mathematical way to do it. I have found a way to move the corners with the use of polar coordinates. But i do not know how i could render a cube in 3d and be able to animate it.
So my question is: how can i render things like a cube in 3d (or are there any good libraries for it) and how could i use these polar coordinates to animate it?
And is there a good tutorial out there for java 3d rendering?
i must say that i have absolutely no experience with 3d rendering, so it might be a bit difficult. But i really would like to try it out.
thanks in advance
Depending on whether you want to take an existing implementation or if you want to build code for 3D animations from scratch, you might try this tutorial. Graphics programming in this area can be quite involved; a full answer of the question is beyond the scope of this site. However, there are a few main areas.
Usage of vector math for transformation of objects (translation, rotation). This can be done directly or via projective geometry using 4-by-4 matrices. The latter is easier for concatenation of transformations.
Backface culling to remove faces of the object which cannot be seen by the camera.
Using a projection and a camera model to transform 3D coordinates to 2D coordinates.
Using a rasterizer to render the 3D vector information to the screen. Here Bresenham's algorithm might be a good start.
I would suggest you look at one of the 3D libraries. One that I've used a lot and found to be excellent is JMonkeyEngine (JME) which is designed for games but would work well for your needs. It also has an excellent tutorial that takes you from basic to very complex. In fact the first step in the tutorial is a revolving coloured cube!
JME takes a huge amount of the work out of 3D modelling. You build a scene in code with materials, lights etc. and JME does all the work to render it. You can even build your models in a tool such as Blender so you don't even need to do the modelling in code. But I will warn you that using modelling tools is definitely not for the faint hearted.
I am having a problem with manipulating images in java 7. I have researched the problem I am having for three weeks and have failed to find a solution,
I am trying to set an image over an area, basically setting the corner posistions.
I am using a BufferedImage.
This is for a 3D game where I am writing the 3D conversion code. I have managed to create a 3d world, and populate it with cubes, filling in the sides with graphics.fillPolygon():
What I would like to do is draw an image that fills a polygon's shape.
Any help I will be grateful for (even if it is formating this post better).
You can use transformations on your graphics. Here is a little tutorial on it. With that you can transform already drawn stuff. If you want to transform multiple images in different ways, you can draw them on different canvases and transform then separately. Then you can merge the images together...
But I would recommend using a 3D engine (JOGL, jMonkeyEngine, or others) for that (unless you want to learn about the geometric calculations with this task). It is also much faster to use OpenGL than drawing the stuff by yourself and doing the calculations in code (most probably meaning: on the CPU and not the GPU).
Have you tried using the drawImage? instead of .fillPolygon?
I'm making a game in Java and I have it so that when the player presses the left arrow button, three images are drawn one after the other. But when the third image is drawn, you can still see the image drawn before it (I rotated the images to make it look more realistic). Is there anyway to "undraw" the images? I've done some research and haven't found anything specific.
No, you can't undraw an image. It sounds like the images aren't fully opaque.
Not to be an over-complication junkie, but how about using OpenGL to draw them on quads. That way you can hide, show, rotate, animate, accelerate etc so much easier. And it will all be tons faster than with Swing/AWT. JOGL library + NeHe Tutorials will quickly show you how to achieve this (really, you only need this and this). Or use Unity if you wanna do it even simpler and more portable.
I'm coding a programm, that will produce 3d coordinates for a rocket and I would like to do a rudimentally graphic output for this.
it just has to be scaleable and rotationable, so that you can change the view manually.
the postions should be connected by lines and
it ould be nice to have spheres for earth and moon ( and perhaps addtional celestial objects).
I think, there should be some ready stuff for this kind of plott already available, but I couldn't find one.
So that's why I'm here to ask you, if you know such a thing.
and if there isn't I would kike to ask you how a bignner like me should start this?
I ust coded for console apllications, because there was no need for a real graphics output.
thank you in advance for any tip! :)
Andreas
I don't think there are sand-box ready things you can use to draw customizable 3d objects in Java, if you can live without strange things you can you just a graph library able to draw 3d graphs like for example jMathTools (link).. otherwise you should go into J3D with opengl and similar things.
I don't think they exist just because doing simple things is trivial if you work with OpenGL or similar APIs..
Doing what you need with OpenGL is not complex at all, just a GL_LINE_STRIP to draw the trajectory and some primitives if you need earth, moon and so on.. rotating and scaling come implicitly moving the camera of your viewport..
Take a look at: Java3D or JOGL
I can't believe nobody has mentioned this yet, but the NASA WorldWind project seems like exactly what you need: http://worldwind.arc.nasa.gov/java/ You can extend it with JOGL if needed, or you can use some of the vast modeling objects already available to mark trajectory and location in 3D coordinates, complete with zooming/rotating and the like. Having accurate Earth layers is nice as well =)
Use JOGL! It is easy to install, and if you know Java it should be easy. There are a few things in JOGL that require you to be decent in trigonometry. This tutorial might help you get started: http://www.youtube.com/watch?v=rT02jFYrXv0
I have created a "blob" from Bezier curves (screenshot below) and would now like to shade it in such a way that it appears pseudo-3D, with darker shading on all "left" edges and lighter on all "right" edges, and perhaps pure white "light spots" on the surface itself. For example: I'd be interested in how to achieve the shading used in this video.
Can anyone recommend a good way to achieve this? I am guessing that standard Graphics2D.fill and setPaint methods may not be sophisticated enough.
Also, can anyone recommend some good resources (preferrably free / online) for learning more on this?
EDIT
Some additional information: To achieve the flat fill effect below I'm creating an Area object and am adding the individual Ellipse2D Shapes to it using add(new Area(ellipse)) and then finally adding the central polygon area to avoid leaving a white space in the middle.
alt text http://www.freeimagehosting.net/uploads/bc8081cbf2.png
The IPhone apps have access to OpenGL-ES which allows significant latitude in shading and rendering what is basically a coloured iso-surface with emissive lighting. Java2d will definitely not be sophisticated enough unless you are willing to write a whole software 3d library for it.
Mixing 2d and 3d is also possible.
I used a custom RadialGradientPaint in this kineic model to get a pseudo-3D effect. I believe a more general implementation is available in Java 6.