java - Android.LibGDX。 3d 粒子系统不工作(广告牌)

标签 java android opengl-es 3d libgdx

我正在使用 LibGDX 博客中描述的 3d 粒子系统(Billboards ar 粒子):https://github.com/libgdx/libgdx/wiki/3D-Particle-Effects 它不起作用。它不会崩溃。它只是没有出现在屏幕上。

这是我的代码:

初始化:

private void createParticles3d() {
    particleSystem3d = ParticleSystem.get();
    particleBatch = new BillboardParticleBatch();
    particleBatch.setCamera(cam);
    particleSystem3d.add(particleBatch);

    ParticleEffectLoader.ParticleEffectLoadParameter loadParam = new ParticleEffectLoader.ParticleEffectLoadParameter(particleSystem3d.getBatches());
    ParticleEffectLoader loader = new ParticleEffectLoader(new InternalFileHandleResolver());
    assets.setLoader(com.badlogic.gdx.graphics.g3d.particles.ParticleEffect.class, loader);
    assets.load("data/test3dparticles.pfx", com.badlogic.gdx.graphics.g3d.particles.ParticleEffect.class, loadParam);

    assets.finishLoading();

    originalBubblesEffect3d = assets.get("data/test3dparticles.pfx");
    bubblesEffect3d = originalBubblesEffect3d.copy();
    bubblesEffect3d.init();
    bubblesEffect3d.start();  
    particleSystem3d.add(bubblesEffect3d);
}

渲染:

    modelBatch.begin(cam);
    //Also tried to set some matrix transform here
    particleSystem3d.update();
    particleSystem3d.begin();
    particleSystem3d.draw();
    particleSystem3d.end();
    modelBatch.render(particleSystem3d);
    modelBatch.end();

粒子文件:

{unique:{billboardBatch:{class:com.badlogic.gdx.graphics.g3d.particles.ResourceData$SaveData,data:{cfg:{class:com.badlogic.gdx.graphics.g3d.particles.batches.BillboardParticleBatch$Config,mode:Screen}},indices:[0]}},data:[],assets:[{filename:C:/Users/tte/Desktop/temp/_FISHES/bubbles/bubbles1.png,type:com.badlogic.gdx.graphics.Texture}],resource:{class:com.badlogic.gdx.graphics.g3d.particles.ParticleEffect,controllers:[{name:"Billboard Controller",emitter:{class:com.badlogic.gdx.graphics.g3d.particles.emitters.RegularEmitter,minParticleCount:0,maxParticleCount:200,continous:true,emission:{active:true,lowMin:0,lowMax:0,highMin:250,highMax:250,relative:false,scaling:[1],timeline:[0]},delay:{active:false,lowMin:0,lowMax:0},duration:{active:true,lowMin:3000,lowMax:3000},life:{active:true,lowMin:0,lowMax:0,highMin:500,highMax:1000,relative:false,scaling:[1,1,0.3],timeline:[0,0.66,1]},lifeOffset:{active:false,lowMin:0,lowMax:0,highMin:0,highMax:0,relative:false,scaling:[1],timeline:[0]}},influencers:[{class:com.badlogic.gdx.graphics.g3d.particles.influencers.RegionInfluencer$Single,regions:[{halfInvAspectRatio:0.5,v2:1,u2:1}]},{class:com.badlogic.gdx.graphics.g3d.particles.influencers.SpawnInfluencer,spawnShape:{class:com.badlogic.gdx.graphics.g3d.particles.values.PointSpawnShapeValue,active:false,xOffsetValue:{active:false,lowMin:0,lowMax:0},yOffsetValue:{active:false,lowMin:0,lowMax:0},zOffsetValue:{active:false,lowMin:0,lowMax:0},spawnWidthValue:{active:false,lowMin:0,lowMax:0,highMin:0,highMax:0,relative:false,scaling:[1],timeline:[0]},spawnHeightValue:{active:false,lowMin:0,lowMax:0,highMin:0,highMax:0,relative:false,scaling:[1],timeline:[0]},spawnDepthValue:{active:false,lowMin:0,lowMax:0,highMin:0,highMax:0,relative:false,scaling:[1],timeline:[0]},edges:false}},{class:com.badlogic.gdx.graphics.g3d.particles.influencers.ColorInfluencer$Single,alpha:{active:false,lowMin:0,lowMax:0,highMin:1,highMax:1,relative:false,scaling:[0,0.15,0.5,0],timeline:[0,0.5,0.8,1]},color:{active:false,colors:[1,0.12156863,0.047058824,0,0,0],timeline:[0,1]}},{class:com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsInfluencer,velocities:[{class:com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsModifier$PolarAcceleration,isGlobal:false,strengthValue:{active:false,lowMin:0,lowMax:0,highMin:5,highMax:10,relative:false,scaling:[1],timeline:[0]},thetaValue:{active:false,lowMin:0,lowMax:0,highMin:0,highMax:360,relative:false,scaling:[1],timeline:[0]},phiValue:{active:true,lowMin:0,lowMax:0,highMin:-35,highMax:35,relative:false,scaling:[1,0,0],timeline:[0,0.5,1]}}]}],renderer:{class:com.badlogic.gdx.graphics.g3d.particles.renderers.BillboardRenderer}}]}}

也许我应该以某种方式指定从哪里获取 particleEffects 等的纹理。在我使用 2d 粒子之前,我可以提供一个可以找到粒子纹理的目录。

最佳答案

在render方法的开头你有没有在下面的GL命令中加入?

    Gdx.gl.glClearColor(0.3f, 0.3f, 0.3f, 1.f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

关于java - Android.LibGDX。 3d 粒子系统不工作(广告牌),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25648386/

相关文章:

java - 如何检查用户是否单击了 JPanel 中的任何按钮

java - 当我按下 JButton 时,我的框架卡住了,为什么?图形用户界面

c# - 使用 Xamarin Forms 在 Android 上快速隐藏和重新出现键盘

Android 开发 - 测试 SD 卡还是假设它在那里?

ios - OpenGL ES - 更新顶点数组,添加/删除顶点

opengl-es - 如何使 OpenGL 绘图与 UIKit 更新同步

java - 来自 ListView 的相同数据被多次打印

java - java中如何将ArrayList转成String[],Arraylist包含VO对象

android:在浏览器中从网络下载文件时设置 Intent 过滤器以触发 Activity 时出现问题

android - OpenGL ES 纹理包装有时会产生奇怪的结果