i have a script request! (Poses)

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

Moderators: Víctor Paredes, Belgarath, slowtiger

chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Post by chucky »

Wooohooo!
Thanks guys, Darth, Vern, that really cleared it up for me.:D
It really is a great script well done everyone.
ImageImage
So one more thing,
Am I correct in thinking that we can't use additional facial bones to adjust expressions in the time line after the poses have been layed down?- unless they are part of the pose already? i.e. eyebrows, jaw etc.:(
Anyone wanting to try the full pose array, can use this example file, and adapt it to make you own 'better' faces or objects.
http://charleskenway.com/anime/fullposeface.zip
User avatar
synthsin75
Posts: 10272
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Great work Genete!

Yeah Chucky, it doesn't work for bone motion.

I have one suggestion which may help this slight deficiency. You already have 'boneselector' to choose your poses in the array. It would be nice if you could have secondary pose selector bones. Basically several separate arrays on one layer.

Like perhaps a 'boneselector_b' that only works with 'pose1_b', 'pose2_b' etc.

Just an idea. :wink:
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

I'm in a process of change my computer... :( in fact I was writing a long post when firefox crashed as usual... the post was lost...

I'm doing now a backup of all my stuff and would like to return to this script after have the new computer.

meanwhile here is a suggested workflow:

Image

You can group the bone poses to have them accessible for the bone selector to produce a lip movements at the 3/4 view. Then you can do a "path" to change to other group of bones in other pose of the head.

Also you should know that you can set the same bone pose name several times in the canvas so you can travel from a cloud of bones to other without the problem of have none bone influence to the resulting pose.

Regarding to the ability to have several bone selector you can easily make a custom script changing the bone selector name and the poses bone names and apply to a different layers. It would allow make eyeblinks using this technique or lipsync in the same way. Just create more custom scripts and apply to the proper layers.

Don't desperate, I'll work on this later.

Wish me luck with the new computer!

Cheers!
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Post by chucky »

Good luck Genete, I hope you don't have too much software to re register :?
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Synchronicity!!

I just got a "new" computer today. A friend put one together from spare parts. My old PC was pretty much dead... barely worked except for AS (I mostly use the mac). Now my PC is more powerful than the Mac.

-vern
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

OK the backup is already done. I think that all the scripts MUST be pasted in the post itself instead of place a link to an external file. Anyone who would use a script should know how to save the portion of text and give it the proper name.
Darthfurby wrote:Genete: Here is my proposal: I will create a pose bones head turn model of your choice from any character in my gallery, AND make a video tutorial/promotional video about the script, if you can fulfill my feature request, which is this:
Your models are lovely Darth but I prefer to use a simpler model. Maybe something like the one that chuky did recently. It wouldn't be hard to me to create the model in the needed poses. I take your proposal to create a video tutorial, though.
Darthfurby wrote:The ability to key/adjust the pose bone and point motion at the same time anywhere on the timeline, including the following channels:
Point Motion, Selected Point Motion, Point Curvature, Selected Point Curvature, Fill Color, Selected Fill Color, Line Color, and Selected Line Color.

I don't know if it's possible, but I'd love to see it happen.
Point Motion and Selected Point motion: what do you exactly mean with selected point motion? are you suggesting that the script would only take care of the selected points when it runs? Mmm it is a good idea but I don't see any application on it for the moment. It is just another if then condition so it is not difficult to do. If no point is selected then it should consider that all they are affected as it works now.

Point Curvature and Selected Point curvature : It is possible too and easy to implement because the interface is related to the Curve Object (easy to obtain from the script interface). The problem is that I've not tested if the interface would change the object value (curvature) without add any keyframe or it would add a keyframe every time the function is called.

Fill Color and Selected Fill Color, Line Color and Selected Line Color: Current interface would allow access those animated channels by the Style property of each shape (outline or fill) but I think that you only can select a shape a time. Using fazec's tools you can select several shapes at once but only the first is affected by the modifications you do by the style palette. Anyway I would try it. Also I don't know if the script interface would produce a keyframe or simply would modify the value during time.

Regarding to:
The ability to key/adjust the pose bone and point motion at the same time anywhere on the timeline
I guess you want this work flow:

