コード例 #1
0
 def drawLinePlot(self, colourFades, dataPoints):
     ac.glBegin(1)
     for dataPoint, colour in zip(dataPoints, colourFades):
         ac.glColor4f(*colour)
         x, y = self.gPlotter.plotG(dataPoint['x'], dataPoint['z'])
         ac.glVertex2f(x,y)
     ac.glEnd()
コード例 #2
0
 def drawCircumference(self, radius, center):
     ac.glBegin(1)
     nlines = max(4, int(100.*radius))
     for i in range(nlines+1):
         x, y = self.gPlotter.plotG(center['x'] + (sin(2*pi*i/nlines)*radius), center['z'] + (cos(2*pi*i/nlines)*radius))
         ac.glVertex2f(x, y)
     ac.glEnd()
コード例 #3
0
    def drawYourself(self):

        global colorRecipeList

        # 配色
        recipe = colorRecipeList[self.colorRecipe]

        ac.glColor4f(1, 1, 1, self.maxOpacity * maxiumAlpha)
        ac.glBegin(3)  # 3 : Draw quads.
        # 先画底框(被车框覆盖后就会留下边线)
        ac.glColor4f(recipe[2][0], recipe[2][1], recipe[2][2],
                     self.maxOpacity * maxiumAlpha)

        for i, pt in enumerate(self.guiBorderPtList):
            ac.glVertex2f(pt.x, pt.y)
        ac.glEnd()

        # 再画车框
        ac.glBegin(3)  # 3 : Draw quads.
        #ac.log('helipicapew::drawYourself car paint pt list:-----------')
        for i, pt in enumerate(self.guiPtList):
            #ac.log('helipicapew::drawYourself tyre index: {}, pt: {} {}'.format(pt.partIndex, pt.x, pt.y))
            # 根据点代表的轮胎位置更新颜色设置
            if pt.partIndex == 0 or pt.partIndex == 1:
                ac.glColor4f(recipe[0][0], recipe[0][1], recipe[0][2],
                             self.maxOpacity * maxiumAlpha)
            else:
                ac.glColor4f(recipe[1][0], recipe[1][1], recipe[1][2],
                             self.maxOpacity * maxiumAlpha)
            ac.glVertex2f(pt.x, pt.y)
        ac.glEnd()
コード例 #4
0
 def drawLinePlot(self, colourFades, dataPoints):
     ac.glBegin(1)
     for dataPoint, colour in zip(dataPoints, colourFades):
         ac.glColor4f(*colour)
         x, y = self.gPlotter.plotG(dataPoint['x'], dataPoint['z'])
         ac.glVertex2f(x, y)
     ac.glEnd()
コード例 #5
0
def draw_triangle(points, color=[1, 1, 1]):
    r, g, b = color
    ac.glColor4f(r, g, b, 1)
    ac.glBegin(acsys.GL.Triangles)
    for x_y_tuple in points:
        x, y = x_y_tuple
        ac.glVertex2f(x, y)
    ac.glEnd()
コード例 #6
0
def draw_colored_bars_with_points(slip, tyre):
    global max_slip, rectangle_corners
    r, g, b = get_color(slip)
    ac.glColor4f(r, g, b, 1)
    ac.glBegin(acsys.GL.Quads)
    for corner in rectangle_corners:
        x, y = tyre[corner]
        ac.glVertex2f(x, y)
    ac.glEnd()
コード例 #7
0
def draw_bar(points, color=[1, 1, 1]):
    global rectangle_corners
    r, g, b = color
    ac.glColor4f(r, g, b, 1)
    ac.glBegin(acsys.GL.Quads)
    for corner in rectangle_corners:
        x, y = points[corner]
        ac.glVertex2f(x, y)
    ac.glEnd()
コード例 #8
0
 def drawCircumference(self, radius, center):
     ac.glBegin(1)
     nlines = max(4, int(100. * radius))
     for i in range(nlines + 1):
         x, y = self.gPlotter.plotG(
             center['x'] + (sin(2 * pi * i / nlines) * radius),
             center['z'] + (cos(2 * pi * i / nlines) * radius))
         ac.glVertex2f(x, y)
     ac.glEnd()
コード例 #9
0
    def polygon(points, color=Color(1, 1, 1, 1), filled=True):
        ac.glColor4f(color.r, color.g, color.b, color.a)
        if filled:
            ac.glBegin(2)
        else:
            ac.glBegin(1)

        for i in points:
            if isinstance(i, Point):
                ac.glVertex2f(i.x, i.y)

        ac.glEnd()
コード例 #10
0
def drawGMeter():
	global posting, post_time_elapsed, post_total_time
	# Colors
	c1 = [0.0,200/255,1.0,g_meter_opacity] # Middle one
	c2 = [0.0,150/255,1.0,g_meter_opacity] # Inner
	c3 = [0.0,125/255,1.0,g_meter_opacity] # Middle inner
	c4 = [0.0,100/255,1.0,g_meter_opacity] # Outer
	g = ac.getCarState(0,acsys.CS.AccG)[0]
	# Neg range: 660..511
	# Pos range: 660..809
	l_x = r_x = 0
	pixels = int(abs(g)*(g_meter_range/2.52))
	if abs(g) >= 2.52:
		pixels = g_meter_range # ALL OF THEM
	if g < 0:
		r_x = g_meter_x_anchor
		l_x = r_x - pixels
	else:
		l_x = g_meter_x_anchor
		r_x = l_x + pixels
	t_y = g_meter_y_anchor
	for i in range(0,11,1):
		c = []
		offset = 0
		if i == 0 or i == 1 or i == 9 or i == 10:
			c = c4
			offset = 4
		elif i == 2 or i == 8:
			c = c3
			offset = 2
		elif i == 3 or i == 7:
			c = c3
			offset = 1
		elif i == 4 or i == 6:
			c = c2
			offset = 1
		else:
			c = c1
		if g > 0 and r_x - offset <= l_x:
			continue
		elif g < 0 and l_x + offset >= r_x:
			continue
		l_offset = r_offset = 0
		if g > 0:
			r_offset = - offset
		if g < 0:
			l_offset = offset
		ac.glBegin(0)
		ac.glColor4f(c[0],c[1],c[2],c[3])
		ac.glVertex2f(l_x+l_offset,t_y+i)
		ac.glVertex2f(r_x+r_offset,t_y+i)
		ac.glEnd()
コード例 #11
0
ファイル: z3dgauge.py プロジェクト: iocube/z3dGauge
def appGL(deltaT):
    
    global gX, gY, gZ, gXleft, gZback
    
    # drawing the gauge's background primitive aka a square
    # initial values
    x0 = 20.0   # point 1
    y0 = 20.0
    x1 = 20.0   # point 2
    y1 = 500.0 #500
    x2 = 500.0   # point 3
    y2 = 500.0
    x3 = 500.0 #500  point 4
    y3 = 20.0  # so I'm gonna have to find a way to make these variables be affected by gforces

    # calucated values with gforces into account
    x00 = x0 + (abs(gZ)*100)    # forward
    y00 = y0 + (abs(gXleft)*100)    #right
    x11 = x1 + (abs(gZback)*100)    #reverse
    y11 = y1 - (abs(gXleft)*100)    #right
    x22 = x2 - (abs(gZback)*100)    #reverse
    y22 = y2 - (abs(gX)*100)    #left
    x33 = x3 - (abs(gZ)*100)    #forward
    y33 = y3 + (abs(gX)*100)    #left

    ac.glBegin(acsys.GL.Quads)
    ac.glColor4f(50,0,0,0.5)

    ac.glVertex2f(x00, y00) # top left in brainlet terms aka for dummies like me
    ac.glVertex2f(x11, y11)   # bottom left
    ac.glVertex2f(x22, y22) # bottom right
    ac.glVertex2f(x33, y33)   #top right
    ac.glEnd()
コード例 #12
0
 def drawCross(self, radius):
     ac.glBegin(1)
     ac.glVertex2f(*self.gPlotter.plotG(-radius, 0))
     ac.glVertex2f(*self.gPlotter.plotG(+radius, 0))
     ac.glEnd()
     ac.glBegin(1)
     ac.glVertex2f(*self.gPlotter.plotG(0, -radius))
     ac.glVertex2f(*self.gPlotter.plotG(0, +radius))
     ac.glEnd()
コード例 #13
0
 def drawCross(self, radius):
     ac.glBegin(1)
     ac.glVertex2f(*self.gPlotter.plotG(-radius, 0))
     ac.glVertex2f(*self.gPlotter.plotG(+radius, 0))
     ac.glEnd()
     ac.glBegin(1)
     ac.glVertex2f(*self.gPlotter.plotG(0, -radius))
     ac.glVertex2f(*self.gPlotter.plotG(0, +radius))
     ac.glEnd()
コード例 #14
0
def drawboostBars(x,y):
    ac.glColor4f(1,0.31,0,1)
    ac.glQuad(0,42,percentage_boost*4.35,8)
    #ac.glQuad(960,42,-percentage_boost*4.35,8)
    ac.glBegin(acsys.GL.Quads)
    ac.glVertex2f(960,42)
    ac.glVertex2f(960-percentage_boost*4.35,42)
    ac.glVertex2f(960-percentage_boost*4.35,50)
    ac.glVertex2f(960,50)
    ac.glEnd()
