**Useful for interchangeable handheld weapons for models to find attachment points**
Add MovieMesh Variable Declaration:
public var leftHandx:Number;
public var leftHandy:Number;
public var leftHandz:Number;
MovieMesh.onEnterFrame:
Place after "while(i--)" update of all vertices:
var tempOffset:int = 100;
leftHandx = _vertices[(tempOffset*3)];
leftHandy = _vertices[(tempOffset*3) + 1];
leftHandz = _vertices[(tempOffset*3) + 2];
Added to MyProject code:
mySphere = new Sphere();
mySphere.radius = 10;
mySphere.x = mySphere.y = mySphere.z = 0;
scene.addChild(mySphere);
MyProject.onEnterFrame:
//trace(mesh.leftHandx);
mySphere.x = mesh.leftHandx;
mySphere.y = mesh.leftHandy;
mySphere.z = mesh.leftHandz;
I just tried this and it seemed like it wouldn't work correctly at first so I figured out I should have kept the rotation and xyz of the model as zeroes.
ReplyDeleteTo keep the correct position of the marker sphere when rotating or moving the mesh you need to add both to an ObjectContainer and perform the rotations and xyz changes on the new ObjectContainer containing the mesh and the sphere together.
Best regards,
CG
Ummm, actually... I remember in the code I had the rotation first... before the change in position so maybe that's why the problem appeared.
ReplyDeleteNot sure but this works anyway. :)