I wrote a script that loads a model twice and change the material of each one independently. I changed the first material of the first model to be blue and i changed the material of the second one to be green. But when i run the script both models appear green. Why do this happen? And how to fix it?
This is a part of the script
self.myModel=loader.loadModel("/car_red")
self.myModel.reparentTo(self.render)
self.directionalLight = DirectionalLight('directionalLight')
self.directionalLight.setColor((1, 1, 1, 1))
self.directionalLightNP = self.render.attachNewNode(self.directionalLight)
self.directionalLightNP.lookAt(self.myModel)
self.myModel.setLight(self.directionalLightNP)
self.pandaModel.findMaterial("Body").setDiffuse((0, 0, 1, 1))
self.myModel2 =loader.loadModel("car_red")
self.myModel2.setPos(0, 0, 5)
self.myModel2.reparentTo(self.render)
self.directionalLight2 = DirectionalLight('directionalLight2')
self.directionalLight2.setColor((1, 1, 1, 1))
self.directionalLightNP2 = self.render.attachNewNode(self.directionalLight2)
self.directionalLightNP2.lookAt(self.myModel2)
self.myModel2.setLight(self.directionalLightNP2)
self.myModel2.findMaterial("Body").setDiffuse((0, 1, 0, 1))
Thanks in advance.