Example #1
0
void VehicleManagerDemo::buildLandscape()
{

	if (1)
	{
		//
		// Create the ground we'll drive on.
		//
		{
			hkpRigidBodyCinfo groundInfo;

			//
			//	Set the if condition to 0 if you want to test the heightfield
			//
			if ( 1 )
			{
				FlatLand* fl = new FlatLand();
				m_track = fl;
				groundInfo.m_shape = fl->createMoppShapeForSpu();
				groundInfo.m_position.set(5.0f, -2.0f, 5.0f);
				groundInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo( GROUND_LAYER, 0 );
			}

			{
				groundInfo.m_motionType = hkpMotion::MOTION_FIXED;
				groundInfo.m_friction = 0.5f;
				hkpRigidBody* groundbody = new hkpRigidBody(groundInfo);
				m_world->addEntity(groundbody);
				groundbody->removeReference();
			}

			groundInfo.m_shape->removeReference();
		}
	}

	if (1)
	{
		hkVector4 halfExtents(10.0f, 0.1f, 10.0f);
		hkVector4 startPos(-240.0f, -7.8f, 0.0f);
		hkVector4 diffPos (30.0f, 0.0f, 0.0f);
		createDodgeBoxes(5, halfExtents, startPos, diffPos);
	}

	if (1)
	{
		hkVector4 halfExtents(10.0f, 0.05f, 10.0f);
		hkVector4 startPos(-240.0f, -7.85f, 30.0f);
		hkVector4 diffPos (30.0f, 0.0f, 0.0f);
		createDodgeBoxes(5, halfExtents, startPos, diffPos);
	}

	if (1)
	{
		int gridSize = 1 + int(hkMath::sqrt( hkReal(m_env->m_cpuMhz/100) ));
		createRagdollGrid( m_world, gridSize, gridSize, 4.0f, 4.0f, m_ragdolls );
	}
}
Example #2
0
void VehicleCloning::buildLandscape()
{
	//
	// Create the ground we will drive on.
	//
	{
		hkpRigidBodyCinfo groundInfo;

		FlatLand* fl = new FlatLand();
		m_track = fl;
		groundInfo.m_shape = fl->createMoppShape();
		groundInfo.m_position.set(5.0f, -2.0f, 5.0f);

		groundInfo.m_motionType = hkpMotion::MOTION_FIXED;
		groundInfo.m_friction = 2.0f;
		hkpRigidBody* groundbody = new hkpRigidBody(groundInfo);
		m_world->addEntity(groundbody);
		groundbody->removeReference();

		groundInfo.m_shape->removeReference();
	}
}
void SuspendInactiveAgentsDemo::buildLandscape()
{
	//
	// Create the ground we'll drive on.
	//
	{
		hkpRigidBodyCinfo groundInfo;


		//
		//	Set the if condition to 0 if you want to test the heightfield
		//
		const int dim = 64;
		const hkReal s = 0.3f;
		if ( this->getDemoVariant() == 1 )
		{
			// Triangle mesh
			FlatLand* fl = new FlatLand( dim );
			m_landscape = fl;
			hkVector4 scaling( s,0.0f,s );
			fl->setScaling( scaling );
			groundInfo.m_shape = fl->createMoppShape();
			//groundInfo.m_position.setMul4( -0.5f * dim, scaling );
			groundInfo.m_position(1) = 0;
		}
		else if (getDemoVariant() == 0)
		{
			// Heightfield
			hkpSampledHeightFieldBaseCinfo ci;
			ci.m_xRes = dim;
			ci.m_zRes = dim;
			ci.m_scale.set( s, 0.5f, s );
			m_landscape = HK_NULL;
			groundInfo.m_shape = new SuspendInactiveAgentsDemoSampledHeightFieldShape( ci );
			groundInfo.m_position.set(-0.5f * ci.m_xRes * ci.m_scale(0), -2.0f, -0.5f * ci.m_zRes * ci.m_scale(2));
		}
		else
		{
			// Warm starting collision manifold
			FlatLand* fl = new FlatLand( 2 );
			fl->setTriangleRadius(0);
			m_landscape = fl;
			hkVector4 scaling( 100,0,100);
			fl->setScaling( scaling );
			groundInfo.m_shape = fl->createMoppShape();
		}



		{
			groundInfo.m_motionType = hkpMotion::MOTION_FIXED;
			groundInfo.m_friction = 2.0f;
			if (getDemoVariant() == 2)
			{
				groundInfo.m_position.set(50,0,50);
			}
			hkpRigidBody* groundbody = new hkpRigidBody(groundInfo);

			m_world->addEntity(groundbody);
			groundbody->removeReference();
		}

		groundInfo.m_shape->removeReference();
	}
}