java 3D drawing - java

I have a matrix that includes X-Y-Z coordinates of an environment. I want to render this matrix in a 3D view, coloring the coordinates in terms of depth. For example, the coordinates are taken from a room, so I'd like this 3D view screen as room screen. How can I do that in Java?

If you don't have a specific question related to programming (in Java), I'l lrecommend you go through the Java 3D tutorial from Sun: http://java.sun.com/developer/onlineTraining/java3d/
You could of course wait for someone to serve you this on a silver platter, but if you then need something changed, you can't do it, because you don't understand any of it.
Better start learning yourself.
Good luck!

Related

How do you create and render a 3D Fractal?

So I've been assigned a recursive art project for my AP CS class and have a bunch of spare time, so I've decided to try something a little bit more ambitious.
My plan is to create a 3D fractal, either rendered and shaded in a visualization with GL, or represented via spatially mapping the respective equations' outputs to points on a cube and drawing those. If this explanation seems unclear, please check out the links at the bottom for images. Now, I don't need the fractal to be able to be modified in-program. I just need it to render a single BufferedImage, which I'll be putting directly on a JFrame.
My experience in Java, as far as this project goes, is a bit limited. I've drawn Mandelbrot and Julia set fractals before, but I have little to no experience drawing/rendering objects in 3D in Java. This is all stuff I can look up and figure out myself though, so no worries here.
Thus, the question: How does one map a fractal that should be in the 2nd dimension (e.g. log(no. of subdivided entities)*log(side length of subdivision) = 2) to the 3rd dimension (e.g. log(no. of subdivided entities)*log(side length of subdivision) = 3)? I'm lost trying to mathematically work this out, and I believe there is a more organized approach to go about this circumventing a lot of the math that already exists.
Also, if you are aware of a structured approach to render a 2D fractal, as drawn by a formula, and render it in 3D, provided the respective formula is provided (power is raised), please let me know. I've heard of Ray Tracers, no idea what they are, a brief summary would be cool.
Here are links with pictures of the result I want to obtain:
http://2008.sub.blue/assets/0000/4575/power8_large.jpg
https://www.youtube.com/watch?v=rK8jhCVlCtU
It looks like the image is an example of a Mandelbulb. The is a similar iteration formula to the Mandlebrot set but using 3D points and a novel idea of what raising a 3D point to a power means.

Custom 3D Rendering

So I've been prodding ever so diligently at the internet as of late and have come across some interesting games. The basic example is Minecraft4k. It was made for the Java4k contest a few years back, but what I am really interested in is how the rendering was done. There are a lot of games like this made every year, but I really can't find much on how the creators went about synthesizing 3D worlds, let alone with minimal code.
The basics that would have be implemented would be polygon filling, z-ordering, and some sort of "fog" in order to prevent too much landscape from being drawn (optional, really). I've read up on the Scan line filling algorithm and have a working example but I have no idea how to get any form of z-buffering working. So the question is, does anyone have any experience with this sort of custom 3D rendering work? If so, any tips/pointers/resources you can point me to?
I know this is a bit of a shallow and perhaps inadequate question, but I figured I would try on here. Thanks in advance!
Wikipedia is a good start point (though it is bad for me to post a link) and explains about different techniques.
I developed a 3D software renderer for dots (the simplest 3D renderer ever ;)) and the z-buffering consists of sorting an array of rendered elements according to the Z coordinate, which in turns depend on the projection you are using, either orthographic, isometric, etc. (see another Wikipedia article about projections). In the simplest projection, you simply ignore the Z coordinate when drawing object, but take it into account during rotations (as it has an impact on X and Y).

java find intersection of a block with a surface in 3D space

At the moment we have a bunch of 3d blocks (think cubes) that are imported in a JMonkey 2 canvas.
I need to find an intersection of these blocks with a 3D surface that is imported by the user.
The problem is that I have no idea how to do this in JME or any other 3D engine for that matter.
If anyone has any experience using JMonkey for this kind of taks, or maybe you did it using some other 3D engines could you please provide some code hints, maybe links to relevant resources?
edit for clarification: I need to divide the block into 2 shapes: below/above the surface.
Thanks
It depends on what you want to accomplish, just find out IF it intersects or "where" it intersects. It will be easier (mathematically) if your boxes are AABB (axis aligned bounding boxes), that is - aligned with the xyz axis and not rotated. Is this the case?
However, you have support in JME for these kind of tasks. You might want to read this text: http://jmonkeyengine.org/wiki/doku.php/jme3:advanced:collision_and_intersection

