public QbModel read(string path) { StopwatchUtil.startclient("regularqbread", "Begin SVP read"); QbModel model = _read(path); model.GenerateVertexBuffers(); model.FillVertexBuffers(); StopwatchUtil.stopclient("regularqbread", "End SVP read"); return(model); }
public override void onclientrecieve(NetIncomingMessage message) { Client.print("info", "Recieve qb packet"); StopwatchUtil.startclient("qbpacket", "Building qb model"); int junk = message.ReadInt32(); QbModel model = new QbModel(message.ReadString()); int matrixcount = message.ReadInt32(); model.setmatrixcount((uint)matrixcount); foreach (var m in model.matrices) { m.name = message.ReadString(); m.position = new OpenTK.Vector3(message.ReadFloat(), message.ReadFloat(), message.ReadFloat()); m.setsize((int)message.ReadFloat(), (int)message.ReadFloat(), (int)message.ReadFloat()); int colorcount = message.ReadInt32(); for (int i = 0; i < colorcount; i++) { m.GetColorIndex(message.ReadFloat(), message.ReadFloat(), message.ReadFloat()); } int voxelcount = message.ReadInt32(); for (int i = 0; i < voxelcount; i++) { int colorindex = message.ReadInt32(); byte alphamask = message.ReadByte(); int x = message.ReadInt32(); int y = message.ReadInt32(); int z = message.ReadInt32(); m.voxels.GetOrAdd(m.GetHash(x, y, z), new Voxel((short)x, (short)y, (short)z, alphamask, (short)colorindex)); } } Client.OpenGLContextThread.Add(() => { model.GenerateVertexBuffers(); model.FillVertexBuffers(); Singleton <QbManager> .INSTANCE.AddModel(model); StopwatchUtil.stopclient("qbpacket", "End building qb model"); }); base.onclientrecieve(message); }
public static void loadqbnetworking(string path) { if (Client.net != null && Client.net.ConnectionsCount == 0) { Client.print("error", "Error : loadqbnetworking - is meant for network loading of files. Connect your client to a server before running this command, or try using \"loadqb\""); return; } Client.OpenGLContextThread.Add(() => { StopwatchUtil.startclient("internalqbread", "Begin Qb Read"); ImporterQb importer = new ImporterQb(); QbModel model = importer._read(path); StopwatchUtil.stopclient("internalqbread", "End Qb Read"); StopwatchUtil.startclient("clientwriteqbpacket", "Begin Qb Packet Write"); var packet = PacketWriter.write <Packet_QbImported>(NetEndpoint.CLIENT); packet.write(model); packet.send(); StopwatchUtil.stopclient("clientwriteqbpacket", "End qb Packet Write"); }); }