public override unsafe void Create(EntityManager entityManager) { if (AutoSetConnected) { RigidTransform aFromB = math.mul(math.inverse(worldFromA), worldFromB); PositionLocal = math.transform(aFromB, PositionInConnectedEntity); OrientationLocal = math.mul(aFromB.rot, OrientationInConnectedEntity); } else { OrientationLocal = math.normalize(OrientationLocal); OrientationInConnectedEntity = math.normalize(OrientationInConnectedEntity); } CreateJointEntity(JointData.CreateFixed( PositionLocal, PositionInConnectedEntity, OrientationLocal, OrientationInConnectedEntity), entityManager); }
void ConvertFixedJoint(LegacyFixed joint) { var legacyWorldFromJointA = math.mul( new RigidTransform(joint.transform.rotation, joint.transform.position), new RigidTransform(quaternion.identity, joint.anchor) ); RigidTransform worldFromBodyA = Math.DecomposeRigidBodyTransform(joint.transform.localToWorldMatrix); var connectedEntity = GetPrimaryEntity(joint.connectedBody); RigidTransform worldFromBodyB = connectedEntity == Entity.Null ? RigidTransform.identity : Math.DecomposeRigidBodyTransform(joint.connectedBody.transform.localToWorldMatrix); var bodyAFromJoint = new JointFrame(math.mul(math.inverse(worldFromBodyA), legacyWorldFromJointA)); var bodyBFromJoint = new JointFrame(math.mul(math.inverse(worldFromBodyB), legacyWorldFromJointA)); var jointData = JointData.CreateFixed(bodyAFromJoint, bodyBFromJoint); CreateJointEntity(joint.gameObject, jointData, GetPrimaryEntity(joint.gameObject), joint.connectedBody == null ? Entity.Null : connectedEntity, joint.enableCollision); }
public override void Create(EntityManager entityManager, GameObjectConversionSystem conversionSystem) { if (AutoSetConnected) { RigidTransform bFromA = math.mul(math.inverse(worldFromB), worldFromA); PositionLocal = math.transform(bFromA, PositionInConnectedEntity); OrientationLocal = math.mul(bFromA.rot, OrientationInConnectedEntity); } else { OrientationLocal = math.normalize(OrientationLocal); OrientationInConnectedEntity = math.normalize(OrientationInConnectedEntity); } CreateJointEntity( JointData.CreateFixed( new RigidTransform(OrientationLocal, PositionLocal), new RigidTransform(OrientationInConnectedEntity, PositionInConnectedEntity) ), entityManager, conversionSystem ); }