public override Application setup(Tree target) { Vector3 halfDimension = worldDimensions / target.voxelSize() /2f; Vector3 center = target.transform.InverseTransformPoint(worldPosition) / target.voxelSize(); Vector3 exactMin = center - halfDimension; Vector3 exactMax = center + halfDimension; CubeApp app = new CubeApp(); app.tree = target; app.halfDimension = halfDimension; app.min = new Index(target.maxDetail, (uint)exactMin.x, (uint)exactMin.y, (uint)exactMin.z); app.max = new Index(target.maxDetail, (uint)exactMax.x, (uint)exactMax.y, (uint)exactMax.z); app.position = center; return app; }
public override Application setup(Tree target) { Vector3 halfDimension = worldDimensions / target.voxelSize() / 2f; Vector3 center = target.transform.InverseTransformPoint(worldPosition) / target.voxelSize(); Vector3 exactMin = center - halfDimension; Vector3 exactMax = center + halfDimension; CubeApp app = new CubeApp(); app.tree = target; app.halfDimension = halfDimension; app.min = new Index(target.maxDetail, (uint)exactMin.x, (uint)exactMin.y, (uint)exactMin.z); app.max = new Index(target.maxDetail, (uint)exactMax.x, (uint)exactMax.y, (uint)exactMax.z); app.position = center; return(app); }
public override LocalAction checkMutation(LocalApplication app, Index p, Vector3 diff, float voxelSize) { CubeApp cApp = (CubeApp)app; CubeAction action = new CubeAction(); if (p.depth >= app.tree.maxDetail) { voxelSize *= 0.5f; } action.percentInside = 1; bool outside = false; bool inside = true; action.percentInside *= 1 - (2 - percentOverlapping(diff.x, cApp.halfDimension.x, voxelSize, ref outside, ref inside) - percentOverlapping(-diff.x, cApp.halfDimension.x, voxelSize, ref outside, ref inside)); if (outside) { return(action); } action.percentInside *= 1 - (2 - percentOverlapping(diff.y, cApp.halfDimension.y, voxelSize, ref outside, ref inside) - percentOverlapping(-diff.y, cApp.halfDimension.y, voxelSize, ref outside, ref inside)); if (outside) { return(action); } action.percentInside *= 1 - (2 - percentOverlapping(diff.z, cApp.halfDimension.z, voxelSize, ref outside, ref inside) - percentOverlapping(-diff.z, cApp.halfDimension.z, voxelSize, ref outside, ref inside)); if (outside) { return(action); } action.modify = true; if (!inside) { action.doTraverse = true; } return(action); }
private void SpawnCube(float sx, float sy, float sz, TypeCube tp) { GameObject go; int freeArrow = 0; switch (tp) { case TypeCube.redCube: go = Instantiate(redCube, new Vector3(0, 0, 0), Quaternion.identity); freeArrow = 2; break; case TypeCube.endCube: go = Instantiate(endCube, new Vector3(0, 0, 0), Quaternion.identity); break; default: go = Instantiate(redCube, new Vector3(0, 0, 0), Quaternion.identity); freeArrow = 20; break; } CubeApp ca = go.GetComponent <CubeApp>(); if (go) { ca.pX = sx; ca.pY = sy; ca.pZ = sz; ca.id = newId; if (isStart && freeArrow > 0) { freeArrow--; isStart = false; } ca.type = freeArrow; } go.transform.Rotate(0f, 0f, 0f); go.transform.SetParent(App.map.transform); go.transform.position = new Vector3(sx, sy, sz); go.transform.rotation = App.map.transform.rotation; listCube.Add(newId, go); newId++; }
private void checkArrow() { var mX = grid.GetLongLength(0); var mY = grid.GetLongLength(1); var mZ = grid.GetLongLength(2); /** for (var x = 0; x < mX; x++) * for (var y = 0; y < mY; y++) * for (var z = 0; z < mZ; z++) * { * if (grid[x, y, z] != TypeCube.nul) * { * // logika * } * } */ for (int x = 0; x < listCube.Count; x++) { CubeApp cb = listCube[x].GetComponent <CubeApp>(); int[] a = new int [6]; int i = 0; if (cb.type > 0) { long _x = (long)(cb.pX + 1); long _y = 0; long _z = 0; if (cb.pX < mX - 1 && (grid[_x, _y, _z] == TypeCube.nul)) { a[i] = 0; //logika } // cb.showArrow(a); } // Debug.Log(" = " + x + " " + listCube[x]); } }