Microscopic model for the formation of nanodomains in relaxor materials