Block attatchment in 3D grid
I'm doing ray picking to find the scene node that my cursor points at. All of those scene nodes are equally sized cubes. I have the hit scenenode's position, the position of the ray intersection and the triangle that the node/mesh that were hit. What i want to do is to attatch a new block to the face of the collided scenenode block that were hit. I want it to work as a 3D grid in MineCraft style. I dont want any code, just some pointers and hints to how i can properly create the new block to the correct position.
If anyone is interested or want/need t开发者_开发问答o know, i'm using Irrlicht 1.7.1.
If you know the triangle that your ray intersects you can calculate the normal vector for that triangle and place a new block at positionOfHitBlock + normal. For example the triangles forming the left face of a block will have a normal of (-1.0,0.0,0.0), so you will want to place a block one farther over to the left.
精彩评论