Arcball camera - custom home?

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?

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
[url]http://www.derivative.ca/wiki088/index.php?title=ArcBall_Class[/url].

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.

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

arcBall.setTransform()

Cheers
Markus

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.
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?

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] 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][/code]

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

[code] 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)
	[/code]

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!

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]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)[/code]

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]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()[/code]

Here’s a fix that has parameters for home position, as well as custom pivot point :slight_smile: Otherwise your pivot is always around 0,0,0 :frowning:
arcballPivot.tox (7.76 KB)

1 Like