Example #1
0
 // ============================================================
 // <T>序列化数据到输出流。</T>
 //
 // @param output 输出流
 // ============================================================
 @Override
 public void serialize(IDataOutput output) {
   super.serialize(output);
   // 输出渲染集合
   if (hasRenderable()) {
     int count = _renderables.count();
     output.writeUint16(count);
     for (FResRenderable renderable : _renderables) {
       renderable.serialize(output);
     }
   } else {
     output.writeUint16(0);
   }
 }
 // ============================================================
 // <T>序列化数据到输出流。</T>
 //
 // @param output 输出流
 // ============================================================
 @Override
 public void serialize(IDataOutput output) {
   super.serialize(output);
   // 非压缩模式
   String format = "jpg";
   if (_optionAlpha) {
     format = "png";
   }
   // 转换数据
   if (_textureBitmap == null) {
     // 写入数据
     output.writeString("flat");
     output.writeString(format);
     output.writeUint16(_size.width);
     output.writeUint16(_size.height);
     // output.writeInt32(0);
   } else {
     String code = _textureBitmap.code();
     if (code.equals("environment")) {
       // 分拆为6个面
       output.writeString("cube");
       output.writeString(format);
       output.writeUint16(_size.width);
       output.writeUint16(_size.height);
       // serializeEnvironment(output);
     } else {
       // 写入数据
       output.writeString("flat");
       output.writeString(format);
       output.writeUint16(_size.width);
       output.writeUint16(_size.height);
       // output.writeInt32(0);
     }
   }
   //      // 非压缩模式
   //      String format = "jpg";
   //      if(_optionAlpha){
   //         format = "png";
   //      }
   //      // 转换数据
   //      if(_textureBitmap == null){
   //         //byte[] data = _image.toBytes("png");
   //         //int length = data.length;
   //         // 写入数据
   //         output.writeBoolean(false);
   //         output.writeString("flat");
   //         output.writeString(format);
   //         output.writeUint16(_size.width);
   //         output.writeUint16(_size.height);
   //         output.writeInt32(4 * _data.length);
   //         for(int value : _data){
   //            output.writeUint8((short)((value >> 16) & 0xFF));
   //            output.writeUint8((short)((value >> 8) & 0xFF));
   //            output.writeUint8((short)(value & 0xFF));
   //            output.writeUint8((short)((value >> 24) & 0xFF));
   //         }
   //         //output.writeInt32(length);
   //         //output.write(data, 0, length);
   //      }else{
   //         output.writeBoolean(true);
   //         String code = _textureBitmap.code();
   //         if(code.equals("environment")){
   //            // 分拆为6个面
   //            output.writeString("cube");
   //            output.writeString(format);
   //            output.writeUint16(_size.width);
   //            output.writeUint16(_size.height);
   //            serializeEnvironment(output);
   //         }else{
   //            byte[] data = _textureBitmap.data();
   //            int length = data.length;
   //            // 写入数据
   //            output.writeString("flat");
   //            output.writeString(format);
   //            output.writeUint16(_size.width);
   //            output.writeUint16(_size.height);
   //            output.writeInt32(length);
   //            output.write(data, 0, length);
   //         }
   //      }
 }