示例#1
0
        //Grab the terrain position and size and pass it to the shaders
        public void GetTargetInfo()
        {
            util.GetObjectPlanarUV(this.gameObject);
            //Determine if the object is a terrain or mesh
            workflow = util.workflow;
            terrain  = util.terrain;

            //Values for the inspector
            if (workflow == TerrainUVUtil.Workflow.Terrain)
            {
                terrain = this.GetComponent <Terrain>();

                targetObject   = this.gameObject;
                targetSize     = terrain.terrainData.size;
                targetPosition = targetObject.transform.position;
                pigmentmapSize = terrain.terrainData.alphamapWidth;
            }
            else if ((workflow == TerrainUVUtil.Workflow.Mesh))
            {
                mesh     = GetComponent <MeshRenderer>();
                material = mesh.sharedMaterial;

                pigmentmapSize       = 1024;
                targetObject         = this.gameObject;
                targetSize           = util.size;
                targetPosition       = util.position;
                targetCenterPosition = util.centerPostion;
            }


            SetPigmentMap();
        }
示例#2
0
        //Grab the terrain position and size and pass it to the shaders
        public void GetTargetInfo()
        {
            if (debug)
            {
                Debug.Log("Getting target info for " + terrainObjects.Length + " object(s)");
            }

            if (!util)
            {
                util = ScriptableObject.CreateInstance <TerrainUVUtil>();
            }


            util.GetObjectPlanarUV(terrainObjects);

            //Terrain UV
            terrainScaleOffset = util.terrainScaleOffset;

            //Determine if the object is a terrain or mesh
            workflow = util.workflow;
            if (debug)
            {
                Debug.Log("Terrain type: " + workflow);
            }

            //If using Unity Terrains
            terrains = util.terrains;

            //Avoid unused variable warning
            material = null;

            //based on first terrain's splatmap resolution, or hardcoded to 1024px for meshes
            pigmentmapSize = util.pigmentMapSize;

            //Summed size
            targetSize = util.size;

            //First terrain makes up the corner
            targetOriginPosition = util.originPosition;

            //Center of terrain(s)
            targetCenterPosition = util.centerPostion;

            SetPigmentMap();
        }