Can Java be used to make a 2D Bird's eye view style game?

I've been working on making a video game, and I've had alot of debate between a few languages, Java can be used well for 3D games but. Can Java make 2D bird's eye view games? I'm quiet new to programming so sorry if I seem somewhat ignorant. Thanks for your time!
that's not a question can Java make a 2d bird's eye game?. the main quesiton is does a 2d bird's game created with java meet your needs or not?. just by looking at cell phones you can easily spot many 2D games using bird's eye camera created with java. so it sure can!
Yes. (This simple answer is as exciting as the question.)
I used LWJGL to make a 2D "bird's eye" game in OpenGL. It just requires setting up the perspective correctly. Performance on a laptop (with a proper OpenGL 1.6+ dedicated video card ;-) was more than adequate for a large number of objects and particles.
However, LWJGL is a low-level OpenGL/basic-IO wrapper targeted for games and is the "hard way". There are other Java game libraries (some are just 2D like Slick) to make writing a game easier. According to list of game engines this also includes Jake2, Jogre, and Java Monkey Engine (3D, but see above).
If one felt like being .. silly .. the Java 2D API could be used directly (there are cases when it will try to use hardware acceleration but there are also gotchas). I do not do any JME programming, but I would suspect there are also frameworks for it.
And remember -- a "bird's eye view" is simply the chosen projection/rendering for a given model.
Happy coding.

How to create 3D Tag Cloud in Java

I need a suggestion/idea how to create a 3D Tag Cloud in Java (Swing)
(exactly like shown here: http://www.adesblog.com/2008/08/27/wp-cumulus-plugin/)
, could you help, please?
I'd go either with Swing and Java2D or OpenGL (JOGL).
I used OpenGL few times and drawing text is easy using JOGL's extenstions (TextRenderer).
If you choose Swing, than the hard part will be implementation of a 3D transformation. You'd have to write some sort of particle system. The particles would have to reside on a 3D sphere. You personally would be responsible of doing any 3D transformation, but using orthogonal projection that would be trivial. So it's a nice exercise - what You need is here: Wiki's spherical coord sys and here 3d to 2d projection.
After You made all of the transformation only drawing is left. And Java2D and Swing have very convenient API for this. It would boil down to pick font size and draw text at given coordinates. Custom JPanel with overriden paintComponent method would be enough to start and finish.
As for the second choice the hardest part is OpenGL API itself. It's procedural so if You're familiar mostly with Java You would have hard time using non-OO stuff. It can get used to and, to be honest, can be quite rewarding since You can do a lot with it. If you picked OpenGL than you would get all the 3D transformations for free, but still have to transform from spherical coordinate system to cartesian by yourself (first wiki article still helpful). After that it's just a matter of using some text drawing class, such as TextRenderer that comes with JOGL distribution.
So OpenGL helps You with view projection calculations and is hardware accelerated. The Java2D would require more math to use, but in my opinion, this approach seems a bit easier. Oh, and by the way - the Java2D tries to use any graphic acceleration there is (OpenGL or DirectDraw) internally. So You are shielded from certain low-level problems.
For both options You need also to bind mouse coordinates s to rotational speed of sphere. Whether it's Java2D or OpenGL the code will look very similar. Just map mouse coordinates related to the center of panel to some speed vector. At the drawing time You could use the vector to rotate the sphere accordingly.
And one more thing: if You would want to try OpenGL I'd recommend: Processing language created on MIT especially for rich graphic applets. Their 3D API, not so coincidentally, is almost the same as OpenGL, but without much of the cruft. So if You want the quickest prototype that's the best bet. Consult this discussion thread for actual example. Note: Processing is written in Java.
That's not really 3D. There are no perspective transformations or mapping the text on some 3D shape (such as, say, a sphere). What you have is a bunch of strings where each string has an associated depth (or Z order). Strings "closer" to you are painted with a stronger shade of gray and larger font size.
The motion of each string as you move the mouse is indeed a 3D shape which looks like a slanted circle around a fixed center - with the slant depending on where the mouse cursor is. That's simple math - if you figure it for one string, you figure it out for all. And then the last piece would be to scatter the strings so that they don't overlap too much, and give each one the initial weight based on their frequency.
That's what most of the code is doing. So you need to either do the math, or translate the ActionScript to Java2D blindly. And no, there is no need for JOGL.
Why don't you just download the source code, and have a look? Even if you can't write PHP, it should still be possible to read it and figure out how the algorithm works.

Categories

Resources