Scott Forbes also placed a hidden camera in another victim’s bedroom and recorded footage of her while she was naked and getting dressed.
A judge told Forbes (49) that the corrosive effect of his behaviour on victims was “incalculable”. Lord Woolman said: “You have altered the course of their lives.”
The judge said that Forbes offending suggested he was a sexual predator and told him: “Your name will remain on the sex offenders’ register for an indefinite period.”
Lord Woolman also ordered at the High Court in Edinburgh that the Royal Navy veteran should be kept under supervision for a further four year period.
The judge said he had “narrowly” decided against calling for a full risk assessment report to be prepared on Forbes which can lead to the making of an Order for Lifelong Restriction.
He told Forbes he was prepared to treat him as a first offender and noted that he had medical problems which have prevented him working for the last eight years.
Forbes, formerly of Firrhill Park, in Edinburgh, was earlier convicted following a jury trial of five offences committed between 2009 and May last year, including rape, sexual assault and possessing and making indecent images of children.
He locked a 14-year-old in a house in Edinburgh and made sexual remarks to the child and molested and raped her and photographed her naked body.
He also plied another 14-year-old with drink, showed her pornography and molested her and exposed her breasts and photographed them while she was intoxicated at an address in Edinburgh on May last year.
Forbes was also found to have set up equipment at a house in Bonnyrigg to covertly shoot and record footage of a third victim in April last year.
Defence counsel David Nicholson said Forbes continued to deny the serious sexual offending.
Mr Nicholson said Forbes had been on long term sick leave following a variety of health problems.
He told the court that Forbes has a neurological condition and was previously diagnosed with post traumatic stress disorder.
The defence counsel said that arose primarily from Forbes’ service when he was stationed in Iraq and the Arabian gulf.
He added: “He is not somebody with any difficulty with drugs or alcohol.”
Detective Sergeant Jonny Wright, of Edinburgh’s Public Protection Unit, said: “Scott Forbes is a devious individual who took advantage of each of the victims’ trust.
“I want to commend their bravery in coming forward, which has led to Forbes’ conviction.
“I would also like to reassure any victims of sexual crime that there is no time limit to reporting offences and we will always investigate.”
Anyone with information about sexual offences can contact Police Scotland on 101, or report this anonymously to the independent charity Crimestoppers on 0800 555 111.