Beispiel #1
0
 /**
  * @param id
  * @param data @Info Stocke le FloatBuffer dans le GPU
  */
 public void bufferData() {
   buffer = BufferUtils.createFloatBuffer(floatlist.size());
   for (Float f : floatlist) {
     buffer.put(f);
   }
   buffer.flip();
   glBindBuffer(GL_ARRAY_BUFFER, vboID);
   glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
   //		glBufferSubData(vboID, 0, buffer);
   glBindBuffer(GL_ARRAY_BUFFER, 0);
   bufferSize = buffer.limit() / 7; // 7 = 3 vertex(x,y,z) + 4 color (r,g,b,a)
 }
 /**
  * BVertexチャンクの読み込み
  *
  * @param br 読み込みストリーム
  * @return 頂点配列
  * @param scale モデルの倍率
  * @throws Exception
  */
 private KGLPoint[] readBvertex(multiInput br, float scale) throws Exception {
   KGLPoint[] ret = null;
   String line = null;
   String[] s;
   int p;
   int pe;
   int datasize = 0;
   try {
     while ((line = br.readLine().trim()) != null) {
       if (line.length() <= 0) continue;
       s = line.split(" ");
       if (s[0].equals("Vector")) {
         if (s.length != 3) {
           line = null;
           break;
         }
         p = s[2].indexOf("[");
         pe = s[2].indexOf("]");
         datasize = Integer.parseInt(s[2].substring(p + 1, pe));
         break;
       }
     }
   } catch (Exception e) {
     Log.e("KGLMetaseq", "MQOファイル フォーマットエラー(Object>Bvertex)[" + line + "]");
     throw new KGLException(e);
   }
   if (line == null) {
     return null;
   }
   if (datasize == 0) return null;
   byte[] bbuf = new byte[datasize];
   if (datasize != br.read(bbuf)) return null;
   ByteBuffer bb;
   bb = ByteBuffer.wrap(bbuf);
   bb.order(ByteOrder.LITTLE_ENDIAN); // MQOファイルのエンディアンはIntel形式
   FloatBuffer fb = bb.asFloatBuffer();
   ret = new KGLPoint[fb.limit() / 3];
   fb.position(0);
   float[] wf = new float[3];
   for (int i = 0; i < ret.length; i++) {
     fb.get(wf);
     ret[i] = KGLPoint.create(wf).scale(scale);
   }
   while ((line = br.readLine().trim()) != null) {
     if (line.equals("}")) break;
   }
   return ret;
 }