コード例 #15
0
def drawboostBars(x, y):
    ac.glColor4f(1, 0.31, 0, 1)
    ac.glQuad(0, 42, percentage_boost * 4.35, 8)
    #ac.glQuad(960,42,-percentage_boost*4.35,8)
    ac.glBegin(acsys.GL.Quads)
    ac.glVertex2f(960, 42)
    ac.glVertex2f(960 - percentage_boost * 4.35, 42)
    ac.glVertex2f(960 - percentage_boost * 4.35, 50)
    ac.glVertex2f(960, 50)
    ac.glEnd()
コード例 #16
0
    def arc(x,
            y,
            radius,
            start=0,
            stop=360,
            color=Color(1, 1, 1, 1),
            filled=True):
        ac.glColor4f(color.r, color.g, color.b, color.a)
        if filled:
            ac.glBegin(2)
        else:
            ac.glBegin(1)

        sample = (stop - start) / (36 * radius)
        while start <= stop:
            rad1 = start
            rad2 = min(start + 1, stop)
            ac.glVertex2f(x + cos(rad1) * radius, y - sin(rad1) * radius)
            ac.glVertex2f(x + cos(rad2) * radius, y - sin(rad2) * radius)
            if filled:
                ac.glVertex2f(x, y)

            start += sample

        ac.glEnd()
コード例 #17
0
    def draw(self, data, delta_t: float) -> None:
        rect = self._box.rect
        camber = data.camber
        tan = math.tan(camber) * rect[2]
        tan_left = -(tan if camber < 0.0 else 0.0)
        tan_right = tan if camber > 0.0 else 0.0

        ac.glBegin(acsys.GL.Quads)
        ac.glColor4f(*Colors.white)
        ac.glVertex2f(rect[0], rect[1] + tan_left)
        ac.glVertex2f(rect[0], rect[1] + rect[3])
        ac.glVertex2f(rect[0] + rect[2], rect[1] + rect[3])
        ac.glVertex2f(rect[0] + rect[2], rect[1] + tan_right)
        ac.glEnd()
コード例 #18
0
ファイル: gl.py プロジェクト: styinx/ACLIB
def circle(x: int,
           y: int,
           radius: int,
           color: Color = Color(1, 1, 1, 1),
           filled: bool = True):
    ac.glColor4f(color.r, color.g, color.b, color.a)
    if filled:
        ac.glBegin(2)
    else:
        ac.glBegin(1)

    start = 0
    stop = 360
    sample = 36 * radius
    while start <= stop:
        rad1 = start
        rad2 = min(start + 1, stop)
        ac.glVertex2f(x + cos(rad1) * radius, y - sin(rad1) * radius)
        ac.glVertex2f(x + cos(rad2) * radius, y - sin(rad2) * radius)
        if filled:
            ac.glVertex2f(x, y)

        start += sample

    ac.glEnd()
コード例 #19
0
ファイル: gl.py プロジェクト: styinx/ACLIB
def arc(x: int,
        y: int,
        r: int,
        start: int = 0,
        stop: int = 360,
        color: Color = Color(1, 1, 1, 1),
        filled: bool = True):
    ac.glColor4f(color.r, color.g, color.b, color.a)
    if filled:
        ac.glBegin(2)
    else:
        ac.glBegin(1)

    sample = (stop - start) / (36 * r)
    while start <= stop:
        rad1 = start
        rad2 = min(start + 1, stop)
        ac.glVertex2f(x + cos(rad1) * r, y - sin(rad1) * r)
        ac.glVertex2f(x + cos(rad2) * r, y - sin(rad2) * r)
        if filled:
            ac.glVertex2f(x, y)

        start += sample

    ac.glEnd()
コード例 #20
0
def drawrpmBars(x,y):
    if(abs(percentage_rpm)<max_user_rpm):ac.glColor4f(1,1,1,1)
    if(abs(percentage_rpm)>max_user_rpm):ac.glColor4f(1,0,0,1)
    if(percentage_rpm <min_user_rpm):
        ac.glQuad(0,20,0,20)
        ac.glQuad(960,20,0,20)
    if(percentage_rpm >min_user_rpm):
        ac.glQuad(0,20,abs(percentage_rpm-min_user_rpm)*435/(100-min_user_rpm),20)
        #ac.glQuad(960,20,-(abs(percentage_rpm-min_user_rpm)*435/(100-min_user_rpm)),20)
        ac.glBegin(acsys.GL.Quads)
        ac.glVertex2f(960,20)
        ac.glVertex2f(960-abs(percentage_rpm-min_user_rpm)*435/(100-min_user_rpm),20)
        ac.glVertex2f(960-abs(percentage_rpm-min_user_rpm)*435/(100-min_user_rpm),40)
        ac.glVertex2f(960, 40)
        ac.glEnd()
コード例 #21
0
 def drawCircle(self, radius, center):
     ac.glBegin(acsys.GL.Triangles)
     prevx, prevy = self.gPlotter.plotG(center['x'], center['z'])
     ntriangles = max(4, int(100.*radius))
     for i in range(ntriangles+1):
         ac.glVertex2f(*self.gPlotter.plotG(center['x'], center['z']))
         ac.glVertex2f(prevx, prevy)
         x, y = self.gPlotter.plotG(center['x'] + (sin(2*pi*i/ntriangles)*radius), center['z'] + (cos(2*pi*i/ntriangles)*radius))
         ac.glVertex2f(x, y)
         prevx, prevy = x, y
     ac.glEnd()
コード例 #22
0
ファイル: AccAnalogSpeedometer.py プロジェクト: acclub/apps
def drawNeedle(delta_t):
    speed = ac.getCarState(0, acsys.CS.SpeedKMH)
    if limited and speed > speedMaximum: speed = speedMaximum
    radValue = speed / speedMaximum * radRange + radStartingPoint

    dx = math.sin(radValue)
    dy = math.cos(radValue)
    tx = halfWidth - dx * halfWidth
    ty = halfHeight + dy * halfHeight
    ax = dx * halfArrowWidth
    ay = dy * halfArrowWidth

    ac.glColor4f(1.0, 0.2, 0.2, 0.8) # color
    ac.glBegin(acsys.GL.Quads)
    ac.glVertex2f(halfWidth + ay, halfHeight + ax)
    ac.glVertex2f(halfWidth - ay, halfHeight - ax)
    ac.glVertex2f(tx - ay, ty - ax)
    ac.glVertex2f(tx + ay, ty + ax)
    ac.glEnd()
コード例 #23
0
 def drawCircle(self, radius, center):
     ac.glBegin(acsys.GL.Triangles)
     prevx, prevy = self.gPlotter.plotG(center['x'], center['z'])
     ntriangles = max(4, int(100. * radius))
     for i in range(ntriangles + 1):
         ac.glVertex2f(*self.gPlotter.plotG(center['x'], center['z']))
         ac.glVertex2f(prevx, prevy)
         x, y = self.gPlotter.plotG(
             center['x'] + (sin(2 * pi * i / ntriangles) * radius),
             center['z'] + (cos(2 * pi * i / ntriangles) * radius))
         ac.glVertex2f(x, y)
         prevx, prevy = x, y
     ac.glEnd()
コード例 #24
0
def drawrpmBars(x, y):
    if (abs(percentage_rpm) < max_user_rpm): ac.glColor4f(1, 1, 1, 1)
    if (abs(percentage_rpm) > max_user_rpm): ac.glColor4f(1, 0, 0, 1)
    if (percentage_rpm < min_user_rpm):
        ac.glQuad(0, 20, 0, 20)
        ac.glQuad(960, 20, 0, 20)
    if (percentage_rpm > min_user_rpm):
        ac.glQuad(
            0, 20,
            abs(percentage_rpm - min_user_rpm) * 435 / (100 - min_user_rpm),
            20)
        #ac.glQuad(960,20,-(abs(percentage_rpm-min_user_rpm)*435/(100-min_user_rpm)),20)
        ac.glBegin(acsys.GL.Quads)
        ac.glVertex2f(960, 20)
        ac.glVertex2f(
            960 - abs(percentage_rpm - min_user_rpm) * 435 /
            (100 - min_user_rpm), 20)
        ac.glVertex2f(
            960 - abs(percentage_rpm - min_user_rpm) * 435 /
            (100 - min_user_rpm), 40)
        ac.glVertex2f(960, 40)
        ac.glEnd()
