当前位置: 首页>>代码示例>>C++>>正文


C++ Point::OtherHand方法代码示例

本文整理汇总了C++中Point::OtherHand方法的典型用法代码示例。如果您正苦于以下问题:C++ Point::OtherHand方法的具体用法?C++ Point::OtherHand怎么用?C++ Point::OtherHand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Point的用法示例。


在下文中一共展示了Point::OtherHand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dummy

void
FlightPlanner::CreateGuardRoute(Element* guard, Element* ward)
{
	if (!guard || !ward)
		return;

	RLoc	rloc;
	Vec3           dummy(0,0,0);
	Point          loc   = ship->Location();
	double         head  = ship->CompassHeading();
	Instruction*   instr = 0;

if (ship->IsAirborne())
	loc += ship->Cam().vup() * 8e3;
	else
	loc += ship->Cam().vup() * 1e3;

	loc = loc.OtherHand();

	rloc.SetReferenceLoc(0);
	rloc.SetBaseLocation(loc);
	rloc.SetDistance(30e3);
	rloc.SetDistanceVar(0);
	rloc.SetAzimuth(head);
	rloc.SetAzimuthVar(0);

	instr = new(__FILE__,__LINE__) Instruction(ship->GetRegion(), dummy, Instruction::VECTOR);
	instr->SetSpeed(750);
	instr->GetRLoc() = rloc;

	guard->AddNavPoint(instr);

	if(ward) {
		rloc.SetReferenceLoc(0);
		rloc.SetBaseLocation(ward->GetShip(1)->Location());
		rloc.SetDistance(10e3);
		rloc.SetDistanceVar(5e3);
		rloc.SetAzimuth(0);
		rloc.SetAzimuthVar(90*DEGREES);

		instr = new(__FILE__,__LINE__) Instruction(ship->GetRegion(), dummy, Instruction::DEFEND);
		instr->SetSpeed(1000);
		instr->GetRLoc() = rloc;
		//instr->SetHoldTime(30 * 60); // 30 minutes or low fuel, whatever comes first.
		instr->SetTarget(ward->Name());

		guard->AddNavPoint(instr);
	}
}
开发者ID:lightgemini78,项目名称:Starshatter-Rearmed,代码行数:49,代码来源:FlightPlanner.cpp

示例2: if

void
FlightPlanner::CreatePatrolRoute(Element* elem, int index)
{
	RLoc           rloc;
	Vec3           dummy(0,0,0);
	Point          loc   = ship->Location();
	double         zone  = ship->CompassHeading();
	Instruction*   instr = 0;

	if (ship->IsAirborne())
	loc.y += 8e3;
	else
	loc.y += 1e3;

	loc = loc.OtherHand();

	if (index > 2)
	zone += 170*DEGREES;
	else if (index > 1)
	zone += -90*DEGREES;
	else if (index > 0)
	zone +=  90*DEGREES;

	rloc.SetReferenceLoc(0);
	rloc.SetBaseLocation(loc);
	rloc.SetDistance(30e3);
	rloc.SetDistanceVar(0);
	rloc.SetAzimuth(-10*DEGREES + zone);
	rloc.SetAzimuthVar(0);

	instr = new(__FILE__,__LINE__) Instruction(ship->GetRegion(), dummy, Instruction::VECTOR);
	instr->SetSpeed(750);
	instr->GetRLoc() = rloc;

	elem->AddNavPoint(instr);

	rloc.SetReferenceLoc(0);
	rloc.SetBaseLocation(loc);
	if (ship->IsAirborne())
	rloc.SetDistance(140e3);
	else
	rloc.SetDistance(220e3);
	rloc.SetDistanceVar(50e3);
	rloc.SetAzimuth(-20*DEGREES + zone);
	rloc.SetAzimuthVar(15*DEGREES);

	instr = new(__FILE__,__LINE__) Instruction(ship->GetRegion(), dummy, Instruction::PATROL);
	instr->SetSpeed(500);
	instr->GetRLoc() = rloc;

	elem->AddNavPoint(instr);

	rloc.SetReferenceLoc(&instr->GetRLoc());
	rloc.SetDistance(120e3);
	rloc.SetDistanceVar(30e3);
	rloc.SetAzimuth(60*DEGREES + zone);
	rloc.SetAzimuthVar(20*DEGREES);

	instr = new(__FILE__,__LINE__) Instruction(ship->GetRegion(), dummy, Instruction::PATROL);
	instr->SetSpeed(350);
	instr->GetRLoc() = rloc;

	elem->AddNavPoint(instr);

	rloc.SetReferenceLoc(&instr->GetRLoc());
	rloc.SetDistance(120e3);
	rloc.SetDistanceVar(30e3);
	rloc.SetAzimuth(120*DEGREES + zone);
	rloc.SetAzimuthVar(20*DEGREES);

	instr = new(__FILE__,__LINE__) Instruction(ship->GetRegion(), dummy, Instruction::PATROL);
	instr->SetSpeed(350);
	instr->GetRLoc() = rloc;

	elem->AddNavPoint(instr);

	rloc.SetReferenceLoc(0);
	rloc.SetBaseLocation(loc);
	rloc.SetDistance(40e3);
	rloc.SetDistanceVar(0);
	rloc.SetAzimuth(180*DEGREES + ship->CompassHeading());
	rloc.SetAzimuthVar(0*DEGREES);

	instr = new(__FILE__,__LINE__) Instruction(ship->GetRegion(), dummy, Instruction::RTB);
	instr->SetSpeed(500);
	instr->GetRLoc() = rloc;

	elem->AddNavPoint(instr);
}
开发者ID:lightgemini78,项目名称:Starshatter-Rearmed,代码行数:89,代码来源:FlightPlanner.cpp

