Exemple #1
0
	def addCar(self,carAppearance,isPlayerCar):

		newVisualCar=Factory.Car(carAppearance)

		newVisualCar.reparentTo(self.carsAndSceneryNode)
		newVisualCar.setPos(self.segments[100].getMidPoint().getX(),self.segments[100].getMidPoint().getY(),0)
		newVisualCar.setH(270)

		constantOneStencil = StencilAttrib.make(1,StencilAttrib.SCFEqual,StencilAttrib.SOZero,StencilAttrib.SOKeep,StencilAttrib.SOReplace,1,0,1)

		bob=ShadowGeometry('models/f1carshadow')
		newVisualCarShadowGeomNode=bob.getSnode()
		lightSourceX,lightSourceY,lightSourceZ=self.getLightSourcePosition()
		bob.setLightPos(lightSourceX,lightSourceY,lightSourceZ)
		newVisualCarShadow=render.attachNewNode(newVisualCarShadowGeomNode)
		newVisualCarShadow.setTwoSided(True)
		newVisualCarShadow.node().setAttrib(constantOneStencil)
		newVisualCarShadow.node().setAttrib(ColorWriteAttrib.make(0))
		newVisualCarShadow.setBin('fixed',40)
		newVisualCarShadow.setDepthWrite(0)

		self.createdNodes.append(newVisualCar)
		self.createdNodes.append(newVisualCarShadow)
		visualCarRepresentation=VisualCarRepresentation(newVisualCar,bob,newVisualCarShadow)
		self.cars.append(visualCarRepresentation)
		if isPlayerCar:
			self.setPlayerCar(visualCarRepresentation)

		return visualCarRepresentation