I am currently making a program to build up and knock down blocks. It’s simple but fun. I have gotten pretty far but have hit a snag.
So far, I have it so that when I click, it creates a block at the position I am looking at, either on another block or the ground. This is achieved through the use of ray tracing from the camera and creating a block at a Vector3F created from the collision between the ray and the other object. What I can’t do is round the Vector3F so that the numbers are all single digit integers. Does anyone know how to achieve this?
You can use Math.round():
http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#round(float)
Examples:
1:
2:
There is also more info: How to convert float to int with Java