Curvature and torsion from matter