def begin_round(self): global j1, j2, pend, scene, pole, ball, grabScreens, frNum global pauseState damping = 0.1 if (pauseState == 1): self.next() return # Calls the super implementation. soya.World.begin_round(self) #~ print(j1.getFeedback(), "#", j2.getFeedback()) # (force1, torque1, force2, torque2) : ((0.0, 332.9216613769531, -257.0126647949219), (180.77870178222656, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)) ..... (((0.0, 426.10772705078125, -1055.581298828125), (-5704.71435546875, 0.0, 0.0), (1.1854985008187952e-42, 2.312142466135948e-43, 9.164491956684304e-43), (1.4461400151832112e-42, 7.777206477002735e-43, 7.903323338791968e-43)), '#', ((0.0, 173.71861267089844, -6280.154296875), (-96.6642074584961, 0.0, 0.0), (0.0, -173.71861267089844, 6280.154296875), (-504.1296081542969, 0.0, 0.0))) self.j1f = j1.getFeedback() self.j2f = j2.getFeedback() frc1 = self.j2f[0] #[0] # note - vector should be referenced to scene, NOT pend, # for the damping to work! dampvect = Vector(scene, -damping * frc1[0], -damping * frc1[1], -damping * frc1[2]) pend.add_force(dampvect) #~ j1fp = j1.getFeedback() # same as j1f #~ print(frc1, "#", j1fp[0]) self.dj1fp = Vector(scene, frc1[0], frc1[1], frc1[2]) + dampvect #~ print(frc1, "#", self.dj1fp) #~ print(bp) #~ frep=bp+0.1*self.dj1fp # float required; no parse #~ frep=bp.add_mul_vector(0.1, self.dj1fp) # awful #~ frep=bp+self.dj1fp.__mul__(0.000001) # ?? #~ frep=Vector(ball,0,0,2) # ref to ball don't seem to matter! # AH - for these kind of transform with convert_to, should have Point, not Vector! # frcpball coord syst: 2 units in each direction, moved 1 unit along x so as not to be hidden by ball movx = 0 if (self.coordViewState == 0): self.bp = ball.position().add_vector(soya.Vector(ball, movx, 0, 0)) self.bp1 = self.bp self.bp2 = self.bp1 if (self.coordViewState == 1): movx = 1 self.bp = ball.position().add_vector(soya.Vector(ball, movx, 0, 0)) self.bp1 = self.bp self.bp2 = self.bp1 elif (self.coordViewState == 2): movx = 1 self.bp = ball.position().add_vector(soya.Vector(ball, movx, 0, 0)) self.bp1 = ball.position().add_vector(soya.Vector(ball, 2, 0, 1)) self.bp2 = self.bp1 elif (self.coordViewState == 3): movx = 1 self.bp = ball.position().add_vector(soya.Vector(ball, movx, 0, 0)) self.bp1 = ball.position().add_vector(soya.Vector(ball, 2, 0, 1)) self.bp2 = ball.position().add_vector(soya.Vector(ball, 3, 0, 2)) self.bp1b = self.bp1.copy().add_vector(soya.Vector(ball, -0.5, 0, 0)) self.frepx = Point(ball, 2 + movx, 0, 0) self.frepy = Point(ball, movx, 2, 0) self.frepz = Point(ball, movx, 0, 2) self.frepx.convert_to(scene) self.frepy.convert_to(scene) self.frepz.convert_to(scene) # scaled so they're approx the same scale_grav = scene.gravity.__mul__(0.5) scale_dfor = self.dj1fp.__mul__(0.03) self.epg = self.bp1 + scale_grav self.epfor = self.bp2 + scale_dfor tp = Vector(ball, 2, 0, 0) # convert_to must go separate! can be vector tp.convert_to(scene) # IN PLACE grav_lx = self.vecProjectionAontoB(scale_grav, tp) tp = Vector(ball, 0, 2, 0) tp.convert_to(scene) grav_ly = self.vecProjectionAontoB(scale_grav, tp) tp = Vector(ball, 0, 0, 2) tp.convert_to(scene) grav_lz = self.vecProjectionAontoB(scale_grav, tp) self.epgx = self.bp1 + grav_lx self.epgy = self.bp1 + grav_ly self.epgz = self.bp1 + grav_lz tp = Vector(ball, 2, 0, 0) tp.convert_to(scene) dfor_lx = self.vecProjectionAontoB(scale_dfor, tp) tp = Vector(ball, 0, 2, 0) tp.convert_to(scene) dfor_ly = self.vecProjectionAontoB(scale_dfor, tp) tp = Vector(ball, 0, 0, 2) tp.convert_to(scene) dfor_lz = self.vecProjectionAontoB(scale_dfor, tp) self.epforx = self.bp2 + dfor_lx self.epfory = self.bp2 + dfor_ly self.epforz = self.bp2 + dfor_lz tp = Vector(scene, 2, 0, 0) grav_lz_mx = self.vecProjectionAontoB(grav_lz, tp) tp = Vector(scene, 0, 2, 0) grav_lz_my = self.vecProjectionAontoB(grav_lz, tp) tp = Vector(scene, 0, 0, 2) grav_lz_mz = self.vecProjectionAontoB(grav_lz, tp) self.epglzx = self.bp1b + grav_lz_mx self.epglzy = self.bp1b + grav_lz_my self.epglzz = self.bp1b + grav_lz_mz if (grabScreens): frNum += 1 tfname = "/dev/shm/soya-pend%05d.png" % (frNum) soya.screenshot(filename=tfname, use_back_buffer=False)