| 760 | } |
| 761 | |
| 762 | void SpacebattleExample::CreateTurret() |
| 763 | { |
| 764 | // Fixed base |
| 765 | m_turret.baseEntity = m_shared.world3D->CreateEntity(); |
| 766 | RegisterEntity(m_turret.baseEntity); |
| 767 | |
| 768 | Ndk::NodeComponent& baseNode = m_turret.baseEntity->AddComponent<Ndk::NodeComponent>(); |
| 769 | //baseNode.SetParent(m_spacestationEntity); |
| 770 | baseNode.SetRotation(Nz::EulerAnglesf(0.f, 180.f, 0.f)); |
| 771 | |
| 772 | Ndk::GraphicsComponent& baseGfx = m_turret.baseEntity->AddComponent<Ndk::GraphicsComponent>(); |
| 773 | baseGfx.Attach(&m_turret.baseModel); |
| 774 | |
| 775 | // Rotating base |
| 776 | m_turret.rotatingBaseEntity = m_shared.world3D->CreateEntity(); |
| 777 | RegisterEntity(m_turret.rotatingBaseEntity); |
| 778 | |
| 779 | Ndk::NodeComponent& rotatingBaseNode = m_turret.rotatingBaseEntity->AddComponent<Ndk::NodeComponent>(); |
| 780 | rotatingBaseNode.SetParent(m_turret.baseEntity); |
| 781 | |
| 782 | Ndk::GraphicsComponent& rotatingBaseGfx = m_turret.rotatingBaseEntity->AddComponent<Ndk::GraphicsComponent>(); |
| 783 | rotatingBaseGfx.Attach(&m_turret.rotatingBaseModel); |
| 784 | |
| 785 | // Cannon base |
| 786 | m_turret.cannonBaseEntity = m_shared.world3D->CreateEntity(); |
| 787 | RegisterEntity(m_turret.cannonBaseEntity); |
| 788 | |
| 789 | Ndk::NodeComponent& cannonBaseNode = m_turret.cannonBaseEntity->AddComponent<Ndk::NodeComponent>(); |
| 790 | cannonBaseNode.SetPosition({0.f, 3.39623547f, 0.f}); |
| 791 | cannonBaseNode.SetParent(m_turret.rotatingBaseEntity); |
| 792 | |
| 793 | Ndk::GraphicsComponent& cannonBaseGfx = m_turret.cannonBaseEntity->AddComponent<Ndk::GraphicsComponent>(); |
| 794 | cannonBaseGfx.Attach(&m_turret.cannonBaseModel); |
| 795 | |
| 796 | // Cannon anchor |
| 797 | m_turret.cannonAnchorEntity = m_shared.world3D->CreateEntity(); |
| 798 | RegisterEntity(m_turret.cannonAnchorEntity); |
| 799 | |
| 800 | Ndk::NodeComponent& cannonAnchorNode = m_turret.cannonAnchorEntity->AddComponent<Ndk::NodeComponent>(); |
| 801 | cannonAnchorNode.SetPosition({0.f, 2.96482944f, 3.20705462f}); |
| 802 | cannonAnchorNode.SetParent(m_turret.cannonBaseEntity); |
| 803 | |
| 804 | // Cannon |
| 805 | m_turret.cannonEntity = m_shared.world3D->CreateEntity(); |
| 806 | RegisterEntity(m_turret.cannonEntity); |
| 807 | |
| 808 | Ndk::NodeComponent& cannonNode = m_turret.cannonEntity->AddComponent<Ndk::NodeComponent>(); |
| 809 | cannonNode.SetParent(m_turret.cannonAnchorEntity); |
| 810 | cannonNode.SetRotation(Nz::EulerAnglesf(0.f, 180.f, 0.f)); |
| 811 | |
| 812 | Ndk::GraphicsComponent& cannonGfx = m_turret.cannonEntity->AddComponent<Ndk::GraphicsComponent>(); |
| 813 | cannonGfx.Attach(&m_turret.cannonModel); |
| 814 | } |
| 815 | |
| 816 | void SpacebattleExample::OnMouseMoved(const Nz::EventHandler* /*eventHandler*/, const Nz::WindowEvent::MouseMoveEvent& event) |
| 817 | { |
nothing calls this directly
no test coverage detected