void VisibleEntityManager::setup(Level* level, IGameView* view, IGameUI* ui, Physics* physics, EventSystem* eventSystem, PlayerState* playerState) {
  level_ = level;
  view_ = view;
  
  Array<Component*> visibles = level->components(VISIBLE_TYPE);
  
  for (Component* visible : visibles) {
    setupComponent(visible);
  }
}
void AnimatableManager::setup(Level* level, IGameView* view, IGameUI* ui, Physics* physics, EventSystem* eventSystem, PlayerState* playerState) {

    level_ = level;
    view_ = view;

    Array<Component*> animatables = level->components(ANIMATABLE_TYPE);

    for (Component* animatable : animatables) {
        setupComponent(animatable);
    }
}
SerialComponent::SerialComponent(QGraphicsItem *parent):
    Component(parent)
{
    setupComponent();

    m_settingDialog = new SerialSettingsDialog();
    m_settingDialog->setConnection(&m_connection);

    connect(&m_connection, SIGNAL(readyRead()), this, SLOT(onReadyRead()));

    //    QMenu *menu = new QMenu();
    //    menu->addAction(new QAction("Open", menu));
    //    setMenu(menu);
}
Esempio n. 4
0
void TractorSetup::buildVehicle( const hkpWorld* world, hkpVehicleInstance& vehicle )
{
    //
    // All memory allocations are made here.
    //

    vehicle.m_data				= new hkpVehicleData;
    vehicle.m_driverInput		= new hkpVehicleDefaultAnalogDriverInput;
    vehicle.m_steering			= new hkpVehicleDefaultSteering;
    vehicle.m_engine			= new hkpVehicleDefaultEngine;
    vehicle.m_transmission		= new hkpVehicleDefaultTransmission;
    vehicle.m_brake				= new hkpVehicleDefaultBrake;
    vehicle.m_suspension		= new hkpVehicleDefaultSuspension;
    vehicle.m_aerodynamics		= new hkpVehicleDefaultAerodynamics;
    vehicle.m_velocityDamper	= new hkpVehicleDefaultVelocityDamper;

    // For illustrative purposes we use a custom hkpVehicleRayCastWheelCollide
    // which implements varying 'ground' friction in a very simple way.
    vehicle.m_wheelCollide		= new FrictionMapVehicleRaycastWheelCollide;

    setupVehicleData( world, *vehicle.m_data );

    // The tyremarks controller is initialised with the number of tyremarks to keep.
    vehicle.m_tyreMarks		= new hkpTyremarksInfo( *vehicle.m_data, 128 );

    setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultAnalogDriverInput* >(vehicle.m_driverInput) );
    setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultSteering*>(vehicle.m_steering));
    setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultEngine*>(vehicle.m_engine) );
    setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultTransmission*>(vehicle.m_transmission) );
    setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultBrake*>(vehicle.m_brake) );
    setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultSuspension*>(vehicle.m_suspension) );
    setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultAerodynamics*>(vehicle.m_aerodynamics) );
    setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultVelocityDamper*>(vehicle.m_velocityDamper) );

    setupWheelCollide( world, vehicle, *static_cast< hkpVehicleRayCastWheelCollide*>(vehicle.m_wheelCollide) );
    //setupCamera( vehicle.m_camera );
    setupTyremarks( *vehicle.m_data, *static_cast< hkpTyremarksInfo*>(vehicle.m_tyreMarks) );

    //
    // Check that all components are present.
    //
    HK_ASSERT(0x0, vehicle.m_data );
    HK_ASSERT(0x7708674a,  vehicle.m_driverInput );
    HK_ASSERT(0x5a324a2d,  vehicle.m_steering );
    HK_ASSERT(0x7bcb2aff,  vehicle.m_engine );
    HK_ASSERT(0x29bddb50,  vehicle.m_transmission );
    HK_ASSERT(0x2b0323a2,  vehicle.m_brake );
    HK_ASSERT(0x7a7ade23,  vehicle.m_suspension );
    HK_ASSERT(0x6ec4d0ed,  vehicle.m_aerodynamics );
    HK_ASSERT(0x67161206,  vehicle.m_wheelCollide );
    HK_ASSERT(0x295015f1,  vehicle.m_tyreMarks );

    //
    // Set up any variables that store cached data.
    //


    // Give driver input default values so that the vehicle (if this input is a default for non
    // player cars) will drive, even if it is in circles!

    // Accelerate.
    vehicle.m_deviceStatus = new hkpVehicleDriverInputAnalogStatus;
    hkpVehicleDriverInputAnalogStatus* deviceStatus= (hkpVehicleDriverInputAnalogStatus*)vehicle.m_deviceStatus;
    deviceStatus->m_positionY = -0.4f;

    // Turn.
    deviceStatus->m_positionX = 0.3f;

    // Defaults
    deviceStatus->m_handbrakeButtonPressed = false;
    deviceStatus->m_reverseButtonPressed = false;


    //
    // Don't forget to call init! (This function ensures all internal data is consistent)
    //

    vehicle.init();

    //
    {
        hkOfstream statOutFile("stat.txt");
        hkReportStatisticsCollector collector( hkBuiltinTypeRegistry::getInstance().getVtableClassRegistry(), statOutFile);
        // Try dumping
        collector.start();
        collector.addReferencedObject(HK_NULL, &vehicle, collector.EXCLUDE_OBJECT_MEMORY);
        collector.end();
    }
}
Esempio n. 5
0
void VehicleSetup::buildVehicle( const hkpWorld* world, hkpVehicleInstance& vehicle )
{
  //
  // All memory allocations are made here.
  //

  vehicle.m_data            = new hkpVehicleData;
  vehicle.m_driverInput     = new hkpVehicleDefaultAnalogDriverInput;
  vehicle.m_steering        = new hkpVehicleDefaultSteering;
  vehicle.m_engine          = new hkpVehicleDefaultEngine;
  vehicle.m_transmission    = new hkpVehicleDefaultTransmission;
  vehicle.m_brake           = new hkpVehicleDefaultBrake;
  vehicle.m_suspension      = new hkpVehicleDefaultSuspension;
  vehicle.m_aerodynamics    = new hkpVehicleDefaultAerodynamics;
  vehicle.m_velocityDamper  = new hkpVehicleDefaultVelocityDamper;
  vehicle.m_wheelCollide    = new hkpVehicleRayCastWheelCollide;

  setupVehicleData( world, *vehicle.m_data );

  // The tyremarks controller is initialised with the number of tyremarks to keep.
  vehicle.m_tyreMarks = new hkpTyremarksInfo( *vehicle.m_data, 1 );

  setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultAnalogDriverInput* >(vehicle.m_driverInput) );
  setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultSteering*>(vehicle.m_steering));
  setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultEngine*>(vehicle.m_engine) );
  setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultTransmission*>(vehicle.m_transmission) );
  setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultBrake*>(vehicle.m_brake) );
  setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultSuspension*>(vehicle.m_suspension) );
  setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultAerodynamics*>(vehicle.m_aerodynamics) );
  setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultVelocityDamper*>(vehicle.m_velocityDamper) );

  setupWheelCollide( world, vehicle, *static_cast< hkpVehicleRayCastWheelCollide*>(vehicle.m_wheelCollide) );
  setupTyremarks( *vehicle.m_data, *static_cast< hkpTyremarksInfo*>(vehicle.m_tyreMarks) );

  //
  // Check that all components are present.
  //
  HK_ASSERT(0x549adbdc, vehicle.m_data );
  HK_ASSERT(0x7708674a,  vehicle.m_driverInput );
  HK_ASSERT(0x5a324a2d,  vehicle.m_steering );
  HK_ASSERT(0x7bcb2aff,  vehicle.m_engine );
  HK_ASSERT(0x29bddb50,  vehicle.m_transmission );
  HK_ASSERT(0x2b0323a2,  vehicle.m_brake );
  HK_ASSERT(0x7a7ade23,  vehicle.m_suspension );
  HK_ASSERT(0x6ec4d0ed,  vehicle.m_aerodynamics );
  HK_ASSERT(0x67161206,  vehicle.m_wheelCollide );
  HK_ASSERT(0x295015f1,  vehicle.m_tyreMarks );

  //
  // Set up any variables that store cached data.
  //


  // Give driver input default values so that the vehicle (if this input is a default for non
  // player cars) will drive, even if it is in circles!

  // Accelerate.
  vehicle.m_deviceStatus = new hkpVehicleDriverInputAnalogStatus;
  hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)vehicle.m_deviceStatus;
  deviceStatus->m_positionY = 0.0f;

  // Turn.
  deviceStatus->m_positionX = 0.0f;

  // Defaults
  deviceStatus->m_handbrakeButtonPressed = false;
  deviceStatus->m_reverseButtonPressed = false;

  //
  // Don't forget to call init! (This function ensures all internal data is consistent)
  //

  vehicle.init();
}
void SixWheelTruckSetup::buildVehicle(hkpWorld* world, hkpVehicleInstance& vehicle )
{
	//
	// All memory allocations are made here.
	//

	vehicle.m_data				= new hkpVehicleData;
	vehicle.m_driverInput		= new hkpVehicleDefaultAnalogDriverInput;
	vehicle.m_steering			= new hkpVehicleDefaultSteering;
	vehicle.m_engine			= new hkpVehicleDefaultEngine;
	vehicle.m_transmission		= new hkpVehicleDefaultTransmission;
	vehicle.m_brake				= new hkpVehicleDefaultBrake;
	vehicle.m_suspension		= new hkpVehicleDefaultSuspension;
	vehicle.m_aerodynamics		= new hkpVehicleDefaultAerodynamics;
	vehicle.m_velocityDamper	= new hkpVehicleDefaultVelocityDamper;

	// For illustrative purposes we use a custom hkpVehicleRaycastWheelCollide
	// which implements varying 'ground' friction in a very simple way.
	vehicle.m_wheelCollide		= new FrictionMapVehicleRaycastWheelCollide;

	setupVehicleData( world, *vehicle.m_data );

	// The tyremarks controller is initialised with the number of tyremarks to keep.
	vehicle.m_tyreMarks		= new hkpTyremarksInfo( *vehicle.m_data, 128 );

	setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultAnalogDriverInput* >(vehicle.m_driverInput) );
	setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultSteering*>(vehicle.m_steering));
	setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultEngine*>(vehicle.m_engine) );
	setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultTransmission*>(vehicle.m_transmission) );
	setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultBrake*>(vehicle.m_brake) );
	setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultSuspension*>(vehicle.m_suspension) );
	setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultAerodynamics*>(vehicle.m_aerodynamics) );
	setupComponent( *vehicle.m_data, *static_cast< hkpVehicleDefaultVelocityDamper*>(vehicle.m_velocityDamper) );

	setupWheelCollide( world, vehicle, *static_cast< hkpVehicleRaycastWheelCollide*>(vehicle.m_wheelCollide) );
	//setupCamera( vehicle.m_camera );
	setupTyremarks( *vehicle.m_data, *static_cast< hkpTyremarksInfo*>(vehicle.m_tyreMarks) );

	//
	// Check that all components are present.
	//
	HK_ASSERT(0x0, vehicle.m_data );
	HK_ASSERT(0x7708674a,  vehicle.m_driverInput );
	HK_ASSERT(0x5a324a2d,  vehicle.m_steering );
	HK_ASSERT(0x7bcb2aff,  vehicle.m_engine );
	HK_ASSERT(0x29bddb50,  vehicle.m_transmission );
	HK_ASSERT(0x2b0323a2,  vehicle.m_brake );
	HK_ASSERT(0x7a7ade23,  vehicle.m_suspension );
	HK_ASSERT(0x6ec4d0ed,  vehicle.m_aerodynamics );
	HK_ASSERT(0x67161206,  vehicle.m_wheelCollide );
	HK_ASSERT(0x295015f1,  vehicle.m_tyreMarks );

	//
	// Set up any variables that store cached data.
	//


	// Give driver input default values so that the vehicle (if this input is a default for non
	// player cars) will drive, even if it is in circles!

	// Accelerate.
	vehicle.m_deviceStatus = new hkpVehicleDriverInputAnalogStatus;
	hkpVehicleDriverInputAnalogStatus* deviceStatus= (hkpVehicleDriverInputAnalogStatus*)vehicle.m_deviceStatus;
	deviceStatus->m_positionY = -0.4f;

	// Turn.
	deviceStatus->m_positionX = 0.3f;

	// Defaults
	deviceStatus->m_handbrakeButtonPressed = false;
	deviceStatus->m_reverseButtonPressed = false;


	//
	// Don't forget to call init! (This function ensures all internal data is consistent)
	//

	vehicle.init();

	//
	// The phantom for collision detection needs to be explicitly added to the world
	//

	world->addPhantom( (hkpPhantom*)(static_cast< hkpVehicleRaycastWheelCollide*>(vehicle.m_wheelCollide)->m_phantom) );
}
void VehicleSetup::buildVehicle(World *world, const hkpWorld* physicsWorld, hkpVehicleInstance& vehicle, EntityID vehicleEntity, std::vector<EntityID> wheelEntities)
{
	auto vehicleComponent = world->GetComponent<Components::Vehicle>(vehicleEntity);
	auto tankSteeringComponent = world->GetComponent<Components::TankSteering>(vehicleEntity);

	WheelData wheelData;
	for (int i = 0; i < wheelEntities.size(); i++)
	{
		wheelData.WheelComponent = world->GetComponent<Components::Wheel>(wheelEntities[i]);
		wheelData.TransformComponent = world->GetComponent<Components::Transform>(wheelEntities[i]);
		m_Wheels.push_back(wheelData);	
	}
	
	//
	// All memory allocations are made here.
	//
	vehicle.m_data = new hkpVehicleData;
	vehicle.m_driverInput = new hkpVehicleDefaultAnalogDriverInput;
	if(tankSteeringComponent)
	{
		vehicle.m_steering = new TankSteering;
	}
	else
	{
		vehicle.m_steering = new hkpVehicleDefaultSteering;
	}
	vehicle.m_engine = new hkpVehicleDefaultEngine;
	vehicle.m_transmission = new hkpVehicleDefaultTransmission;
	vehicle.m_brake = new hkpVehicleDefaultBrake;
	vehicle.m_suspension = new hkpVehicleDefaultSuspension;
	vehicle.m_aerodynamics = new hkpVehicleDefaultAerodynamics;
	vehicle.m_velocityDamper = new hkpVehicleDefaultVelocityDamper;

	// For illustrative purposes we use a custom hkpVehicleRayCastWheelCollide
	// which implements varying 'ground' friction in a very simple way.
	vehicle.m_wheelCollide = new hkpVehicleRayCastWheelCollide;

	setupVehicleData(physicsWorld, *vehicle.m_data);


	setupComponent(*vehicle.m_data, *static_cast<hkpVehicleDefaultAnalogDriverInput*>(vehicle.m_driverInput));
	setupComponent(*vehicle.m_data, *static_cast<hkpVehicleDefaultSteering*>(vehicle.m_steering), *vehicleComponent);
	setupComponent(*vehicle.m_data, *static_cast<hkpVehicleDefaultEngine*>(vehicle.m_engine), *vehicleComponent);
	setupComponent(*vehicle.m_data, *static_cast<hkpVehicleDefaultTransmission*>(vehicle.m_transmission), *vehicleComponent);
	setupComponent(*vehicle.m_data, *static_cast<hkpVehicleDefaultBrake*>(vehicle.m_brake), *vehicleComponent);
	setupComponent(*vehicle.m_data, *static_cast<hkpVehicleDefaultSuspension*>(vehicle.m_suspension), *vehicleComponent);
	setupComponent(*vehicle.m_data, *static_cast<hkpVehicleDefaultAerodynamics*>(vehicle.m_aerodynamics), *vehicleComponent);
	setupComponent(*vehicle.m_data, *static_cast<hkpVehicleDefaultVelocityDamper*>(vehicle.m_velocityDamper), *vehicleComponent);

	setupWheelCollide(physicsWorld, vehicle, *static_cast<hkpVehicleRayCastWheelCollide*>(vehicle.m_wheelCollide));

	//
	// Check that all components are present.
	//
	HK_ASSERT(0x0		, vehicle.m_data);
	HK_ASSERT(0x7708674a, vehicle.m_driverInput);
	HK_ASSERT(0x5a324a2d, vehicle.m_steering);
	HK_ASSERT(0x7bcb2aff, vehicle.m_engine);
	HK_ASSERT(0x29bddb50, vehicle.m_transmission);
	HK_ASSERT(0x2b0323a2, vehicle.m_brake);
	HK_ASSERT(0x7a7ade23, vehicle.m_suspension);
	HK_ASSERT(0x6ec4d0ed, vehicle.m_aerodynamics);
	HK_ASSERT(0x67161206, vehicle.m_wheelCollide);

	//
	// Set up any variables that store cached data.
	//


	// Give driver input default values so that the vehicle (if this input is a default for non
	// player cars) will drive, even if it is in circles!

	// Steering Defaults
	vehicle.m_deviceStatus = new hkpVehicleDriverInputAnalogStatus;
	hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)vehicle.m_deviceStatus;
	deviceStatus->m_positionY = 0.f;
	deviceStatus->m_positionX = 0.f;
	deviceStatus->m_handbrakeButtonPressed = false;
	deviceStatus->m_reverseButtonPressed = false;

	//
	// Don't forget to call init! (This function is necessary to set up derived data)
	//
	vehicle.init();
}