コード例 #1
0
    public static Block45ChunkGo CreateChunkGo(IVxSurfExtractReq req, Transform parent = null)
    {
        if (req.FillMesh(null) == 0)
        {
            return(null);
        }

        Block45ChunkGo b45Go = VFGoPool <Block45ChunkGo> .GetGo();

        req.FillMesh(b45Go._mf.mesh);

        // set material
        SurfExtractReqB45 b45ret = req as SurfExtractReqB45;

        if (b45ret != null)
        {
            List <Material> tmpMatList = new List <Material>();
            for (int i = 0; i < b45ret.matCnt; i++)
            {
                tmpMatList.Add(_defMats[b45ret.materialMap[i]]);
            }
            b45Go._mr.sharedMaterials = tmpMatList.ToArray();
        }
        if (parent != null)
        {
            b45Go.transform.parent = parent;
        }
        b45Go.gameObject.SetActive(true);
        return(b45Go);
    }
コード例 #2
0
    public static VFVoxelChunkGo CreateChunkGo(IVxSurfExtractReq req, Material mat = null, int layer = 0)
    {
        if (req.FillMesh(null) == 0)
        {
            return(null);
        }

        VFVoxelChunkGo vfGo = VFGoPool <VFVoxelChunkGo> .GetGo();

        int nMesh = req.FillMesh(vfGo.Mf.sharedMesh);

        vfGo._bPrimal = true;
        if (mat != null)
        {
            vfGo.Mr.sharedMaterial = mat;
        }
        if (layer != 0)
        {
            vfGo.gameObject.layer = layer;
        }
        vfGo.gameObject.SetActive(true);

        while (nMesh > 0)
        {
            VFVoxelChunkGo subGo = VFGoPool <VFVoxelChunkGo> .GetGo();

            nMesh = req.FillMesh(subGo.Mf.sharedMesh);
            subGo.transform.parent        = vfGo.transform;
            subGo.transform.localScale    = Vector3.one;
            subGo.transform.localPosition = Vector3.zero;
            if (mat != null)
            {
                subGo.Mr.sharedMaterial = mat;
            }
            if (layer != 0)
            {
                subGo.gameObject.layer = layer;
            }
            subGo.gameObject.SetActive(true);
        }

        return(vfGo);
    }
コード例 #3
0
    public void SetTransGo(IVxSurfExtractReq req, int faceMask)
    {
        if (TransvoxelGo != null)
        {
            VFGoPool <VFTransVoxelGo> .FreeGo(TransvoxelGo);

            TransvoxelGo = null;
        }
        if (faceMask != 0)
        {
            VFTransVoxelGo go = VFGoPool <VFTransVoxelGo> .GetGo();

            req.FillMesh(go._mf.sharedMesh);
            go._faceMask        = faceMask;
            go.transform.parent = transform;
            //go.transform.localScale = Vector3.one;
            go.transform.localPosition = Vector3.zero;
            go.gameObject.SetActive(true);
            TransvoxelGo = go;
        }
    }