Page 1 of 1

what is test for translation by dragging a curve?

Posted: Mon Nov 08, 2021 10:43 am
by davoodice2

Code: Select all

	-- finally, test for translation by dragging a curve
	local selCount = 0
	local selBone = nil
	for i = 0, skel:CountBones() - 1 do
		local bone = skel:Bone(i)
		if (bone.fSelected) then
			selCount = selCount + 1
			selBone = bone
			if (selCount > 1) then
				break
			end
		end
	end
	if (selCount == 1 and selBone ~= nil and self.showPath) then
		local translationWhen = -20000
		local g = mouseEvent.view:Graphics()
		local m = LM.Matrix:new_local()
		local vec = LM.Vector2:new_local()
		local pt = LM.Point:new_local()
		local totalTimingOffset = moho.layer:TotalTimingOffset()
		moho.layer:GetFullTransform(moho.frame, m, moho.document)
		-- First see if any keyframes were picked
		for i = 0, selBone.fAnimPos:CountKeys() - 1 do
			local frame = selBone.fAnimPos:GetKeyWhen(i)
			vec = selBone.fAnimPos:GetValue(frame)
			m:Transform(vec)
			g:WorldToScreen(vec, pt)
			if (math.abs(pt.x - mouseEvent.pt.x) < self.TOLERANCE and math.abs(pt.y - mouseEvent.pt.y) < self.TOLERANCE) then
				translationWhen = frame
				self.trPathBone = selBone
				break
			end
		end
		-- If no keyframes were picked, try picking a random point along the curve.
		if (translationWhen <= -10000) then
			local startFrame = selBone.fAnimPos:GetKeyWhen(0)
			local endFrame = selBone.fAnimPos:Duration()
			if (endFrame > startFrame) then
				local oldVec = LM.Vector2:new_local()
				g:Clear(0, 0, 0, 0)
				g:SetColor(255, 255, 255)
				g:BeginPicking(mouseEvent.pt, 4)
				for frame = startFrame, endFrame do
					vec = selBone.fAnimPos:GetValue(frame)
					m:Transform(vec)
					if (frame > startFrame) then
						g:DrawLine(oldVec.x, oldVec.y, vec.x, vec.y)
					end
					if (g:Pick()) then
						translationWhen = frame
						self.trPathBone = selBone
						break
					end
					oldVec:Set(vec)
				end
			end
		end
		if (translationWhen > -10000) then
			self.translationFrame = translationWhen
			return 0
		end
	end
Hello friends. I don't know what does this code. anybody can help me?
this is part of code in boneTranslate tool.

Re: what is test for translation by dragging a curve?

Posted: Mon Nov 08, 2021 4:26 pm
by synthsin75
If you have show path enabled on the tool, it will display the translation path. If you click on this path, you can pull it around and set new keyframes on the timeline, at that time on the path...without having to be on that frame.

Re: what is test for translation by dragging a curve?

Posted: Mon Nov 08, 2021 5:07 pm
by davoodice2
synthsin75 wrote: Mon Nov 08, 2021 4:26 pm If you have show path enabled on the tool, it will display the translation path. If you click on this path, you can pull it around and set new keyframes on the timeline, at that time on the path...without having to be on that frame.
thank you again.