1 package com.badlogic.gdx.graphics.g3d.particles.batches; 2 3 import com.badlogic.gdx.assets.AssetManager; 4 import com.badlogic.gdx.graphics.g3d.Renderable; 5 import com.badlogic.gdx.graphics.g3d.particles.ResourceData; 6 import com.badlogic.gdx.graphics.g3d.particles.renderers.ModelInstanceControllerRenderData; 7 import com.badlogic.gdx.utils.Array; 8 import com.badlogic.gdx.utils.Pool; 9 10 /*** This class is used to render particles having a model instance channel. 11 * @author Inferno */ 12 public class ModelInstanceParticleBatch implements ParticleBatch<ModelInstanceControllerRenderData> { 13 Array<ModelInstanceControllerRenderData> controllersRenderData; 14 int bufferedParticlesCount; 15 public ModelInstanceParticleBatch () { 16 controllersRenderData = new Array<ModelInstanceControllerRenderData>(false, 5); 17 } 18 19 @Override 20 public void getRenderables (Array<Renderable> renderables, Pool<Renderable> pool) { 21 for(ModelInstanceControllerRenderData data : controllersRenderData){ 22 for(int i=0, count = data.controller.particles.size; i < count; ++i){ 23 data.modelInstanceChannel.data[i].getRenderables(renderables, pool); 24 } 25 } 26 } 27 28 public int getBufferedCount(){ 29 return bufferedParticlesCount; 30 } 31 32 @Override 33 public void begin () { 34 controllersRenderData.clear(); 35 bufferedParticlesCount = 0; 36 } 37 38 @Override 39 public void end () {} 40 41 @Override 42 public void draw (ModelInstanceControllerRenderData data) { 43 controllersRenderData.add(data); 44 bufferedParticlesCount += data.controller.particles.size; 45 } 46 47 @Override 48 public void save (AssetManager manager, ResourceData assetDependencyData) {} 49 50 @Override 51 public void load (AssetManager manager, ResourceData assetDependencyData) {} 52 } 53