So if I want to create a circle solid, I'd just use this: PHP: function src(Position $centre, $radius, Block $block){ for ($x = $centre->x - $radius; $x <= $centre->x + $radius; $x++) { // same for z if ($centre->distance(new Vector3($x, $centre->y, $z)) <= $radius) { // set block } }} But what about hollow spheres?
Yes, but consider the thickness variation for larger circles. (Rounding to integer will create holes)
@PEMapModder http://forums.pocketmine.net/plugins/drawstuff.410/ function fncDrawSphere (line 548) * lines 580-590 (forget about Y) maybe you can learn something about that little piece of code from BC Yorkie
It shouldn't create blank spots because the distance from Center to the xMin is less than that to a corner.
For a world editor, a fine solution is user-defined thickness. But I want to generate spleef arena walls with it, so there I'd something different. https://github.com/PEMapModder/PEMa...rc/pemapmodder/utils/spaces/CylinderSpace.php
If you want a vertical circle you could use this: PHP: function circle(Position $pos, $radius, Block $block) { for($a = 0; $a <= 360; $a++) { $x = $pos->x + (cos(deg2rad($a)) * $radius); $y = $pos->y + (sin(deg2rad($a)) * $radius); $z = $pos->z; // set block here }} Not sure about horizontal though.
It's hard to explain it, but I'll try. First you generate one circle with the radius that you want the hollow sphere to have and store it into the memory. Then you generate and draw radius amount of circles with a radius equal to the hight of the sphere minus the y value of the first generated circle at x = number of the circle. I'll try to make an example code.
Ok I made a hollow sphere generator, it uses the Bresenham's circle algorithm which is one of the fastest ways to generate a circle. So this should also be one of the fastest ways to generate a hollow sphere. I couldn't test it yet, but it should work. http://pastebin.com/j0Hr6HcC