示例#1
0
    public void makeCloud()
    {
        var data = new TC.PointCloudData();

        data.Initialize(cloud.pPosition, cloud.pNormals, cloud.pColours, 1, new Vector3(), new Vector3());
        data.name = CloudName;


        var system = gameObject.AddComponent <TCParticleSystem>();

        system.Emitter.Shape      = EmitShapes.PointCloud;
        system.Emitter.PointCloud = data;
        system.Emitter.SetBursts(new[] { new BurstEmission {
                                             Time = 0, Amount = data.PointCount
                                         } });
        system.Emitter.EmissionRate = 0;
        system.Emitter.Lifetime     = MinMaxRandom.Constant(-1.0f);
        system.Looping              = false;
        system.MaxParticles         = data.PointCount + 1000;
        system.Emitter.Size         = MinMaxRandom.Constant(cloud.cloudInfo.minVoxelSize);
        system.Manager.NoSimulation = true;

        if (data.Normals != null)
        {
            system.ParticleRenderer.pointCloudNormals = true;
            system.ParticleRenderer.RenderMode        = GeometryRenderMode.Mesh;

            var quadGo = GameObject.CreatePrimitive(PrimitiveType.Quad);
            system.ParticleRenderer.Mesh = quadGo.GetComponent <MeshFilter>().sharedMesh;
            DestroyImmediate(quadGo);
        }

        system.enabled = true;
    }
示例#2
0
    public override void OnImportAsset(AssetImportContext context)
    {
        // ComputeBuffer container
        // Create a prefab with PointCloudRenderer.
        var gameObject = new GameObject();
        var data       = ImportAsPointCloudData(context.assetPath);

        if (data == null)
        {
            Debug.LogError("data is null... importing didnt work...");
        }

        var system = gameObject.AddComponent <TCParticleSystem>();

        system.Emitter.Shape      = EmitShapes.PointCloud;
        system.Emitter.PointCloud = data;
        system.Emitter.SetBursts(new[] { new BurstEmission {
                                             Time = 0, Amount = data.PointCount
                                         } });
        system.Emitter.EmissionRate = 0;
        system.Emitter.Lifetime     = MinMaxRandom.Constant(-1.0f);
        system.Looping              = false;
        system.MaxParticles         = data.PointCount + 1000;
        system.Emitter.Size         = MinMaxRandom.Constant(DefaultPointSize);
        system.Manager.NoSimulation = true;

        if (data.Normals != null)
        {
            system.ParticleRenderer.pointCloudNormals = true;
            system.ParticleRenderer.RenderMode        = GeometryRenderMode.Mesh;

            var quadGo = GameObject.CreatePrimitive(PrimitiveType.Quad);
            system.ParticleRenderer.Mesh = quadGo.GetComponent <MeshFilter>().sharedMesh;
            DestroyImmediate(quadGo);
        }

        context.AddObjectToAsset("prefab", gameObject);
        if (data != null)
        {
            context.AddObjectToAsset("data", data);
        }

        context.SetMainObject(gameObject);
    }