コード例 #1
0
    def createPitchLineOld(self,points=[0.5,0.25,-0.25,-0.5],
                            tick=0.00,colour=None):
        """ create a line to hint at the pitch of the aircraft on the hud """
        if colour is None:
            colour = self.colour

        l = LineNodePath(aspect2d,'pitchline',4,Vec4(colour[0],colour[1],
                                                       colour[2],colour[3]))

        plist = []
        for p in points:
            plist.append((p,0.0,0.0))
        plist.insert(0,(points[0],0.0,tick))
        plist.append((points[3],0.0,tick))

        linelist = []
        linelist = [[plist[p],plist[p+1]] for p in range(len(plist)-1)]
        linelist.pop(2)
        l.drawLines(linelist)
        l.create()

        # These lines are drawn from scratch rather than using a graphic file

        format = GeomVertexFormat.getV3()
        vdata = GeomVertexData("vertices",format,Geom.UHStatic)

        # create vertices to add to use in creating lines
        vertexWriter=GeomVertexWriter(vdata,"vertex")
        # here we define enough positions to create two separated lines
        for p in points:
            vertexWriter.addData3f(p,0.0,0.0)
        # and another two positions for the 'ticks' at the line ends
        vertexWriter.addData3f(points[0],0.0,tick)
        vertexWriter.addData3f(points[3],0.0,tick)

        # create the primitives
        line = GeomLines(Geom.UHStatic)
        line.addVertices(4,0) # the tick part
        line.addVertices(0,1) # part of the horizontal line
        line.closePrimitive()
        line2 = GeomLines(Geom.UHStatic)
        line2.addVertices(2,3) # other part of the horizontal line
        line2.addVertices(3,5) # second tick
        line2.closePrimitive()

        # add the lines to a geom object
        lineGeom = Geom(vdata)
        lineGeom.addPrimitive(line)
        lineGeom.addPrimitive(line2)

        # create the node..
        lineGN=GeomNode("splitline")
        lineGN.addGeom(lineGeom)

        # and parent the node to aspect2d
        lineNP = aspect2d.attachNewNode(lineGN)
        return lineNP
コード例 #2
0
def create_line(x1, z1, x2, z2):
    format = GeomVertexFormat.getV3n3c4t2()
    vdata = GeomVertexData('', format, Geom.UHStatic)
    vertex = GeomVertexWriter(vdata, 'vertex')
    normal = GeomVertexWriter(vdata, 'normal')
    vertex.addData3f(x1, 0, z1)
    vertex.addData3f(x2, 0, z2) 
    for _i in range(2):
        normal.addData3f(0, - 1, 0)
    prim_hint = Geom.UHStatic
    prim = GeomLines(prim_hint)
    prim.addVertices(0, 1)
    prim.closePrimitive()
    geom = Geom(vdata)
    geom.addPrimitive(prim)
    node = GeomNode('')
    node.addGeom(geom)
    return (node, vdata)
コード例 #3
0
    def createCentreMarkOld(self,colour=None):
        """ create a line to hint at the pitch of the aircraft on the hud """
        if colour is None:
            colour = self.colour

        # These lines are drawn from scratch rather than using a graphic file

        format = GeomVertexFormat.getV3()
        vdata = GeomVertexData("vertices",format,Geom.UHStatic)

        # create vertices to add to use in creating lines
        vertexWriter=GeomVertexWriter(vdata,"vertex")
        # essentially I am trying to create a line that gives an idea of
        #       where the forward vector of the plane is pointing which
        #       helps indicate the pitch
        # the bends in the line could be used to indicate a few angles but
        #       I am not sure how useful this really is.
        vertexWriter.addData3f(0.15,0.0,0.0)
        vertexWriter.addData3f(0.10,0.0,0.0)
        vertexWriter.addData3f(0.05,0.0,-0.025)
        vertexWriter.addData3f(0.00,0.0,0.025)
        vertexWriter.addData3f(-0.05,0.0,-0.025)
        vertexWriter.addData3f(-0.10,0.0,0.0)
        vertexWriter.addData3f(-0.15,0.0,0.0)

        # create the primitives
        line = GeomLines(Geom.UHStatic)
        line.addVertices(0,1)
        line.addVertices(1,2)
        line.addVertices(2,3)
        line.addVertices(3,4)
        line.addVertices(4,5)
        line.addVertices(5,6)
        line.closePrimitive()

        # add the lines to a geom object
        lineGeom = Geom(vdata)
        lineGeom.addPrimitive(line)

        # create the node..
        lineGN=GeomNode("centremark")
        lineGN.addGeom(lineGeom)

        # and parent the node to aspect2d
        lineNP = aspect2d.attachNewNode(lineGN)
        return lineNP
