public void WorldPositionToIJK(Vector3 worldPos, out PlanetChunck planetChunck, out int i, out int j, out int k) { PlanetSide planetSide; int iPos, jPos, kPos; WorldPositionToIJKPos(worldPos, out planetSide, out iPos, out jPos, out kPos); planetChunck = planetSide.chuncks[iPos / PlanetUtility.ChunckSize][jPos / PlanetUtility.ChunckSize][kPos / PlanetUtility.ChunckSize]; i = iPos % PlanetUtility.ChunckSize; j = jPos % PlanetUtility.ChunckSize; k = kPos % PlanetUtility.ChunckSize; }
public PlanetChunck SetDataAtIJKPos(PlanetSide planetSide, int iPos, int jPos, int kPos, Byte data, bool ifZero = false, bool rebuild = true, bool save = true) { PlanetChunck planetChunck = planetSide.chuncks[iPos / PlanetUtility.ChunckSize][jPos / PlanetUtility.ChunckSize][kPos / PlanetUtility.ChunckSize]; if ((ifZero && planetChunck.data[iPos % PlanetUtility.ChunckSize][jPos % PlanetUtility.ChunckSize][kPos % PlanetUtility.ChunckSize] == 0) || !ifZero) { planetChunck.SetData(data, iPos % PlanetUtility.ChunckSize, jPos % PlanetUtility.ChunckSize, kPos % PlanetUtility.ChunckSize); } if (rebuild) { planetChunck.SetMesh(); } if (save) { PlanetUtility.Save(planetChunck.PlanetName, planetChunck.data, planetChunck.iPos, planetChunck.jPos, planetChunck.kPos, planetChunck.planetSide.side); } return(planetChunck); }
static public PlanetChunck InstantiatePlanetChunck(Vector3 orientation, Vector3 posInChunck, PlanetSide planetSide) { GameObject planetChunckInstance = new GameObject(); PlanetChunck planetChunck = planetChunckInstance.AddComponent <PlanetChunck> (); planetChunck.Initialize(orientation, posInChunck, planetSide); planetChunckInstance.AddComponent <MeshFilter> (); MeshRenderer planetChunckMeshRenderer = planetChunckInstance.AddComponent <MeshRenderer> (); planetChunckMeshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; planetChunckMeshRenderer.receiveShadows = true; // Adding MeshCollider at runtime gives much better performances. //planetChunckInstance.AddComponent<MeshCollider> (); return(planetChunck); }
static public PlanetChunck InstantiatePlanetChunck(int iPos, int jPos, int kPos, PlanetSide planetSide) { GameObject planetChunckInstance = new GameObject(); PlanetChunck planetChunck = planetChunckInstance.AddComponent <PlanetChunck> (); planetChunck.iPos = iPos; planetChunck.jPos = jPos; planetChunck.kPos = kPos; planetChunck.planetSide = planetSide; planetChunckInstance.AddComponent <MeshFilter> (); MeshRenderer planetChunckMeshRenderer = planetChunckInstance.AddComponent <MeshRenderer> (); planetChunckMeshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; planetChunckMeshRenderer.receiveShadows = true; planetChunckInstance.AddComponent <MeshCollider>(); return(planetChunck); }