void CFPSCameraController::UpdateCameraValues(CCamera *Camera) const
{
	Vect3f l_Direction = GetDirection();
	Camera->SetPosition(m_Position);
	Camera->SetLookAt(m_Position + l_Direction);
	Camera->SetUp(GetUp());
	Camera->SetMatrixs();
}
Example #2
0
void Epsilon5Tests::GetDirectionTests() {
    {
        QPointF a(0, 0);
        QPointF b(1, 0);
        QCOMPARE(GetDirection(a, b), QPointF(1, 0));
    }
    {
        QPointF a(2, 1);
        QPointF b(1, 1);
        QCOMPARE(GetDirection(a, b), QPointF(-1, 0));
    }
    {
        QPointF a(-2, 0);
        QPointF b(-3, 0);
        QCOMPARE(GetDirection(a, b), QPointF(-1, 0));
    }
}
Example #3
0
	const Math::vec3 Source::GetDirection() const
	{
	    #ifdef HAS_AUDIO_SOURCE
		return impl->GetDirection();
		#else
		throw System::PunkException(L"Audio source is not available");
		#endif
	}
Example #4
0
File: ray.cpp Project: JT-a/USD
bool
GfRay::Intersect(const GfRange3d &box,
		 double *enterDistance, double *exitDistance) const
{
    if (box.IsEmpty())
	return false;

    // Compute the intersection distance of all 6 planes of the
    // box. Save the largest near-plane intersection and the smallest
    // far-plane intersection.
    double maxNearest = -DBL_MAX, minFarthest = DBL_MAX;
    for (size_t i = 0; i < 3; i++) {

        // Skip dimensions almost parallel to the ray.
        double d = GetDirection()[i];
        if (GfAbs(d) < GF_MIN_VECTOR_LENGTH) {
            // ray is parallel to this set of planes.
            // If origin is not between them, no intersection.
            if (GetStartPoint()[i] < box.GetMin()[i] ||
                GetStartPoint()[i] > box.GetMax()[i]) {
                return false;
            } else {
                continue;
            }
        }

        d = 1.0 / d;
        double t1 = d * (box.GetMin()[i] - GetStartPoint()[i]);
        double t2 = d * (box.GetMax()[i] - GetStartPoint()[i]);

        // Make sure t1 is the nearer one
        if (t1 > t2) {
            double tmp = t1;
            t1 = t2;
            t2 = tmp;
        }

        // Update the min and max
        if (t1 > maxNearest)
            maxNearest = t1;
        if (t2 < minFarthest)
            minFarthest = t2;
    }

    // If the largest near-plane intersection is after the smallest
    // far-plane intersection, the ray's line misses the box. Also
    // check if both intersections are completely outside the near/far
    // bounds.
    if (maxNearest  >  minFarthest ||
        minFarthest < 0.0)
        return false;
        
    if (enterDistance)
	*enterDistance = maxNearest;
    if (exitDistance)
        *exitDistance = minFarthest;
    return true;
}
Example #5
0
bool Game_Player::CheckEventTriggerThere(const std::vector<int>& triggers, bool triggered_by_decision_key) {
	if ( Game_Map::GetInterpreter().IsRunning() ) return false;

	bool result = false;

	int front_x = Game_Map::XwithDirection(GetX(), GetDirection());
	int front_y = Game_Map::YwithDirection(GetY(), GetDirection());

	std::vector<Game_Event*> events;
	Game_Map::GetEventsXY(events, front_x, front_y);

	for (const auto& ev : events) {
		if ( ev->GetLayer() == RPG::EventPage::Layers_same &&
			std::find(triggers.begin(), triggers.end(), ev->GetTrigger() ) != triggers.end()
		)
		{
			if (!ev->GetList().empty()) {
				ev->StartTalkToHero();
			}
			ev->Start(triggered_by_decision_key);
			result = true;
		}
	}

	if ( !result && Game_Map::IsCounter(front_x, front_y) ) {
		front_x = Game_Map::XwithDirection(front_x, GetDirection());
		front_y = Game_Map::YwithDirection(front_y, GetDirection());

		Game_Map::GetEventsXY(events, front_x, front_y);

		for (const auto& ev : events) {
			if ( ev->GetLayer() == 1 &&
				std::find(triggers.begin(), triggers.end(), ev->GetTrigger() ) != triggers.end()
			)
			{
				if (!ev->GetList().empty()) {
					ev->StartTalkToHero();
				}
				ev->Start(triggered_by_decision_key);
				result = true;
			}
		}
	}
	return result;
}
Example #6
0
//=============================================================================
// GetDirection - need the startPoint
//=============================================================================
StatusCode HTBlob::GetDirection( Minerva::IDBlob *idBlob ) const
{
    debug() << " HTtool::GetDirection " << endmsg;

    Gaudi::XYZPoint vertex = idBlob->startPoint();
    GetDirection( idBlob, vertex );
    return StatusCode::SUCCESS;

}
Example #7
0
void UNIT::MoveUnit(INTPOINT to)
{
	m_lastWP = m_pTerrain->GetWorldPos(m_mappos);
	m_rotation = GetDirection(m_mappos, to);

	m_mappos = to;		//New mappos
	m_movePrc = 0.0f;
	m_nextWP = m_pTerrain->GetWorldPos(m_mappos);
}
Example #8
0
void clSpaceShip::Fire()
{
	if ( m_FireTime > 0.0f ) { return; }

	const float FireCooldown = 1.0f; // seconds

	m_FireTime = FireCooldown;

	g_Game->FireRocket( m_Pos, m_Vel * Math::RandomInRange( 1.1f, 1.5f ) + GetDirection() );
}
Example #9
0
static int ResGetKeyVal(int num, USHORT id)
{
    int val;
    char *res = lib_msprintf("KeySet%d%s", num ? 1 : 2, GetDirection(id));

    resources_get_int(res, &val);
    lib_free (res);

    return val;
}
Example #10
0
bool Game_Player::GetOffVehicle() {
	if (!InAirship()) {
		int front_x = Game_Map::XwithDirection(GetX(), GetDirection());
		int front_y = Game_Map::YwithDirection(GetY(), GetDirection());
		if (!CanWalk(front_x, front_y))
			return false;
	}

	GetVehicle()->GetOff();
	if (!InAirship()) {
		location.unboarding = true;
		Unboard();
		through = true;
		MoveForward();
		through = false;
	}

	return true;
}
Example #11
0
    void SegmentShape2D::SetDirection(Vector2 value)
    {
        if (value != Vector2::Zero)
            value.Normalize();

        if (GetDirection() != value)
        {
            direction = value;
            revision = -1;
        }
    }
