I'm trying to build a food menu that the first things users will see on the screen monitor are rotating images of twelve different dishes. I imagine trying to use threads and a timer that will rotate the objects in a circle via changing coordinates or layout managers.
However, 3d rotational movements are encouraged to which I have no real experience in. I've also heard that you can use a java applet and let javascript rotate the objects. I welcome any recommendations and thank you for reading.
If you don't want to go the whole Java 3D or OpenGL route, you can get a 2½ D effect by using AffineTransform and varying x, y and the apparent size. There's an example here.
Related
I am trying to make a simple game using OpenGL. I have already modeled 3D scene. Now I want to add some fog to make it look like in horror. I have used this code below
gl.glEnable(GL2.GL_FOG);
gl.glFogi(GL2.GL_FOG_MODE,GL2.GL_LINEAR);
gl.glFogi(GL2.GL_FOG_START,(int)1);
gl.glFogi(GL2.GL_FOG_END,(int)5);
However that just creates a static fog with some random coordinates. How to make It dependent on the camera movement? So the player will only see clearly on the set distance?
You can find the definition of glFog (and all the other OpenGL commands, even the classic ones) at www.opengl.org. Fog is always calculated according to the distance from the eye / camera / viewpoint coordinates, so you don't need to do anything special.
Be warned that glFog is part of the old classic OpenGL API and may not work reliably on modern 3D systems.
I have a 3D scene that runs on libGDX(Android). I want to use particle system. When I create one using the tutorials/examples found online (e.g. Particle System libGDX) I get a particle system which works fine. Except for one thing: it is fixed on screen.
When I move the camera around the particle system stays on the same place on screen (like a fixed HUD element or so). Maybe it's because of Sprite-nature of ParticleEffect.
The other issue related is that the ParticleEffect.setPosition() method takes values not in the World coordinates but in screen pixels. Is this correct? I can calculate new on-screen coordinates in pixels and update ParticleEffect position every frame. But that seems like a hack to me.
Is there a more "right" way to make my particle system behave like other objects in my 3D scene and not be fixed on screen?
The Particle System is just working in 2D System. It's not a 3D Particle System thats why you wont get it into your world. That's why it's inside of the g2d package (graphics 2D). Thats also the reason why it just take 2D cords and not 3D cords.
Also the Feature list says that it's inside of the 2D Highlevel API.
Featurelist
I want to implement a TPP Camera for my project, but something is not working + i don't know if i use the right concept.
Should I rotate the whole scene model-view matrices except my main model, which will be centered on the screen or rotate the lookAt camera?
Other thing is how to make the model move in given direction after rotating? (I think moving the whole scene makes it easier?) + how to add collision detection to it?
Collision detection is nothing to do with openGL you use you game state variables to work that out you can manage it in the same loop as the game where you do user input and display.
You should use a LookAtMatrix for the third person camera you will have the eye component behind the player and the at somewhere infront. Persective can be implemented by using a perspective matrix.
So the matrix multiplication will look like.
PerspectiveMatrix * LookAtMatrix * worldSpacePosition
Here is a good answer from gamedev explaining a lookatmatrix, most OpenGL / Computer Graphics books will also cover this.
Are you working with the new or old pipeline model?
I'm looking to use the java2d API to make a graph in which users can manipulate certain features using their mouse - such as the scale used for an axis or move around the different points plotted on the graph.
So far all I have found is the drawX methods on a Graphics2D object, however there does not seem to be an easy way to capture a user clicking on one of these and moving it so that I can redraw the graph.
Can anyone suggest the best/easiest way to implement this? Just looking for a point in the right direction.
Not reinventing the wheel is always the best way, there are plenty of excellent libraries you can use: http://www.jfree.org/jfreechart/
If you are looking to implement this yourself, you would listen to mouse events on whatever component you're actually using to display your chart (say a JPanel), and then would have to convert between screen and chart coordinates to figure out what you need to change.
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.