Package com.ngt.jopenmetaverse.shared.protocol

Examples of com.ngt.jopenmetaverse.shared.protocol.BitPack


              header.PatchSize = 16;
              header.Type = type;

              // Should be enough to fit even the most poorly packed data
              byte[] data = new byte[patches.length * 16 * 16 * 2];
              BitPack bitpack = new BitPack(data, 0);
              bitpack.PackBits(header.Stride, 16);
              bitpack.PackBits(header.PatchSize, 8);
              bitpack.PackBits((int)header.Type.getIndex(), 8);

              for (int i = 0; i < patches.length; i++)
                  CreatePatch(bitpack, patches[i].Data, patches[i].X, patches[i].Y);

              bitpack.PackBits(END_OF_PATCHES, 8);

              layer.LayerData.Data = new byte[bitpack.getBytePos() + 1];
//              Buffer.BlockCopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.getBytePos() + 1);
              Utils.arraycopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.getBytePos() + 1);

              return layer;
          }
View Full Code Here


              header.Stride = STRIDE;
              header.PatchSize = 16;
              header.Type = TerrainPatch.LayerType.Land;

              byte[] data = new byte[1536];
              BitPack bitpack = new BitPack(data, 0);
              bitpack.PackBits(header.Stride, 16);
              bitpack.PackBits(header.PatchSize, 8);
              bitpack.PackBits((int)header.Type.getIndex(), 8);

              for (int i = 0; i < patches.length; i++)
                  CreatePatchFromHeightmap(bitpack, heightmap, patches[i] % 16, (patches[i] - (patches[i] % 16)) / 16);

              bitpack.PackBits(END_OF_PATCHES, 8);

              layer.LayerData.Data = new byte[bitpack.getBytePos() + 1];
              Utils.arraycopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.getBytePos() + 1);

              return layer;
          }
View Full Code Here

              header.Stride = STRIDE;
              header.PatchSize = 16;
              header.Type = TerrainPatch.LayerType.Land;

              byte[] data = new byte[1536];
              BitPack bitpack = new BitPack(data, 0);
              bitpack.PackBits(header.Stride, 16);
              bitpack.PackBits(header.PatchSize, 8);
              bitpack.PackBits((int)header.Type.getIndex(), 8);

              CreatePatch(bitpack, patchData, x, y);

              bitpack.PackBits(END_OF_PATCHES, 8);

              layer.LayerData.Data = new byte[bitpack.getBytePos() + 1];
              Utils.arraycopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.getBytePos() + 1);

              return layer;
          }
View Full Code Here

              header.Stride = STRIDE;
              header.PatchSize = 16;
              header.Type = TerrainPatch.LayerType.Land;

              byte[] data = new byte[1536];
              BitPack bitpack = new BitPack(data, 0);
              bitpack.PackBits(header.Stride, 16);
              bitpack.PackBits(header.PatchSize, 8);
              bitpack.PackBits((int)header.Type.getIndex(), 8);

              CreatePatch(bitpack, patchData, x, y);

              bitpack.PackBits(END_OF_PATCHES, 8);

              layer.LayerData.Data = new byte[bitpack.getBytePos() + 1];
              Utils.arraycopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.getBytePos() + 1);

              return layer;
          }