Example #12
0
void Game_Event::Setup(RPG::EventPage* new_page) {
	page = new_page;

	// Free resources if needed
	if (interpreter) {
		interpreter->Clear();
		Game_Map::ReserveInterpreterDeletion(interpreter);
		interpreter.reset();
	}

	if (page == NULL) {
		tile_id = 0;
		SetSpriteName("");
		SetSpriteIndex(0);
		SetDirection(RPG::EventPage::Direction_down);
		//move_type = 0;
		trigger = -1;
		list.clear();
		return;
	}
	SetSpriteName(page->character_name);
	SetSpriteIndex(page->character_index);

	tile_id = page->character_name.empty() ? page->character_index : 0;

	if (GetDirection() != page->character_direction) {
		SetDirection(page->character_direction);
		SetSpriteDirection(page->character_direction);
	}

	if (original_pattern != page->character_pattern) {
		pattern = page->character_pattern;
		original_pattern = pattern;
	}
	
	move_type = page->move_type;
	SetMoveSpeed(page->move_speed);
	SetMoveFrequency(page->move_frequency);
	max_stop_count = (GetMoveFrequency() > 7) ? 0 : pow(2.0, 8 - GetMoveFrequency());
	original_move_frequency = page->move_frequency;
	original_move_route = page->move_route;
	SetOriginalMoveRouteIndex(0);
	animation_type = page->animation_type;
	SetOpacity(page->translucent ? 160 : 255);

	SetLayer(page->layer);
	trigger = page->trigger;
	list = page->event_commands;

	if (trigger == RPG::EventPage::Trigger_parallel) {
		interpreter.reset(new Game_Interpreter_Map());
	}
	CheckEventTriggerAuto();
}
void CSphericalCameraController::SetCamera(CCamera *Camera) const
{
	Vect3f l_Direction = GetDirection();

	Camera->SetLookAt(m_Position);

	Camera->SetPosition(m_Position-l_Direction);

	Camera->SetUp(GetUp());
	Camera->SetMatrixs();
}
Example #14
0
bool ZActor::CanSee(ZObject* pTarget)
{
	rvector vTargetDir = pTarget->GetPosition() - GetPosition();
	rvector vBodyDir = GetDirection();
	vBodyDir.z = vTargetDir.z = 0.0f;

	float angle = fabs(GetAngleOfVectors(vTargetDir, vBodyDir));
	if (angle <= m_pNPCInfo->fViewAngle) return true;

	return false;
}
Example #15
0
bool CCar::TurnEngineOff()
{
	bool isOnNeutralGear = (m_gear == CCar::Gear::Neutral);
	bool isOnZeroSpeed = (GetDirection() == CCar::Direction::StandStill);
	if (m_isEngineOn && isOnNeutralGear && isOnZeroSpeed)
	{
		m_isEngineOn = false;
		return true;
	}
	return false;
}
FSphere USpotLightComponent::GetBoundingSphere() const
{
	float ClampedInnerConeAngle = FMath::Clamp(InnerConeAngle,0.0f,89.0f) * (float)PI / 180.0f;
	float ClampedOuterConeAngle = FMath::Clamp(OuterConeAngle * (float)PI / 180.0f,ClampedInnerConeAngle + 0.001f,89.0f * (float)PI / 180.0f + 0.001f);

	float CosOuterCone = FMath::Cos(ClampedOuterConeAngle);

	// Use the law of cosines to find the distance to the furthest edge of the spotlight cone from a position that is halfway down the spotlight direction
	const float BoundsRadius = FMath::Sqrt(1.25f * AttenuationRadius * AttenuationRadius - AttenuationRadius * AttenuationRadius * CosOuterCone);
	return FSphere(ComponentToWorld.GetLocation() + .5f * GetDirection() * AttenuationRadius, BoundsRadius);
}
Example #17
0
func FxIntTurnStart(pTarget, effect, fTmp)
{
	if(fTmp) return;
	effect.dir = GetDirection();
	var iTurnPos = 0;
	if(effect.dir == COMD_Right) iTurnPos = 1;

	effect.curr_rot = 24;
	effect.rot = 25;
	effect.turn_type = -1;
	SetTurnType(0);
}
Example #18
0
char M::SearchPathForAnt(Ant* ant, Bot* bot)
{			
	vector<Cell> closedCells, openCells, neighborCells;
	Cell start;	
	start.col = ant->location.col;
	start.row = ant->location.row;
	start.gScore = 0;
	start.hScore = GetDirectDistance(ant->location.row, ant->location.col, ant->destination.row, ant->destination.col);
	start.fScore = start.gScore + start.hScore;
	openCells.push_back(start);	
	while(!openCells.empty())
	{
		vector<Cell>::iterator cellIt = openCells.begin();
		for(auto it = openCells.begin(); it != openCells.end(); it++)
			if ((*it).fScore <= cellIt->fScore)
				cellIt = it;
		Cell *cell = new Cell((*cellIt).row, (*cellIt).col, (*cellIt).gScore,(*cellIt).hScore, 
							  (*cellIt).fScore, (*cellIt).parent);		
		if (SearchPathIsComplete(cell, ant) || cell->gScore > DIST_TO_TARGET)
		{
			Cell *currentCell = cell;	
			if(cell->gScore > DIST_TO_TARGET)
			{
				ant->destination.row = cell->row;
				ant->destination.col = cell->col;
			}
			if(currentCell->parent)
			while(currentCell->parent->parent != NULL)
			{
				currentCell = currentCell->parent;
			}				
			ant->direction = GetDirection(currentCell->row, currentCell->col, ant->location.row, ant->location.col);
			return ant->direction;			
		}
		closedCells.push_back(*cell);
		openCells.erase(cellIt);
		GetNeighborCells(cell, &neighborCells, bot->water);		
		for (auto it = neighborCells.begin(); it != neighborCells.end(); it++)
		{
			if (find(closedCells.begin(), closedCells.end(), *it) != closedCells.end())
				continue;
			int neighborGScore = cell->gScore + GetDistance(cell->row, cell->col, (*it).row, (*it).col);
			if(find(openCells.begin(), openCells.end(), *it) == openCells.end())
			{
				int gScore = neighborGScore;
				float hScore = (*it).hScore = 
					GetDirectDistance((*it).row, (*it).col, ant->destination.row, ant->destination.col);
				float fScore = neighborGScore + hScore;
				openCells.push_back(Cell((*it).row, (*it).col, gScore, hScore, fScore, cell));
			}	
		}		
	}
}
Example #19
0
wxObject * MaxBannerWindowXmlHandler::DoCreateResource()
{
    XRC_MAKE_INSTANCE(banner, MaxBannerWindow)

    banner->Create(m_parentAsWindow,
                   GetID(),
                   GetDirection(wxS("direction")),
                   GetPosition(),
                   GetSize(),
                   GetStyle(wxS("style")),
                   GetName());

	banner->MaxBind(CB_PREF(wx_wxbannerwindow_wxBannerWindow__xrcNew)(banner));

    SetupWindow(banner);

    const wxColour colStart = GetColour(wxS("gradient-start"));
    const wxColour colEnd = GetColour(wxS("gradient-end"));
    if ( colStart.IsOk() || colEnd.IsOk() )
    {
        if ( !colStart.IsOk() || !colEnd.IsOk() )
        {
            ReportError
            (
                "Both start and end gradient colours must be "
                "specified if either one is."
            );
        }
        else
        {
            banner->SetGradient(colStart, colEnd);
        }
    }

    wxBitmap bitmap = GetBitmap();
    if ( bitmap.IsOk() )
    {
        if ( colStart.IsOk() || colEnd.IsOk() )
        {
            ReportError
            (
                "Gradient colours are ignored by wxBannerWindow "
                "if the background bitmap is specified."
            );
        }

        banner->SetBitmap(bitmap);
    }

    banner->SetText(GetText(wxS("title")), GetText(wxS("message")));

    return banner;
}
Example #20
0
void ZActor::PostBasicInfo()
{
	DWORD nNowTime = GetGlobalTimeMS();
	if (GetInitialized() == false) return;

	if(IsDie() && ZGetGame()->GetTime() - GetDeadTime()>5.f) return;
	int nMoveTick = (ZGetGameClient()->GetAllowTunneling() == false) ? PEERMOVE_TICK : PEERMOVE_AGENT_TICK;

	if ((int)(nNowTime - m_nLastTime[ACTOR_LASTTIME_BASICINFO]) >= nMoveTick)
	{
		m_nLastTime[ACTOR_LASTTIME_BASICINFO] = nNowTime;

		ZACTOR_BASICINFO pbi;
		pbi.fTime = ZGetGame()->GetTime();
		pbi.uidNPC = GetUID();

		pbi.posx = m_Position.x;
		pbi.posy = m_Position.y;
		pbi.posz = m_Position.z;

		pbi.velx = GetVelocity().x;
		pbi.vely = GetVelocity().y;
		pbi.velz = GetVelocity().z;

		pbi.dirx = GetDirection().x*32000.0f;
		pbi.diry = GetDirection().y*32000.0f;
		pbi.dirz = GetDirection().z*32000.0f;

		pbi.anistate = GetCurrAni();

		ZPOSTCMD1(MC_QUEST_PEER_NPC_BASICINFO, MCommandParameterBlob(&pbi,sizeof(ZACTOR_BASICINFO)));

		ZBasicInfoItem Item;
		Item.info.position = m_Position;
		Item.info.direction = GetDirection();
		Item.info.velocity = GetVelocity();
		Item.fSendTime = Item.fReceivedTime = ZGetGame()->GetTime();
		AddToHistory(Item);
	}
}
Example #21
0
bool BattleSquad::move(int tgx, int tgy, unsigned int &eventflag, bool costap)
{
	MapDataManager* mapdatamanager = MapDataManager::getSingletonPtr();
	if(mapdatamanager->getPassable(tgx, tgy, getFaction()))
	{
		float mapapcost = 0.0f;
		if(getHorseId() != "none")
			mapapcost = mapdatamanager->getCavApCost(tgx, tgy, getFaction());
		else
			mapapcost = mapdatamanager->getInfApCost(tgx, tgy, getFaction());

		LuaTempContext* luatempcontext = new LuaTempContext();
		luatempcontext->strMap["squadid"] = getSquadId();
		luatempcontext->intMap["srcx"] = getGridX();
		luatempcontext->intMap["srcy"] = getGridY();
		luatempcontext->intMap["tgtx"] = tgx;
		luatempcontext->intMap["tgty"] = tgy;
		luatempcontext->floatMap["apcost"] = mapapcost;
		Trigger("MoveTo", luatempcontext);
		mapdatamanager->Trigger("MoveTo", luatempcontext);
		mapapcost = luatempcontext->floatMap["apcost"];
		delete luatempcontext;

		if(costap)
		{
			float ap = getActionPoint();
			if(mapapcost <= ap)
			{
				ap -= mapapcost;
				setActionPoint(ap);
				if(mapapcost <= 2)
				{
					eventflag |= MOVEEVENT_CHARGE;
					int curdir = GetDirection(getGridX(), getGridY(), tgx, tgy);
					eventflag &= 0x03f;
					eventflag |= SetChargeDir(curdir);
				}
				else
				{
					eventflag &= ~MOVEEVENT_CHARGE;
				}
				return true;
			}
		}
		else
		{
			return true;
		}
	}
	eventflag |= MOVEEVENT_WRONG;
	return false;
}
void CSphericalCameraController::SetCamera(CCamera *Camera) const
{
	Vect3f l_Direction = GetDirection();

	Camera->SetFOV(DEG2RAD(50.0f));
	Camera->SetAspectRatio(16.0f/9.0f);
	Camera->SetLookAt(m_Position);

	Camera->SetPosition(m_Position-l_Direction);

	Camera->SetUp(GetUp());
	Camera->SetMatrixs();
}
Example #23
0
void Projectile::Update(float dt)
{
  if (position_.x < point_attack_.x )
     SetDirection (EActorDirection::EAST);
  if (position_.x > point_attack_.x )
     SetDirection (EActorDirection::WEST);
  if (position_.y < point_attack_.y )
     SetDirection (EActorDirection::NORTH);
  if (position_.y > point_attack_.y )
    SetDirection (EActorDirection::SOUTH);
  SetVelocity (directionToVector[static_cast<unsigned>(GetDirection())]);
  position_ +=  velocity_*dt;
}
Example #24
0
bool CCar::SetGear(CCar::Gear gear)
{
	if (gear == m_gear)
	{
		return true;
	}

	if (gear == CCar::Gear::Rear)
	{
		if ((m_gear != CCar::Gear::Neutral) && (m_gear != CCar::Gear::First))
		{
			throw std::exception("Cannot set rear gear from this gear");
			return false;
		}
		if (GetDirection() != CCar::Direction::StandStill)
		{
			throw std::exception("Cannot set rear gear at nonzero speed");
			return false;
		}
	}

	if ((gear == CCar::Gear::First) && (m_gear == CCar::Gear::Rear))
	{
		if (GetDirection() != CCar::Direction::StandStill)
		{
			throw std::exception("Cannot set first gear from rear gear at nonzero speed");
			return false;
		}
	}

	if ((m_speed < gearSpeedRange.at(gear).min) || (m_speed > gearSpeedRange.at(gear).max))
	{
		throw std::exception("Cannot set this gear at this speed");
		return false;
	}

	m_gear = gear;
	return true;
}
Example #25
0
void Game_Event::Setup(RPG::EventPage* new_page) {
	page = new_page;

	if (page == NULL) {
		tile_id = 0;
		SetSpriteName("");
		SetSpriteIndex(0);
		SetDirection(RPG::EventPage::Direction_down);
		//move_type = 0;
		through = true;
		trigger = -1;
		list.clear();
		interpreter.reset();
		return;
	}
	SetSpriteName(page->character_name);
	SetSpriteIndex(page->character_index);

	tile_id = page->character_name.empty() ? page->character_index : 0;

	if (GetDirection() != page->character_direction) {
		SetDirection(page->character_direction);
		SetPrelockDirection(page->character_direction);
	}

	if (original_pattern != page->character_pattern) {
		pattern = page->character_pattern;
		original_pattern = pattern;
	}
	//opacity = page.opacity;
	//opacity = page.translucent ? 192 : 255;
	//blend_type = page.blend_type;
	move_type = page->move_type;
	SetMoveSpeed(page->move_speed);
	SetMoveFrequency(page->move_frequency);
	original_move_route = page->move_route;
	SetOriginalMoveRouteIndex(0);
	animation_type = page->animation_type;

	SetLayer(page->layer);
	trigger = page->trigger;
	list = page->event_commands;
	through = false;

	// Free resources if needed
	interpreter.reset();
	if (trigger == RPG::EventPage::Trigger_parallel) {
		interpreter.reset(new Game_Interpreter_Map());
	}
	CheckEventTriggerAuto();
}
Example #26
0
void Player::Draw() {
  TexCoords tc = Engine::Get().Scripts()->GetPlayerSprite(GetType(), 
                                                          GetDirection(), 
                                                          IsDying(), 
                                                          SDL_GetTicks() - m_current_action_start_time);

//   std::cerr << "type = " << GetType() << ", direction = " << GetDirection().x() << ", " << GetDirection().y()
// 	    << ", is dying = " << IsDying() << "dt = " << SDL_GetTicks() - m_current_action_start_time << "\n";
//   std::cerr << "tc = " << tc.left << ", " << tc.bottom << ", " << tc.width << ", " << tc.height << "\n";

  Engine::Get().Renderer()->DrawSprite(tc, GetPosition());
  if (g_render_aabbs)
    Engine::Get().Renderer()->DrawAABB(GetAABB());
}
Example #27
0
int Game_Character::GetRealY() const {
	int y = GetY() * SCREEN_TILE_WIDTH;

	if (IsMoving()) {
		int d = GetDirection();
		if (d == Down || d == DownRight || d == DownLeft)
			y -= remaining_step;
		else if (d == Up || d == UpRight || d == UpLeft)
			y += remaining_step;
	} else if (IsJumping())
		y -= (GetY() - jump_y) * remaining_step;

	return y;
}
Example #28
0
int Game_Character::GetRealX() const {
	int x = GetX() * SCREEN_TILE_WIDTH;

	if (IsMoving()) {
		int d = GetDirection();
		if (d == Right || d == UpRight || d == DownRight)
			x -= remaining_step;
		else if (d == Left || d == UpLeft || d == DownLeft)
			x += remaining_step;
	} else if (IsJumping())
		x -= ((GetX() - jump_x) * remaining_step);

	return x;
}
Example #29
0
//! Updates the view matrix.
void Camera::UpdateViewMatrix()
{
    // Update the right vector.
    XMVECTOR up = XMLoadFloat3(&mUp);
    XMVECTOR dir = XMLoadFloat3(&GetDirection());
    XMVECTOR right = XMVector3Cross(up, dir);
    right = XMVector3Normalize(right);
    XMStoreFloat3(&mRight, right);

    // Update the view matrix
    XMVECTOR pos = XMLoadFloat3(&mPosition);
    XMVECTOR target = XMLoadFloat3(&mTarget);
    XMStoreFloat4x4(&mView, XMMatrixLookAtLH(pos, target, up));
}
Example #30
0
FReply SGraphPin::OnPinNameMouseDown( const FGeometry& SenderGeometry, const FPointerEvent& MouseEvent )
{
	const float LocalX = SenderGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() ).X;

	if ((GetDirection() == EGPD_Input) || (LocalX > SenderGeometry.GetDrawSize().X * 0.5f))
	{
		// Right half of the output pin or all of the input pin, treat it like a connection attempt
		return OnPinMouseDown(SenderGeometry, MouseEvent);
	}
	else
	{
		return FReply::Unhandled();
	}
}