class Ship(Item):
    __module__ = __name__

    def __init__(self, shipInfo, *args, **kwargs):
        name = shipInfo[1]
        Item.__init__(self, name, *args, **kwargs)
        self.setTag('shipName', name)
        self.shipModel = ShipMeter(shipInfo[0], shipInfo[2], shipInfo[3])
        self.shipModel.reparentTo(self)
        self.shipModel.setScale(0.13)
        self.shipModel.setTwoSided(1)
        formattedName = '\x01smallCaps\x01\x01slant\x01' + name.replace(
            ' ', '\n') + '\x02\x02'
        self.text = Text(name + '-text',
                         NodePath(),
                         0.0,
                         formattedName,
                         0,
                         scale=0.017)
        self.text.reparentTo(self)
        if self.shipModel.getBounds().isEmpty():
            r = 10
        else:
            r = self.shipModel.getBounds().getRadius()
        self.text.setPos(0, -r * 0.75, 0.001)
        self.setBin('fixed', 300)
        self.text.setBin('fixed', 301)
        self.shipNode = NodePath('Ship')
        self.shipNode.reparentTo(self)
        self.shipNode.setBillboardPointEye()
        self.shipNode.setPos(0, -0.005, 0)
        self.shipNode.setHpr(0, 30, 0)
        self.shipModel.reparentTo(self.shipNode)

    def setRotation(self, worldNorth, rotation):
        self.shipModel.setH(rotation)

    def updateZoom(self, zoom):
        self.text.setScale(1 - zoom / 1.5)

    def destroy(self):
        if self.shipModel:
            self.shipModel.destroy()
            self.shipModel = None
        return
Exemple #2
0
class Ship(Item):

    def __init__(self, shipInfo, *args, **kwargs):
        name = shipInfo[1]
        Item.__init__(self, name, *args, **kwargs)
        self.setTag('shipName', name)
        self.shipModel = ShipMeter(shipInfo[0], shipInfo[2], shipInfo[3])
        self.shipModel.reparentTo(self)
        self.shipModel.setScale(0.13)
        self.shipModel.setTwoSided(1)
        formattedName = 'smallCapsslant' + name.replace(' ', '\n') + ''
        self.text = Text(name + '-text', NodePath(), 0.0, formattedName, 0, scale = 0.017000000000000001)
        self.text.reparentTo(self)
        if self.shipModel.getBounds().isEmpty():
            r = 10
        else:
            r = self.shipModel.getBounds().getRadius()
        self.text.setPos(0, -r * 0.75, 0.001)
        self.setBin('fixed', 300)
        self.text.setBin('fixed', 301)
        self.shipNode = NodePath('Ship')
        self.shipNode.reparentTo(self)
        self.shipNode.setBillboardPointEye()
        self.shipNode.setPos(0, -0.0050000000000000001, 0)
        self.shipNode.setHpr(0, 30, 0)
        self.shipModel.reparentTo(self.shipNode)


    def setRotation(self, worldNorth, rotation):
        self.shipModel.setH(rotation)


    def updateZoom(self, zoom):
        self.text.setScale(1 - zoom / 1.5)


    def destroy(self):
        if self.shipModel:
            self.shipModel.destroy()
            self.shipModel = None