コード例 #25
0
def drawFuelGauge():
	global max_fuel, fuel_warning_label
	fuel = sim_info.physics.fuel
	rad = (fuel/max_fuel)*math.pi # 180 deg range so it's easy
	outer_radius = fuel_radius 
	inner_radius = outer_radius - 4
	if fuel/max_fuel > 0.125:
		ac.setPosition(fuel_warning_label,-10000,0)
	else:
		ac.setPosition(fuel_warning_label,fuel_pivot_x - 6,fuel_pivot_y - 30)
	for i in range(0,int((fuel/max_fuel)*100),1):
		# p3 p4 - rad2
		# p1 p2 - rad1
		rad1 = math.pi - math.pi*(i/100)
		rad2 = math.pi - math.pi*((i+1)/100)
		
		p1_x = math.cos(rad1)*outer_radius + fuel_pivot_x
		p1_y = fuel_pivot_y - math.sin(rad1)*outer_radius
		p2_x = math.cos(rad1)*inner_radius + fuel_pivot_x
		p2_y = fuel_pivot_y - math.sin(rad1)*inner_radius
		p3_x = math.cos(rad2)*outer_radius + fuel_pivot_x
		p3_y = fuel_pivot_y - math.sin(rad2)*outer_radius
		p4_x = math.cos(rad2)*inner_radius + fuel_pivot_x
		p4_y = fuel_pivot_y - math.sin(rad2)*inner_radius
		
		ac.glBegin(2)
		ac.glColor4f(fuel_bar_color[0],fuel_bar_color[1],fuel_bar_color[2],fuel_bar_color[3])
		ac.glVertex2f(p1_x,p1_y)
		ac.glVertex2f(p2_x,p2_y)
		ac.glVertex2f(p3_x,p3_y)
		ac.glEnd()
		ac.glBegin(2)
		ac.glColor4f(fuel_bar_color[0],fuel_bar_color[1],fuel_bar_color[2],fuel_bar_color[3])
		ac.glVertex2f(p3_x,p3_y)
		ac.glVertex2f(p2_x,p2_y)
		ac.glVertex2f(p4_x,p4_y)
		ac.glEnd()
	# Needle
	rad = math.pi - rad
	bigend_x    = math.cos(rad)*fuel_radius + fuel_pivot_x
	bigend_y    = fuel_pivot_y - math.sin(rad)*fuel_radius
	littleend_x = math.cos(rad+math.pi)*fuel_needle_end + fuel_pivot_x
	littleend_y = fuel_pivot_y - math.sin(rad+math.pi)*fuel_needle_end
	# p1 p2 = big end
	# p3 p4 = little end
	p1_x = math.cos(rad+math.pi/2) + bigend_x
	p1_y = bigend_y - math.sin(rad+math.pi/2)
	p2_x = math.cos(rad-math.pi/2) + bigend_x
	p2_y = bigend_y - math.sin(rad-math.pi/2)
	p3_x = math.cos(rad+math.pi/2) + littleend_x
	p3_y = littleend_y - math.sin(rad+math.pi/2)
	p4_x = math.cos(rad-math.pi/2) + littleend_x
	p4_y = littleend_y - math.sin(rad-math.pi/2)
	
	ac.glBegin(2)
	ac.glColor4f(fuel_needle_color[0],fuel_needle_color[1],fuel_needle_color[2],fuel_needle_color[3])
	ac.glVertex2f(p1_x,p1_y)
	ac.glVertex2f(p3_x,p3_y)
	ac.glVertex2f(p4_x,p4_y)
	ac.glEnd()
	ac.glBegin(2)
	ac.glColor4f(fuel_needle_color[0],fuel_needle_color[1],fuel_needle_color[2],fuel_needle_color[3])
	ac.glVertex2f(p1_x,p1_y)
	ac.glVertex2f(p4_x,p4_y)
	ac.glVertex2f(p2_x,p2_y)
	ac.glEnd()
コード例 #26
0
def drawBoostGauge():
	global max_boost
	boost = ac.getCarState(0,acsys.CS.TurboBoost)
	if boost > max_boost:
		max_boost = boost
	rad = (boost/max_boost)*math.pi # 180 deg range so it's easy
	outer_radius = boost_radius
	inner_radius = outer_radius - 4
	for i in range(0,int((boost/max_boost)*100),1):
		# p3 p4 - rad2
		# p1 p2 - rad1
		rad1 = math.pi - math.pi*(i/100)
		rad2 = math.pi - math.pi*((i+1)/100)
		
		p1_x = math.cos(rad1)*outer_radius + boost_pivot_x
		p1_y = boost_pivot_y - math.sin(rad1)*outer_radius
		p2_x = math.cos(rad1)*inner_radius + boost_pivot_x
		p2_y = boost_pivot_y - math.sin(rad1)*inner_radius
		p3_x = math.cos(rad2)*outer_radius + boost_pivot_x
		p3_y = boost_pivot_y - math.sin(rad2)*outer_radius
		p4_x = math.cos(rad2)*inner_radius + boost_pivot_x
		p4_y = boost_pivot_y - math.sin(rad2)*inner_radius
		
		ac.glBegin(2)
		ac.glColor4f(boost_bar_color[0],boost_bar_color[1],boost_bar_color[2],boost_bar_color[3])
		ac.glVertex2f(p1_x,p1_y)
		ac.glVertex2f(p2_x,p2_y)
		ac.glVertex2f(p3_x,p3_y)
		ac.glEnd()
		ac.glBegin(2)
		ac.glColor4f(boost_bar_color[0],boost_bar_color[1],boost_bar_color[2],boost_bar_color[3])
		ac.glVertex2f(p3_x,p3_y)
		ac.glVertex2f(p2_x,p2_y)
		ac.glVertex2f(p4_x,p4_y)
		ac.glEnd()
	# Needle
	rad = math.pi - rad
	bigend_x    = math.cos(rad)*boost_radius + boost_pivot_x
	bigend_y    = boost_pivot_y - math.sin(rad)*boost_radius
	littleend_x = math.cos(rad+math.pi)*boost_needle_end + boost_pivot_x
	littleend_y = boost_pivot_y - math.sin(rad+math.pi)*boost_needle_end
	# p1 p2 = big end
	# p3 p4 = little end
	p1_x = math.cos(rad+math.pi/2) + bigend_x
	p1_y = bigend_y - math.sin(rad+math.pi/2)
	p2_x = math.cos(rad-math.pi/2) + bigend_x
	p2_y = bigend_y - math.sin(rad-math.pi/2)
	p3_x = math.cos(rad+math.pi/2) + littleend_x
	p3_y = littleend_y - math.sin(rad+math.pi/2)
	p4_x = math.cos(rad-math.pi/2) + littleend_x
	p4_y = littleend_y - math.sin(rad-math.pi/2)
	
	ac.glBegin(2)
	ac.glColor4f(boost_needle_color[0],boost_needle_color[1],boost_needle_color[2],boost_needle_color[3])
	ac.glVertex2f(p1_x,p1_y)
	ac.glVertex2f(p3_x,p3_y)
	ac.glVertex2f(p4_x,p4_y)
	ac.glEnd()
	ac.glBegin(2)
	ac.glColor4f(boost_needle_color[0],boost_needle_color[1],boost_needle_color[2],boost_needle_color[3])
	ac.glVertex2f(p1_x,p1_y)
	ac.glVertex2f(p4_x,p4_y)
	ac.glVertex2f(p2_x,p2_y)
	ac.glEnd()
