EpicJefferson published a full tutorial on how to make Arduino based 3d drawing pen with 3d printed enclosure. It can sedn data to other software like Processing and uses an external motion tracking system (like Optitrack in the video)
Full build guide and all the files can be found at:
http://www.instructables.com/id/Wireless-3D-Drawing-Stylus/?ALLSTEPS
Here you can clearly see the internal electronics, battery and 3d printed shell with motion tracking points on the cap.