Bone Point binding from switch layers
Moderators: Víctor Paredes, Belgarath, slowtiger
- synthsin75
- Posts: 10271
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
- synthsin75
- Posts: 10271
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
- synthsin75
- Posts: 10271
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
The only fix I could think of would be to modify the script temporally for SWF output so all point motion is converted to keys. Then remove the scripts, bind the layers and it's ready for flash out put.
------
Scripts are generally not flash friendly due to how the movements are created. AS exports the motion it "knows about". A script is doing stuff that the AS flash export has no clue about.
When you export to a movie, it renders the screen and saves that as the "frame image". When exporting to flash, there is no preview, no rendering, it could be that most scripts are "ignored" completely during flash export. It is converting key framed or bone controlled motion to the SWF format. The scripts need to have a preview to work.
So if a script can be modified to "hard code" the motion into built in AS standardized motion, the SWF export will work.
-vern
------
Scripts are generally not flash friendly due to how the movements are created. AS exports the motion it "knows about". A script is doing stuff that the AS flash export has no clue about.
When you export to a movie, it renders the screen and saves that as the "frame image". When exporting to flash, there is no preview, no rendering, it could be that most scripts are "ignored" completely during flash export. It is converting key framed or bone controlled motion to the SWF format. The scripts need to have a preview to work.
So if a script can be modified to "hard code" the motion into built in AS standardized motion, the SWF export will work.
-vern
- synthsin75
- Posts: 10271
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
I was just helping DK out, and it seems that as long as the layer is optimized for SWF, the script still works. But optimized seems to mean that you can't do selective point binding, so it doesn't really do the meshinstance from bone motion to a switch layer. Point motion is fine though.
I'll keep testing this.
I'll keep testing this.

