void BMaxObject::GetLocalTransform(Matrix4* localTransform) { if (localTransform) { if (GetFacing() != 0) { ParaMatrixRotationY(localTransform, GetFacing()); } else *localTransform = Matrix4::IDENTITY; } }
void UnitTrackingMarker::AppendFacingMarker(VertexShape_2f_2f* vertices, BattleView* battleView) { if (_path.empty()) return; TerrainViewport* terrainViewport = &battleView->GetTerrainViewport(); float facing = GetFacing(); bounds2f b = battleView->GetUnitFacingMarkerBounds(_path.back(), facing); glm::vec2 p = b.mid(); float size = b.y().size(); float direction = facing - terrainViewport->GetCameraFacing(); if (terrainViewport->GetFlip()) direction += glm::pi<float>(); glm::vec2 d1 = size * vector2_from_angle(direction - glm::half_pi<float>() / 2.0f); glm::vec2 d2 = glm::vec2(d1.y, -d1.x); glm::vec2 d3 = glm::vec2(d2.y, -d2.x); glm::vec2 d4 = glm::vec2(d3.y, -d3.x); float tx1 = 0.125f; float tx2 = 0.125f + 0.125f; float ty1 = 0.75f; float ty2 = 0.75f + 0.125f; vertices->AddVertex(Vertex_2f_2f(terrainViewport->LocalToNormalized(p + d1), glm::vec2(tx1, ty1))); vertices->AddVertex(Vertex_2f_2f(terrainViewport->LocalToNormalized(p + d2), glm::vec2(tx1, ty2))); vertices->AddVertex(Vertex_2f_2f(terrainViewport->LocalToNormalized(p + d3), glm::vec2(tx2, ty2))); vertices->AddVertex(Vertex_2f_2f(terrainViewport->LocalToNormalized(p + d3), glm::vec2(tx2, ty2))); vertices->AddVertex(Vertex_2f_2f(terrainViewport->LocalToNormalized(p + d4), glm::vec2(tx2, ty1))); vertices->AddVertex(Vertex_2f_2f(terrainViewport->LocalToNormalized(p + d1), glm::vec2(tx1, ty1))); }
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::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)); } } }
void Pacman::Update(sf::Time elapsed, int ghostMode, sf::Color spriteColor) { if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) { if ((!map->isCollision(GetRow(), GetColumn() + 1) || !ColumnBoundary() || (GetColumn() >= 27 || GetColumn() < 0)) && RowBoundary()) { SetFacing(Pacman::RIGHT); } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) { if ((!map->isCollision(GetRow(), GetColumn() - 1) || !ColumnBoundary() || (GetColumn() - 1) < 0) && RowBoundary()) { SetFacing(Pacman::LEFT); } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) { if ((!map->isCollision(GetRow() + 1, GetColumn()) || !RowBoundary()) && ColumnBoundary()) { SetFacing(Pacman::DOWN); } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) { if ((!map->isCollision(GetRow() - 1, GetColumn()) || !RowBoundary()) && ColumnBoundary()) { SetFacing(Pacman::UP); } } timeBetweenMoves -= elapsed; if (timeBetweenMoves <= sf::Time::Zero) { if (GetFacing() == Pacman::RIGHT) { if (RowBoundary()) { if (!map->isCollision(GetRow(), GetColumn() + 1) || !ColumnBoundary() || (GetColumn() >= 27 || GetColumn() < 0)) { walk(map); } } } else if (GetFacing() == Pacman::LEFT) { if (RowBoundary()) { if (!map->isCollision(GetRow(), GetColumn() - 1) || !ColumnBoundary() || (GetColumn() - 1) < 0) { walk(map); } } } else if (GetFacing() == Pacman::DOWN) { if (ColumnBoundary()) { if (!map->isCollision(GetRow() + 1, GetColumn()) || !RowBoundary()) { walk(map); } } } else if (GetFacing() == Pacman::UP) { if (ColumnBoundary()) { std::cout << "row:" << RowBoundary() << std::endl; if (!map->isCollision(GetRow() - 1, GetColumn()) || !RowBoundary()) { walk(map); } } } timeBetweenMoves = sf::milliseconds(25); if (debug) { Debug(); } } }