Exemplo n.º 1
0
	Particle *ParticleSystemNode::createParticle(const mat4 *tf) {
		Particle *p = new Particle();

		float sizeD = 0.0f;
		float speedD = 0.0f;
		float growthD = 0.0f;
		float lifeD = 0.0f;
		vec3 srcD;
		vec3 dstD;
		vec3 dirD;

		if (sizeDispersion > EPSILON) sizeD = (math::random(1.0f) - 0.5f) * sizeDispersion;
		if (growthDispersion > EPSILON) growthD = (math::random(1.0f) - 0.5f) * growthDispersion;
		if (speedDispersion > EPSILON) speedD = (math::random(1.0f) - 0.5f) * speedDispersion;
		if (lifeTimeDispersion > EPSILON) lifeD = (math::random(1.0f) - 0.5f) * lifeTimeDispersion;
		srcD = (math::random(vec3(1.0f, 1.0f, 1.0f)) - vec3(0.5f, 0.5f, 0.5f)) * srcColorDispersion;
		dstD = (math::random(vec3(1.0f, 1.0f, 1.0f)) - vec3(0.5f, 0.5f, 0.5f)) * dstColorDispersion;
		if (directionDispersion > EPSILON) dirD = normalize(math::random(vec3(1.0f, 1.0f, 1.0f)) - vec3(0.5f, 0.5f, 0.5f));

		if (emitter == EMITTER_BOX) {
			p->pos = math::random(box);
		} else if (emitter == EMITTER_SPHERE) {
			p->pos = math::random(sphere);
		} else {
			p->pos = vec3();
		}

		if (tf == NULL) {
			p->pos = origin * p->pos;
		} else {
			p->pos = *tf * p->pos;
		}

		p->velocity = normalize(nodeDirection + (dirD - nodeDirection) * directionDispersion) * (speed + speedD);
		p->size = math::max(size + sizeD, 0.001f);
		p->growth = math::max(growth + growthD, 0.001f);

		float ilife = lifeTime + lifeD;

		if (ilife < 0.0001) {
			ilife = 0.0001;
		}

		p->ilife = 1.0f / ilife;
		p->srcColor = clampColor(srcColor + srcD);
		p->dstColor = clampColor(dstColor + dstD);

		p->force = vec3(0, 0, gravity);

		return p;
	}
Exemplo n.º 2
0
VolumeSlider::VolumeSlider(QWidget *p)
    : QSlider(p)
    , lineWidth(0)
    , shown(false)
    , down(false)
    , fadingStop(false)
    , muteAction(0)
    , menu(0)
{
    widthStep=Utils::touchFriendly() ? 5 : 4;
    setRange(0, 100);
    setPageStep(Settings::self()->volumeStep());
    lineWidth=Utils::scaleForDpi(1);

    int w=lineWidth*widthStep*19;
    int h=lineWidth*constHeightStep*10;
    setFixedHeight(h+1);
    setFixedWidth(w);
    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    setOrientation(Qt::Horizontal);
    setFocusPolicy(Qt::NoFocus);
    setStyle(new VolumeSliderProxyStyle());
    setStyleSheet(QString("QSlider::groove:horizontal {border: 0px;} "
                          "QSlider::sub-page:horizontal {border: 0px;} "
                          "QSlider::handle:horizontal {width: 0px; height:0px; margin:0;}"));
    textCol=clampColor(palette().color(QPalette::Active, QPalette::Text));
    generatePixmaps();
}
Exemplo n.º 3
0
void VolumeSlider::showEvent(QShowEvent *ev)
{
    if (!shown) {
        shown=true;
        QLabel lbl(parentWidget());
        lbl.ensurePolished();
        QColor col=clampColor(lbl.palette().text().color());

        if (col!=textCol) {
            textCol=col;
            generatePixmaps();
        }
    }
    QSlider::showEvent(ev);
}
Exemplo n.º 4
0
			// - clamp() | clamps the component values between 0 and 1
			void clamp() {
				this->r = clampColor(r);
				this->g = clampColor(g);
				this->b = clampColor(b);
			}
Exemplo n.º 5
0
			Color3f(float red, float green, float blue) {
				r = clampColor(red);
				g = clampColor(green);
				b = clampColor(blue);
			}
Exemplo n.º 6
0
			Color3f(float val) {
				r = g = b = clampColor(val);
			}