Esempio n. 1
0
Particle SphereParticleEmitter::newParticle(int anim, int time)
{
    Particle p;
	float l = sys->areal.getValue(anim, time);
	float w = sys->areaw.getValue(anim, time);
	float spd = sys->speed.getValue(anim, time);
	float var = sys->variation.getValue(anim, time);

	float t = randfloat(0,2*PI);

	// TODO: fix shpere emitters to work properly

	//Vec3D bdir(l*cosf(t), 0, w*sinf(t));
	Vec3D bdir(0, l*cosf(t), w*sinf(t));

	/*
	float theta_range = sys->spread.getValue(anim, time);
	float theta = -0.5f* theta_range + randfloat(0, theta_range);
	Vec3D bdir(0, l*cosf(theta), w*sinf(theta));

	float phi_range = sys->lat.getValue(anim, time);
	float phi = randfloat(0, phi_range);
	rotate(0,0, &bdir.z, &bdir.x, phi);
	*/

	p.pos = sys->pos + bdir;
	p.pos = sys->parent->mat * p.pos;

	if (bdir.lengthSquared()==0) p.speed = Vec3D(0,0,0);
	else {
		Vec3D dir = sys->parent->mrot * (bdir.normalize());
		p.speed = dir.normalize() * spd * (1.0f+randfloat(-var,var));   // ?
	}

	p.down = sys->parent->mrot * Vec3D(0,-1.0f,0);

	p.life = 0;
	p.maxlife = sys->lifespan.getValue(anim, time);

	p.origin = p.pos;

	p.tile = randint(0, sys->rows*sys->cols-1);
	return p;
}
Esempio n. 2
0
void 
FileSelector::MessageReceived(BMessage * msg)
{
	switch (msg->what) {
		case START_MSG:
		{
			BMessenger messenger(this);
			fSavePanel = new BFilePanel(B_SAVE_PANEL, 
							&messenger, NULL, 0, false);

			fSavePanel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE);
			fSavePanel->Show();
			break;
		}
		case B_SAVE_REQUESTED:
		{
			entry_ref dir;
			
			if (msg->FindRef("directory", &dir) == B_OK) {
				const char* name;

				BDirectory bdir(&dir);
				if (msg->FindString("name", &name) == B_OK) {
					if (name != NULL)
						fResult = fEntry.SetTo(&bdir, name);
				};
			};

			release_sem(fExitSem);
			break;
		};
		
		case B_CANCEL:
			release_sem(fExitSem);
			break;

		default:
			inherited::MessageReceived(msg);
			break;
	};
}
Esempio n. 3
0
Particle SphereParticleEmitter::newParticle(int anim, int time, float w, float l, float spd, float var, float spr, float spr2)
{
	Particle p;
	Vec3D dir;
	float radius;

	radius = misc::randfloat(0, 1);

	// Old method
	//float t = misc::randfloat(0,2*PI);

	// New
	// Spread should never be zero for sphere particles ?
	float t = 0;
	if (spr == 0)
		t = misc::randfloat((float)-PI, (float)PI);
	else
		t = misc::randfloat(-spr, spr);

	//Spread Calculation
	Matrix mrot;

	CalcSpreadMatrix(spr * 2, spr2 * 2, w, l);
	mrot = sys->parent->mrot*SpreadMat;

	// New
	// Length should never technically be zero ?
	//if (l==0)
	//  l = w;

	// New method
	// Vec3D bdir(w*cosf(t), 0.0f, l*sinf(t));
	// --

	//! \todo fix shpere emitters to work properly
	/* // Old Method
	//Vec3D bdir(l*cosf(t), 0, w*sinf(t));
	//Vec3D bdir(0, w*cosf(t), l*sinf(t));


	float theta_range = sys->spread.getValue(anim, time);
	float theta = -0.5f* theta_range + misc::randfloat(0, theta_range);
	Vec3D bdir(0, l*cosf(theta), w*sinf(theta));

	float phi_range = sys->lat.getValue(anim, time);
	float phi = misc::randfloat(0, phi_range);
	rotate(0,0, &bdir.z, &bdir.x, phi);
	*/

	if (sys->flags == 57 || sys->flags == 313) { // Faith Halo
		Vec3D bdir(w*cosf(t)*1.6f, 0.0f, l*sinf(t)*1.6f);

		p.pos = sys->pos + bdir;
		p.pos = sys->parent->mat * p.pos;

		if (bdir.lengthSquared() == 0)
			p.speed = Vec3D(0, 0, 0);
		else {
			dir = sys->parent->mrot * (bdir.normalize());//mrot * Vec3D(0, 1.0f,0);
			p.speed = dir.normalize() * spd * (1.0f + misc::randfloat(-var, var));   // ?
		}

	}
	else {
		Vec3D bdir;
		float temp;

		bdir = mrot * Vec3D(0, 1, 0) * radius;
		temp = bdir.z;
		bdir.z = bdir.y;
		bdir.y = temp;

		p.pos = sys->parent->mat * sys->pos + bdir;


		//p.pos = sys->pos + bdir;
		//p.pos = sys->parent->mat * p.pos;


		if (!bdir.lengthSquared() && !(sys->flags & 0x100))
		{
			p.speed = Vec3D(0, 0, 0);
			dir = sys->parent->mrot * Vec3D(0, 1, 0);
		}
		else
		{
			if (sys->flags & 0x100)
				dir = sys->parent->mrot * Vec3D(0, 1, 0);
			else
				dir = bdir.normalize();

			p.speed = dir.normalize() * spd * (1.0f + misc::randfloat(-var, var));   // ?
		}
	}

	p.dir = dir.normalize();//mrot * Vec3D(0, 1.0f,0);
	p.down = Vec3D(0, -1.0f, 0);

	p.life = 0;
	p.maxlife = sys->lifespan.getValue(anim, time);

	p.origin = p.pos;

	p.tile = misc::randint(0, sys->rows*sys->cols - 1);
	return p;
}