Hi Vasudev,
You'd have to write your own program I'm afraid. A possible algorithm would be to start by making sure that both the Wavefront and the NIFTI file to be masked have the same coordinate system. Then create a 3D array full of zeros (0) of the same size of the NIFTI. Then subdivide each triangle of the .obj file into multiple smaller triangles such that they become well smaller than the voxel size. One way of accomplishing this is by recursive subdivision, i.e., split each edge into 2 parts, which produces 4 new triangles for each original triangle. Then for each voxel of the 3D array, check whether it contains any vertex inside it. If yes, fill it with "1", otherwise, leave it with zero. Then save as NIFTI.
If you need fuzzy masking, create the 3D array with a higher resolution than the intended final NIFTI output. Then do as above and at the far end, downsample using an existing tool, e.g., FLIRT, with trilinear or sinc interpolation.
The above assumes that there is just one surface (e.g., representing the pia-mater, for instance). If there are two surfaces that delineate the cortical gray matter, it's simpler then: for each voxel, check if its centre is within the cortex or not. If yes, mark it with 1.
If the surfaces represent subcortical volumes, then finding whether the centre of a voxel is inside is the 3D version of the well known "point in polygon" problem. Perhaps this Wikipedia article and the references therein could be a good starting point:
https://en.wikipedia.org/wiki/Point_in_polygon
There are certainly other way, the above is just a suggestion.
All the best,
Anderson