18. Find the number of right triangles in the plane that satisfy the following conditions:
(1) The three vertices of the triangle are integer points, with the origin as the right-angle vertex;
(2) The coordinates of the incenter $M$ are $(96 p, 672 p)$, where $p$ is a prime number.
18. Suppose the right-angled triangle $OAB$ satisfies the given conditions, then the slope of the line $OM$ is $\tan \alpha=7$;
the slope of the line $OA$ is $\tan \left(\alpha-45^{\circ}\right)=\frac{\tan \alpha-1}{1+\tan \alpha}=\frac{3}{4}$;
the slope of the line $OB$ is $-\frac{4}{3}$.
Thus, we can set the coordinates of point $A$ as $A(4t, 3t)$, and the coordinates of point $B$ as $B(-3s, 4s)$ (where $s, t > 0$), then
$t=4t-3t, s=-3s+4s$ are both positive integers.
Let the inradius of $\triangle OAB$ be $r$, then
$$
r=\frac{\sqrt{2}}{2} \cdot OM=\frac{\sqrt{2}}{2} p \cdot 96 \cdot \sqrt{1^{2}+7^{2}}=5 p \cdot 96.
$$

Also, $OA=5t, OB=5s, AB=5\sqrt{t^{2}+s^{2}}$.
By $OA+OB-AB=2r$, we get
$5\sqrt{t^{2}+s^{2}}=5t+5s-2 \cdot 5p \cdot 96$,
which simplifies to $t^{2}+s^{2}=(t+s)^{2}-4p \cdot 96 \cdot (t+s)+4p^{2} \cdot 96^{2}$,
rearranging gives $(t-192p)(s-192p)=2p^{2} \cdot 96^{2}=2^{11} \cdot 3^{2} \cdot p^{2}$.
Since $5t>2r, 5s>2r$, it follows that $t-192p>0, s-192p>0$.
Therefore, the number of triangles that meet the conditions is equal to the number of positive divisors of $2^{11} \cdot 3^{2} \cdot p^{2}$, which is $(11+1)(2+1)(2+1)=108$ when $p \neq 2, 3$; when $p=2$, there are $(13+1)(2+1)=42$ triangles; when $p=3$, there are $(11+1)(4+1)=60$ triangles.