123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- /*
- * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
- * its licensors.
- *
- * For complete copyright and license terms please see the LICENSE at the root of this
- * distribution (the "License"). All use of this software is governed by the License,
- * or, if provided, by the license below or the license accompanying this file. Do not
- * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- */
- #include <AuxGeomExampleComponent.h>
- #include <Atom/Component/DebugCamera/NoClipControllerComponent.h>
- #include <Atom/RPI.Public/AuxGeom/AuxGeomFeatureProcessorInterface.h>
- #include <Atom/RPI.Public/AuxGeom/AuxGeomDraw.h>
- #include <AzCore/Component/Entity.h>
- #include <AzCore/Math/Matrix3x3.h>
- #include <AzFramework/Components/TransformComponent.h>
- #include <AzFramework/Components/CameraBus.h>
- #include <SampleComponentManager.h>
- #include <SampleComponentConfig.h>
- #include <AuxGeomSharedDrawFunctions.h>
- #include <RHI/BasicRHIComponent.h>
- namespace AtomSampleViewer
- {
- void AuxGeomExampleComponent::Reflect(AZ::ReflectContext* context)
- {
- if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
- {
- serializeContext->Class<AuxGeomExampleComponent, AZ::Component>()
- ->Version(0)
- ;
- }
- }
- AuxGeomExampleComponent::AuxGeomExampleComponent()
- {
- }
- void AuxGeomExampleComponent::LoadConfigFiles()
- {
- }
- void AuxGeomExampleComponent::Activate()
- {
- AZ::Debug::CameraControllerRequestBus::Event(GetCameraEntityId(), &AZ::Debug::CameraControllerRequestBus::Events::Enable,
- azrtti_typeid<AZ::Debug::NoClipControllerComponent>());
- Camera::CameraRequestBus::Event(GetCameraEntityId(),
- &Camera::CameraRequestBus::Events::SetFarClipDistance,
- 200.f);
- m_imguiSidebar.Activate();
- AZ::TickBus::Handler::BusConnect();
- }
- void AuxGeomExampleComponent::Deactivate()
- {
- AZ::TickBus::Handler::BusDisconnect();
- m_imguiSidebar.Deactivate();
- AZ::Debug::CameraControllerRequestBus::Event(GetCameraEntityId(), &AZ::Debug::CameraControllerRequestBus::Events::Disable);
- }
-
- void AuxGeomExampleComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
- {
- if (m_imguiSidebar.Begin())
- {
- ImGui::Text("Draw Options");
- if (ScriptableImGui::Button("Select All"))
- {
- m_drawBackgroundBox = true;
- m_drawThreeGridsOfPoints = true;
- m_drawAxisLines = true;
- m_drawLines = true;
- m_drawTriangles = true;
- m_drawShapes = true;
- m_drawBoxes = true;
- m_drawManyPrimitives = true;
- m_drawDepthTestPrimitives = true;
- m_draw2DWireRect = true;
- }
- if (ScriptableImGui::Button("Unselect All"))
- {
- m_drawBackgroundBox = false;
- m_drawThreeGridsOfPoints = false;
- m_drawAxisLines = false;
- m_drawLines = false;
- m_drawTriangles = false;
- m_drawShapes = false;
- m_drawBoxes = false;
- m_drawManyPrimitives = false;
- m_drawDepthTestPrimitives = false;
- m_draw2DWireRect = false;
- }
- ImGui::Indent();
- ScriptableImGui::Checkbox("Draw background box", &m_drawBackgroundBox);
- ScriptableImGui::Checkbox("Draw three grids of points", &m_drawThreeGridsOfPoints);
- ScriptableImGui::Checkbox("Draw axis lines", &m_drawAxisLines);
- ScriptableImGui::Checkbox("Draw lines", &m_drawLines);
- ScriptableImGui::Checkbox("Draw triangles", &m_drawTriangles);
- ScriptableImGui::Checkbox("Draw shapex", &m_drawShapes);
- ScriptableImGui::Checkbox("Draw boxes", &m_drawBoxes);
- ScriptableImGui::Checkbox("Draw many primitives", &m_drawManyPrimitives);
- ScriptableImGui::Checkbox("Draw depth test primitives", &m_drawDepthTestPrimitives);
- ScriptableImGui::Checkbox("Draw 2d wire rect", &m_draw2DWireRect);
- ImGui::Unindent();
- m_imguiSidebar.End();
- }
- // Currently this does this one thing, the intention is that this sample has a sidebar to allow selection of different
- // examples/tests
- DrawSampleOfAllAuxGeom();
- }
- void AuxGeomExampleComponent::DrawSampleOfAllAuxGeom() const
- {
- auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene();
- if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene))
- {
- if (m_drawBackgroundBox)
- {
- DrawBackgroundBox(auxGeom);
- }
- if (m_drawThreeGridsOfPoints)
- {
- DrawThreeGridsOfPoints(auxGeom);
- }
- if (m_drawAxisLines)
- {
- DrawAxisLines(auxGeom);
- }
- if (m_drawLines)
- {
- DrawLines(auxGeom);
- }
- if (m_drawTriangles)
- {
- DrawTriangles(auxGeom);
- }
- if (m_drawShapes)
- {
- DrawShapes(auxGeom);
- }
- if (m_drawBoxes)
- {
- DrawBoxes(auxGeom);
- }
- if (m_drawManyPrimitives)
- {
- DrawManyPrimitives(auxGeom);
- }
- if (m_drawDepthTestPrimitives)
- {
- DrawDepthTestPrimitives(auxGeom);
- }
- if (m_draw2DWireRect)
- {
- Draw2DWireRect(auxGeom, AZ::Colors::Red, 1.0f);
- }
- }
- }
- } // namespace AtomSampleViewer
|