PhysicsCollisionObjectSample.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef PHYSICSCOLLISIONOBJECTSAMPLE_H_
  2. #define PHYSICSCOLLISIONOBJECTSAMPLE_H_
  3. #include "gameplay.h"
  4. #include "Sample.h"
  5. using namespace gameplay;
  6. /**
  7. * Sample loading a physics scene from .scene file with .physics bindings
  8. */
  9. class PhysicsCollisionObjectSample : public Sample, Control::Listener
  10. {
  11. public:
  12. PhysicsCollisionObjectSample();
  13. void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
  14. void keyEvent(Keyboard::KeyEvent evt, int key);
  15. void controlEvent(Control* control, EventType evt);
  16. protected:
  17. void initialize();
  18. void finalize();
  19. void update(float elapsedTime);
  20. void render(float elapsedTime);
  21. private:
  22. bool drawScene(Node* node);
  23. bool bindLights(Node* node);
  24. void fireProjectile(const Ray& ray);
  25. void incrementDebugDraw();
  26. void toggleWireframe();
  27. enum ObjectsTypes
  28. {
  29. SPHERE = 0,
  30. BOX = 1,
  31. CAPSULE = 2,
  32. DUCK = 3
  33. };
  34. Font* _font;
  35. Scene* _scene;
  36. Node* _lightNode;
  37. Form* _form;
  38. int _objectType;
  39. bool _throw;
  40. int _drawDebug;
  41. bool _wireFrame;
  42. std::vector<const char*> _collisionObjectPaths;
  43. std::vector<const char*> _nodeIds;
  44. std::vector<const char*> _nodeNames;
  45. std::vector<Vector4> _colors;
  46. };
  47. #endif