Esempio n. 1
0
 public void initLight(int i) {
   realLightcount += i;
   for (int j = 0; j < i; j++) {
     lights.add(new Light());
   }
   virtualLightcount = realLightcount;
 }
Esempio n. 2
0
  public void updatelights(
      GL2GL3 gl,
      int uniformlightsview,
      int uniformlightsproj,
      int uniformlightscolor,
      int uniformlightsattr,
      int uniformlightcount) {
    FloatBuffer lightspos = FloatBuffer.allocate(16 * realLightcount);
    FloatBuffer lightsproj = FloatBuffer.allocate(16 * realLightcount);
    FloatBuffer lightscolor = FloatBuffer.allocate(4 * realLightcount);
    IntBuffer lightsattr = IntBuffer.allocate(4 * realLightcount);

    for (int i = 0; i < realLightcount; i++) {
      FloatBuffer tmp = lights.get(i).getMatrixf(GL2.GL_MODELVIEW);
      // putするときにFloatBufferの位置が動いていけないのでmark()とreset()を行う。
      tmp.mark();
      lightspos.put(tmp);
      tmp.reset();
      tmp = lights.get(i).getMatrixf(GL2.GL_PROJECTION);
      tmp.mark();
      lightsproj.put(tmp);
      tmp.reset();

      lightscolor.put(lights.get(i).color());
      lightscolor.put((float) lights.get(i).intensity);

      lightsattr.put(lights.get(i).attr());
    }

    lightspos.rewind();
    lightsproj.rewind();
    lightscolor.rewind();
    lightsattr.rewind();

    gl.glUniformMatrix4fv(uniformlightsview, realLightcount, false, lightspos);
    gl.glUniformMatrix4fv(uniformlightsproj, realLightcount, false, lightsproj);
    gl.glUniform2i(uniformlightcount, realLightcount, virtualLightcount);
    gl.glUniform4fv(uniformlightscolor, realLightcount, lightscolor);
    gl.glUniform4iv(uniformlightsattr, realLightcount, lightsattr);
  }
Esempio n. 3
0
 public Light getLight(int index) {
   if (index > realLightcount) return null;
   return lights.get(index);
 }