コード例 #1
0
ファイル: Ship.cpp プロジェクト: Metamartian/pioneer
void Ship::Init()
{
	// XXX the animation namespace must match that in LuaConstants
	// note: this must be set before generating the collision mesh
	// (which happens in SetModel()) and before rendering
	GetLmrObjParams().animationNamespace = "ShipAnimation";
	GetLmrObjParams().equipment = &m_equipment;

	const ShipType &stype = GetShipType();

	// Dirty hack: Always use gear-down mesh for collision detection
	// necessary because some ships have non-docking meshes too large for docking
	float temp = GetLmrObjParams().animValues[ANIM_WHEEL_STATE];
	GetLmrObjParams().animValues[ANIM_WHEEL_STATE] = 1.0f;
	SetModel(stype.lmrModelName.c_str());
	GetLmrObjParams().animValues[ANIM_WHEEL_STATE] = temp;

	SetMassDistributionFromModel();
	UpdateStats();
	m_stats.hull_mass_left = float(stype.hullMass);
	m_stats.shield_mass_left = 0;
	m_hyperspace.now = false;			// TODO: move this on next savegame change, maybe
	m_hyperspaceCloud = 0;

	m_landingGearAnimation = 0;
	SceneGraph::Model *nmodel = dynamic_cast<SceneGraph::Model*>(GetModel());
	if (nmodel) {
		m_landingGearAnimation = nmodel->FindAnimation("gear_down");
	}
}
コード例 #2
0
ファイル: SpaceStation.cpp プロジェクト: christiank/pioneer
void SpaceStation::InitStation()
{
	m_adjacentCity = 0;
	for(int i=0; i<NUM_STATIC_SLOTS; i++) m_staticSlot[i] = false;
	Random rand(m_sbody->GetSeed());
	const bool ground = m_sbody->GetType() == SystemBody::TYPE_STARPORT_ORBITAL ? false : true;
	m_type = SpaceStationType::RandomStationType(rand, ground);

	if(m_shipDocking.empty()) {
		m_shipDocking.reserve(m_type->NumDockingPorts());
		for (unsigned int i=0; i<m_type->NumDockingPorts(); i++) {
			m_shipDocking.push_back(shipDocking_t());
		}
		// only (re)set these if we've not come from the ::Load method
		m_doorAnimationStep = m_doorAnimationState = 0.0;
	}
	assert(m_shipDocking.size() == m_type->NumDockingPorts());

	// This SpaceStation's bay ports are an instance of...
	m_ports = m_type->Ports();

	SetStatic(ground);			// orbital stations are dynamic now

	// XXX hack. if we loaded a game then ModelBody::Load already restored the
	// model and we shouldn't overwrite it
	if (!GetModel())
		SetModel(m_type->ModelName().c_str());

	SceneGraph::Model *model = GetModel();

	m_navLights.reset(new NavLights(model, 2.2f));
	m_navLights->SetEnabled(true);

	if (ground) SetClipRadius(CITY_ON_PLANET_RADIUS);		// overrides setmodel

	m_doorAnimation = model->FindAnimation("doors");

	SceneGraph::ModelSkin skin;
	skin.SetDecal("pioneer");

	if (model->SupportsPatterns()) {
		skin.SetRandomColors(rand);
		skin.Apply(model);
		model->SetPattern(rand.Int32(0, model->GetNumPatterns()));
	} else {
		skin.Apply(model);
	}
}