0

I want move an object using keyboard input, but it is not working. It sticks with the initial position and does not change to the position returned by getX(). How can I get the object to change positions?

from direct.showbase.ShowBase import ShowBase
from direct.task.TaskManagerGlobal import taskMgr
from panda3d.core import *
from panda3d.vision import WebcamVideo, ARToolKit

# the webcam feed can not be made into a power of two texture
loadPrcFileData("", "textures-power-2 none")
# usualy the drawn texture lags a bit behind the calculted positions.
# this is a trying to reduce the lag.
loadPrcFileData("","auto-flip 0")

class MyApp(ShowBase):
    def __init__(self):
    ShowBase.__init__(self)
    # self.disableMouse()
    self.physics = False
    option = WebcamVideo.getOption(0)
    self.tex = MovieTexture(option)
    # self.tex.setKeepRamImage(True)
    cm = CardMaker("card")
    cm.setUvRange(Point2(0, 0), Point2(1, 1))
    cm.setFrame(-1, 1, -1, 1)
    card = self.render2d.attachNewNode(cm.generate())
    card.setTexture(self.tex)

    # Starting ARToolkit
    self.cam.node().getDisplayRegion(0).setSort(20)
    self.ar2 = ARToolKit.make(self.cam, "./camera_para.dat", 1)

    self.prep = False
    self.changeObject()
    taskMgr.add(self.updatePatterns, 'updatePatterns')
    self.accept('arrow_up', self.moveup)

# Changing selected object on secondary pattern
def changeObject(self):
    self.pandaActor = self.loader.loadModel("models/teapot")
    self.pandaActor.reparent_to(self.render)
    self.ar2.attachPattern("./aa.pat", self.pandaActor)

def updatePatterns(self, task):
    self.ar2.analyze(self.tex)
    return task.cont

def moveup(self):
    self.pandaActor.setX(self.pandaActor.getX()+1)
    print self.pandaActor.getX()

app = MyApp()
app.run()
James
  • 32,991
  • 4
  • 47
  • 70
  • Welcome to Stack Overflow. I edited your question so it will be better understood by other users. – James Apr 04 '17 at 12:13
  • Thanks for editing :) – Mahmoud Shoair Apr 04 '17 at 17:20
  • Hi, up front I'm not familiar with the python part of ARToolKit. But I think you might be changing the wrong coordinate system. To me it looks like you are changing the model coordinates which won't change the position where the model is rendered. Try and make changes the transformation matrix returned by ARToolKit – Thor_Bux Apr 11 '17 at 03:17
  • You right i tried to change the model coordinates but that i have four functions only in panda3d to deal with ARToolKit – Mahmoud Shoair Apr 12 '17 at 20:31

0 Answers0