Notifications
Clear all

[Closed] Trying to attach meshes without losing their skin modifiers

What I’m trying to do, as a whole, is to bake out object explosions into a form I can import into Unreal Tournament using ActorX.

Towards that end, I’ve modeled an object, worked out a script to fragment it into an arbitrarily large number of peices, and put each fragment into a different object (one object, one element). I’ve then imported these into pflow to impart over time, and baked the results out with Oleg’s Pflow_baker script. So far, so good.

That means that instead of a single object, I have 50 or so smaller fragments, each with its own keyframed motions. In order to make it usable, I need one object, with50 (or so) elements, each skinned to a different keyframed bone.

So, I created a bone, copied the TM for each fragment, and keyframed it every 5 (arbitrary) frames for the length of my animation. I then copied each mesh, and skinned them to the appropriate bone.

So: I now have 50 keyframed bones, and 50 meshes skinned to them. I need to turn this into one object containing those 50 meshes as elements. I’ve got pretty close to no idea how to do this properly, and I could really use some help.

My code for the current stage:

Incoming = $Test as array
j=0
delete $Autobone*
delete $Outgoing*

for i in Incoming do (
j=j+1
resetXform(i)
collapseStack(i)
AutoBone= bonesys.createbone [0,0,0] [0,0,0] [0,0,0] – i.center i.center i.center –
Autobone.name = (“Autobone_” +(j as string))
print autobone.name
for t in 0f to 150f by 5f do (
with animate on (
at time t autobone.transform= i.transform –in coordsys world
)
addnewkey autobone.controller t
)
outgoing=editable_mesh()
Outgoing.mesh=i.mesh
Outgoing.transform=Autobone.transform
addmodifier Outgoing (skin())
select Outgoing
skinOps.addBone $.modifiers[#Skin] Autobone 1
Outgoing.name = (“Outgoing_” + (j as string))
)

3 Replies
 JHN

This new mesh you want is it a skinned mesh? or just an animated mesh from the chunks you have… I don’t get where exactly you’re going with the final mesh.

Even still sounds like a “fun” task

-Johan

I think I have a very simple solution for you that can even be done without scripting…
Simply copy all the objects, attach them together and apply skinwrap modifier to them.
use these setting in the skin wrap modifier:
deformation engine: vertex deformation
falloff: 1.0
Distance infl: 0.02
Face Limit:3.0
.
.
.
Weight All Points: true

now, test if everything works, if it is, press the ‘Convert to skin’ button and your done.

JHN– what I need is one mesh object containing all of my fragments, each fragment skinned to a different bone. The game editor needs to see this as one object that flies apart.

TzMtN–

Thank you! This definitely points in the direction towards a solution. As of now, it still doesn’t work quite right– results are a little erratic, but work some of the time, under certain conditions, which may ultimately be good enough. Part of this, I assume, is just my code inexperience and general sloppiness.

I don’t suppose there’s an obvious way to get it to initialize on frames other than 0? If I try to do that now, the transforms in the final meshe are all off. This wouldn’t really be an issue, but since skinwrap works by vertex location, I’d like to initialize at the END of the animation, when my object has blown apart, rather than at the beginning, when the vertices are packed on top of one another.

Incoming = $Test as array
j=0
delete $Autobone*
delete $Outgoing*
delete $Final
final = editable_mesh()
final.name=“Final”
addmodifier final (Skin_Wrap())
final.Skin_Wrap.Distance = 0.01
final.Skin_Wrap.weightAllVerts = True

for i in Incoming do (
j=j+1
resetXform(i)
collapseStack(i)

AutoBone=  bonesys.createbone [0,0,0] [0,0,0] [0,0,0] 
Autobone.name = ("Autobone_" +(j as string))
print autobone.name

for t in 0f to 150f by 5f do (
    with animate on (
    at time t autobone.transform= i.transform --in coordsys world
                                )
addnewkey autobone.controller t 
)
outgoing=copy i
addmodifier Outgoing (skin())
print "B"
print outgoing
select Outgoing
skinOps.addBone outgoing.modifiers[#skin] (Autobone) 1
print "C"
Outgoing.name = ("Outgoing_" + (j as string))
Final_Component= copy i
attach Final Final_Component
)
Result_Array= $Outgoing* as array
final.skin_wrap.meshList = Result_Array
select final
$.modifiers[#Skin_Wrap].meshDeformOps.convertToSkin off
deleteModifier final 2