コード例 #4
0
ファイル: world.py プロジェクト: JustinMarshall98/Ganesha
	def init_node_path(self):
		if self.node_path:
			self.node_path.remove()
		vdata = GeomVertexData('name_me', self.format, Geom.UHStatic)
		vertex = GeomVertexWriter(vdata, 'vertex')
		color = GeomVertexWriter(vdata, 'color')
		primitive = GeomLines(Geom.UHStatic)
		vertex.addData3f(*coords_to_panda(0, 0, 0))
		vertex.addData3f(*coords_to_panda(1000, 0, 0))
		vertex.addData3f(*coords_to_panda(0, 0, 0))
		vertex.addData3f(*coords_to_panda(0, -1000, 0))
		vertex.addData3f(*coords_to_panda(0, 0, 0))
		vertex.addData3f(*coords_to_panda(0, 0, 1000))
		color.addData4f(1.0, 0.0, 0.0, 1.0)
		color.addData4f(1.0, 0.0, 0.0, 1.0)
		color.addData4f(0.0, 1.0, 0.0, 1.0)
		color.addData4f(0.0, 1.0, 0.0, 1.0)
		color.addData4f(0.0, 0.0, 1.0, 1.0)
		color.addData4f(0.0, 0.0, 1.0, 1.0)
		primitive.addNextVertices(6)
		primitive.closePrimitive()
		geom = Geom(vdata)
		geom.addPrimitive(primitive)
		node = GeomNode('gnode')
		node.addGeom(geom)
		self.node_path = self.parent.node_path_ui.attachNewNode(node)
コード例 #5
0
ファイル: world.py プロジェクト: JustinMarshall98/Ganesha
	def init_node_path_line(self, light_number):
		if self.node_path_line:
			self.node_path_line.remove()
		vdata = GeomVertexData('name_me', self.format, Geom.UHStatic)
		vertex = GeomVertexWriter(vdata, 'vertex')
		color = GeomVertexWriter(vdata, 'color')
		primitive = GeomLines(Geom.UHStatic)
		vertex.addData3f(*coords_to_panda(0, 0, 0))
		vertex.addData3f(*coords_to_panda(*self.direction.coords))
		if light_number == 0:
			line_color = (0.0, 1.0, 1.0, 1.0)
		elif light_number == 1:
			line_color = (1.0, 0.0, 1.0, 1.0)
		elif light_number == 2:
			line_color = (1.0, 1.0, 0.0, 1.0)
		color.addData4f(*line_color)
		color.addData4f(*line_color)
		primitive.addNextVertices(2)
		primitive.closePrimitive()
		geom = Geom(vdata)
		geom.addPrimitive(primitive)
		node = GeomNode('gnode')
		node.addGeom(geom)
		self.node_path_line = self.parent.node_path_ui.attachNewNode(node)
		self.node_path_line.setScale(1000)
		self.node_path_line.setPos(100, 100, 0)
		self.show_line(self.parent.parent.lights_edit_window.IsShown())
コード例 #6
0
def create_line(x1, z1, x2, z2):
    format = GeomVertexFormat.getV3n3c4t2()
    vdata = GeomVertexData('', format, Geom.UHStatic)
    vertex = GeomVertexWriter(vdata, 'vertex')
    normal = GeomVertexWriter(vdata, 'normal')
    vertex.addData3f(x1, 0, z1)
    vertex.addData3f(x2, 0, z2) 
    for _i in range(2):
        normal.addData3f(0, - 1, 0)
    prim_hint = Geom.UHStatic
    prim = GeomLines(prim_hint)
    prim.addVertices(0, 1)
    prim.closePrimitive()
    geom = Geom(vdata)
    geom.addPrimitive(prim)
    node = GeomNode('')
    node.addGeom(geom)
    return (node, vdata)
コード例 #7
0
ファイル: world.py プロジェクト: JustinMarshall98/Ganesha
	def init_node_path(self):
		if self.node_path:
			self.node_path.remove()
		vdata = GeomVertexData('name_me', self.format, Geom.UHStatic)
		vertex = GeomVertexWriter(vdata, 'vertex')
		color = GeomVertexWriter(vdata, 'color')
		primitive = GeomLines(Geom.UHStatic)
		vertex.addData3f(*coords_to_panda(*self.vector))
		vertex.addData3f(*coords_to_panda(*[-x for x in self.vector]))
		color.addData4f((1.0, 0.0, 0.0, 1.0,))
		color.addData4f((0.0, 0.0, 1.0, 1.0,))
		primitive.addNextVertices(2)
		primitive.closePrimitive()
		geom = Geom(vdata)
		geom.addPrimitive(primitive)
		node = GeomNode('gnode')
		node.addGeom(geom)
		self.node_path = self.parent.parent.node_path_ui.attachNewNode(node)
		self.node_path.setScale(20)
		self.node_path.setPos(*coords_to_panda(*self.coords))