コード例 #27
0
def drawTachometer(deltaT):
	rpm = ac.getCarState(0,acsys.CS.RPM)
	# degree range: 190..-10
	r = abs(tach_min_angle - tach_max_angle)
	rpm_deg = tach_max_angle - (rpm/indicated_max_rpm)*r
	rpm_rad = math.radians(rpm_deg)
	# Redline
	redline_start = (max_rpm - 500) - (max_rpm % 250)
	for i in range(0,indicated_max_rpm+1,250):
		if i >= redline_start and i+250 <= indicated_max_rpm:
			rad1 = math.radians(tach_max_angle - (i/indicated_max_rpm)*r)
			rad2 = math.radians(tach_max_angle - ((i+250)/indicated_max_rpm)*r)
			p1_x = math.cos(rad1)*tach_radius+rpm_pivot_x
			p1_y = -math.sin(rad1)*tach_radius+rpm_pivot_y
			p2_x = math.cos(rad1)*(tach_radius*9/10)+rpm_pivot_x
			p2_y = -math.sin(rad1)*(tach_radius*9/10)+rpm_pivot_y
			p3_x = math.cos(rad2)*tach_radius+rpm_pivot_x
			p3_y = -math.sin(rad2)*tach_radius+rpm_pivot_y
			p4_x = math.cos(rad2)*(tach_radius*9/10)+rpm_pivot_x
			p4_y = -math.sin(rad2)*(tach_radius*9/10)+rpm_pivot_y
			ac.glBegin(2)
			ac.glColor4f(tach_redline_color[0],tach_redline_color[1],tach_redline_color[2],tach_redline_color[3])
			ac.glVertex2f(p1_x,p1_y)
			ac.glVertex2f(p2_x,p2_y)
			ac.glVertex2f(p3_x,p3_y)
			ac.glEnd()
			ac.glBegin(2)
			ac.glColor4f(tach_redline_color[0],tach_redline_color[1],tach_redline_color[2],tach_redline_color[3])
			#ac.glColor4f(1,1,1,1)
			ac.glVertex2f(p3_x,p3_y)
			ac.glVertex2f(p2_x,p2_y)
			ac.glVertex2f(p4_x,p4_y)
			ac.glEnd()
		if i % 1000 == 0:
			rad  = math.radians(tach_max_angle - (i/indicated_max_rpm)*r)
			p1_x = math.cos(rad)*tach_radius+rpm_pivot_x
			p1_y = -math.sin(rad)*tach_radius+rpm_pivot_y
			p2_x = math.cos(rad)*(tach_radius*4/5)+rpm_pivot_x
			p2_y = -math.sin(rad)*(tach_radius*4/5)+rpm_pivot_y
			ac.glBegin(0)
			ac.glColor4f(tach_bigline_color[0],tach_bigline_color[1],tach_bigline_color[2],tach_bigline_color[3])
			ac.glVertex2f(p1_x,p1_y)
			ac.glVertex2f(p2_x,p2_y)
			ac.glEnd()
		elif i % 250 == 0 and i != 0:
			rad  = math.radians(tach_max_angle - (i/indicated_max_rpm)*r)
			p1_x = math.cos(rad)*tach_radius+rpm_pivot_x
			p1_y = -math.sin(rad)*tach_radius+rpm_pivot_y
			p2_x = math.cos(rad)*(tach_radius*9.25/10)+rpm_pivot_x
			p2_y = -math.sin(rad)*(tach_radius*9.25/10)+rpm_pivot_y
			ac.glBegin(0)
			ac.glColor4f(tach_smallline_color[0],tach_smallline_color[1],tach_smallline_color[2],tach_smallline_color[3])
			ac.glVertex2f(p1_x,p1_y)
			ac.glVertex2f(p2_x,p2_y)
			ac.glEnd()
	# Needle
	rpm_x       = math.cos(rpm_rad)*(tach_radius-3)+rpm_pivot_x
	rpm_y       = -math.sin(rpm_rad)*(tach_radius-3)+rpm_pivot_y
	rpm_end_x   = math.cos(rpm_rad+math.pi)*tach_needle_end+rpm_pivot_x
	rpm_end_y   = -math.sin(rpm_rad+math.pi)*tach_needle_end+rpm_pivot_y
	
	rpm_p1_x     = rpm_x + math.cos(rpm_rad-math.pi/2)*1.5
	rpm_p1_y     = rpm_y - math.sin(rpm_rad-math.pi/2)*1.5
	rpm_p2_x     = rpm_x + math.cos(rpm_rad+math.pi/2)*1.5
	rpm_p2_y     = rpm_y - math.sin(rpm_rad+math.pi/2)*1.5
	rpm_end_p1_x = rpm_end_x + math.cos(rpm_rad-math.pi/2)*3
	rpm_end_p1_y = rpm_end_y - math.sin(rpm_rad-math.pi/2)*3
	rpm_end_p2_x = rpm_end_x + math.cos(rpm_rad+math.pi/2)*3
	rpm_end_p2_y = rpm_end_y - math.sin(rpm_rad+math.pi/2)*3
	ac.glBegin(2)
	ac.glColor4f(tach_needle_color1[0],tach_needle_color1[1],tach_needle_color1[2],tach_needle_color1[3])
	ac.glVertex2f(rpm_p1_x,rpm_p1_y)
	ac.glVertex2f(rpm_p2_x,rpm_p2_y)
	ac.glVertex2f(rpm_end_p1_x,rpm_end_p1_y)
	ac.glEnd()
	ac.glBegin(2)
	ac.glColor4f(tach_needle_color1[0],tach_needle_color1[1],tach_needle_color1[2],tach_needle_color1[3])
	#ac.glColor4f(1,1,1,1)
	ac.glVertex2f(rpm_p2_x,rpm_p2_y)
	ac.glVertex2f(rpm_end_p2_x,rpm_end_p2_y)
	ac.glVertex2f(rpm_end_p1_x,rpm_end_p1_y)
	ac.glEnd()
コード例 #28
0
 def _draw_polygon(p1, p2, p3, p4, reversed_normal):
     ac.glBegin(3)
     if not reversed_normal:
         ac.glVertex2f(*p1)
         ac.glVertex2f(*p2)
         ac.glVertex2f(*p3)
         ac.glVertex2f(*p4)
     else:
         ac.glVertex2f(*p1)
         ac.glVertex2f(*p4)
         ac.glVertex2f(*p3)
         ac.glVertex2f(*p2)
     ac.glEnd()
コード例 #29
0
def onFormRender(deltaT):
    global doRender, maxRPM, maxGear

    if not doRender:
        return

    gear = ac.getCarState(0, acsys.CS.Gear)
    rpm = ac.getCarState(0, acsys.CS.RPM)

    hBarWidth = appWidth * 0.04
    lineWidth = appWidth * 0.01
    doubleWidth = lineWidth * 2
    halfWidth = lineWidth / 2

    gearY = appHeight - (gear * gearSpacing)
    rpmY = appHeight * (rpm / CarData["maxRPM"])
    rpmX = rpmY / lineSlope
    rpmXL = doubleWidth + rpmX
    rpmXR = (appWidth - doubleWidth) - rpmX
    rpmY = appHeight - rpmY

    centerX = appWidth / 2
    centerY = gearY - fontSize / 2
    l = centerX - fontSize / 2
    r = centerX + fontSize / 2
    t = gearY - fontSize

    ac.glColor4f(0.7, 0.0, 0.0, 0.9)
    ac.glBegin(acsys.GL.Quads)

    # red diagonals
    ac.glVertex2f(0, appHeight)
    ac.glVertex2f(lineWidth, appHeight)
    ac.glVertex2f(appHeight / lineSlope + lineWidth, 0)
    ac.glVertex2f(appHeight / lineSlope, 0)

    ac.glVertex2f(appWidth - lineWidth, appHeight)
    ac.glVertex2f(appWidth, appHeight)
    ac.glVertex2f(appWidth - (appHeight / lineSlope), 0)
    ac.glVertex2f(appWidth - lineWidth - (appHeight / lineSlope), 0)

    ac.glEnd()

    # red RPM x1000 ticks
    y = appHeight
    while y > -1:
        dx = (appHeight - y) / lineSlope
        ac.glQuad(dx, y, hBarWidth, lineWidth)
        ac.glQuad(appWidth - dx - hBarWidth, y, hBarWidth, lineWidth)
        y -= (PxPer1000RPM * RPMdivs)

    # red/green diagonal quads
    ac.glColor4f(0.0, 0.9, 0.0, 0.9)
    topY = appHeight - (PxPer1000RPM * RPMdivs) + doubleWidth
    botY = appHeight - lineWidth
    while botY > 0:
        if topY < (PxPer1000RPM * RPMdivs):
            ac.glColor4f(0.7, 0.0, 0.0, 0.9)
            y = max(0, topY)  # redline bars
        elif topY < rpmY:
            y = rpmY  # current rpm bar
        else:
            y = topY  # rest of the lower rpm bars
        dxt = (appHeight - y + doubleWidth) / lineSlope + doubleWidth
        dxb = (appHeight - botY + doubleWidth) / lineSlope + doubleWidth

        ac.glBegin(acsys.GL.Quads)
        ac.glVertex2f(dxb, botY)
        ac.glVertex2f(dxb + lineWidth * 3, botY)
        ac.glVertex2f(dxt + lineWidth * 3, y)
        ac.glVertex2f(dxt, y)

        ac.glVertex2f(appWidth - dxb - lineWidth * 3, botY)
        ac.glVertex2f(appWidth - dxb, botY)
        ac.glVertex2f(appWidth - dxt, y)
        ac.glVertex2f(appWidth - dxt - lineWidth * 3, y)

        ac.glEnd()

        botY = topY - lineWidth * 3
        topY -= (PxPer1000RPM * RPMdivs)

    # white boxes around gears
    for g in range(CarData["totalGears"] + 2):
        if g == gear:
            ac.glColor4f(0.0, 0.9, 0.0, 0.9)
            lw = lineWidth
        else:
            ac.glColor4f(0.9, 0.9, 0.9, 0.9)
            lw = halfWidth
        gy = appHeight - (g * gearSpacing)
        gt = gy - fontSize
        ac.glQuad(l - lw, gy, fontSize + (lw * 2), lw)  # bot
        ac.glQuad(r, gt, lw, fontSize)  # right
        ac.glQuad(l - lw, gt - lw, fontSize + (lw * 2), lw)  # top
        ac.glQuad(l - lw, gt, lw, fontSize)  # left

    ac.glColor4f(0.9, 0.9, 0.9, 0.9)
    ac.glBegin(acsys.GL.Lines)

    # white diagonal back to selected gear
    ac.glVertex2f(rpmXL + hBarWidth + lineWidth, rpmY)
    ac.glVertex2f(l - hBarWidth - lineWidth, centerY)
    ac.glVertex2f(rpmXR - hBarWidth - lineWidth, rpmY)
    ac.glVertex2f(r + hBarWidth + lineWidth, centerY)

    ac.glEnd()

    ac.glColor4f(0.9, 0.9, 0.9, 0.9)
    # white horizontal rpms
    ac.glQuad(rpmXL + lineWidth, rpmY - halfWidth, hBarWidth, lineWidth)
    ac.glQuad(rpmXR - hBarWidth - lineWidth, rpmY - halfWidth, hBarWidth,
              lineWidth)

    # white horizontal selected gear
    ac.glQuad(l - hBarWidth - lineWidth, centerY - halfWidth, hBarWidth,
              lineWidth)
    ac.glQuad(r + lineWidth, centerY - halfWidth, hBarWidth, lineWidth)
