/// <summary> /// This callback is called for every point that changes materials in a digging operation. /// </summary> public static void PointCallback(float x, float y, float z, int matPrev, int matNow, int lod) { // If material was changed from non-air to air: add a particle animation. if (matPrev != 0 && matNow == 0) { // Create particle systems on demand. if (!instance.stoneParticles.ContainsKey(matPrev)) { SolidTerrainResource res = TerrainResource.FromIndex(matPrev) as SolidTerrainResource; if (res != null) { instance.stoneParticles.Add(matPrev, new StoneParticles(res, LocalScript.world)); } else { instance.stoneParticles.Add(matPrev, null); } } // Add particle. StoneParticles particles = instance.stoneParticles[matPrev]; if (particles != null) { /*instance.stoneParticles[matPrev].particlesStones.AddParticle3D( * new vec3(x, y, z) + RandomDir() * (float)random.NextDouble() * .3f, * RandomDir() * (float)random.NextDouble() * .4f, * new vec4(1), * .4f + (float)random.NextDouble() * .3f, * .2f + (float)random.NextDouble() * .3f, * RandomDir(), * RandomDir(), * new vec3(0));*/ } } }
//public CpuParticleSystemBase particlesStones; public StoneParticles(SolidTerrainResource res, World world) { resource = res; /*particlesStones = CpuParticleSystem.Create3D(new vec3(0, -9.81f, 0), world); * LocalScript.ParticleEntity.AddComponent(new CpuParticleComponent(particlesStones, mat4.Identity)); * LocalScript.ParticleEntity.AddComponent(new RenderComponent( * (new CpuParticleRenderJob(particlesStones, * Renderer.Opaque.CpuParticles, * res.DigParticleMaterial, * Resources.UseMesh("::Particles/Rock", null), * mat4.Identity)), * mat4.Identity, * true)); * LocalScript.ParticleEntity.AddComponent(new RenderComponent( * (new CpuParticleRenderJob(particlesStones, * Renderer.Shadow.CpuParticles, * Resources.UseMaterial("Particles/Shadow/Mesh", UpvoidMiner.ModDomain), * Resources.UseMesh("::Particles/Rock", null), * mat4.Identity)), * mat4.Identity, * true));*/ }