a dynamically updating point arc tracker?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
capricorn33
Posts: 249
Joined: Sun Oct 02, 2005 9:49 am
Location: Finland
Contact:

a dynamically updating point arc tracker?

Post by capricorn33 »

Has anyone of you scripters thought of making a good arc tracker tool for AS? That is something I really miss in my toolbox...

A dynamically updating point tracker showing you frame by frame spacing and keyframes positions..... like this:

Image

It should be completely dynamic so that when you move a point in the viewport (or nudge a keyframe in timeline or graph editor!) the tracking device updates and redraws to reflect the changed positions and spacing.
And OF COURSE you ought to be able to bind the tracker to a bone's tip (or end) or a layer origo point as well....

gaaaaaaah... makes me drool just thinking about it...!!!!
capricorn ( - just call me "cap")
children's tv pro, character animator
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

ponysmasher made a point tracker for me once - you select a point and it creates a new empty folder that tracks that point over the animation (so you can attach new parts to already animated things)

Perhaps that script could be adapted to 'plot' the movement of a point in an onion skin kind of way? Ramon did some pretty impressive stuff adding highlighting to points in the UI with his new lost wiggle tool - maybe advances in the scripting interface now allow for such a thing.

Having said that, I'm not totally sure if it's soething I'm missing, but I guess being able to visually track bone tips would be a useful way to see how your movement arcs are developing... interesting thread cap :)
User avatar
capricorn33
Posts: 249
Joined: Sun Oct 02, 2005 9:49 am
Location: Finland
Contact:

Post by capricorn33 »

Hey Funk :)
ponysmasher made a point tracker for me once - you select a point and it creates a new empty folder that tracks that point over the animation (so you can attach new parts to already animated things)
Yeah, I remember. I actually had a closer look at that one and tried a little modding on that very idea, and moved the code into an embedded script and actually got it to work "dynamically", in realtime, on one single selected translated point, with resulting keys on every frame - to show the overall spacing properly.


There are two problems that give me a headache, though...

1. How to get it to work on a point that is moved by a bone (or several interconnected bones)? I hate all these "matrix calculation" stuff, I can't seem to get my head around it. :evil:

2. And of course you have to know how to make it nice and pretty too and make it Draw() as well. That is also something I don't quite have understood properly yet.

So much coding to learn, so little time.

Actually I could put my little "embedded script"-experiment up here, if anyone is interested to have a look at it....
capricorn ( - just call me "cap")
children's tv pro, character animator
User avatar
capricorn33
Posts: 249
Joined: Sun Oct 02, 2005 9:49 am
Location: Finland
Contact:

Post by capricorn33 »

This is my little experiment, using ponysmasher's original script and putting it into the form of an embedded script (to make it dynamic).

Code: Select all

function LayerScript(moho)

