Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

Arcball camera - custom home?

Still a little green? Ask your beginner's questions here

Arcball camera - custom home?

Postby asterix » Tue Aug 09, 2016 11:32 am

Would be good to set a custom home view or any view in arcball. I can do something similar by setting tx,ty etc variables. Or by creating my own matrix and dumping it into cam1/newMat. However those values are wiped whenever I perform a zoom or pan / dolly. I'm assuming the previous or current transforms are stored inside td.Storetools somewhere but I can't seem to get to them. Any ideas or pointers?
asterix
 
Posts: 137
Joined: Fri Jul 19, 2013 1:34 pm

Re: Arcball camera - custom home?

Postby raganmd » Tue Aug 09, 2016 12:15 pm

For me the "h" key returns me to the home position of the tx ty tz transformations - similar to how the geo viewers work. Is that the kind of function you're thinking about?

Looking over the extensions inside, it looks like arcInst is using tdu.ArcBall
http://www.derivative.ca/wiki088/index.php?title=ArcBall_Class.
raganmd
 
Posts: 1301
Joined: Thu Mar 28, 2013 5:21 am
Location: San Francisco, CA

Re: Arcball camera - custom home?

Postby asterix » Tue Aug 09, 2016 6:34 pm

Awesome thanks Matt. Yeah couldn't find the arcball class so it looks like it possibly inherits from the matrix class. Maybe I can set it that way.
asterix
 
Posts: 137
Joined: Fri Jul 19, 2013 1:34 pm

Re: Arcball camera - custom home?

Postby snaut » Tue Aug 09, 2016 7:18 pm

Not sure if it's in the current builds but you can try

Code: Select all
arcBall.setTransform()


Cheers
Markus
User avatar
snaut
Staff
 
Posts: 841
Joined: Mon Nov 12, 2007 6:21 pm
Location: Toronto

Re: Arcball camera - custom home?

Postby Diatom » Tue Aug 16, 2016 2:21 am

I just tried it and no love.

fMat = self.ownerComp.fetch('Matrix'+str(ID) )
self.arcInst.setTransform(fMat)

python >>>
Restore Matrix 3
[0.9383832 -0.1607936 0.3059123 0,
-0.1033918 0.714015 0.6924542 0,
-0.3297681 -0.6814162 0.6533949 0,
0 0 0 1]

AttributeError: 'tdu.ArcBall' object has no attribute 'setTransform'

Storing and fetching a matrix works, just not setting the transform of cam or arcball.
------
Also tried setting the matrix directly

for i in range(4):
for j in range(4):
self.arcInst.transform[i,j] = fMat[i,j]
TypeError: 'builtin_function_or_method' object does not support item assignment

It appears that the tdu matrix supports setting elements.
https://www.derivative.ca/wiki088/index ... trix_Class
Special Functions
[row, column] → float
Gets or sets the specified entry in the matrix.

Like Asterix, I'm trying to make a saved state for the arcball, so I can jump to different cam views. Preferably with a lagged interpolation to that view.

Is it possible to set the transform in any way?
Sounds like this feature is coming soon?
Diatom
 
Posts: 27
Joined: Sat Jan 14, 2012 9:06 pm
Location: Los Angeles

Re: Arcball camera - custom home?

Postby archo-p » Mon Nov 06, 2017 5:54 am

Hey there!

Bumping this! I have been trying to use the arcBall.setTransform() to have a custom "home" for my arc ball camera and it works initially, but when i click to start moving the camera again it seems to default to a bunk matrix that points the camera in some bad state until homing again. Any advice?

My code as an added function to the arcBall camera extension:

Code: Select all
 def SetPos(self):
      if self.ownerComp.par.Resetobject.eval():
         newMat = self.ownerComp.par.Resetobject.eval().transform()
         self.arcInst.setTransform(newMat)
         #pulling the fillMat code as this seems needed
         self.matrix = newMat
         self.ownerComp.cook(force=True)
         for i in range(4):
            for j in range(4):
               op('newMat')[i,j] = newMat[i,j]
User avatar
archo-p
 
Posts: 473
Joined: Thu Nov 19, 2009 3:03 pm
Location: Los Angeles

Re: Arcball camera - custom home?

Postby lucasm » Thu Nov 09, 2017 3:33 pm

archo-p had the same issue with it resetting upon zooming or interacting at all.
I recently built this method attached to ext1ArcBallExt:

Code: Select all
   def Home(self, tx, ty, tz, size):
      
      homeInfo = op("homeInfo")
      tx = float(tx)
      ty = float(ty)
      tz = float(tz)

      self.arcInst.identity()
      self.fillMat()
      
      u = tx * -1
      v = ty * -1
      scaler = 1
      self.arcInst.panTo(u,v,scale=scaler)
      
      u = 0
      v = size * -1.5
      scaler = 1
      self.arcInst.dollyTo(u,v,scale=scaler)
      
      self.fillMat()
      # self.ownerComp.cook(force=True)
      


It positions, then zooms back enough to encapsulate whatever thing was in focus - scale was the greatest number out of width/height/depth.

So, if your subject was 5 wide, 2 deep, and 10 tall, size would == 10.

Could probably modify this easily to add rotation as well!
User avatar
lucasm
 
Posts: 222
Joined: Sat Apr 28, 2012 7:55 pm
Location: Dallas, TX

Re: Arcball camera - custom home?

Postby archo-p » Fri Jul 06, 2018 2:49 am

Coming back around to this, it came up again today with another collegue trying to do the same thing and we finally sussed it out. If you store a matrix you want to recall in the arcBall by saving the ArcBall.transform() as a list using the Matrix.vals function then you need to send the inverse back into the setTransform() function of the ArcBall to get it back properly. EG:

Code: Select all
def SavePosToTable(self, posName):
   matVals =  self.arcInst.transform().vals
   self.ownerComp.op('cameraPosDat')[posName,1].val = savedMatrix

def SetCameraToPos(self, posName):
   newMatVals = self.ownerComp.op('cameraPosDat')[posName,1].val
   newMat = tdu.Matrix(eval(newMatVals))
   newMat.invert()
   self.arcInst.setTransform(newMat)
User avatar
archo-p
 
Posts: 473
Joined: Thu Nov 19, 2009 3:03 pm
Location: Los Angeles

Re: Arcball camera - custom home?

Postby doctorhandshake » Sat Aug 25, 2018 11:14 am

Revisiting this implementing Peter's method with a couple of fixes (variable naming prob in SavePosToTable() and adding a call to fillMat() at the end to update the view)...


Code: Select all
def SavePosToTable(self, posName):
   matVals =  self.arcInst.transform().vals
   self.ownerComp.op('cameraPosDat')[posName,1].val = matVals


def SetCameraToPos(self, posName):
   newMatVals = self.ownerComp.op('cameraPosDat')[posName,1].val
   newMat = tdu.Matrix(eval(newMatVals))
   newMat.invert()
   self.arcInst.setTransform(newMat)
   self.fillMat()
Noah Norman
http://hardwork.party

codename: massapequa
User avatar
doctorhandshake
 
Posts: 115
Joined: Wed Aug 17, 2011 6:31 pm
Location: Brooklyn, NY


Return to Beginners

Who is online

Users browsing this forum: Bing [Bot] and 8 guests