コード例 #30
0
def drawSpeedometer():
	speed = ac.getCarState(0,acsys.CS.DriveTrainSpeed)/dt_ratio #Drivetrain speed seems to be about 75-90% of the real speed wtf
	if imperial:
		speed = speed / 1.632
	# degree range: 190..-10
	r = abs(speedo_min_angle - speedo_max_angle)
	speed_deg = speedo_max_angle - (speed/indicated_max_speed)*r
	speed_rad = math.radians(speed_deg)
	for i in range(0,indicated_max_speed+1,5):
		if i % 20 == 0:
			rad  = math.radians(speedo_max_angle - (i/indicated_max_speed)*r)
			p1_x = math.cos(rad)*speedo_radius+speed_pivot_x
			p1_y = -math.sin(rad)*speedo_radius+speed_pivot_y
			p2_x = math.cos(rad)*(speedo_radius*4/5)+speed_pivot_x
			p2_y = -math.sin(rad)*(speedo_radius*4/5)+speed_pivot_y
			ac.glBegin(0)
			ac.glColor4f(speedo_bigline_color[0],speedo_bigline_color[1],speedo_bigline_color[2],speedo_bigline_color[3])
			ac.glVertex2f(p1_x,p1_y)
			ac.glVertex2f(p2_x,p2_y)
			ac.glEnd()
		elif i % 5 == 0 and i != 0:
			rad  = math.radians(speedo_max_angle - (i/indicated_max_speed)*r)
			p1_x = math.cos(rad)*speedo_radius+speed_pivot_x
			p1_y = -math.sin(rad)*speedo_radius+speed_pivot_y
			p2_x = math.cos(rad)*(speedo_radius*9.25/10)+speed_pivot_x
			p2_y = -math.sin(rad)*(speedo_radius*9.25/10)+speed_pivot_y
			ac.glBegin(0)
			ac.glColor4f(speedo_smallline_color[0],speedo_smallline_color[1],speedo_smallline_color[2],speedo_smallline_color[3])
			ac.glVertex2f(p1_x,p1_y)
			ac.glVertex2f(p2_x,p2_y)
			ac.glEnd()
	# Needle
	speed_x       = math.cos(speed_rad)*(speedo_radius-3)+speed_pivot_x
	speed_y       = -math.sin(speed_rad)*(speedo_radius-3)+speed_pivot_y
	speed_end_x   = math.cos(speed_rad+math.pi)*speedo_needle_end+speed_pivot_x
	speed_end_y   = -math.sin(speed_rad+math.pi)*speedo_needle_end+speed_pivot_y
	
	speed_p1_x     = speed_x + math.cos(speed_rad-math.pi/2)*1.5
	speed_p1_y     = speed_y - math.sin(speed_rad-math.pi/2)*1.5
	speed_p2_x     = speed_x + math.cos(speed_rad+math.pi/2)*1.5
	speed_p2_y     = speed_y - math.sin(speed_rad+math.pi/2)*1.5
	speed_end_p1_x = speed_end_x + math.cos(speed_rad+math.pi/2)*3
	speed_end_p1_y = speed_end_y - math.sin(speed_rad+math.pi/2)*3
	speed_end_p2_x = speed_end_x + math.cos(speed_rad-math.pi/2)*3
	speed_end_p2_y = speed_end_y - math.sin(speed_rad-math.pi/2)*3
	ac.glBegin(2)
	ac.glColor4f(speedo_needle_color1[0],speedo_needle_color1[1],speedo_needle_color1[2],speedo_needle_color1[3])
	ac.glVertex2f(speed_p1_x,speed_p1_y)
	ac.glVertex2f(speed_end_p1_x,speed_end_p1_y)
	ac.glVertex2f(speed_end_p2_x,speed_end_p2_y)
	ac.glEnd()
	ac.glBegin(2)
	ac.glColor4f(speedo_needle_color1[0],speedo_needle_color1[1],speedo_needle_color1[2],speedo_needle_color1[3])
	ac.glVertex2f(speed_p1_x,speed_p1_y)
	ac.glVertex2f(speed_end_p2_x,speed_end_p2_y)
	ac.glVertex2f(speed_p2_x,speed_p2_y)
	ac.glEnd()
コード例 #31
0
	def drawGraph(self, flip=False):
		global Options
		x = self.xPosition
		y = self.yPosition - 10
		dx1 = 55
		dx2 = dx1 + Options["graphWidth"]
		f = 1 # flip mult thisisreallydumbbutineedit
		if flip:
			dx1 = -5
			dx2 = dx1 - Options["graphWidth"]
			f = -1

		halfHeight = Options["graphHeight"] / 2
		middleHeight = Options["graphHeight"] / 4
		ac.glBegin(acsys.GL.Lines)
		# bottom - red
		ac.glColor4f(1, 0, 0, 1)
		ac.glVertex2f(x + dx1, y + halfHeight)
		ac.glVertex2f(x + dx2, y + halfHeight)
		# right bottom - red
		ac.glVertex2f(x + dx2, y + halfHeight)
		ac.glVertex2f(x + dx2, y + middleHeight)
		# right top - green to yellow
		ac.glColor4f(0, 1, 0, 1)
		ac.glVertex2f(x + dx2, y + middleHeight)
		ac.glColor4f(1, 1, 0, 1)
		ac.glVertex2f(x + dx2, y - halfHeight)
		# top - yellow
		ac.glVertex2f(x + dx2, y - halfHeight)
		ac.glVertex2f(x + dx1, y - halfHeight)
		# left top - yellow to green
		ac.glVertex2f(x + dx1, y - halfHeight)
		ac.glColor4f(0, 1, 0, 1)
		ac.glVertex2f(x + dx1, y + middleHeight)
		# left bottom - red
		ac.glColor4f(1, 0, 0, 1)
		ac.glVertex2f(x + dx1, y + middleHeight)
		ac.glVertex2f(x + dx1, y + halfHeight)
		# middle - red
		ac.glVertex2f(x + dx1, y + middleHeight)
		ac.glVertex2f(x + dx2, y + middleHeight)
		ac.glEnd()

		sumPos = 1
		sumNeg = -1
		countPos = 1
		countNeg = 1

		scaleNeg = -(halfHeight + middleHeight) / self.minVal
		scalePos = (halfHeight - middleHeight) / self.maxVal

		for i in range(len(self.serie)):
			#~ color = getColor(self.serie[i])
			color = self.serie[i]["color"]
			h = max(min(self.maxVal,self.serie[i]["value"]),self.minVal)
			if self.serie[i]["value"] > 0:
				sumPos += self.serie[i]["value"]
				countPos += 1
				h *= scalePos
				ac.glColor4f(1, 0, 0, 1)
			else:
				sumNeg += self.serie[i]["value"]
				countNeg += 1
				h *= scaleNeg
				ac.glColor4f(1, 1, 1, 1)
			ac.glBegin(acsys.GL.Lines)
			ac.glVertex2f(x + dx2 - i * f, y + middleHeight - 1)
			ac.glColor4f(color['r'], color['g'], color['b'], color['a'])
			ac.glVertex2f(x + dx2 - i * f, y + middleHeight - 1 + h)
			ac.glEnd()

		if Options["normalize"] and len(self.serie) == Options["graphWidth"]:
			avgPos = sumPos / countPos
			avgNeg = sumNeg / countNeg
			self.maxVal = avgPos * 1.5
			self.minVal = avgNeg * 1.5
		else:
			if 0 != Options["targetCamber"]:
				self.minVal = Options["targetCamber"] * 1.5
			else:
				self.minVal = 6
			self.maxVal = 1.5
