Beispiel #1
0
void GuardianSystemDemo::InitSceneGraph()
{
    for (int32_t i = 0; i < Scene::MAX_MODELS; ++i) {
        TriangleSet mesh;
        mesh.AddSolidColorBox(-0.035f, -0.035f, -0.035f, 0.035f, 0.035f, 0.035f, 0xFFFFFFFF);

        // Objects start 1 meter high
        mObjPosition[i] = XMVectorSet(0.0f, 1.0f, 0.0f, 1.0f);
        // Objects have random velocity
        mObjVelocity[i] = XMVectorSet(randVelocity(), randVelocity() * 0.5f, randVelocity(), 0);
        mObjVelocity[i] = XMVector3Normalize(mObjVelocity[i]) * 0.3f;

        Material* mat = new Material(new Texture(false, 256, 256, Texture::AUTO_FLOOR));
        mDynamicScene.Add(new Model(&mesh, XMFLOAT3(0, 0, 0), XMFLOAT4(0, 0, 0, 1), mat));
    }
}
Beispiel #2
0
void circleTemplate(Bullet *previous, Bullet *bullet, World *world, int n,
		int max, int rand) {
	bullet->x = (world->width / 2) + rand;
	bullet->y = world->height / 4;
	bullet->theta = wrapDegree(n * 10 + rand);
	bullet->velocity =
			(previous == NULL) ? randVelocity(world) : previous->velocity;
	bullet->sFn = decreasingVelocity;
}
Beispiel #3
0
void playerCircleTemplate(Bullet *previous, Bullet *bullet, World *world, int n,
		int max, int rand) {
	bullet->x = world->player.x;
	bullet->y = world->player.y;
	bullet->theta = wrapDegree(n * (360.0 / max) + rand);
	bullet->velocity =
			(previous == NULL) ? randVelocity(world) : previous->velocity;
	bullet->sFn = decreasingVelocity;
}
Beispiel #4
0
void horizontalTemplate(Bullet *previous, Bullet *bullet, World *world, int n,
		int max, int rand) {
	bullet->x = round(
			((double) world->width
					/ (max >= world->width ? world->width / 2 : max)) * n);
	bullet->y = randRange(2, 10);
	bullet->theta = 0; // 0 degree does down
	bullet->velocity =
			(previous == NULL) ? randVelocity(world) : previous->velocity;
	bullet->sFn = increasingVelocity;
}
Beispiel #5
0
void spiralTemplate(Bullet *previous, Bullet *bullet, World *world, int n,
		int max, int rand) {

	int shift = rand > 0 ? -2 : 2;

	bullet->x =
			previous == NULL ? (world->width / 2 + rand) : previous->x + shift;
	bullet->y = previous == NULL ? (world->height / 4) : previous->y + shift;
	bullet->theta = wrapDegree(n * 10 + rand);
	bullet->velocity =
			(previous == NULL) ? randVelocity(world) : previous->velocity;
	bullet->sFn = increasingVelocity;
}
Beispiel #6
0
	ParticleState::ParticleState( PARTICLE_TYPES newType )
	{
		Vector3 randVelocity( randInRange( -1.f, 1.f ), randInRange( -1.f, 1.f ), randInRange( -1.f, 1.f ) );
		Vector3 newLocation;

		switch( newType )
		{
		case EXPLOSION:
			break;
		case  FIREWORKS:
			randVelocity.y = sign( randVelocity.y ) * lerp( FIREWORKS_MIN_Y, FIREWORKS_MAX_Y,	fabs( randVelocity.y ) );
			break;
		case FOUNTAIN:
		case DEBRIS:
			randVelocity.x = lerp( -DEBRIS_MAX_XZ,	DEBRIS_MAX_XZ,	fabs( randVelocity.x ) );
			randVelocity.y = lerp( DEBRIS_MIN_Y,	DEBRIS_MAX_Y,	fabs( randVelocity.y ) );
			randVelocity.z = lerp( -DEBRIS_MAX_XZ,	DEBRIS_MAX_XZ,	fabs( randVelocity.z ) );
			break;
		case SMOKE:
			randVelocity.x = lerp( -SMOKE_MAX_XZ,	SMOKE_MAX_XZ,	fabs( randVelocity.x ) );
			randVelocity.y = lerp( SMOKE_MIN_Y,		SMOKE_MAX_Y,	fabs( randVelocity.y ) );
			randVelocity.z = lerp( -SMOKE_MAX_XZ,	SMOKE_MAX_XZ,	fabs( randVelocity.z ) );
			break;
		case TORNADO:
			//location
			float particleHeight = randInRangeWithDistribution( 0.f, TORNADO_HEIGHT, FilterFunctionSmoothStart );
			float particleHeightRatio = RangeMapFloat( 0.f, 1.f, particleHeight / TORNADO_HEIGHT, 0.1f, 1.f, FilterFunctionSmoothStart );
			newLocation = Vector3( randInRange( -particleHeightRatio, particleHeightRatio ), particleHeight, 
				randInRange( -particleHeightRatio, particleHeightRatio ) );

			//new velocity
			Vector2 flatVelocity( newLocation.x, newLocation.z );
			flatVelocity.rotateMinus90Degrees();
			//velocity in y and z
			randVelocity.setXYZ( flatVelocity.x, randInRange( -TORNADO_VERTICAL_SPEED, TORNADO_VERTICAL_SPEED ), flatVelocity.y );

			break;
		}

		m_Vel = randVelocity;
		m_Loc = newLocation;
	}