TargetActor.cpp 895 B

123456789101112131415161718192021222324252627282930
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #include "TargetActor.h"
  9. #include "Game.h"
  10. #include "Renderer.h"
  11. #include "MeshComponent.h"
  12. #include "BoxComponent.h"
  13. #include "Mesh.h"
  14. #include "TargetComponent.h"
  15. TargetActor::TargetActor(Game* game)
  16. :Actor(game)
  17. {
  18. //SetScale(10.0f);
  19. SetRotation(Quaternion(Vector3::UnitZ, Math::Pi));
  20. MeshComponent* mc = new MeshComponent(this);
  21. Mesh* mesh = GetGame()->GetRenderer()->GetMesh("Assets/Target.gpmesh");
  22. mc->SetMesh(mesh);
  23. // Add collision box
  24. BoxComponent* bc = new BoxComponent(this);
  25. bc->SetObjectBox(mesh->GetBox());
  26. new TargetComponent(this);
  27. }