public static bool GetRigidbody(string name, out RigidbodyDefinition def) { def = null; if (instance == null) { return(false); } if (instance.rigidbodies.ContainsKey(name)) { def = instance.rigidbodies[name]; return(true); } return(false); }
void HandleRigidbody(List <object> data) { //id //name //POSITION //x //y //z //ROTATION //x //y //z //w int index = 0; int id = (int)data[index++]; string name = (string)data[index++]; //Debug.Log( "rb: "+name ); //WorldErrors.Print("rb: " + name); Vector3 position; position.x = (float)data[index++]; position.y = (float)data[index++]; position.z = (float)data[index++]; Quaternion orientation; orientation.x = (float)data[index++]; orientation.y = (float)data[index++]; orientation.z = (float)data[index++]; orientation.w = (float)data[index++]; Vector3 velocity; velocity.x = (float)data[index++]; velocity.y = (float)data[index++]; velocity.z = (float)data[index++]; Vector3 angVel; angVel.x = (float)data[index++]; angVel.y = (float)data[index++]; angVel.z = (float)data[index++]; bool isActive = ((int)data[index++]) == 1; position = position * scale; FixValues(ref position, ref velocity, ref orientation); RigidbodyDefinition def; if (rigidbodies.ContainsKey(name)) { def = rigidbodies[name]; def.position = mRotation * position + mPosition; def.rotation = mRotation * orientation; def.velocity = velocity; def.angularVelocity = angVel; def.isActive = isActive; } else { def = new RigidbodyDefinition(); def.position = mRotation * position + mPosition; def.rotation = mRotation * orientation; def.velocity = velocity; def.angularVelocity = angVel; def.id = id; def.name = name; def.isActive = isActive; rigidbodies.Add(name, def); } }