Ejemplo n.º 1
0
    def Step(self, settings) :
        sweep1=box2d.b2Sweep()
        sweep1.c0.Set(0.0, 20.0)
        sweep1.a0 = 0.0
        sweep1.c = sweep1.c0
        sweep1.a = sweep1.a0
        sweep1.t0 = 0.0
        sweep1.localCenter = self.m_body1.GetLocalCenter()

        sweep2=box2d.b2Sweep()
        sweep2.c0.Set(9.6363468, 28.050615)
        sweep2.a0 = 1.6408679
        sweep2.c = sweep2.c0 + box2d.b2Vec2(-0.075121880, 0.27358246)
        sweep2.a = sweep2.a0 - 10.434675
        sweep2.t0 = 0.0
        sweep2.localCenter = self.m_body2.GetLocalCenter()

        toi = box2d.b2TimeOfImpact(self.m_shape1, sweep1, self.m_shape2, sweep2)

        self.DrawString(5, self.textLine, "toi = %g" % (toi))
        self.textLine += 15

        xf2=box2d.b2XForm ()
        sweep2.GetXForm(xf2, toi)
        vertexCount = self.m_shape2.GetVertexCount()
        vertices = []

        localVertices = self.m_shape2.getVertices_b2Vec2()
        for vertex in localVertices:
            vertices.append( box2d.b2Mul(xf2, vertex).tuple() )

        self.debugDraw.DrawPolygon(vertices, vertexCount, box2d.b2Color(0.5, 0.7, 0.9))

        localVertices = self.m_shape2.getCoreVertices_b2Vec2()
        for vertex in localVertices:
            vertices.append( box2d.b2Mul(xf2, vertex).tuple() )
        self.debugDraw.DrawPolygon(vertices, vertexCount, box2d.b2Color(0.5, 0.7, 0.9))
     
        settings.pause = True
        super(TimeOfImpact, self).Step(settings)
        settings.pause = False
Ejemplo n.º 2
0
	def Step(self, settings):
		"""Called upon every step.
		You should always call
		 -> super(Your_Test_Class, self).Step(settings)
		at the _end_ of your function.
		"""

		airfoil_angle = self.joystick.get_axis(0) * 10.0
		self.craft.airfoil.set_wing_angle(radians(airfoil_angle))
		hydrofoil_angle = self.joystick.get_axis(2) * 10.0
		self.craft.hydrofoil.set_wing_angle(radians(hydrofoil_angle))

		# do stuff        
		self.craft.step()
		
		#if settings.draw:
		if True:
			self.DrawString(0,self.textLine,"Use a and s to rotate the hydrofoil, q and w to rotate the airfoil")
			self.textLine+=15
			v = self.craft.velocity()
			relative_v = mph(v.Length())
			force = reduce(add, [d[0] for d in self.craft.get_force_vectors()])
			self.DrawString(0,self.textLine, "Absolute Velocity (mph) : %3.1f" % mph(relative_v))
			self.textLine+=15
			self.DrawString(0,self.textLine, "Windspeed (mph): %4.1f    Angle to wind: %4.1f" % (mph(self.craft.windspeed()), degrees(math.atan2(v.y, v.x))))
			self.textLine+=15
			self.DrawString(0,self.textLine, "Force (lbs): %5.0f,%5.0f" % (lbs(force.x), lbs(force.y)))
			self.textLine+=15			
			if mph(relative_v) > 58.2:
				self.textLine+=15				
				self.DrawString(0,self.textLine, "RECORD PACE")
				self.textLine+=15
		
		super(Masheet, self).Step(settings)

		#if settings.draw:
		if True:
			center = self.craft.get_center()
			self.setCenter(center * self._viewZoom)

			# draw velocity vector
			print v
			self.debugDraw.DrawSegment(center, center + v, box2d.b2Color(1.0, 1.0, 1.0))

			for force in self.craft.get_force_vectors():
				world_force, world_point, color = force
				self.debugDraw.DrawSegment(world_point, world_point + (world_force / 100.0), color)

		self.craft.clear_force_vectors()
Ejemplo n.º 3
0
    def Step(self, settings):
        """Called upon every step.
		You should always call
		 -> super(Your_Test_Class, self).Step(settings)
		at the _end_ of your function.
		"""

        airfoil_angle = self.joystick.get_axis(0) * 10.0
        self.craft.airfoil.set_wing_angle(radians(airfoil_angle))
        hydrofoil_angle = self.joystick.get_axis(2) * 10.0
        self.craft.hydrofoil.set_wing_angle(radians(hydrofoil_angle))

        # do stuff
        self.craft.step()

        #if settings.draw:
        if True:
            self.DrawString(
                0, self.textLine,
                "Use a and s to rotate the hydrofoil, q and w to rotate the airfoil"
            )
            self.textLine += 15
            v = self.craft.velocity()
            relative_v = mph(v.Length())
            force = reduce(add, [d[0] for d in self.craft.get_force_vectors()])
            self.DrawString(
                0, self.textLine,
                "Absolute Velocity (mph) : %3.1f" % mph(relative_v))
            self.textLine += 15
            self.DrawString(
                0, self.textLine,
                "Windspeed (mph): %4.1f    Angle to wind: %4.1f" %
                (mph(self.craft.windspeed()), degrees(math.atan2(v.y, v.x))))
            self.textLine += 15
            self.DrawString(
                0, self.textLine,
                "Force (lbs): %5.0f,%5.0f" % (lbs(force.x), lbs(force.y)))
            self.textLine += 15
            if mph(relative_v) > 58.2:
                self.textLine += 15
                self.DrawString(0, self.textLine, "RECORD PACE")
                self.textLine += 15

        super(Masheet, self).Step(settings)

        #if settings.draw:
        if True:
            center = self.craft.get_center()
            self.setCenter(center * self._viewZoom)

            # draw velocity vector
            print v
            self.debugDraw.DrawSegment(center, center + v,
                                       box2d.b2Color(1.0, 1.0, 1.0))

            for force in self.craft.get_force_vectors():
                world_force, world_point, color = force
                self.debugDraw.DrawSegment(world_point,
                                           world_point + (world_force / 100.0),
                                           color)

        self.craft.clear_force_vectors()