コード例 #1
0
    public void createProjectedDynamicDecal(Vector3 position, Quaternion rotation, Vector3 scale, Material mat, int layer, bool isCubeMap)
    {
        SceneData sd = gameObject.GetComponent <SceneData>();

        if (sd == null)
        {
            Debug.Log("Error in function createProjectedDynamicDecal(), SceneData not found. No action taken");
            return;
        }

        GameObject obj = new GameObject();

        obj.name = "ProjectedDynamicDecal";
        obj.tag  = "ProjectedStaticDecal";
        ProjectedStaticDecal decal = obj.AddComponent <ProjectedStaticDecal>();

        obj.transform.position   = position;
        obj.transform.rotation   = rotation;
        obj.transform.localScale = scale;

        decal.material = mat;
        decal.layer    = layer;
        decal.cubeMap  = isCubeMap;

        decal.create(sd);
        pddList.Add(decal);

        pddBatcher.addDecal(decal);

        decal.updateMesh();

        pddBatcher.updateBatch();
    }
コード例 #2
0
    public void createProjectedStaticDecal(string dname, SceneData sd)
    {
        GameObject obj = new GameObject();

        if (dname == "")
        {
            obj.name = "Default Projected Decal";
        }
        else
        {
            obj.name = dname;
            dname    = "";
        }
        obj.tag = "ProjectedStaticDecal";
        obj.AddComponent(typeof(ProjectedStaticDecal));
        obj.transform.parent = sd.transform;

        ProjectedStaticDecal decal = obj.GetComponent <ProjectedStaticDecal>();

        decal.create(sd);
        psdList.Add(decal);

        // add to batch
        psdBatcher.addDecal(decal);
    }
コード例 #3
0
ファイル: MeshBatcher.cs プロジェクト: DavidArayan/EzyDecal
 public void addDecal(ProjectedStaticDecal decal)
 {
     decals.Add(decal);
 }
コード例 #4
0
ファイル: MeshBatcher.cs プロジェクト: eclipseanu/EzyDecal
    public void updateBatch()
    {
        // update the decals and respective geometry
        for (int j = 0; j < decals.Count; j++)
        {
            ProjectedStaticDecal decal = decals[j];

            if (decal == null || decal.gameObject == null)
            {
                decals.RemoveAt(j);
                continue;
            }

            if (decal.isRtUpdateEnabled())
            {
                decal.updateMesh();
            }

            filler.reset();

            decal.fillBatchData(filler);

            // we have our batched data, add it into overall batch
            if (filler.material != null)
            {
                // we already have this material, add to batch
                if (batch.ContainsKey(filler.material))
                {
                    BatchedGeometry m = batch[filler.material];

                    int offset = m.vertices.Count;

                    m.vertices.AddRange(filler.vertices);

                    // offset out indices to new vertex positions
                    for (int i = 0; i < filler.indices.Count; i++)
                    {
                        m.indices.Add(filler.indices[i] + offset);
                    }

                    m.uv.AddRange(filler.uv);
                }
                else
                {
                    // add a new key because key doesnt exist, and add to batch
                    batch.Add(filler.material, new BatchedGeometry());

                    BatchedGeometry m = batch[filler.material];

                    int offset = m.vertices.Count;

                    m.vertices.AddRange(filler.vertices);

                    // offset our indices to new vertex positions
                    for (int i = 0; i < filler.indices.Count; i++)
                    {
                        m.indices.Add(filler.indices[i] + offset);
                    }

                    m.uv.AddRange(filler.uv);
                }
            }
        }

        // batch all the updated decals and clear previous buffers
        foreach (BatchedGeometry b in batch.Values)
        {
            b.batch();
        }
    }
コード例 #5
0
ファイル: MeshBatcher.cs プロジェクト: eclipseanu/EzyDecal
 public void addDecal(ProjectedStaticDecal decal)
 {
     decals.Add(decal);
 }