Let us consider a sentence like: 'The teacher gave me a book'. This sentence has two objects, 'me' and 'book'. Of these, the one that helps to form a complete sentence is the direct object, as: The teacher gave a book. The one that leaves the sentence incomplete is the indirect object, as: The teacher gave me.
Similarly in a sentence like: I gave him a present, the direct object is 'present', as it can form a complete sentence, like: I gave a present. The indirect object is 'him', as it does not complete the sentence as in: I gave him.