示例3: if

void
NavAI::FindObjective()
{
	navpt    = 0;
	distance = 0;

	// runway takeoff:
	if (takeoff) {
		obj_w   = ship->Location()   + ship->Heading() * 10e3;
		obj_w.y = ship->Location().y + 2e3;

		// transform into camera coords:
		objective = Transform(obj_w);
		ship->SetDirectorInfo(Game::GetText("ai.takeoff"));
		return;
	}

	// PART I: Find next NavPoint:
	if (ship->GetNavSystem())
	navpt = ship->GetNextNavPoint();

	complete = !navpt;
	if (complete) return;

	// PART II: Compute Objective from NavPoint:
	Point       npt = navpt->Location();
	Sim*        sim = Sim::GetSim();
	SimRegion*  self_rgn = ship->GetRegion();
	SimRegion*  nav_rgn = navpt->Region();

	if (self_rgn && !nav_rgn) {
		nav_rgn = self_rgn;
		navpt->SetRegion(nav_rgn);
	}

	if (self_rgn == nav_rgn) {
		if (farcaster) {
			if (farcaster->GetShip()->GetRegion() != self_rgn)
			farcaster = farcaster->GetDest()->GetFarcaster();

			obj_w = farcaster->EndPoint();
		}

		else {
			obj_w = npt.OtherHand();
		}

		// distance from self to navpt:
		distance = Point(obj_w - self->Location()).length();

		// transform into camera coords:
		objective = Transform(obj_w);

		if (!ship->IsStarship())
		objective.Normalize();

		if (farcaster && distance < 1000)
		farcaster = 0;
	}

	// PART III: Deal with orbital transitions:
	else if (ship->IsDropship()) {
		if (nav_rgn->GetOrbitalRegion()->Primary() ==
				self_rgn->GetOrbitalRegion()->Primary()) {

			Point npt = nav_rgn->Location() - self_rgn->Location();
			obj_w = npt.OtherHand();

			// distance from self to navpt:
			distance = Point(obj_w - ship->Location()).length();

			// transform into camera coords:
			objective = Transform(obj_w);

			if (nav_rgn->IsAirSpace()) {
				drop_state = -1;
			}
			else if (nav_rgn->IsOrbital()) {
				drop_state = 1;
			}
		}

		// PART IIIa: Deal with farcaster jumps:
		else if (nav_rgn->IsOrbital() && self_rgn->IsOrbital()) {
			ListIter<Ship> s = self_rgn->Ships();
			while (++s && !farcaster) {
				if (s->GetFarcaster()) {
					const Ship* dest = s->GetFarcaster()->GetDest();
					if (dest && dest->GetRegion() == nav_rgn) {
						farcaster = s->GetFarcaster();
					}
				}
			}

			if (farcaster) {
				Point apt   = farcaster->ApproachPoint(0);
				Point npt   = farcaster->StartPoint();
				double r1   = (ship->Location() - npt).length();

				if (r1 > 50e3) {
//.........这里部分代码省略.........
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:101,代码来源:NavAI.cpp


注:本文中的Point::OtherHand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。