I'm trying to make a reactor for my ship, everything works fine long as i don't do translation. For example: More i'll turn right with my ship more the reactor particles detaches (see screenshot).What's the problem ?
I'm a beginner in 3D games dev, also i have the same problem for the rocket ship ( red particle on screenshot) I wonder if the particles 3D are a proper technique to make a lazer Fx or other. Someone has an idea ?
Screenshot :
My translation fonction :
public void translate(ParticleEffect effect, Vector3 position){
Matrix4 targetMatrix = new Matrix4();
targetMatrix.idt();
targetMatrix.setToTranslation(new Vector3(position));
effect.setTransform(targetMatrix);
}
And my test effect.p
{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}}]}}
Thanks, and sorry for my little english.
This is one of the many flaws of the 3d-particle editor. If you have used the 2d equivalent you can check the attach option, but there is no such thing for the 3d-editor. You can hack the code and change the update method of the ParticleController class. I did this and it works pretty well.
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();
}