Imagine, if you will, that your original circuit with +Ve, -Ve, GND, Vin and it's associated GND, and Iout, taken between the mosfet drain and -Ve, are all enclosed in a "black box" completely insulated from the outside world. +Ve and -Ve are supplied from batteries or from well-isolated line-operated power supplies. GND is just a name for a node shared by Vin and current-sensing resistor R3.
If you could create Vin inside the "black box" without a galvanic reference to anything outside the "black box" then your current Iout would be totally floating without reference to any "ground" outside the "black box." You could connect it as you would with the 3 V battery and series 1 Meg-Ω resistor with the same effect. So, how do you create a Vin control signal inside the "black box" without any reference to anything outside the "black box?" There are many possible solutions, and I have described two (using optical isolators) in post #14. You could also use transformer isolation, but this is a little more difficult.
Since you are already comfortable using a PIC and a DAC, simply place both of these components inside and power them from the "black box." Communicate with this PIC using an optical isolator (or a pulse transformer) to transfer a digital representation of Vin to the inside of the "black box." The DAC output then becomes your Vin control signal. If the signal Vin changes slowly, you can implement a simple serial data protocol requiring only one optical isolator. Some PICs have serial UARTs "built in" that make this approach particularly easy. You don't need the UART duplex capability since data flow occurs only from the external real world into the "black box." The transistor in the optical coupler should be able to directly control the serial data input to the PIC.
If you decide to use pulse-transformer isolation, more signal conditioning is required between the transformer secondary winding and the PIC input, and the software is usually more complicated. I would choose the optical isolator approach for the sake of simplicity.
Please let us know what you decide to do.