Guest User

Untitled

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