def draw(self, canvas): PlatoBody.draw(self, canvas) #if self._newton is not None: # TODO - move to base class #x,y = self.position #canvas.move_to(x,y) # draw a square canvas.set_line_width(1.0) # BUG with thick borders we end up going over the decorators... should we inset ? or should we move the decorators further out ? canvas.set_source_rgb(0.5, 0.3, 0.0) canvas.rectangle(self.left, self.top, self.width, self.height) canvas.fill()
def ode_init(self): PlatoBody.ode_init(self) # warning these are overridden, so init order very important - need a fix - maybe pass in as fn args w = self.world_width h = self.world_height x = self.x y = self.y print (w,h) #self._ode_body.w = w #self._ode_body.h = h # 1. create ode.body self._ode_body = ode.Body(self._newton.ode_world) # 2. Set Mass M = ode.Mass() M.setBox(7900.0, w, h, 1.0) #M.mass = 10.0 M.mass = 2.0 self._ode_body.setMass(M) #self._ode_body.setGravityMode(0) # 3. Set geom self._ode_geom = ode.GeomBox(self._newton.ode_space, lengths=(w, h, 1.0)) self._ode_geom.setBody(self._ode_body) self._ode_geom.particle = self # 4. Set position #self._ode_body.setPosition((self.x+(w/2.0), self.y+(h/2.0), 0.0)) self._ode_body.setPosition((x, y, 0.0)) #self._ode_body.addForce((0,0,0)) self._ode_body.setFiniteRotationMode(0) # ? # anchor wall joint = ode.FixedJoint(self._newton.ode_world, self._newton.ode_anchorgroup); joint.attach(self._ode_body, None); joint.setFixed()
def __init__(self, x, y, w, h): PlatoBody.__init__(self, x, y, w, h)