コード例 #32
0
def drawNineSegment(x,y,x_size,y_size,digit,colors,background):
	# Background
	ac.glBegin(2)
	ac.glColor4f(background[0],background[1],background[2],background[3])
	ac.glVertex2f(x,y)
	ac.glVertex2f(x+x_size,y+y_size)
	ac.glVertex2f(x+x_size,y)
	ac.glEnd()
	ac.glBegin(2)
	ac.glColor4f(background[0],background[1],background[2],background[3])
	#ac.glColor4f(1,1,1,1)
	ac.glVertex2f(x,y+y_size)
	ac.glVertex2f(x+x_size,y+y_size)
	ac.glVertex2f(x,y)
	ac.glEnd()
	# 2px padding
	root_x = x + 2
	root_y = y + 2
	max_x  = x + x_size - 2
	max_y  = y + y_size - 2
	# Definitions (DIFFERENT FOR SEGMENTS 8 AND 9)
	segment_width  = (max_y - root_y)/9
	segment_height = (max_x - root_x)/6
	
	i = 1
	segment_dict = {
		'1' : [ False, True, True, False, False, False, False, False, False],
		'2' : [ True, True, False, True, True, False, True, False, False],
		'3' : [ True, True, True, True, False, False, True, False, False],
		'4' : [ False, True, True, False, False, True, True, False, False],
		'5' : [ True, False, True, True, False, True, True, False, False],
		'6' : [ True, False, True, True, True, True, True, False, False],
		'7' : [ True, True, True, False, False, True, False, False, False],
		'8' : [ True, True, True, True, True, True, True, False, False],
		'9' : [ True, True, True, True, False, True, True, False, False],
		'0' : [ True, True, True, True, True, True, False, False, False],
		'N' : [ False, True, True, False, True, True, False, True, True],
		'R' : [ True, True, False, False, True, True, True, False, True],
		''  : [ False, False, False, False, False, False, False, False, False]}
	segments = segment_dict.get(digit,[True, True, True, True, True, True, True, True, True])
	for segment in segments:
		if segment:
			if i == 1 or i == 4 or i == 7: # horizontal segments
				l_x = segment_height + 1
				t_y = 0
				if i == 1:
					t_y = 1
				elif i == 7:
					t_y = segment_width*4 + 1
				elif i == 4:
					t_y = segment_width*8 + 1
				r_x = l_x + segment_height*4 - 2
				b_y = t_y + segment_width - 2
				# left/right triangle vertexes
				lt_x = l_x - segment_height/2 + 1
				tr_y = t_y + segment_width/2  - 1
				rt_x = r_x + segment_height/2 - 1
				# Adding the base coords
				l_x  = l_x + root_x
				r_x  = r_x + root_x
				t_y  = t_y + root_y
				b_y  = b_y + root_y
				lt_x = lt_x + root_x
				rt_x = rt_x + root_x
				tr_y = tr_y + root_y
				# Drawing the triangles
				# Left
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(lt_x,tr_y)
				ac.glVertex2f(l_x,b_y)
				ac.glVertex2f(l_x,t_y)
				ac.glEnd()
				# Right
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(rt_x,tr_y)
				ac.glVertex2f(r_x,t_y)
				ac.glVertex2f(r_x,b_y)
				ac.glEnd()
				# Middle top lt lb rt
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(l_x,t_y)
				ac.glVertex2f(l_x,b_y)
				ac.glVertex2f(r_x,t_y)
				ac.glEnd()
				# Middle bottom lb rt rb
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(l_x,b_y)
				ac.glVertex2f(r_x,b_y)
				ac.glVertex2f(r_x,t_y)
				ac.glEnd()
			elif i == 2 or i == 3 or i == 5 or i == 6:
				# (2 and 3) and (5 and 6) have same X coords
				# (2 and 6) and (3 and 5) have same Y coords
				l_x = r_x = t_y = b_y = tr_x = tt_y = bt_y = 0
				# X coords
				if i == 2 or i == 3:
					l_x  = segment_height*5 + 1
					r_x  = l_x + segment_height - 2
					tr_x = segment_height*5 + (segment_height - 2)/2 + 1
				elif i == 5 or i == 6:
					l_x  = 1
					r_x  = l_x + segment_height - 2
					tr_x = (segment_height - 2)/2 + 1
				# Y coords
				if i == 2 or i == 6:
					t_y  = segment_width + 1
					b_y  = segment_width*4 - 1
					tt_y = t_y - (segment_width - 2)/2 + 1
					bt_y = b_y + (segment_width - 2)/2 - 1
				elif i == 3 or i == 5:
					t_y  = segment_width*5 + 1
					b_y  = segment_width*8 - 1
					tt_y = t_y - (segment_width - 2)/2 + 1
					bt_y = b_y + (segment_width - 2)/2 - 1
				# Adding the base coords
				l_x  = l_x  + root_x
				r_x  = r_x  + root_x
				t_y  = t_y  + root_y
				b_y  = b_y  + root_y
				tr_x = tr_x + root_x
				tt_y = tt_y + root_y
				bt_y = bt_y + root_y
				# Drawing the triangles
				# Top
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(tr_x,tt_y)
				ac.glVertex2f(l_x,t_y)
				ac.glVertex2f(r_x,t_y)
				ac.glEnd()
				# Bottom
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(l_x,b_y)
				ac.glVertex2f(tr_x,bt_y)
				ac.glVertex2f(r_x,b_y)
				ac.glEnd()
				# Middle top lt lb rt
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(l_x,t_y)
				ac.glVertex2f(l_x,b_y)
				ac.glVertex2f(r_x,t_y)
				ac.glEnd()
				# Middle bottom lb rt rb
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(l_x,b_y)
				ac.glVertex2f(r_x,b_y)
				ac.glVertex2f(r_x,t_y)
				ac.glEnd()
			elif i == 8: # Top diagonal
				t1_x  = segment_height + segment_width/4
				t2_x  = segment_height
				t1_y = segment_width
				t2_y = t1_y + segment_width/4
				b1_x = segment_height*3
				b2_x = b1_x - segment_width/2
				b_y  = segment_width*4
				# Adding the base
				t1_x = t1_x + root_x
				t2_x = t2_x + root_x
				t1_y = t1_y + root_y
				t2_y = t2_y + root_y
				b1_x = b1_x + root_x
				b2_x = b2_x + root_x
				b_y  = b_y  + root_y
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(t1_x,t1_y)
				ac.glVertex2f(t2_x,t2_y)
				ac.glVertex2f(b1_x,b_y)
				ac.glEnd()
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(b2_x,b_y)
				ac.glVertex2f(b1_x,b_y)
				ac.glVertex2f(t2_x,t2_y)
				ac.glEnd()
			elif i == 9: # Bottom diagonal
				t_x  = segment_height*5
				t1_y = segment_width*8 - segment_width/2
				t2_y = t1_y + segment_width/2
				b1_x = segment_height*3 + segment_width/2
				b2_x = b1_x - segment_width/2
				b_y  = segment_width*5
				# Adding the base
				t_x  = t_x  + root_x
				t1_y = t1_y + root_y
				t2_y = t2_y + root_y
				b1_x = b1_x + root_x
				b2_x = b2_x + root_x
				b_y  = b_y  + root_y
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				ac.glVertex2f(t_x,t2_y)
				ac.glVertex2f(t_x,t1_y)
				ac.glVertex2f(b1_x,b_y)
				ac.glEnd()
				ac.glBegin(2)
				ac.glColor4f(colors[0],colors[1],colors[2],colors[3])
				#ac.glColor4f(1,1,1,1)
				ac.glVertex2f(b1_x,b_y)
				ac.glVertex2f(b2_x,b_y)
				ac.glVertex2f(t_x,t2_y)
				ac.glEnd()
		i = i + 1
コード例 #33
0
def drawBrakeGauge():
	global posting, post_time_elapsed, post_total_time
	inner_min_rad = math.asin((brake_gauge_root_y-brake_gauge_min_y)/brake_gauge_inner_radius)
	inner_max_rad = math.asin((brake_gauge_root_y-brake_gauge_max_y)/brake_gauge_inner_radius)
	outer_min_rad = math.asin((brake_gauge_root_y-brake_gauge_min_y)/brake_gauge_outer_radius)
	outer_max_rad = math.asin((brake_gauge_root_y-brake_gauge_max_y)/brake_gauge_outer_radius)
	for i in range(0,int((ac.getCarState(0,acsys.CS.Brake))*100),1):
		# p1 = inner, p2 = outer
		# p3 = inner, p4 = outer
		rad1 = (inner_max_rad-inner_min_rad)/100*i     + inner_min_rad + (math.pi if brake_gauge_right else 0)
		rad2 = (outer_max_rad-outer_min_rad)/100*i     + outer_min_rad + (math.pi if brake_gauge_right else 0)
		rad3 = (inner_max_rad-inner_min_rad)/100*(i+1) + inner_min_rad + (math.pi if brake_gauge_right else 0)
		rad4 = (outer_max_rad-outer_min_rad)/100*(i+1) + outer_min_rad + (math.pi if brake_gauge_right else 0)
		
		p1_x = math.cos(rad1)*brake_gauge_inner_radius + brake_gauge_root_x
		p1_y = brake_gauge_root_y - math.sin(rad1)*brake_gauge_inner_radius
		p2_x = math.cos(rad2)*brake_gauge_outer_radius + brake_gauge_root_x
		p2_y = brake_gauge_root_y - math.sin(rad2)*brake_gauge_outer_radius
		p3_x = math.cos(rad3)*brake_gauge_inner_radius + brake_gauge_root_x
		p3_y = brake_gauge_root_y - math.sin(rad3)*brake_gauge_inner_radius
		p4_x = math.cos(rad4)*brake_gauge_outer_radius + brake_gauge_root_x
		p4_y = brake_gauge_root_y - math.sin(rad4)*brake_gauge_outer_radius
		
		ac.glBegin(2)
		ac.glColor4f(brake_gauge_color[0],brake_gauge_color[1],brake_gauge_color[2],brake_gauge_color[3])
		ac.glVertex2f(p1_x,p1_y)
		ac.glVertex2f(p2_x,p2_y)
		ac.glVertex2f(p3_x,p3_y)
		ac.glEnd()
		ac.glBegin(2)
		ac.glColor4f(brake_gauge_color[0],brake_gauge_color[1],brake_gauge_color[2],brake_gauge_color[3])
		ac.glVertex2f(p3_x,p3_y)
		ac.glVertex2f(p2_x,p2_y)
		ac.glVertex2f(p4_x,p4_y)
		ac.glEnd()