Hi guys
I've following this thread since the beggining. Honestly I have not have time to test that great script from fazek but I bet that it is awesome.
Regarding to the swf output I believe that the solution that heyvern's suggested is a good one. I would like to see if the script can be modified in that way. Nothing to promise because the script seems to be a little complex.
DK, forget my comments on my PM. As stated by the script instructions you should be able to produce layer transformations on the duplicated layers:
Cheers!
-G
I've following this thread since the beggining. Honestly I have not have time to test that great script from fazek but I bet that it is awesome.
Regarding to the swf output I believe that the solution that heyvern's suggested is a good one. I would like to see if the script can be modified in that way. Nothing to promise because the script seems to be a little complex.
DK, forget my comments on my PM. As stated by the script instructions you should be able to produce layer transformations on the duplicated layers:
EDIT: Mmm it is a complex script and it is awesome. I'll give a try when be at home.This is a layer script for creating duplicate instances
of a vector layer's mesh points in other layers.
There is one "source" vector layer and any number of
"copy" vector layers. The script must be applied both to
the source and to all of the copy layers. The source and
the copy layer could be anywhere in the layers tree, but
the source layer's script must be executed first (must be
lower on the list). If the order is wrong, you get an
error message to swap the source and copy layers.
The copy layers must have a name composed from the name
of the source layer and a ".dup" extension, For example if
the source layer has the name "NAME" then the copy layers
must have the name "NAME.dup".
The script copies the actual position of the points in the
mesh. The original positions of the copy layers are unused
(even their bone transformations), so you can modify the
copy layers' points only through the source layer.
You can transform (replace, rotate etc.) the copy layers
through layer transformations.
License: Free
I am waiting your ideas and suggestions at:
viewtopic.php?t=3507
Fazek
Cheers!
-G
Try this (I've not tested in AS). I've modified the script to perform a point motion keyframe on each frame for the duplicated layers. As well as the duplicated layers should never be modified you wouldn't take care of those bunch of keyframes. I hope it would allow to export to swf properly.
Please test it in a dummy file, not ready for production files. At this moment I cannot test it in AS (not in this computer).
-G
Please test it in a dummy file, not ready for production files. At this moment I cannot test it in AS (not in this computer).
-G
Code: Select all
--[[
MeshInstance: Instancing the positions of mesh points on vector layers
1. Use NAME for the name of the source layer, and NAME.dup for all of the other layers.
2. Set this script for all of the layers (ie. for the original and for the instances)
3. Modify always the source layer only.
]]--
-- written by Fazek
function LayerScript(moho)
local mesh= moho:Mesh()
if (mesh == nil) then return end
local ownLayer= moho.layer
local name= ownLayer:Name()
local tab
local mi= ownLayer.FA_MeshInst
local len= mesh:CountPoints()
if (string.sub(name,-4) == ".dup") then
--copy instance
if (mi and ownLayer.FA_MeshInstName == name) then
--cached
if (mi[2] ~= moho.frame) then
print("MeshInstance: wrong order - swap the source and the copy!")
return
end
tab= mi[1]
if (mi[3] < len) then len= mi[3] end
for p= 1, len do
local pt= mesh:Point(p - 1)
pt.fPos.x= tab[p][1]
pt.fPos.y= tab[p][2]
end
else
local srcName= string.sub(name,1,-5)
-- recursive search for the source
local stack= {}
local sp= 0
local document= moho.document
for i= 0, document:CountLayers() - 1 do
local layer= document:Layer(i)
local parent= nil
local sub= 0
while true do
if (layer:IsGroupType()) then
table.insert(stack, { parent, sub - 1 })
sp= sp + 1
parent= moho:LayerAsGroup(layer)
sub= parent:CountLayers()
elseif (layer:Name() == srcName) then
local mi= layer.FA_MeshInst
if (mi) then
if (mi[2] == moho.frame) then
tab= mi[1]
if (mi[3] < len) then len= mi[3] end
-------------------------------MODIFICATIONS BY GENETE
local vec = LM.Vector2:newlocal() ---<<< This create a needed 2D vector
for p= 1, len do
local pt= mesh:Point(p - 1)
local animpos=pt.fAnimPos ---<<< This wrap the AnimPosition channel of the point to move.
vec.Set(tab[p][1],tab[p]2])) ---<<< This fills the 2D vector with the proper values
animpos.SetValue(moho.frame, vec) ---<<< Now add a keyframe at the current frame to move the point
--******** Those lines are commented to avoid point motion
--pt.fPos.x= tab[p][1]
--pt.fPos.y= tab[p][2]
--********
end
-------------------------------END OF MODIFICATIONS BY GENETE
ownLayer.FA_MeshInst= mi
ownLayer.FA_MeshInstName= name
return
end
end
print("MeshInstance: wrong order - swap the source and the copy!")
return
end
if (sub > 0) then
sub= sub - 1
layer= parent:Layer(sub)
else
sub= -1
while (sp > 0) do
parent, sub= stack[sp][1], stack[sp][2]
table.remove(stack)
sp= sp - 1
if (sub >= 0) then
layer= parent:Layer(sub)
break
end
end
if (sub < 0) then
break
end
end
end
end
end
else
--source
tab= {}
for p= 0, len - 1 do
local pt= mesh:Point(p)
table.insert(tab, { pt.fPos.x, pt.fPos.y })
end
--trick: FA_MeshInst won't change in the address space (no orphans)
if (mi and not ownLayer.FA_MeshInstName == name) then
--cached
mi[1]= tab
mi[2]= moho.frame
mi[3]= len
else
ownLayer.FA_MeshInst= { tab, moho.frame, len }
ownLayer.FA_MeshInstName= name
mi= ownLayer.FA_MeshInst
name= name..".dup"
--avoid orphaning: update all dependencies
-- recursive search for the copy
local stack= {}
local sp= 0
local document= moho.document
for i= 0, document:CountLayers() - 1 do
local layer= document:Layer(i)
local parent= nil
local sub= 0
while true do
if (layer:IsGroupType()) then
table.insert(stack, { parent, sub - 1 })
sp= sp + 1
parent= moho:LayerAsGroup(layer)
sub= parent:CountLayers()
elseif (layer:LayerType() == MOHO.LT_VECTOR and layer:Name() == name) then
layer.FA_MeshInst= mi
layer.FA_MeshInstName= name
end
if (sub > 0) then
sub= sub - 1
layer= parent:Layer(sub)
else
sub= -1
while (sp > 0) do
parent, sub= stack[sp][1], stack[sp][2]
table.remove(stack)
sp= sp - 1
if (sub >= 0) then
layer= parent:Layer(sub)
break
end
end
if (sub < 0) then
break
end
end
end
end
end
end
end
There seems to be an extra ")" on line 72:
Next to the [2] in brackets is an extra parenths.
------
On another note regarding the problem that DK was having.
It was a confusing "illusion". It only looked like the layer binding wasn't happening. What was really happening is that since the mesh instance script can't export to SWF the head in his file wasn't moving at all... but the eye bound to the bone WERE moving.
While watching the animation both DK and I were fooled by it. It looked as if the head motion was there when it really wasn't... making it look like the bound layer (the eyes) was acting crazy.
The bound layer WAS working properly... but the mesh instancing wasn't... creating a bizarre confusing illusion.
It took me a few minutes to figure it out... I laughed out loud when I realized what was happening.
-vern
Code: Select all
vec.Set(tab[p][1],tab[p]2])) ---<<< This fills the 2D vector with the proper values
------
On another note regarding the problem that DK was having.
It was a confusing "illusion". It only looked like the layer binding wasn't happening. What was really happening is that since the mesh instance script can't export to SWF the head in his file wasn't moving at all... but the eye bound to the bone WERE moving.
While watching the animation both DK and I were fooled by it. It looked as if the head motion was there when it really wasn't... making it look like the bound layer (the eyes) was acting crazy.
The bound layer WAS working properly... but the mesh instancing wasn't... creating a bizarre confusing illusion.
It took me a few minutes to figure it out... I laughed out loud when I realized what was happening.
-vern