Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Particles

Comments in 'Plugin Development' started by Flabe, Jan 15, 2016.

  1. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Hello there friends!
    I wanna ask you how to make an particle sphere?
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Use the search bar.
    applqpak and PEMapModder like this.
  3. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    There is no answers on my question , all that I gat is the spiral , but I need SPHERE!
  4. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Not really sure if it is correct, but you would need to know the equation of a sphere ((x - a)^2 + (y - b)^2 + (z - c)^2 = r^2), and plot it with particles.
    applqpak likes this.
  5. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    SOFe and applqpak like this.
  6. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
  7. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    applqpak and Vaivez66 like this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    First of all, we need to know your parameters. For example, how do you specifiy the density of particles?
    Remember, particles are points, and we are making an area, so density is definitely a concern.
    I am not very good with spheres (I had never learnt anything about it except the formula of its surface area and volume, as well as definite integration for calculating volume of solid of revolution with equations of circles), so I am not sure how to provide parameters properly.
    With my limited knowledge, I would consider using $t, the number of dots per revolution. So, from a cross section from top view (assuming "north pole" is top and "south pole" is bottom), we will see longitudinal lines going vertically, and from a cross section from front view, we will see latitudinal lines running.
    We will be drawing points on the intersecting points of the longitudinal and latitudinal lines.

    PHP:
    /**
    * @param Vector3 $center the central point of the sphere
    * @param float $radius the radius of the sphere
    * @param int $t number of latitudinal lines. This can be a decimal number, but it will work strangely, won't it?
    * @param callable $spawnParticle a callable that accepts three parameters: $x, $y, $z. It is called per dotted point
    */
    function(Vector3 $center$radius$t, callable $spawnParticle){
        
    /**
         * This is the angle formed by longitudinal lines from the top view.
         * Use your imagination to think how it works with latitudinal lines.
         *
         * @var float $delta
         */
        
    $delta M_PI $t;
      
        
    // now, for every longitudinal line
        // $ry is the angle EOP, where O is center of sphere, E is the horizontal equator and P is one point on the longitudinal line
        // M_PI_2 radian is 90 degrees
        
    for($ry = -M_PI_2$ry M_PI_2$ry += $delta){
            
    $y $center->$radius sin($ry); // draw the picture yourself to understand why sin
            /** @var float $xz the radius of the longitudinal line's circle */
            
    $xz $radius cos($ry);
           
    // $rh is the angle PO'P', where P and P' are points on the longitudinal line, and O' is the center of the longitudinal line's circle
            
    for($rh 0$rh M_PI 2$rh += $delta){
                
    $x $center->$xz cos($rh);
                
    $z $center->$xz sin($rh);
                
    $spawnParticle($x$y$z);
            }
        }
    }
  9. FaigerSYS
    Offline

    FaigerSYS New Member

    Joined:
    May 9, 2016
    Posts:
    8
    This code not working for me((
  10. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Just saying that it is not working means nothing. Explain further.
  11. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Have you tried actually reading the code to adapt into your use case?

    Please note that PHP code isn't charcoal that you can put into any furnace to smelt any items. They should be treated like enzymes, handled with care at proper conditions (air pressure, temperature, pH), and only used to catalyze a limited amount of reactions, but not all.
    Using code snippets without checking whether they work would be like trying to increase the rate of a reversible exothermic reaction by increasing the temperature. Indeed increasing the temperature can increase the rate of reactions, but while it makes the exothermic reaction faster, it makes the endothermic reverse reaction even faster, thus reducing the yield of the exothermic reaction's product. Have you thought clearly enough before putting in any code? It is just like putting `rm -rf ` in front of a directory name can remove a directory properly, but if you use it wrongly and put it in front of a slash, you will be trying to delete the whole filesystem.
    Survingo likes this.

Share This Page

Advertisement