Hi geeks,
After a long day I’m here again . Wow Christmas is coming near !! Hope I can blog more post before Christmas 🙂
Today I’m going to explain about the 3D Concepts. Well this post is not related to specific Java Language because in this post there will be no any talks about the language specific code. But we’ll be talking about codes in next part of this post. Before going to 3D Object we need to know what is the axis and rotation.
After Looking in above diagram, you can easily find a cube Object which looks like a real Cube with the help of Axis and Rotation. There is given a sample position for the cube on axes and it’s being rotated with few angle of degrees. As I’ve used the lighting and color in the above cube which makes the 3D Object even more interactive. Furthermore we can even add the Shadows and smoothness but our post is mostly related to only making the 3D Object primarily the Cube 3D Object.
If you have good knowledge of 2D coordinates and angles then the 3D will quiet much familiar.For learning more about the 3D Cube Object I’ve made one big flow picture of how the Cube are formed with the pieces of 2D Sqaures. To make the Cube we need about 8 faces i.e 8 square Object. To make this thing more real you can even try to make a cube in a real world.
Test in Real Object
Try to grab some 8 pieces of hard paper with equal height and width. Now just attach them to make some thing like below.
As you can see We can make the 3D Object with the help of real world. I’ve pointed the Axis of the Object so that it can be more easy for you to know how the 3D Objects are made. Here I’ve cut down 8 pieces of square and attached them to make the Cube. Now in the same way we need to picture this object in the computer with the help of 2D squares. Lets see how we can make this.
Now here are about 6 procedure I’ve followed I’ve pinned there with number 1,2,3..
1. Here we have only stacked the 6 squared in the normal Axis which is just a normal Stacked in Z-axis. Now We’ll arrange those all squares to make the perfect 3D Cube.
2. The first top most square has brought at front for the depth of the Cube. In this process the position of Z axis is translated toward the view. The final view picture of that Object looks like in 2-2.
3. The Second top-most square brought just half of the translate position of that previous square. It will reside at the mid of the Cube depth object. Now that object is being rotated 90˚ of Y-axis and pushed to the left-most face of the Cube. Altogether here we need to do translation of Z-axis and Y-axis with equal measure and the degree of rotation on Y-axis with pivotX,pivotY,pivotZ to the center of the existing 2D square . Final rotated cube image is like in 3-3.
4. This has same process of the Procedure 3 . Only difference is that it is driven at opposite direction i.e. negative direction. Till here we have successfully made left and right faces of the cube
5. Now it’s time to make the top part of the cube. It’s also brought just at the mid of the depth measure unit (Z-axis translate) and it’s being flipped or rotated 90˚ at X-axis with pivotx,pivoty and pivotz exactly the center of the existing square. It’s now pushed at the top part for the cube top face with the translate of Y-axis.
6. This has same process like of the Procedure 5 the only difference is the translate on Y-axis negatively.
Well this was the basic procedure to make 3D Cube in any programming Language which supports the 3D. The implementation of this cube 3D in JavaFX will be described in the coming blog post.
Have a good day folk 🙂
Pingback: 3d Object (Cube) Concept to Code Part 2 « Java and FX
You’ll notice that the object remains still in the same place, even after you rotate the device away from it. It’s as if the cube ‘exists’ in the real world, but can only be seen with the device camera.
When you apply this code to your Cube and run your program, you will notice that your Cube is now rotating on its Y-Axis, one degree continuously.
I just tested an it worked . I pulled code from git repo and tested. I know it doesn’t work perfectly because it was written early time of javafx 3d lib.