Libgdx粒子3D为什么平移分离粒子?

Libgdx粒子3D为什么平移分离粒子?,3d,libgdx,particle-system,3d,Libgdx,Particle System,我正试图为我的飞船制造一个反应堆,只要我不做翻译,一切都能正常工作。 例如:我的飞船右转的次数越多,反应堆颗粒分离的次数就越多(见截图)。有什么问题 我是一个3D游戏开发的初学者,我也有同样的问题,火箭飞船(屏幕截图上的红色粒子)我想知道粒子3D是否是制作lazer Fx或其他游戏的合适技术。有人有主意吗 截图: 我的翻译建议: public void translate(ParticleEffect effect, Vector3 position){ Matrix4 targ

我正试图为我的飞船制造一个反应堆,只要我不做翻译,一切都能正常工作。 例如:我的飞船右转的次数越多,反应堆颗粒分离的次数就越多(见截图)。有什么问题

我是一个3D游戏开发的初学者,我也有同样的问题,火箭飞船(屏幕截图上的红色粒子)我想知道粒子3D是否是制作lazer Fx或其他游戏的合适技术。有人有主意吗

截图:

我的翻译建议:

public void translate(ParticleEffect effect, Vector3 position){
    Matrix4 targetMatrix = new Matrix4();
    targetMatrix.idt();
    targetMatrix.setToTranslation(new Vector3(position));
    effect.setTransform(targetMatrix);
}
还有我的测试效果

{unique:{pointSpriteBatch:{class:com.badlogic.gdx.graphics.g3d.particles.ResourceData$SaveData,data:{},indices:[0]}},data:[],assets:[{filename:"/home/julio/Eclipse workspace/SpaceInvaders3d/android/assets/particles/pre_particle.png",type:com.badlogic.gdx.graphics.Texture}],resource:{class:com.badlogic.gdx.graphics.g3d.particles.ParticleEffect,controllers:[{name:"PointSprite Controller",emitter:{class:com.badlogic.gdx.graphics.g3d.particles.emitters.RegularEmitter,minParticleCount:0,maxParticleCount:200,continous:true,emission:{active:true,lowMin:250,lowMax:250,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:250,lowMax:250,highMin:250,highMax:250,relative:false,scaling:[1,1,1],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.ScaleInfluencer,value:{active:false,lowMin:0,lowMax:0,highMin:1,highMax:1,relative:false,scaling:[0.0056179776,0.050561797,0.12921348,0.31460676],timeline:[0,0.3408,0.6928,0.9904]}},{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.2982456,0],timeline:[0,0.5,0.82191783,1]},color:{active:false,colors:[0.23137255,1,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:true,strengthValue:{active:false,lowMin:0,lowMax:10,highMin:0,highMax:10,relative:true,scaling:[1,1,1],timeline:[0,0.14383562,0.4041096]},thetaValue:{active:false,lowMin:90,lowMax:90,highMin:90,highMax:90,relative:false,scaling:[1],timeline:[0]},phiValue:{active:false,lowMin:90,lowMax:90,highMin:90,highMax:90,relative:false,scaling:[1],timeline:[0]}}]}],renderer:{class:com.badlogic.gdx.graphics.g3d.particles.renderers.PointSpriteRenderer}}]}}

谢谢,很抱歉我会说一点英语。

这是3d粒子编辑器的众多缺陷之一。如果使用了二维等效项,则可以选中“附加”选项,但三维编辑器中没有此类选项。您可以破解代码并更改ParticleController类的更新方法。我这样做了,效果很好

    public boolean attached = true;
private float deltaX, deltaY, deltaZ;

public void update(){

        this.transform.getTranslation(pos);
        if(firstUpdate){
            firstUpdate=false;
            oldPos.set(pos);
        }

        emitter.update();

        if (attached) {
            deltaX = pos.x - oldPos.x;
            deltaY = pos.y - oldPos.y;
            deltaZ = pos.z - oldPos.z;
            for (int i = 0; i < ((FloatChannel)particles.getChannel(ParticleChannels.Position)).data.length; i += ((FloatChannel)particles
                .getChannel(ParticleChannels.Position)).strideSize) {
                ((FloatChannel)particles.getChannel(ParticleChannels.Position)).data[i + ParticleChannels.XOffset] += deltaX;
                ((FloatChannel)particles.getChannel(ParticleChannels.Position)).data[i + ParticleChannels.YOffset] += deltaY;
                ((FloatChannel)particles.getChannel(ParticleChannels.Position)).data[i + ParticleChannels.ZOffset] += deltaZ;
                if (particles.getChannel(ParticleChannels.PreviousPosition) != null) {
                    ((FloatChannel)particles.getChannel(ParticleChannels.PreviousPosition)).data[i + ParticleChannels.XOffset] += deltaX;
                    ((FloatChannel)particles.getChannel(ParticleChannels.PreviousPosition)).data[i + ParticleChannels.YOffset] += deltaY;
                    ((FloatChannel)particles.getChannel(ParticleChannels.PreviousPosition)).data[i + ParticleChannels.ZOffset] += deltaZ;
                }
            }
            oldPos.set(pos);
        }

        for(Influencer influencer : influencers)
            influencer.update();

    }
public boolean attached=true;
私人浮动deltaX、deltaY、deltaZ;
公共无效更新(){
this.transform.getTranslation(pos);
如果(首次更新){
firstUpdate=false;
旧pos.set(pos);
}
emitter.update();
如有(附件){
deltaX=位置x-旧位置x;
deltaY=位置y-旧位置y;
deltaZ=位置z-旧位置z;
对于(int i=0;i<((FloatChannel)particles.getChannel(particleChannel.Position)).data.length;i+=((FloatChannel)particles
.getChannel(particleChannel.Position)).StudeSize){
((FloatChannel)particles.getChannel(ParticleChannels.Position)).data[i+ParticleChannels.XOffset]+=deltaX;
((FloatChannel)particles.getChannel(ParticleChannels.Position)).data[i+ParticleChannels.YOffset]+=deltaY;
((FloatChannel)particles.getChannel(ParticleChannels.Position)).data[i+ParticleChannels.ZOffset]+=deltaZ;
if(particles.getChannel(particleChannel.PreviousPosition)!=null){
((FloatChannel)particles.getChannel(ParticleChannels.PreviousPosition)).data[i+ParticleChannels.XOffset]+=deltaX;
((FloatChannel)particles.getChannel(ParticleChannels.PreviousPosition)).data[i+ParticleChannels.YOffset]+=deltaY;
((FloatChannel)particles.getChannel(ParticleChannels.PreviousPosition)).data[i+ParticleChannels.ZOffset]+=deltaZ;
}
}
旧pos.set(pos);
}
对于(影响者影响者:影响者)
update();
}