1) Setup the poses.
2) Place interpolated poses along the time using bone motion.
3) Refine it using point motion AFTER the pose bone motion is FIXED. This is important. If you don't have clear which are the final bone poses and you modify the middle interpolations using direct point motion (don't know how now but suppose you can) then it would be a nightmare if you modify the bone poses again and want to remove the point adjustments.

It is similar to point fixing after a normal bone movements. If you fix the point motion according to a resulting bone motion then it would not be good if you modify the bone motion (make it faster for example) because the point motion wouldn't follow. You have to re-adjust it again.

If you agree with this work flow I can implement a variable that would let you produce a keyframe on the current frame with the actual interpolation values. That variable can be toggled by an external script using a button.

So the work flow would be:

1) Setup the poses.
2) Place interpolated poses along the time using bone motion.
3) Refine it using point motion AFTER the pose bone motion is FIXED:
3.1) Go to the frame where the interpolation did a bad job.
3.2) Produce a point motion keyframe at that frame using the current values of the interpolated mesh.
3.3) Next time the embedded script runs when the time cursor is placed where a point motion keyframe is, the script would be internally disabled (you can freely adjust the point motion using standard tools).

There is a problem with this work flow, though. When the time cursor stay on a frame where there is not a keyframe the script would produce directly the original interpolation so if you are not careful you can produce point motion steps interpolations. This can be solved if any frame (or set of frames) you correct using point motion has a untouched keyframe before and after the touched frame(s). The user should take care on make the interpolation smooth between the touched and the untouched keyframes.

Does it make sense? :roll:

-G
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

OK, OK here it is:

http://www.darthfurby.com/genete/Scripting/poses2.zip

This zip file includes:

poses-2.0.lua
New version of the embedded script
modeltest.anme
5.6 anme file of a beautiful model form DarthFurby used to test the script.
/Poses/ge_toggle_keyframe_poses.lua
A menu script needed to allow create keyframes when the script runs and not only move the points. It only do keyframes for point motion. Usage: Copy this folder in to your scritps/Menu folder and reload (CTRL+F5) Anime Studio scripts.

News:
  • I've added some testing to speed up the positioning on the poses. You can edit the poses freely staying at its own frame but if you modify a pose then you have to go to frame 0 to store the modifications on the pose array. Frame 0 is slow!!!
  • Now the pose bone length has influence on the final weight of the poses. So you can control the interpolated pose with the poses lengths.
  • Added the Curvature channel. Now the curvature is stored and is interpolated between poses. It produces automatically a keyframe on each frame. There is NO WAY to solve this because the curvature channel has not a fCurvature variable to set like the one for the points.
  • Added the functionality of an external variable: GE_ToggleKeyframePoses.Status
    You have to run the ge_toggle_keyframe_poses.lua script by the menu or button script to modify the variable Status form false (default value) to true and vice versa. When this variable is set to true the interpolated point motion is stored in a keyframe. This is useful to store all the animation in its own keyframes and be able to remove the embedde scripts. Also useful when used on single frames to key all the point motions for all layers where the script is embedded.
  • Added the ability to avoid interpolate or set again an existing keyframe. This allows the user to insert a keyframe in any moment of the interpolation and manually modify the interpolated values. This solves the situation where the interpolated poses produces a bad value difficult to solve by modifying the poses themselves.
If you carefully look to the modeltest you can see how the curvature of the point of the nose changes along the keyframes. Also some points of the cheek.

Regarding to the new functionality of be able to produce its own point motion instead of the interpolated by the script. I have to say that I discovered it accidentally. What a good surprise!!! Using the script normally you can now move any point at any moment and the script automatically would pass over that keyframe and would work in the rest.

Please test it and let me know.

-G

PD: I would like that the frame where the script stores the poses values in the arrays in the memory were the frame 1 instead of frame 0... what do you think?

-------------poses-2.0,lua-----------------
--Embed this script into all the vector layers that want to copy poses from frames 1,2,3,4, ..., maxposes
--it must be under a bone type layer and the following ROOT named bones MUST exists:

-- posek (with k form 1 to maxposes)
-- bonelesector

