I am very new to developing applications with LibGDX and 3D apps in general and I would just like to know how to move around a 3D object that I imported from blender. I have checked the Mesh class for a transform method but I can't find one.
Moving objects around in 3D is normally done by manipulating a transformation matrix. LibGDX doesn't seem to be open source anymore (for 1 day - April 1st ;P) so I can't tell you how to do it there but I guess the mesh class isn't the right place to look for. Meshes normally only represent a shape/mesh without any position. You'd often create an object/entity and assign a mesh to it. Then you change the transformation of that entity.
As I said, transforming entities is often either done by calling some move/scale/rotate methods or by creating a transformation matrix yourself and loading it into the graphics pipeline. Modern 3D graphics applications normally use the shaders for that and just load the transformation matrix into the shader pipeline.
Related
I would like to add this feature to my android app:
https://en.wikipedia.org/wiki/Synthetic_vision_system
In short it I believe it is a terrain heightmap. I specifically need help with rendering the terrain. The rest of the display I can accomplish.
After a day of google I appear to be no closer. My research seems to point to using opengl, heightmaps and SRTM. However I have no clue how to tie it all together. None of the java examples are android specific.
Alternatively maybe using openstreetmaps and a tile overlay but I cant establish if it is possible in 3D.
The app will be a moving map based on GPS position of the aircraft. As the aircraft moves over the earth the terrain ahead will be updated.
Can someone point me in the right direction?
I can recommend you to use a vector format with few layers. For example, layer of depth, layer of landscape type and layer of objects. To build 3D from this data you need to divide the map in small tiles and load data in memory for visible area only. Your 3D builder will parse this data. E.g. a simple renderer (using OpenGL)... You create mesh as large as tile size and with enough count of vertexes. Next, you parse depth layer and move each vertex along Z-axis like it need. After you need to set color like it specified in type layer. And finally, you need create and locate objects like object layer data (it's already built-in meshes). When you build needed tiles you pass it to renderer.
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'm trying to make a project in OpenGL using JOGL.
If you see my image http://imgur.com/DDHoXEz, I have 4 viewports with different projections but all Teapots are out of "scale", and I want to make something like a bounding box, a square with side 1, that contains all objects on the viewports, to make a scale out of the square.
Any tips?
Unless you're going to use the base teapot model for programs (which you shouldn't), I don't think this is something to spend your time on. When you get into actually using your own models, you will have direct control over the scale.
I would recommend at this point learning about different drawing methods in OpenGL (e.g., GL_TRIANGLE_FAN, GL_LINE_LOOP). Then move on to learning about vertex arrays and maybe write an OBJ importer. I can point you in the right direction if you'd like.
Here is a good place to get started on different drawing techniques.
Happy coding!
I built an app in JavaFX 8 that can rotate and move TriangleMesh objects on screen. I use the libraries from www.interactivemesh.org to read the STL files and create the TriangleMesh objects.
When I write the TriangleMesh objects back to STL the original data is saved. JavaFX doesn't change the original data. I logged a jira and they said this is how it is supposed to work.
How can I transform the mesh data when I save it? I am hoping for a cross platform library that can transform a mesh that could integrate easily with JavaFX 8.
I found hg.postspectacular.com/toxiclibs/wiki/Home. They developed their own TriangleMesh and other objects. If all else fails I will probably write a converter to convert the JavaFX TriangleMesh to their one and then use their transforms to transform the data so that I can save it to STL. I am not sure if they actually change the data so that I can actually use it
I also see I might need to look at JOGL (Java Bindings for the OpenGL).
See javadoc of javafx.scene.Node for:
Transform Node.getLocalToSceneTransform()
"An affine transform that holds the computed local-to-scene transform. This is the concatenation of all transforms in this node's parents and in this node, including all of the convenience transforms.""
See javadoc of javafx.scene.transform.Transform for:
Point3D transform(Point3D point)
"Transforms the specified point by this transform."
Get the 'LocalToSceneTransform' from the TriangleMesh's Shape3D node
Apply the transform-method to the three Point3Ds of each triangle
Convert the Point3Ds from JavaFX 3D coordinate system to one of STL by flipping the y- and z-values
Use the transformed and converted three Point3Ds to calculate the face/triangle normal
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?