You need to specify which RailCars should be (in)visible. You need to add the method getCar(int i) after the Train agent (in your case, apparently the Headway agent), to get the RailCar agent that has the 3D object. The train agent should not have 3D objects representing RailCars, let the 3D representation of a RailCar only in the RailCar agent.