protected override VoxelHolder modifyVoxel(VoxelHolder original, int x, int y, int z) { double percentInside = 1; percentInside *= percentOverlapping(x, min.x); percentInside *= percentOverlapping(y, min.y); percentInside *= percentOverlapping(z, min.z); percentInside *= percentOverlapping(-x, -max.x); percentInside *= percentOverlapping(-y, -max.y); percentInside *= percentOverlapping(-z, -max.z); if (percentInside <= 0.001) { return(original); } if (percentInside >= 0.999) { return(new Voxel(value.averageMaterialType(), overwriteShape? value.averageOpacity(): original.averageOpacity())); } byte newOpacity = (byte)((original.averageOpacity() * (1 - percentInside) + value.averageOpacity() * (percentInside))); byte newSubstance = original.averageMaterialType(); if (newOpacity >= 2 * original.averageOpacity() || (overwriteSubstance && percentInside > 0.5)) { newSubstance = value.averageMaterialType(); } if (!overwriteShape) { newOpacity = original.averageOpacity(); } return(new Voxel(newSubstance, newOpacity)); }
protected override VoxelHolder modifyVoxel(VoxelHolder original, int x, int y, int z) { float dis = (center - new Vector3(x, y, z)).magnitude; if (dis > maxDis) { return(original); } if (dis < minDis) { return(new Voxel(value.averageMaterialType(), overwriteShape? value.averageOpacity(): original.averageOpacity())); } byte newOpacity = (byte)((original.averageOpacity() * (dis - minDis) + value.averageOpacity() * (maxDis - dis)) / 2); byte newSubstance = value.averageMaterialType(); if (newOpacity >= 2 * original.averageOpacity() || (overwriteSubstance && dis < radius)) { newSubstance = value.averageMaterialType(); } if (!overwriteShape) { newOpacity = original.averageOpacity(); } return(new Voxel(newSubstance, newOpacity)); }
protected override VoxelHolder modifyVoxel(VoxelHolder original, int x, int y, int z) { float dis = (center - new Vector3(x, y, z)).magnitude; if (dis > maxDis) return original; if (dis < minDis) return new Voxel(value.averageMaterialType(), overwriteShape? value.averageOpacity(): original.averageOpacity()); byte newOpacity = (byte)((original.averageOpacity() * (dis - minDis) + value.averageOpacity() * (maxDis - dis)) / 2); byte newSubstance = value.averageMaterialType(); if (newOpacity >= 2 *original.averageOpacity() || (overwriteSubstance && dis < radius)) newSubstance = value.averageMaterialType(); if (!overwriteShape) newOpacity = original.averageOpacity(); return new Voxel(newSubstance, newOpacity); }
protected override VoxelHolder modifyVoxel(VoxelHolder original, int x, int y, int z) { Vector3 center = (min + max) / 2; float radius = center.x - min.x; float minDis = (radius - 1); float maxDis = (radius + 1); float dis = (center - new Vector3(x, y, z)).magnitude; if (dis > maxDis) return original; if (dis < minDis) return value; byte newOpacity = (byte)((original.averageOpacity() * (dis - minDis) + value.averageOpacity() * (maxDis - dis)) / 2); if (newOpacity >= 2 *original.averageOpacity() || (overwriteSubstance && dis < radius)) return new Voxel(value.averageMaterialType(), newOpacity); return new Voxel(original.averageMaterialType(), newOpacity); }
protected override VoxelHolder modifyVoxel(VoxelHolder original, int x, int y, int z) { double percentInside = 1; percentInside *= percentOverlapping(x, min.x); percentInside *= percentOverlapping(y, min.y); percentInside *= percentOverlapping(z, min.z); percentInside *= percentOverlapping(-x, -max.x); percentInside *= percentOverlapping(-y, -max.y); percentInside *= percentOverlapping(-z, -max.z); if (percentInside <= 0.001) return original; if (percentInside >= 0.999) return new Voxel(value.averageMaterialType(), overwriteShape? value.averageOpacity(): original.averageOpacity()); byte newOpacity = (byte)((original.averageOpacity() * (1 -percentInside) + value.averageOpacity() * (percentInside))); byte newSubstance = original.averageMaterialType(); if (newOpacity >= 2 *original.averageOpacity() || (overwriteSubstance && percentInside > 0.5)) newSubstance = value.averageMaterialType(); if (!overwriteShape) newOpacity = original.averageOpacity(); return new Voxel(newSubstance, newOpacity); }
public static VoxelHolder setSphere(VoxelHolder original, int x, int y, int z, Vector3 min, Vector3 max, VoxelHolder val) { Vector3 center = (min + max) / 2; float radius = center.x - min.x; float minDis = (radius - 1); float maxDis = (radius + 1); float dis = (center - new Vector3(x, y, z)).magnitude; if (dis > maxDis) return original; if (dis < minDis) return val; byte newOpacity = (byte)((original.averageOpacity() * (dis - minDis) + val.averageOpacity() * (maxDis - dis)) /2); if ((dis - minDis) > 0.5f) return new Voxel(val.averageMaterialType(), newOpacity); return new Voxel(original.averageMaterialType(), newOpacity); }
public static VoxelHolder setSphere(VoxelHolder original, int x, int y, int z, Vector3 min, Vector3 max, VoxelHolder val) { Vector3 center = (min + max) / 2; float radius = center.x - min.x; float minDis = (radius - 1); float maxDis = (radius + 1); float dis = (center - new Vector3(x, y, z)).magnitude; if (dis > maxDis) { return(original); } if (dis < minDis) { return(val); } byte newOpacity = (byte)((original.averageOpacity() * (dis - minDis) + val.averageOpacity() * (maxDis - dis)) / 2); if ((dis - minDis) > 0.5f) { return(new Voxel(val.averageMaterialType(), newOpacity)); } return(new Voxel(original.averageMaterialType(), newOpacity)); }