Guest User

Untitled

a guest
Jul 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include "pandaFramework.h"
  2. #include "pandaSystem.h"
  3.  
  4. #include "genericAsyncTask.h"
  5. #include "asyncTaskManager.h"
  6.  
  7. PandaFramework framework;
  8.  
  9. PT(AsyncTaskManager) taskMgr = AsyncTaskManager::get_global_ptr();
  10.  
  11. PT(ClockObject) globalClock = ClockObject::get_global_clock();
  12.  
  13. NodePath camera;
  14.  
  15. AsyncTask::DoneStatus SpinCameraTask(GenericAsyncTask* task, void* data) {
  16. // Calculate the new position and orientation (inefficient - change me!)
  17. double time = globalClock->get_real_time();
  18. double angledegrees = time * 6.0;
  19. double angleradians = angledegrees * (3.14 / 180.0);
  20. camera.set_pos(20*sin(angleradians),-20.0*cos(angleradians),3);
  21. camera.set_hpr(angledegrees, 0, 0);
  22.  
  23. // Tell the task manager to continue this task the next frame.
  24. return AsyncTask::DS_cont;
  25. }
  26.  
  27. int main(int argc, char *argv[]) {
  28.  
  29. framework.open_framework(argc, argv);
  30. framework.set_window_title("My Panda3D Window");
  31.  
  32.  
  33. WindowFramework *window = framework.open_window();
  34. camera = window->get_camera_group();
  35.  
  36. NodePath m = window->load_model(framework.get_models(), "/d/cuboid.egg");
  37. m.set_scale(0.05);
  38. m.reparent_to(window->get_render());
  39.  
  40.  
  41. taskMgr->add(new GenericAsyncTask("Spins the camera", &SpinCameraTask, (void*) NULL));
  42.  
  43. framework.main_loop();
  44. framework.close_framework();
  45. return (0);
  46. }
Add Comment
Please, Sign In to add comment