コード例 #1
0
 private byte GetVoxelTypeFromCurRegion()
 {
     VoxelPaintXML.HeightDescArrayCLS heightDesc;
     for (int i = 0; i < curRegion.HeightDescArrayValues.Length; i++)
     {
         heightDesc = curRegion.HeightDescArrayValues [i];
         if (heightDesc.start <= reqHeight && heightDesc.end > reqHeight)
         {
             curHeight = heightDesc;
             return(GetVoxelTypeFromCurHeight());
         }
     }
     return(defType);
 }
コード例 #2
0
    public void LoadXMLInResources(string xmlPath, string regionMapFolder, SimplexNoise noise, System.Random rand)
    {
        TextAsset xmlResource = Resources.Load(xmlPath) as TextAsset;

        XmlSerializer serializer = new XmlSerializer(typeof(VoxelPaintXML.rootCLS));
        StringReader  reader     = new StringReader(xmlResource.text);

        if (null == reader)
        {
            return;
        }

        prms = (VoxelPaintXML.rootCLS)serializer.Deserialize(reader);
        reader.Close();
        Grad1000ToTanAndSetHeight();

        //SetPlantHeight();
        //SetTerrainTextureHeight();

        Texture2D terrainSectionsMap = Resources.Load(regionMapFolder + prms.regionsMap) as Texture2D;

        if (terrainSectionsMap != null)
        {
            terrainSectionsMapW = terrainSectionsMap.width;
            //terrainSectionsMapH = terrainSectionsMap.height;
            terrainSectionsCols32 = terrainSectionsMap.GetPixels32();
        }
        else
        {
            terrainSectionsCols32 = null;
            Debug.LogWarning("VoxelPaintXMLParser: No sectionmap found.");
        }
        curRegion   = prms.RegionDescArrayValues[0];
        curHeight   = curRegion.HeightDescArrayValues[0];
        curGradient = curHeight.GradientDescArrayValues[0];
        defType     = 3;
        myNoise     = noise;
        myRand      = rand;
    }
コード例 #3
0
    // Load XML
#if UNITY_EDITOR
    public void LoadXMLAtPath(string xmlPath = "Assets/Editor/EditorAssets/paintVxMat.xml", string regionMapFolder = "Assets/Editor/EditorAssets/")
    {
        TextAsset    xmlResource = UnityEditor.AssetDatabase.LoadAssetAtPath(xmlPath, typeof(TextAsset)) as TextAsset;
        StringReader reader      = new StringReader(xmlResource.text);

        if (null == reader)
        {
            return;
        }

        XmlSerializer serializer = new XmlSerializer(typeof(VoxelPaintXML.rootCLS));

        prms = (VoxelPaintXML.rootCLS)serializer.Deserialize(reader);
        reader.Close();
        Grad1000ToTan();

        Texture2D terrainSectionsMap = UnityEditor.AssetDatabase.LoadAssetAtPath(regionMapFolder + prms.regionsMap, typeof(Texture2D)) as Texture2D;

        if (terrainSectionsMap != null)
        {
            terrainSectionsMapW = terrainSectionsMap.width;
            //terrainSectionsMapH = terrainSectionsMap.height;
            terrainSectionsCols32 = terrainSectionsMap.GetPixels32();
        }
        else
        {
            terrainSectionsCols32 = null;
            Debug.LogWarning("VoxelPaintXMLParser: No sectionmap found.");
        }
        curRegion   = prms.RegionDescArrayValues[0];
        curHeight   = curRegion.HeightDescArrayValues[0];
        curGradient = curHeight.GradientDescArrayValues[0];
        defType     = 3;
        myNoise     = new SimplexNoise();
        myRand      = new System.Random(0);
    }