コード例 #34
0
	def drawTire(self, suspX, suspY, suspH, flip=False):
		global Options

		x = self.xPosition + 25
		y = self.yPosition
		#~ rad = self.value * Options["radScale"]
		#~ rad = self.value * Options["radScale"] / (2 * -Options["targetCamber"])
		rad = self.value
		if flip:
			#~ x = self.xPosition + 50
			rad = math.pi - rad

		ac.glColor4f(
			self.color['r'],
			self.color['g'],
			self.color['b'],
			self.color['a']
		)

		h = Options["tireHeight"]
		w = h / 2
		cosrad = math.cos(rad)
		sinrad = math.sin(rad)
		halfpi = math.pi/2
		if flip:
			cosradnorm = math.cos(rad+halfpi)
			sinradnorm = math.sin(rad+halfpi)
			# Have to draw counterclockwise
			ac.glBegin(acsys.GL.Quads)
			ac.glVertex2f(x, y)
			ac.glVertex2f(x+h*cosradnorm, y+h*sinradnorm)
			ac.glVertex2f(x+w*cosrad+h*cosradnorm, y+w*sinrad+h*sinradnorm)
			ac.glVertex2f(x+w*cosrad, y+w*sinrad)
			ac.glEnd()
		else:
			cosradnorm = math.cos(rad-halfpi)
			sinradnorm = math.sin(rad-halfpi)
			# Have to draw counterclockwise
			ac.glBegin(acsys.GL.Quads)
			ac.glVertex2f(x, y)
			ac.glVertex2f(x+w*cosrad, y+w*sinrad)
			ac.glVertex2f(x+w*cosrad+h*cosradnorm, y+w*sinrad+h*sinradnorm)
			ac.glVertex2f(x+h*cosradnorm, y+h*sinradnorm)
			ac.glEnd()

		# Suspension bits
		ac.glColor4f(0.9, 0.9, 0.9, 0.9)
		ac.glBegin(acsys.GL.Lines)
		ac.glVertex2f(x+(h/2 - suspH)*cosradnorm, y+(h/2 - suspH)*sinradnorm)
		ac.glVertex2f(suspX, suspY + suspH)
		ac.glVertex2f(x+(h/2 + suspH)*cosradnorm, y+(h/2 + suspH)*sinradnorm)
		ac.glVertex2f(suspX, suspY - suspH)
		ac.glEnd()
コード例 #35
0
def drawClutchGauge():
	global posting, post_time_elapsed, post_total_time
	inner_min_rad = math.asin((clutch_gauge_root_y-clutch_gauge_min_y)/clutch_gauge_inner_radius)
	inner_max_rad = math.asin((clutch_gauge_root_y-clutch_gauge_max_y+1)/clutch_gauge_inner_radius)
	outer_min_rad = math.asin((clutch_gauge_root_y-clutch_gauge_min_y)/clutch_gauge_outer_radius)
	outer_max_rad = math.asin((clutch_gauge_root_y-clutch_gauge_max_y+1)/clutch_gauge_outer_radius)
	for i in range(0,int((1-ac.getCarState(0,acsys.CS.Clutch))*100),1):
		# p1 = inner, p2 = outer
		# p3 = inner, p4 = outer
		rad1 = (inner_max_rad-inner_min_rad)/100*(100-i)     - inner_max_rad + (math.pi if clutch_gauge_right else 0)
		rad2 = (outer_max_rad-outer_min_rad)/100*(100-i)     - outer_max_rad + (math.pi if clutch_gauge_right else 0)
		rad3 = (inner_max_rad-inner_min_rad)/100*(100 - i+1) - inner_max_rad + (math.pi if clutch_gauge_right else 0)
		rad4 = (outer_max_rad-outer_min_rad)/100*(100 - i+1) - outer_max_rad + (math.pi if clutch_gauge_right else 0)
		
		p1_x = math.cos(rad1)*clutch_gauge_inner_radius + clutch_gauge_root_x
		p1_y = clutch_gauge_root_y - math.sin(rad1)*clutch_gauge_inner_radius
		p2_x = math.cos(rad2)*clutch_gauge_outer_radius + clutch_gauge_root_x
		p2_y = clutch_gauge_root_y - math.sin(rad2)*clutch_gauge_outer_radius
		p3_x = math.cos(rad3)*clutch_gauge_inner_radius + clutch_gauge_root_x
		p3_y = clutch_gauge_root_y - math.sin(rad3)*clutch_gauge_inner_radius
		p4_x = math.cos(rad4)*clutch_gauge_outer_radius + clutch_gauge_root_x
		p4_y = clutch_gauge_root_y - math.sin(rad4)*clutch_gauge_outer_radius
		
		ac.glBegin(2)
		ac.glColor4f(clutch_gauge_color[0],clutch_gauge_color[1],clutch_gauge_color[2],clutch_gauge_color[3])
		ac.glVertex2f(p1_x,p1_y)
		ac.glVertex2f(p2_x,p2_y)
		ac.glVertex2f(p3_x,p3_y)
		ac.glEnd()
		ac.glBegin(2)
		ac.glColor4f(clutch_gauge_color[0],clutch_gauge_color[1],clutch_gauge_color[2],clutch_gauge_color[3])
		ac.glVertex2f(p3_x,p3_y)
		ac.glVertex2f(p2_x,p2_y)
		ac.glVertex2f(p4_x,p4_y)
		ac.glEnd()
コード例 #36
0
 def rect(x, y, w, h, color=Color(1, 1, 1, 1), filled=True):
     ac.glColor4f(color.r, color.g, color.b, color.a)
     if filled:
         ac.glQuad(x, y, w, h)
     else:
         ac.glBegin(1)
         ac.glVertex2f(x, y)
         ac.glVertex2f(x + w, y)
         ac.glVertex2f(x + w, y)
         ac.glVertex2f(x + w, y + h)
         ac.glVertex2f(x + w, y + h)
         ac.glVertex2f(x, y + h)
         ac.glVertex2f(x, y + h)
         ac.glVertex2f(x, y)
         ac.glEnd()
コード例 #37
0
 def line(x1, y1, x2, y2, color=Color(1, 1, 1, 1)):
     ac.glColor4f(color.r, color.g, color.b, color.a)
     ac.glBegin(1)
     ac.glVertex2f(x1, y1)
     ac.glVertex2f(x2, y2)
     ac.glEnd()
コード例 #38
0
def onWindowRender(deltaT):
	ac.log("Rendering window")
	global debug_label, indicated_max_rpm, max_rpm, indicated_max_speed, shift_light_drawn, sl_timer
	global tach_radius, rpm_pivot_x, rpm_pivot_y, speedo_radius, speed_pivot_x, speed_pivot_y
	global speedo_tl_x, speedo_tl_y, speedo_total_width, speedo_total_height, gear_color, gear_background, speedo_color, speedo_background
	global abs_label, abs_off_label, tcs_label, tcs_off_label
	global draw_abs_status, draw_tcs_status
	global telemetry_client
	if draw_abs_status:
		if telemetry_client.abs_enabled:
			ac.setPosition(abs_off_label,-10000,-10000)
		else:
			ac.setPosition(abs_off_label,0,0)
		if telemetry_client.abs_in_action:
			ac.setPosition(abs_label,0,0)
		else:
			ac.setPosition(abs_label,-10000,-10000)
	if draw_tcs_status:
		if telemetry_client.tc_enabled:
			ac.setPosition(tcs_off_label,-10000,-10000)
		else:
			ac.setPosition(tcs_off_label,0,0)
		if telemetry_client.tc_in_action:
			ac.setPosition(tcs_label,0,0)
		else:
			ac.setPosition(tcs_label,-10000,-10000)
	rpm = ac.getCarState(0,acsys.CS.RPM)
	# Distance covered
	if draw_odometer:
		drawOdometer()
	# Tach
	if draw_tachometer:
		drawTachometer(deltaT)
	# Speedo
	if draw_speedometer:
		drawSpeedometer()
	# Shift light
	if draw_shift_light:
		sl_center_x = shift_light_x
		sl_center_y = shift_light_y
		sl_radius   = shift_light_radius
		if sl_timer > 0.1:
			shift_light_drawn = not shift_light_drawn
			sl_timer = 0
		else:
			sl_timer = sl_timer + deltaT
		if max_rpm - rpm <= 500 and shift_light_drawn:
			color = shift_light_on_color
		else:
			color = shift_light_off_color
		for i in range(0,360,15):
			ac.glBegin(2)
			ac.glColor4f(color[0],color[1],color[2],color[3])
			ac.glVertex2f(sl_center_x + math.cos(math.radians(i+15))*sl_radius,sl_center_y + math.sin(math.radians(i+15))*sl_radius)
			ac.glVertex2f(sl_center_x + math.cos(math.radians(i))*sl_radius,sl_center_y + math.sin(math.radians(i))*sl_radius)
			ac.glVertex2f(sl_center_x,sl_center_y)
			ac.glEnd()
	# Gear
	if draw_gear_indicator:
		gear = ac.getCarState(0,acsys.CS.Gear)
		digit = ''
		if gear > 1:
			digit = "%d" % (gear - 1)
		elif gear == 1:
			digit = "N"
		elif gear == 0:
			digit = "R"
		drawNineSegment(gear_x,gear_y,gear_width,gear_height,digit,gear_color,gear_background)
	# Digital speedo
	if draw_digital_speedo:
		# First Digit
		hundred = ''
		speed = ac.getCarState(0,acsys.CS.SpeedKMH) # Actual speed instead of drivetrain speed
		if imperial:
			speed = ac.getCarState(0,acsys.CS.SpeedMPH)
		if speed >= 100:
			hundred = "%d" % ((speed - (speed % 100))/100)
		drawNineSegment(speedo_tl_x,speedo_tl_y,speedo_total_width/3,speedo_total_height,hundred,speed_color,speed_background)
		# Second Digit
		ten = ''
		if speed >= 10:
			ten = "%d" % (((speed % 100) - (speed % 10))/10)
		drawNineSegment(speedo_tl_x+speedo_total_width/3,speedo_tl_y,speedo_total_width/3,speedo_total_height,ten,speed_color,speed_background)
		# Third Digit
		dec = "%d" % (speed % 10)
		drawNineSegment(speedo_tl_x+2*(speedo_total_width/3),speedo_tl_y,speedo_total_width/3,speedo_total_height,dec,speed_color,speed_background)
	
	# Brake Gauge
	if draw_brake_gauge:
		drawBrakeGauge()
	# Throttle Gauge
	if draw_throttle_gauge:
		drawThrottleGauge()
	# Clutch Gauge
	if draw_clutch_gauge:
		drawClutchGauge()
	# G Meter
	if draw_g_meter:
		drawGMeter()
	# Tyre Monitor
	if draw_tyre_monitor:
		drawTyreMonitor()
	# BOOOOOST
	if draw_boost_gauge:
		drawBoostGauge()
	# Fuel
	if draw_fuel_gauge:
		drawFuelGauge()
