ok,
So I have a system, that is quite complex. I need help re-coding from scratch or simplifying commands.
1.“Component”
a piece that can be assembled with other pieces
Each component is a simple physics bound(cube sphere etc)
you can’t detect materials on anything except triangle mesh, however triangle mesh is not compoundable.
So, I spawn “Jack markers” aka Tmesh that are a triangle mesh object that copies each components location and rotation.
2. “DetectSocket”______________________________________
Raycast from component A(component to be parented) ,
if raycast from Component A and hits a Tmesh get Tmesh[‘Father’](the component associated with the TMESH),
if “MA_Jack” (a property named the same as the material of the jack)
if Father[hitMat]=False
(if the slot is empty)
continue
2.b- Center and mass_________
Calculate center of mass for component A + Father.childrenRecursive (component B and it’s children)
add “Fake Parent” at center of mass, assign mass of all objects to it, parent component A to it, and component B to it, and all of component B’s children.
3.“power and target passing”
Find root, do children recursive, pass “+power”(add power to items) or pass target if target!=“Empty”
Purpose-assembly of robotics in game
4.Unparent all,
unparent all and delete fake root
5.Unparent single
this is where I have issues, as there is no Parent/child hierarchy preserved when “Fake parent”
I could use the help of another coder,
and their patience
I started coding this as I just got into python, so it’s a mess.
all rights reserved at the moment. it’s not done
http://www.pasteall.org/blend/29784
I may just restart tonight…