-- Copyright 2008 Genete
-- Released for free.
-- Thanks to Selgin for that great idea.
-- It can be extended for other animated values (curvatures, widths, shape fill colors, shape outline color, etc.)
-- (curvature done!)
-- Also weights w[k] can be overweigthed by the pose bone legth. It would allow some sort of variable action weights...
-- Under development...
-- Modififed June 5th, 2008:
-- Tim Fischer: Added local variables to speed up looping (interpreted languages recalculate every iteration so a variable can be much faster)
-- Added garbage collection routine to free memory (Auto GC doesn't appear to work). This fixes hanging, etc

--Genete 2008 july, 27th
---I've added some testing to speed up the positioning on the poses. You can edit the poses freely staying at its own frame but
---if you modify a pose then you have to go to frame 0 to store the modifications on the pose array. Frame 0 is slow!!!
---Now the pose bone legth has influence on the final weight of the poses. So you can control the interpolated pose with the poses lengths.
---Added the Curvature channel. Now the curvature is stored and is interpolated between poses. It produces automatically a keyframe on each frame
---There is NO WAY to solve this because the curvature channel has not a fCurvature variable to set like the one for the points.
---Added the functionality of an external variable: GE_ToggleKeyframePoses.Status
---You have to run the ge_toggle_keyframe_poses.lua script by the menu or button script to modify the variable Status form false (default value)
---to True and viceversa. When this variable is set to true the inrterpolated point motion is stored in a keyframe. This is useful to
---store all the animation in its own keyframes and be able to remove the embedde scripts. Also useful when used on single frames to key all the
---point motions for all layers where the script is embedded.
---Added the ability to avoid interpolate or set again an existing keyframe. This allows the user to insert a keyframe in any moment of the
---interpolation and manually modify the interpolated values. This solves the situation where the interpolated poses produces a bad value
---difficult to solve by modifying the poses thenselves.

poses = {}

maxposes = 4

bone = {}
boneselector = nil

function LayerScript(moho)
local w = {}
local distance
local posk
local pos_selector
local r
local length

local k,i,l
local layer = moho.layer
local frame = moho.frame
local pimoved =LM.Vector2:new_local()
local pi

local skel = moho:ParentSkeleton()
if (skel == nil) then
print ("No parent skeleton found in layer:".. layer:Name())
return
end

local mesh = moho:Mesh()

if (mesh==nil) then
print ("No mesh found in layer:".. layer:Name())
return
end
if (frame <=maxposes and frame > 0) then return end
if (frame <= maxposes or boneselector == nil) then
-----------------------------------look for the bones
for k=1, maxposes do
bone[k] = nil
local fc1 = skel:CountBones()-1 -- added to speed up loops
for i=0, fc1 do
local bonei = skel:Bone(i)
local bonek = "pose" .. tostring(k)
if (bonei:Name() == bonek) then
bone[k]=bonei
elseif (bonei:Name() == "boneselector") then
boneselector=bonei
end
end
if (bone[k] == nil) then
print("bone "..k.." is missing")
return
end
end
if boneselector == nil then
print("boneselector is missing")
return
end
---------------------------------
--------------------------------- creates a new array for the layer
poses[layer]={}
poses[layer]["points"]={} -- this is the array for the point motion
for k=1, maxposes do
poses[layer]["points"][k]={}
local fc2 = mesh:CountPoints()-1 -- added to speed up loops
for i=0, fc2 do
poses[layer]["points"][k]=mesh:Point(i).fAnimPos:GetValue(k) --store all the points/pose/positions
end
collectgarbage(fc2)
end
poses[layer]["curvature"]={} -- this is the array for the curvatures
for k=1, maxposes do
poses[layer]["curvature"][k]={}
local fc3 = mesh:CountCurves()-1
for i=0, fc3 do
poses[layer]["curvature"][k]={}
local curvei = mesh:Curve(i)
local fc4 = curvei:CountPoints()-1
for l=0, fc4 do
poses[layer]["curvature"][k][l]=curvei:GetCurvature(l,k)--store all the point of curves/pose /curvature
end
collectgarbage(fc4)
end
collectgarbage(fc3)
end
return
end -- end of frame < maxposes or boneselector == nil

pos_selector = boneselector.fPos --position of the selector bone.
-- length = boneselector.fLength*boneselector.fAnimScale:GetValue(moho.frame) --current length of the boneselector
length = boneselector.fLength*boneselector.fScale --current length of the boneselector

-- Calculate the distance form the boneselector to all the pose bones and calculate its "weight" influence
for k=1, maxposes do
w[k]=0
posk = bone[k].fPos
distance = posk - pos_selector
r = distance:Mag()
w[k]=weight(r, length)*bone[k].fScale --***THE SCALE OF THE POSE BONE CREATE INFLUENCE ON THE POSE!***
end

local wtot=0.0 --total weight initially = 0.0
for k=1, maxposes do
wtot =wtot +w[k]
end
if (wtot == 0.0) then return end
for k=1, maxposes do
w[k]=w[k]/wtot -- normalize the weights.
end

---------------------------------------------POINT MOTION
local fc3=mesh:CountPoints()-1 -- added to speed up loops
for i=0, fc3 do --- move the points.
pimoved:Set(0,0)
pi= mesh:Point(i)
if (pi.fAnimPos:HasKey(frame)) then break end -- if there is a keyframe then don't overrride it.
for k=1, maxposes do
pimoved = pimoved + poses[layer]["points"][k]*w[k]
end
if(GE_ToggleKeyframePoses.Status==false) then
mesh:Point(i).fPos:Set(pimoved) --move the point
else
pi.fAnimPos.value=pimoved -- move the point
pi.fAnimPos:StoreValue()--this produces a keyframe and stores its valule
moho.document:SetDirty()
end
end
---------------------------------------------END POINT MOTION
---------------------------------------------CURVATURE
fc3 = mesh:CountCurves()-1
for i=0, fc3 do
local curvei = mesh:Curve(i)
local fc4 = curvei:CountPoints()-1
for l=0, fc4 do
local currentcurvature = 0.0
for k=1, maxposes do
currentcurvature=currentcurvature + poses[layer]["curvature"][k][l]*w[k]
curvei:SetCurvature(l,currentcurvature,frame)
end
end
end

---------------------------------------------END CURVATURE
collectgarbage (fc3)

end ---FUNCTION END


function weight (r, l)
if (r <= l) then
local w =1-r/l
return w
else
return 0.0
end
end

------------ge_toggle_keyframe_poses.lua----------
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************

ScriptName = "GE_ToggleKeyframePoses"

-- **************************************************
-- General information about this script
-- **************************************************

GE_ToggleKeyframePoses = {}

function GE_ToggleKeyframePoses:Name()
return "Toggle Keyframe Poses"
end

function GE_ToggleKeyframePoses:Version()
return "1.0"
end

function GE_ToggleKeyframePoses:Description()
return "Chage the status of keyframe an interpolated pose"
end

function GE_ToggleKeyframePoses:Creator()
return "Genete"
end

function GE_ToggleKeyframePoses:UILabel()
return("Toggle Keyframe Poses")
end

-- **************************************************
-- Recurring Values
-- **************************************************
GE_ToggleKeyframePoses.Status=false

-- **************************************************
-- The guts of this script
-- **************************************************

function GE_ToggleKeyframePoses:Run(moho)
if (GE_ToggleKeyframePoses.Status ==false) then GE_ToggleKeyframePoses.Status = true
else GE_ToggleKeyframePoses.Status= false
end
print("Pose Keyframe Status = "..tostring(GE_ToggleKeyframePoses.Status))
end
Last edited by Genete on Sun Jul 27, 2008 5:28 pm, edited 1 time in total.
User avatar
synthsin75
Posts: 10272
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Hey Genete, your link has a comma instead of a period. And the zip file doesn't appear to contain the new pose script, just two versions of the toggle menu script.

Sounds great though. :wink:
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Yes it is my mistake.
I'll upload again the zip and correct the link

-EDIT: OK link and zip fixed. Anyway the script is pasted in the post itself for this kind of mistakes.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

This is a new version

http://www.darthfurby.com/genete/Scripting/poses2.1.zip

News:

It allows Shape fill and Line color interpolation.
Line Width doesn't seem to work although I've tried it.

The zip files includes a simple sample file to demonstrate the new features.

Please tell me if it works for you.

-G

-----------poses-2.1.lua-----------

Code: Select all

--Embed this script into all the vector layers that want to copy poses from frames 1,2,3,4, ..., maxposes
--it must be under a bone type layer and the following ROOT named bones MUST exists:

-- posek (with k form 1 to maxposes)
-- bonelesector

-- Copyright 2008 Genete
-- Released for free.
-- Thanks to Selgin for that great idea.
-- It can be extended for other animated values (curvatures, widths, shape fill colors, shape outline color, etc.)
-- (curvature done!)
-- Also weights w[k] can be overweigthed by the pose bone legth. It would allow some sort of variable action weights...
-- Under development...
-- Modififed June 5th, 2008:
-- Tim Fischer:  Added local variables to speed up looping (interpreted languages recalculate every iteration so a variable can be much faster)
-- Added garbage collection routine to free memory (Auto GC doesn't appear to work).  This fixes hanging, etc

--Genete 2008 july, 27th
---I've added some testing to speed up the positioning on the poses. You can edit the poses freely staying at its own frame but 
---if you modify a pose then you have to go to frame 0 to store the modifications on the pose array. Frame 0 is slow!!!
---Now the pose bone legth has influence on the final weight of the poses. So you can control the interpolated pose with the poses lengths.
---Added the Curvature channel. Now the curvature is stored and is interpolated between poses. It produces automatically a keyframe on each frame
---There is NO WAY to solve this because the curvature channel has not a fCurvature variable to set like the one for the points.
---Added the functionality of an external variable: GE_ToggleKeyframePoses.Status
---You have to run the ge_toggle_keyframe_poses.lua script by the menu or button script to modify the variable Status form false (default value)
---to True and viceversa. When this variable is set to true the inrterpolated point motion is stored in a keyframe. This is useful to 
---store all the animation in its own keyframes and be able to remove the embedde scripts. Also useful when used on single frames to key all the 
---point motions for all layers where the script is embedded.
---Added the ability to avoid interpolate or set again an existing keyframe. This allows the user to insert a keyframe in any moment of the
---interpolation and manually modify the interpolated values. This solves the situation where the interpolated poses produces a bad value
---difficult to solve by modifying the poses thenselves.

---Added interpolation for style shape fill and line color. I've tried Line Widht but it seems not to work.

poses = {}

maxposes = 4

bone = {}
boneselector = nil

function LayerScript(moho)
   local w = {}
   local distance
   local posk
   local pos_selector
   local r
   local length

   local k,i,l
   local layer = moho.layer
   local frame = moho.frame
   local pimoved =LM.Vector2:new_local()
   local pi

   local skel = moho:ParentSkeleton()
   if (skel == nil) then
      print ("No parent skeleton found in layer:".. layer:Name())
      return
   end

   local mesh = moho:Mesh()
   
   if (mesh==nil) then
      print ("No mesh found in layer:".. layer:Name())
      return
   end   
   if (frame <=maxposes and frame > 0) then return end
   if (frame <= maxposes or boneselector == nil) then
-----------------------------------look for the bones
      for k=1, maxposes do
         bone[k] = nil
         local fc1 = skel:CountBones()-1   -- added to speed up loops
         for i=0, fc1 do
            local bonei = skel:Bone(i)
            local bonek = "pose" .. tostring(k)
            if (bonei:Name() == bonek) then
               bone[k]=bonei
            elseif (bonei:Name() == "boneselector") then
               boneselector=bonei
            end
         end   
         if (bone[k] == nil) then
            print("bone "..k.." is missing")
            return
         end
      end
      if boneselector == nil then
         print("boneselector is missing")
         return
      end
---------------------------------
--------------------------------- creates a new array for the layer
      poses[layer]={}
      poses[layer]["points"]={} -- this is the array for the point motion
      for k=1, maxposes do
         poses[layer]["points"][k]={}
         local fc2 = mesh:CountPoints()-1   -- added to speed up loops
         for i=0, fc2 do
            poses[layer]["points"][k][i]=mesh:Point(i).fAnimPos:GetValue(k) --store all the points/pose/positions
         end
         collectgarbage(fc2)
      end
      poses[layer]["curvature"]={} -- this is the array for the curvatures
      for k=1, maxposes do
         poses[layer]["curvature"][k]={}
         local fc3 = mesh:CountCurves()-1
         for i=0, fc3 do
            poses[layer]["curvature"][k][i]={}
            local curvei = mesh:Curve(i)
            local fc4 = curvei:CountPoints()-1
            for l=0, fc4 do
               poses[layer]["curvature"][k][i][l]=curvei:GetCurvature(l,k)--store all the point of curves/pose /curvature
            end
            collectgarbage(fc4)
         end
         collectgarbage(fc3)
      end
      poses[layer]["fillcolor"]={}
      poses[layer]["linecolor"]={}
      poses[layer]["linewidth"]={}
      for k=1, maxposes do
         poses[layer]["fillcolor"][k]={}
         poses[layer]["linecolor"][k]={}
         poses[layer]["linewidth"][k]={}
         
         local fc5=mesh:CountShapes()-1
         for i=0, fc5 do
            local shapei=mesh:Shape(i)
            poses[layer]["fillcolor"][k][i]=shapei.fMyStyle.fFillCol:GetValue(k)
            poses[layer]["linecolor"][k][i]=shapei.fMyStyle.fLineCol:GetValue(k)
            poses[layer]["linewidth"][k][i]=shapei.fMyStyle.fLineWidth
         end
      end
      
      return
   end -- end of frame < maxposes or boneselector == nil
   
   pos_selector = boneselector.fPos --position of the selector bone.   
--   length = boneselector.fLength*boneselector.fAnimScale:GetValue(moho.frame) --current length of the boneselector
   length = boneselector.fLength*boneselector.fScale --current length of the boneselector

-- Calculate the distance form the boneselector to all the pose bones and calculate its "weight" influence
   for k=1, maxposes do
      w[k]=0
      posk = bone[k].fPos
      distance = posk - pos_selector
      r = distance:Mag()
      w[k]=weight(r, length)*bone[k].fScale --***THE SCALE OF THE POSE BONE CREATE INFLUENCE ON THE POSE!***
   end
   
   local wtot=0.0 --total weight initially = 0.0
   for k=1, maxposes do
      wtot =wtot +w[k]
   end
   if (wtot == 0.0) then  return  end
   for k=1, maxposes do
      w[k]=w[k]/wtot -- normalize the weights.
   end
   
---------------------------------------------POINT MOTION
   local fc3=mesh:CountPoints()-1  -- added to speed up loops
   for i=0, fc3 do --- move the points.
      pimoved:Set(0,0)
      pi= mesh:Point(i)
      if (pi.fAnimPos:HasKey(frame)) then break end -- if there is a keyframe then don't overrride it.
      for k=1, maxposes do
         pimoved = pimoved + poses[layer]["points"][k][i]*w[k]
      end
      if(GE_ToggleKeyframePoses.Status==false) then
         mesh:Point(i).fPos:Set(pimoved) --move the point
      else
         pi.fAnimPos.value=pimoved -- move the point
         pi.fAnimPos:StoreValue()--this produces a keyframe and stores its valule
         moho.document:SetDirty()
      end
   end
---------------------------------------------END POINT MOTION   
---------------------------------------------CURVATURE
   fc3 = mesh:CountCurves()-1
   for i=0, fc3 do
      local curvei = mesh:Curve(i)
      local fc4 = curvei:CountPoints()-1
      for l=0, fc4 do
         local currentcurvature = 0.0
         for k=1, maxposes do
            currentcurvature=currentcurvature + poses[layer]["curvature"][k][i][l]*w[k]
            curvei:SetCurvature(l,currentcurvature,frame)
         end
      end
   end

---------------------------------------------END CURVATURE
---------------------------------------------STYLE

   fc3 = mesh:CountShapes()-1
   for i=0, fc3 do
      local shapei = mesh:Shape(i)
         local currentfillcol = LM.ColorVector:new_local()
         local currentlinecol = LM.ColorVector:new_local()
         local currentlinewidth = 0.0
         currentfillcol:Set(0.0,0.0,0.0)
         currentlinecol:Set(0.0,0.0,0.0)
         for k=1, maxposes do
            currentfillcol=currentfillcol+poses[layer]["fillcolor"][k][i]*w[k]
            currentlinecol=currentlinecol+poses[layer]["linecolor"][k][i]*w[k]
            currentlinewidth=currentlinewidth+poses[layer]["linewidth"][k][i]*w[k]
            --if(shapei.fMyStyle.fDefineFillCol) then
             shapei.fMyStyle.fFillCol:SetValue(frame,currentfillcol) --end
            --if(shapei.fMyStyle.fDefineLinecol) then 
            shapei.fMyStyle.fLineCol:SetValue(frame,currentlinecol) --end
            --if(shapei.fMyStyle.fDefineLineWidth) then 
            shapei.fMyStyle.fLineWidth=currentlinewidth --end
         end
   end
--------------------------------------------- END STYLE


   collectgarbage (fc3)

end ---FUNCTION END


function weight (r, l)
   if (r <= l) then
   local w =1-r/l
      return w
   else
      return 0.0
   end
end 
DarthFurby
Posts: 510
Joined: Sat Jul 29, 2006 1:34 pm
Location: New York City
Contact:

Post by DarthFurby »

WOW!!!

It works! But when I add keyframes it adds extra keyframes randomly on the timeline. Also it doesn't delete all the keyframes. Hopefully somone can figure out how to fix the point curvature issue, and add the other channels. But still, I can't believe it!! You got the point motion part working!

Genete you are a genius!!!!!!! You are very close to making history.

Anyway, I would love to make the video tutorial with one of your characters! I agree that a simple model is definitely best for training purposes.

Edit: and also the fill and line color channels work too!! But have the same keyframe issues as the point motion channel.
User avatar
synthsin75
Posts: 10272
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Great work Genete!

I'm not really understanding how you are getting that interpolation from and to the poses. Everything I try just gives me a step interpolation, and it somehow seems to 'remember' what you have done manually but without visible keyframes.

I must be doing something wrong.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Yes you're right. I've noticed it also. It is so strange because it seems like if the script believes that it is not using the current frame.
If you use directly the point motion tool it takes a small time of amount to notice that the embedded script have to avoid this produced keyframe. Maybe due to the fact that the script runs three times in the same frame it produces strange results with two consecutive calls have different parameters...

When want to modify a point motion in a certain keyframe try to produce the keyframe first without producing the motion. Like for example selecting the points and making a single click in the canvas with the original LM translate points too. After that you can move the selected point(s) using any tool (magnet, scale, translate, etc..)

Also do you know that the rest of bones of the skeleton still working?? Try yo rig the model as usual and you would see that the head turn still working although you bend the head up and down or left and right. The point motion is relative to bone motion!!!! This is freaking cool!!!
synthsin75 wrote:I'm not really understanding how you are getting that interpolation from and to the poses. Everything I try just gives me a step interpolation, and it somehow seems to 'remember' what you have done manually but without visible keyframes.
You're modifying a single frame when use the point motion and overrride the script interpolation. If the point movement is so big or different from the previous or next frames without keyframes then the interpolation is a step. To avoid that you have to set keyframes in this way:

frame---keyframe
20---none
21---none
22---yes (just the same than the script point motion at frame 22)
23---yes (small variation) (very similar to frame 23)
24---yes (small variation)

... insert more here

25---yes (small variation)
26---yes (small variation) (very similar to frame 27)
27---yes (just the same than the script point motion at frame 27)

remember that this was designed for a bad interpolation in some frames (not all) so a manual work should be done there. :wink:

-G
User avatar
synthsin75
Posts: 10272
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Oh, I see now. To do what you have in the example, I had to copy the keyframe from one of the poses and then my manual point manipulation will interpolate from this key.

I just wasn't thinking. It's obvious that you need to define the keyframe from and to which you want to interpolate from the poses which only have bone keys.

Awesome script, but that workflow will take some getting use to. :wink:
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Darth, do the tutorial with a simple model created by you. I'm so tired today. Need to rest.

Heyvern, please take a look to the script and see if there is more room to improve performance. How about to place the poses at negative frames? would be difficult to edit there?
Post Reply