tags:

views:

18

answers:

1

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 to know, i'm using Irrlicht 1.7.1.

+1  A: 

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.

nonVirtualThunk
Thank you. For some reason my normal vector were in size of hundreds i.e (-100.0, 0.0, 0.0). The size of my blocks is 10, so newPos = hitBlockPos + (triangleNormal / 10) worked just fine.
EClaesson