View Full Code Here

      }

      private void LayerDataHandler(Object sender, PacketReceivedEventArgs e)
      {
          LayerDataPacket layer = (LayerDataPacket)e.getPacket();
          BitPack bitpack = new BitPack(layer.LayerData.Data, 0);
          TerrainPatch.GroupHeader header = new TerrainPatch.GroupHeader();
          TerrainPatch.LayerType type = TerrainPatch.LayerType.get(layer.LayerID.Type);

          // Stride
          header.Stride = bitpack.UnpackBits(16);
          // Patch size
          header.PatchSize = bitpack.UnpackBits(8);
          // Layer type
          header.Type = TerrainPatch.LayerType.get((byte)bitpack.UnpackBits(8));

          switch (type)
          {
              case Land:
                  if (onLandPatchReceived != null || Client.settings.STORE_LAND_PATCHES)
View Full Code Here

            {
                // TODO: Not sure exactly how many bytes we need here, so partial
                // (truncated) data will cause an exception to be thrown
                if (data.length > 0)
                {
                    BitPack pack = new BitPack(data, pos);

                    CRC = pack.UnpackLBits(32);
                    PartFlags = pack.UnpackLBits(32);
                    Pattern = SourcePattern.get(pack.UnpackByte());
                    MaxAge = pack.UnpackFixed(false, 8, 8);
                    StartAge = pack.UnpackFixed(false, 8, 8);
                    InnerAngle = pack.UnpackFixed(false, 3, 5);
                    OuterAngle = pack.UnpackFixed(false, 3, 5);
                    BurstRate = pack.UnpackFixed(false, 8, 8);
                    BurstRadius = pack.UnpackFixed(false, 8, 8);
                    BurstSpeedMin = pack.UnpackFixed(false, 8, 8);
                    BurstSpeedMax = pack.UnpackFixed(false, 8, 8);
                    BurstPartCount = pack.UnpackByte();
                    float x = pack.UnpackFixed(true, 8, 7);
                    float y = pack.UnpackFixed(true, 8, 7);
                    float z = pack.UnpackFixed(true, 8, 7);
                    AngularVelocity = new Vector3(x, y, z);
                    x = pack.UnpackFixed(true, 8, 7);
                    y = pack.UnpackFixed(true, 8, 7);
                    z = pack.UnpackFixed(true, 8, 7);
                    PartAcceleration = new Vector3(x, y, z);
                    Texture = pack.UnpackUUID();
                    Target = pack.UnpackUUID();

                    PartDataFlags = ParticleDataFlags.get(pack.UnpackLBits(32));
                    PartMaxAge = pack.UnpackFixed(false, 8, 8);
                    byte r = pack.UnpackByte();
                    byte g = pack.UnpackByte();
                    byte b = pack.UnpackByte();
                    byte a = pack.UnpackByte();
                    PartStartColor = new Color4(r, g, b, a);
                    r = pack.UnpackByte();
                    g = pack.UnpackByte();
                    b = pack.UnpackByte();
                    a = pack.UnpackByte();
                    PartEndColor = new Color4(r, g, b, a);
                    PartStartScaleX = pack.UnpackFixed(false, 3, 5);
                    PartStartScaleY = pack.UnpackFixed(false, 3, 5);
                    PartEndScaleX = pack.UnpackFixed(false, 3, 5);
                    PartEndScaleY = pack.UnpackFixed(false, 3, 5);
                }
                else
                {
                    CRC = PartFlags = 0;
                    Pattern = SourcePattern.None;
View Full Code Here

            /// </summary>
            /// <returns>Byte array</returns>
            public byte[] GetBytes() throws Exception
            {
                byte[] bytes = new byte[86];
                BitPack pack = new BitPack(bytes, 0);

                pack.PackBits(CRC, 32);
                pack.PackBits(PartFlags & 0xffffffff, 32);
                pack.PackBits(Pattern.getIndex() & 0xff, 8);
                pack.PackFixed(MaxAge, false, 8, 8);
                pack.PackFixed(StartAge, false, 8, 8);
                pack.PackFixed(InnerAngle, false, 3, 5);
                pack.PackFixed(OuterAngle, false, 3, 5);
                pack.PackFixed(BurstRate, false, 8, 8);
                pack.PackFixed(BurstRadius, false, 8, 8);
                pack.PackFixed(BurstSpeedMin, false, 8, 8);
                pack.PackFixed(BurstSpeedMax, false, 8, 8);
                pack.PackBits(BurstPartCount, 8);
                pack.PackFixed(AngularVelocity.X, true, 8, 7);
                pack.PackFixed(AngularVelocity.Y, true, 8, 7);
                pack.PackFixed(AngularVelocity.Z, true, 8, 7);
                pack.PackFixed(PartAcceleration.X, true, 8, 7);
                pack.PackFixed(PartAcceleration.Y, true, 8, 7);
                pack.PackFixed(PartAcceleration.Z, true, 8, 7);
                pack.PackUUID(Texture);
                pack.PackUUID(Target);

                pack.PackBits(ParticleDataFlags.getIndex(PartDataFlags), 32);
                pack.PackFixed(PartMaxAge, false, 8, 8);
                pack.PackColor(PartStartColor);
                pack.PackColor(PartEndColor);
                pack.PackFixed(PartStartScaleX, false, 3, 5);
                pack.PackFixed(PartStartScaleY, false, 3, 5);
                pack.PackFixed(PartEndScaleX, false, 3, 5);
                pack.PackFixed(PartEndScaleY, false, 3, 5);

                return bytes;
            }
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.protocol.BitPack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.