-- thinking about making an automatically and dynamically updating arc and spacing tracker...
-- this is a little mod of ponysmasher's original code 
-- At this moment it's only reacting to translation of ONE point at a time.
-- .....making it an embedded layer script so that it, in time, will react to ALL tools


    local layer = moho.layer
	local curLayer = layer

	if (layer:LayerType() ~= MOHO.LT_VECTOR) or ( layer:IsGroupType() ) then
		print "not vectorlayer. break!"
		return
	end

	local mesh = moho:Mesh()
	if (mesh == nil) then
		return
	end

	local Interpolation = 0
	local val1 = 0
	local val2 = 0
	local xTable={}
	local yTable={}
	local pv=LM.Vector2:new_local()
	local lv=LM.Vector3:new_local()
	local startFrame = moho.document:StartFrame()
	local endFrame = moho.document:EndFrame()
	local thePoint = nil
	local theGroupLayer = nil

	-----------------------------------------------------Get the point we're looking for
	for i = 0, mesh:CountPoints() - 1 do
			local pt = mesh:Point(i)
			if (pt.fSelected) then
			thePoint=mesh:Point(i)
				break
			end
	end

	if (thePoint == nil) then
		--LM.GUI.Alert(LM.GUI.ALERT_INFO, "No point selected.", nil, nil, "OK", nil, nil)
		print "error. no point selected"
		return
	end

	---------------------------------------------------- check if tracklayer exists, if not create a new one
	if moho.document:LayerByName("Tracked motion") ~= nil then
	local iLayer = nil
		for i = 0, moho.document:CountLayers()-1 do
				iLayer = moho.document:Layer(i)
				if (moho.document:Layer(i).Name(iLayer) == ("Tracked motion")) then
					--print "Tracked motion layer found"
					theGroupLayer = iLayer
					break
				else
					--continue
				end
		end
	end

	if moho.document:LayerByName("Tracked motion") == nil then
				theGroupLayer = (moho:CreateNewLayer(MOHO.LT_GROUP)) -- The group layer that contains everything
				theGroupLayer:SetName("Tracked motion")
				--print "Tracked motion layer created"
	end


	---------------------------------------------------- get translate positions from selected point, transfer to
													  -- layer position in "Tracked motion"-layer

	local ch = thePoint.fAnimPos                        -- PROBLEM; only gets the pointanimated position, not the real screen position !!!
														-- does not work with bone action for instance...
		for frame = 0, ch:Duration() do

		--	if (ch:HasKey(frame)) then       -- use this to find the KEYED frames only !   -- >   keyframes should be marked in different color, of course...

				if (ch.GetKeyInterpMode ~= nil) then
					Interpolation, val1, val2 = ch:GetKeyInterp(frame, Interpolation,val1, val2);
				end
				if theGroupLayer ~= nil then
					lv=theGroupLayer.fTranslation:GetValue(frame)

					pv = thePoint.fAnimPos:GetValue(frame)
					lv.x = pv.x
					lv.y = pv.y
					theGroupLayer.fTranslation:SetValue(frame, lv)
					theGroupLayer.fTranslation:SetKeyInterp(frame, Interpolation, val1, val2)
				end

		--	end

		end

	moho:SetSelLayer(curlayer)
	moho:UpdateUI()
end


It's kind of halfway there...
How do you get it to work on points moved by influence of bones?
How do you get it to Draw() nicely in the UI without having to switch layers to see how the track is updated?

Pointers, anyone?
capricorn ( - just call me "cap")
children's tv pro, character animator
User avatar
capricorn33
Posts: 249
Joined: Sun Oct 02, 2005 9:49 am
Location: Finland
Contact:

Post by capricorn33 »

First problem solved... halfway to a working arctracking tool :)

Try translating a couple of points with this tool, anywhere on the timeline. (on frame 0 nothing special happens)

http://dl.dropbox.com/u/19247240/hl_tra ... ctrack.lua

Cool, huh?
Also try nudging keyframes around on the timeline - and my favorite; in the motion graph editor...! Suddenly the motion graph became a little easier to use for spacing purposes... :-)


So... how to get it to work with points that are influenced by and moved by bones?
I could need some help here... those matrix transformations and what have you makes my head go into total spin....... :roll:
capricorn ( - just call me "cap")
children's tv pro, character animator
User avatar
Víctor Paredes
Site Admin
Posts: 5815
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

Hi, Cap, sorry, I can't help here. Actually, I'm so useless than I can't make the current script work, can you explain the steps needed?
Thanks.
Image Image Image Image Image Image
Moho co-owner

Previously Rigged animation supervisor: My father's dragon, Wolfwalkers & Star Wars Visions "Screecher's Reach"
My personal Youtube Channel
User avatar
capricorn33
Posts: 249
Joined: Sun Oct 02, 2005 9:49 am
Location: Finland
Contact:

Post by capricorn33 »

Sure, Selgin. Sorry if I didn't explain very well.


- Install as a toolscript (copy to the tool folder)

- Make a vector layer, draw a couple of points.

- Pick one point and drag it around on a couple of different spots on the timeline, using this tool.

- You should see the translated point's frame positions trailed with small red, transparent dots.


It's basically a mod of the normal translate point tool, the only difference is that it leaves this "tracking trail" around the selected point, clearly showing you the spacing of the point's movement.
It works on one point at a time.


(Just a demo of a work in progress)
capricorn ( - just call me "cap")
children's tv pro, character animator
User avatar
Víctor Paredes
Site Admin
Posts: 5815
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

Fantastic! thanks, Cap.
Image Image Image Image Image Image
Moho co-owner

Previously Rigged animation supervisor: My father's dragon, Wolfwalkers & Star Wars Visions "Screecher's Reach"
My personal Youtube Channel
Post Reply