void UnitTrackingMarker::RenderTrackingFighters(VertexShape_3f_4f_1f* vertices) { if (!_meleeTarget && !_missileTarget) { bool isBlue = _unit->GetTeam() == _battleView->GetCommander()->GetTeam(); glm::vec4 color = isBlue ? glm::vec4(0, 0, 255, 16) / 255.0f : glm::vec4(255, 0, 0, 16) / 255.0f; glm::vec2 destination = DestinationXXX(); //glm::vec2 orientation = _missileTarget ? _missileTarget->state.center : _orientation; BattleObjects::Formation formation = _unit->GetFormation(); formation.SetDirection(GetFacing()); glm::vec2 frontLeft = formation.GetFrontLeft(destination); int count = _unit->GetFighterCount(); for (int index = 0; index < count; ++index) { BattleObjects::FighterAssignment assignment = _unit->GetFighterAssignment(index); glm::vec2 offsetRight = formation.towardRight * (float)assignment.file; glm::vec2 offsetBack = formation.towardBack * (float)assignment.rank; glm::vec3 p = _battleView->GetBattleSimulator()->GetBattleMap()->GetHeightMap()->GetPosition(frontLeft + offsetRight + offsetBack, 0.5); vertices->AddVertex(Vertex_3f_4f_1f(p, color, 3.0)); } } }
void UnitTrackingMarker::RenderTrackingShadow(BillboardTextureShape* renderer) { glm::vec2 destination = DestinationXXX(); glm::vec3 position = _battleView->GetBattleSimulator()->GetBattleMap()->GetHeightMap()->GetPosition(destination, 0); renderer->AddBillboard(position, 32, affine2(glm::vec2(0, 0), glm::vec2(1, 1))); }
void UnitTrackingMarker::RenderTrackingMarker(BillboardTextureShape* renderer) { if (_meleeTarget == nullptr) { glm::vec2 destination = DestinationXXX(); glm::vec3 position = _battleView->GetBattleSimulator()->GetBattleMap()->GetHeightMap()->GetPosition(destination, 0); glm::vec2 texsize(0.1875, 0.1875); // 48 / 256 glm::vec2 texcoord = texsize * glm::vec2(_unit->GetTeam() == _battleView->GetCommander()->GetTeam() ? 2 : 0, 2); renderer->AddBillboard(position, 32, affine2(texcoord, texcoord + texsize)); } }
void UnitTrackingMarker::RenderTrackingFighters(VertexShape_3f_4f_1f* vertices) { if (!_meleeTarget && !_missileTarget) { bool isBlue = _unit->commander->GetTeam() == _battleView->GetCommander()->GetTeam(); glm::vec4 color = isBlue ? glm::vec4(0, 0, 255, 16) / 255.0f : glm::vec4(255, 0, 0, 16) / 255.0f; glm::vec2 destination = DestinationXXX(); //glm::vec2 orientation = _missileTarget ? _missileTarget->state.center : _orientation; Formation formation = _unit->formation; formation.SetDirection(GetFacing()); glm::vec2 frontLeft = formation.GetFrontLeft(destination); for (Fighter* fighter = _unit->fighters, * end = fighter + _unit->fightersCount; fighter != end; ++fighter) { glm::vec2 offsetRight = formation.towardRight * (float)Unit::GetFighterFile(fighter); glm::vec2 offsetBack = formation.towardBack * (float)Unit::GetFighterRank(fighter); glm::vec3 p = _battleView->GetSimulator()->GetBattleMap()->GetHeightMap()->GetPosition(frontLeft + offsetRight + offsetBack, 0.5); vertices->AddVertex(Vertex_3f_4f_1f(p, color, 3.0)); } } }
float UnitTrackingMarker::GetFacing() const { glm::vec2 orientation = _missileTarget ? _missileTarget->GetCenter() : _orientation; return angle(orientation - DestinationXXX()); }