I’m trying to create a block world where i can take(“Mine”) blocks and place them adjacent to each other.
I don’t know how to tell what side of the block i hit and how to use the results to place another block exactly on top/side/bottom etc. of that one.
Code:
CollisionResults results = new CollisionResults();
Ray ray = new Ray(cam.getLocation(), cam.getDirection());
rootNode.collideWith(ray, results);
float x = results.getCollision(0).getContactPoint().x;
float y = results.getCollision(0).getContactPoint().y;
float z = results.getCollision(0).getContactPoint().z;
You have a grid, dont you? In a world of boxes everything is somehow parallel, isnt it?
Just compute the normal of the hit triangle and look up in which direction it points. E.g. in positive x direction, in negative x direction aso.
That is how i would do it. If you know which side it is you can easily access the right block in the grid…
I dont know wether this is the right approach to do that since i didnt really worked myself into minecraft like games but it was the first thing coming to my mind… And it should work i guess. XD
Lol, whatever. Just to inform you: You will only be able to select images from the assets folder for things like material editing, skybox creation etc. using the SDK. The asset folder contents are on the class path though, so theres no difference code-wise when putting them to the assets folder.
normen said:
Lol, whatever. Just to inform you: You will only be able to select images from the assets folder for things like material editing, skybox creation etc. using the SDK. The asset folder contents are on the class path though, so theres no difference code-wise when putting them to the assets folder.