コード例 #39
0
def onFormRender(deltaT):
	global doRender, CamberIndicators, Options, Labels, redrawText

	if not doRender:
		return

	ac.glColor4f(0.9, 0.9, 0.9, 0.9)
	#~ ac.setText(Labels["targetCamber"], "{0:.1f}°".format(Options["targetCamber"]))

	# Suspension travel to find body position relative to tires
	radius = Options["tireRadius"]
	pixelsPerMeter = Options["tireHeight"] / radius
	w,x,y,z = ac.getCarState(0, acsys.CS.SuspensionTravel)
	dyFL = w * pixelsPerMeter
	dyFR = x * pixelsPerMeter
	dyRL = y * pixelsPerMeter
	dyRR = z * pixelsPerMeter

	# Draw front "car body"
	xFR = CamberIndicators["FR"].xPosition
	xFL = CamberIndicators["FL"].xPosition + Options["tireHeight"]
	y = CamberIndicators["FR"].yPosition - Options["tireHeight"] / 2
	yFL = y + dyFL
	yFR = y + dyFR
	h = Options["tireHeight"] / 4
	ac.glColor4f(0.9, 0.9, 0.9, 0.9)
	ac.glBegin(acsys.GL.Lines)
	ac.glVertex2f(xFL, yFL + h)
	ac.glVertex2f(xFR, yFR + h)
	ac.glVertex2f(xFR, yFR + h)
	ac.glVertex2f(xFR, yFR - h)
	ac.glVertex2f(xFR, yFR - h)
	ac.glVertex2f(xFL, yFL - h)
	ac.glVertex2f(xFL, yFL - h)
	ac.glVertex2f(xFL, yFL + h)
	ac.glEnd()

	# Draw rear "car body"
	xRR = CamberIndicators["RR"].xPosition
	xRL = CamberIndicators["RL"].xPosition + Options["tireHeight"]
	y = CamberIndicators["RR"].yPosition - Options["tireHeight"] / 2
	yRL = y + dyRL
	yRR = y + dyRR
	h = Options["tireHeight"] / 4
	ac.glColor4f(0.9, 0.9, 0.9, 0.9)
	ac.glBegin(acsys.GL.Lines)
	ac.glVertex2f(xRL, yRL + h)
	ac.glVertex2f(xRR, yRR + h)
	ac.glVertex2f(xRR, yRR + h)
	ac.glVertex2f(xRR, yRR - h)
	ac.glVertex2f(xRR, yRR - h)
	ac.glVertex2f(xRL, yRL - h)
	ac.glVertex2f(xRL, yRL - h)
	ac.glVertex2f(xRL, yRL + h)
	ac.glEnd()

	# Draw flappy gauges
	h *= 0.75
	CamberIndicators["FL"].drawTire(xFL, yFL, h, flip=True)
	CamberIndicators["FR"].drawTire(xFR, yFR, h)
	CamberIndicators["RL"].drawTire(xRL, yRL, h, flip=True)
	CamberIndicators["RR"].drawTire(xRR, yRR, h)

	# Draw history graphs
	if Options["drawGraphs"]:
		CamberIndicators["FL"].drawGraph(flip=True)
		CamberIndicators["FR"].drawGraph()
		CamberIndicators["RL"].drawGraph(flip=True)
		CamberIndicators["RR"].drawGraph()

	flC, frC, rlC, rrC = ac.getCarState(0, acsys.CS.CamberRad)
	CamberIndicators["FL"].setValue(flC, deltaT, Options["optimalCamberF"])
	CamberIndicators["FR"].setValue(frC, deltaT, Options["optimalCamberF"])
	CamberIndicators["RL"].setValue(rlC, deltaT, Options["optimalCamberR"])
	CamberIndicators["RR"].setValue(rrC, deltaT, Options["optimalCamberR"])

	# Check if tyre compound changed
	tyreCompound = ac.getCarTyreCompound(0)
	if tyreCompound != Options["tyreCompound"]:
		loadTireData()
		Options["tyreCompound"] = tyreCompound

	# Weight Front and Rear by lateral weight transfer
	filter = 0.97
	flL, frL, rlL, rrL = ac.getCarState(0, acsys.CS.Load)

	outer = max(0.001, flL, frL)
	inner = min(flL, frL)
	camberSplit = abs(flC - frC)
	# DY_LS_FL = DY_REF * pow(TIRE_LOAD_FL / FZ0, LS_EXPY)
	ls_outer = pow(outer, Options["LS_EXPY"])
	ls_inner = pow(inner, Options["LS_EXPY"])
	weightXfer = ls_outer / (ls_inner + ls_outer)
	# (2*(1-w)*D1*rad(c)-(1-2*w)*D0)/(2*D1)
	oldTargetCamber = Options["optimalCamberF"]
	Options["optimalCamberF"] = math.degrees((2 * (1 - weightXfer) * Options["dcamber1"] * math.radians(camberSplit) - (1 - 2 * weightXfer) * Options["dcamber0"]) / (2 * Options["dcamber1"]))
	Options["optimalCamberF"] = filter * oldTargetCamber + (1 - filter) * Options["optimalCamberF"]

	outer = max(0.001, rlL, rrL)
	inner = min(rlL, rrL)
	camberSplit = abs(rlC - rrC)
	# DY_LS_FL = DY_REF * pow(TIRE_LOAD_FL / FZ0, LS_EXPY)
	ls_outer = pow(outer, Options["LS_EXPY"])
	ls_inner = pow(inner, Options["LS_EXPY"])
	weightXfer = ls_outer / (ls_inner + ls_outer)
	# (2*(1-w)*D1*rad(c)-(1-2*w)*D0)/(2*D1)
	oldTargetCamber = Options["optimalCamberR"]
	Options["optimalCamberR"] = math.degrees((2 * (1 - weightXfer) * Options["dcamber1"] * math.radians(camberSplit) - (1 - 2 * weightXfer) * Options["dcamber0"]) / (2 * Options["dcamber1"]))
	Options["optimalCamberR"] = filter * oldTargetCamber + (1 - filter) * Options["optimalCamberR"]

	ac.setText(Labels["targetCamberF"], "{0:.1f}°".format(Options["optimalCamberF"]))
	ac.setText(Labels["targetCamberR"], "{0:.1f}°".format(Options["optimalCamberR"]))

	if redrawText:
		updateTextInputs()
		redrawText = False
コード例 #40
0
 def _draw_polygon(p1, p2, p3, p4, reversed_normal):
   ac.glBegin(3)
   if not reversed_normal:
     ac.glVertex2f(*p1)
     ac.glVertex2f(*p2)
     ac.glVertex2f(*p3)
     ac.glVertex2f(*p4)
   else:
     ac.glVertex2f(*p1)
     ac.glVertex2f(*p4)
     ac.glVertex2f(*p3)
     ac.glVertex2f(*p2)
   ac.glEnd()
コード例 #41
0
ファイル: gl.py プロジェクト: styinx/ACLIB
def quad(x: int, y: int, w: int, h: int, colors=None, r=None):
    if type(colors) == list:
        ac.glBegin(3)
        if len(colors) >= 1:
            c = colors[0]
            ac.glColor4f(c.r, c.g, c.b, c.a)
        if r is not None:
            ac.glVertex2f(r.x, r.y)
        else:
            ac.glVertex2f(x, y)

        if len(colors) >= 2:
            c = colors[1]
            ac.glColor4f(c.r, c.g, c.b, c.a)
        if r is not None:
            ac.glVertex2f(r.x, r.y + r.h)
        else:
            ac.glVertex2f(x, y + h)

        if len(colors) >= 3:
            c = colors[2]
            ac.glColor4f(c.r, c.g, c.b, c.a)
        if r is not None:
            ac.glVertex2f(r.x + r.w, r.y + r.h)
        else:
            ac.glVertex2f(x + w, y + h)

        if len(colors) >= 4:
            c = colors[3]
            ac.glColor4f(c.r, c.g, c.b, c.a)
        if r is not None:
            ac.glVertex2f(r.x + r.w, r.y)
        else:
            ac.glVertex2f(x + w, y)
        ac.glEnd()