public byte[] PacketizeMessage() { m_serialization.msg_hdr = new RDB_MSG_HDR_t(35712, 0x011e, 24, 448, ++counter, SimTime); m_serialization.start_of_frame = new RDB_MSG_ENTRY_HDR_t(16, 0, 0, 1, 0); m_serialization.msg_entry_hdr_object_state = new RDB_MSG_ENTRY_HDR_t(16, 208, 208, 9, 0x01); m_serialization.msg_entry_hdr_wheel = new RDB_MSG_ENTRY_HDR_t(16, 176, 44, 14, 0); m_serialization.end_of_frame = new RDB_MSG_ENTRY_HDR_t(16, 0, 0, 2, 0); RDB_GEOMETRY_t geo = new RDB_GEOMETRY_t(4.6f, 1.86f, 1.6f, 0.8f, 0.0f, 0.3f); RDB_COORD_t pos = new RDB_COORD_t(Pos.z, -Pos.x, Pos.y, -transform.eulerAngles.y / 180f * Mathf.PI, transform.eulerAngles.x / 180f * Mathf.PI, -transform.eulerAngles.z / 180f * Mathf.PI, 0x01 | 0x02, 0, 0); RDB_COORD_t speed = new RDB_COORD_t(Vel.z, -Vel.x, Vel.y, -localangularvelocity.y, localangularvelocity.x, -localangularvelocity.z, 0x01 | 0x02, 0, 0); RDB_OBJECT_STATE_BASE_t object_base = new RDB_OBJECT_STATE_BASE_t(id, 1, 1, 0x06, ClientName, geo, pos, 0, 0, 0); RDB_COORD_t accel = new RDB_COORD_t(0.0D, 0.0D, 0.0D, 0.0f, 0.0f, 0.0f, 0x01, 0, 0); RDB_OBJECT_STATE_EXT_t object_ext = new RDB_OBJECT_STATE_EXT_t(speed, accel, 1.0f, spare); m_serialization.object_state = new RDB_OBJECT_STATE_t(object_base, object_ext); Vector4 steeringAngle = new Vector4(-m_Car.CurrentSteerAngle / 180 * Mathf.PI, -m_Car.CurrentSteerAngle / 180 * Mathf.PI, 0, 0); for (int k = 0; k < 4; k++) { RDB_WHEEL_BASE_t wheel_base = new RDB_WHEEL_BASE_t(id, (byte)k, 0, spare0, 1.0f, -0.025f, rotAngle, 0.0f, steeringAngle[k], spare1); m_serialization.wheel[k] = new RDB_WHEEL_t(wheel_base); } data_serialized = m_serialization.Serialize(); return(data_serialized); }
public UInt16 cfgModelId; //(2-byte) visual model ID public RDB_OBJECT_STATE_BASE_t(UInt32 id, Byte category, Byte type, UInt16 visMask, char[] name, RDB_GEOMETRY_t geo, RDB_COORD_t pos, UInt32 parent, UInt16 cfgFlags, UInt16 cfgModelId) { this.id = id; this.category = category; this.type = type; this.visMask = visMask; this.name = name; this.geo = geo; this.pos = pos; this.parent = parent; this.cfgFlags = cfgFlags; this.cfgModelId = cfgModelId; }