Qml official tutorial -- using the QT quick particle system

Source: Internet
Author: User

URL: http://qt-project.org/doc/qt-5/qtquick-effects-particles.html


Using the QT quick particle system -- using the QT quick particle system

The types of all particle systems can be found in the document of the qtquick. particles module.

Note that you need to use the following code to introduce the types in the particle module:

import QtQuick.Particles 2.0

·

The participating system

The particle system contains four major qml types: Particle System, painters, emitters, and affectors.

The participation system type must work with all other types and manage the shared timeline. Painters, emitters, and affectors must interact with each other in the same participant system.

You may have multiple participating systems to achieve complex results. Therefore, you should place the types that can interact with each other in a single participant system, or use only one participant system when the number of these types is small.


Logical particles -- Logical Particles

All particle system types are based on logical particles ". Each particle has a logical representation in the particle system, which determines how these types work. Not every logical particle needs to be visualized, but some logical particles can generate multiple visual particles on the screen.


Particle groups-Particle Group

Each logical particle is a member of a particle group, and each particle belongs to a group. If the group to which the logical particle belongs is not specified, it will be attributed to the group named "" (empty character. Using groups has two purposes: to control particles, they can have random state transitions.

The benefit of using a group to control particles is that you do not need to use any particle system type to access a single particle. All types in the group work as a whole, so any particle that needs to behave differently from other particles (except for the usual random parameter changes) should be placed in different particle groups.

Particles can also change the group dynamically, and the particle trajectory does not change, but this can be achieved through different patriclepainter or affectors. A particle can also change its group through an affector, or define a random state transition in the particle group type.

Generally, if a group requires random state transition, they can be defined in only one participant group. Otherwise, enough groups will be defined and the attributes of particle/Participant attributes will be used as the group name.


Emitters -- Transmitter

Emitters sends logical particles to the system. These particles have trajectories and lifetime, but are not visualized. These particles are sent from the coordinates defined in the emitter.

Trailemitters is a special type in which the emitted particles are based on the coordinates of other particles. Any of the following logical particles within the trailemitter range will cause the emission of trailemitter, just as there is an emitter with the same attributes as the trailemitter.


Particle painters

The Paster is a type used to visualize logical particles. For any group of particles allocated to it, they are within the defined emission range (or outside the range, if you do not define the clip attribute as true ), the particle visualization effect depends on the definition of the particle painter type. The particle painters base class does not draw anything. imageparticle renders an image on the particle coordinate. customparticle allows you to use your own shader to render particles based on vertex data. Itemparticle allows you to render any qml proxy type. Modelparticle is similar, but it processes the coordinate model data in the proxy in a way similar to the view type.

Since the particle painter is used to draw the qml type of particles on the screen, we should set its Z value for its stacked layers.


Stochastic Parameters -- Random Parameters

The random behavior of the particle system is benefited from multiple attributes used to generate random parameters. If your parameters do not require any randomness, you do not need to define any attribute with "variation.


Directions -- direction

We can use the angle and intensity to define the direction, or use the X and Y parameters. However, we can also use random parameters for these parameters. In this way, the random X and Y parameters will define a rectangular area, and the random angle will define a sector.


Shapes -- shape

The particle system contains multiple types that represent shapes. These types are not used to visualize the shape, but to generate a series of random points in the shape. If you want to generate a non-random point, you can set the height and width of the shape to 0 (default ). Otherwise, you can use these shape types to specify a region and then perform the operations you want on random points in the region.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.