예제 #1
0
void SpaceStation::TimeStepUpdate(const float timeStep)
{
	// rotate the thing
	double len = m_type->angVel * timeStep;
	if (!is_zero_exact(len)) {
		matrix3x3d r = matrix3x3d::RotateY(-len);		// RotateY is backwards
		SetOrient(r * GetOrient());
	}
	m_oldAngDisplacement = len;

	// reposition the ships that are docked or docking here
	for (int i=0; i<m_type->numDockingPorts; i++) {
		const shipDocking_t &dt = m_shipDocking[i];
		if (!dt.ship) { //free
			m_navLights->SetColor(i+1, NavLights::NAVLIGHT_GREEN);
			continue;
		}
		if (dt.stage == 1) //reserved
			m_navLights->SetColor(i+1, NavLights::NAVLIGHT_YELLOW);
		if (dt.ship->GetFlightState() == Ship::FLYING)
			continue;
		PositionDockedShip(dt.ship, i);
		m_navLights->SetColor(i+1, NavLights::NAVLIGHT_RED); //docked
	}

	if (m_doorAnimation)
		GetModel()->UpdateAnimations();
}
예제 #2
0
bool SpaceStation::LaunchShip(Ship *ship, int port)
{
	/* XXX bad to keep duplicating this */
	if (m_type->dockOneAtATimePlease) {
		for (int i=0; i<m_type->numDockingPorts; i++) {
			if (m_shipDocking[i].ship && m_shipDocking[i].stage &&
			    (m_shipDocking[i].stage != m_type->numDockingStages+1)) {
				return false;
			}
		}
	}
	matrix4x4d rot;
	GetRotMatrix(rot);

	shipDocking_t &sd = m_shipDocking[port];
	sd.ship = ship;
	sd.stage = -1;
	sd.stagePos = 0;
	sd.fromPos = rot.InverseOf() * (ship->GetPosition() - GetPosition());
	{
		matrix4x4d temp;
		ship->GetRotMatrix(temp);
		sd.fromRot = Quaterniond::FromMatrix4x4(temp);
	}
	ship->SetFlightState(Ship::DOCKING);

	PositionDockedShip(ship, port);
	return true;
}
예제 #3
0
void SpaceStation::SetDocked(Ship *ship, int port)
{
	m_shipDocking[port].ship = ship;
	m_shipDocking[port].stage = m_type->numDockingStages+1;

	// have to do this crap again in case it was called directly (Ship::SetDockWith())
	ship->SetFlightState(Ship::DOCKED);
	ship->SetVelocity(vector3d(0.0));
	ship->SetAngVelocity(vector3d(0.0));
	ship->ClearThrusterState();
	PositionDockedShip(ship, port);
}
예제 #4
0
void SpaceStation::TimeStepUpdate(const float timeStep)
{
	// rotate the thing 
	double len = m_type->angVel * timeStep;
	if (!is_zero_exact(len)) {
		matrix3x3d r = matrix3x3d::RotateY(-len);		// RotateY is backwards
		SetOrient(r * GetOrient());
	}
	m_oldAngDisplacement = len;

	// reposition the ships that are docked or docking here
	for (int i=0; i<m_type->numDockingPorts; i++) {
		const shipDocking_t &dt = m_shipDocking[i];
		if (!dt.ship || dt.stage == 1) continue;
		if (dt.ship->GetFlightState() == Ship::FLYING) continue;
		PositionDockedShip(dt.ship, i);
	}
}
예제 #5
0
void SpaceStation::SetDocked(Ship *ship, int port)
{
	PositionDockedShip(ship, port);
	m_shipDocking[port].ship = ship;
	m_shipDocking[port].stage = m_type->numDockingStages+1;
}