2
0

HelloPolycodeApp.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "HelloPolycodeApp.h"
  2. HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {
  3. #ifdef __APPLE__
  4. core = new CocoaCore(view, 640,480,false,0,90);
  5. #else
  6. core = new SDLCore(view, 640,480,false,0,90);
  7. #endif
  8. CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
  9. CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
  10. CoreServices::getInstance()->getResourceManager()->addDirResource("Resources", false);
  11. Scene *scene = new Scene();
  12. ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 5,5);
  13. ground->setMaterialByName("GroundMaterial");
  14. scene->addEntity(ground);
  15. ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_TORUS, 0.8,0.3,30,20);
  16. box->setMaterialByName("CubeMaterial");
  17. box->setPosition(0.0, 0.5, 0.0);
  18. scene->addEntity(box);
  19. SceneLight *light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  20. light->setPosition(3,2,3);
  21. light->setLightColor(1,0,0);
  22. scene->addLight(light);
  23. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  24. light->setPosition(-3,2,3);
  25. light->setLightColor(0,1,0);
  26. scene->addLight(light);
  27. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  28. light->setPosition(-3,2,-3);
  29. light->setLightColor(0,0,1);
  30. scene->addLight(light);
  31. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  32. light->setPosition(3,2,-3);
  33. light->setLightColor(1,0,1);
  34. scene->addLight(light);
  35. light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  36. light->setPosition(0,2,2);
  37. light->setSpotlightProperties(30,6);
  38. light->setLightColor(1,1,0);
  39. scene->addLight(light);
  40. light->lookAt(Vector3(0,0,0));
  41. light->enableShadows(true);
  42. light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  43. light->setPosition(0,2,-2);
  44. light->setSpotlightProperties(30,6);
  45. light->setLightColor(0,1,1);
  46. scene->addLight(light);
  47. light->lookAt(Vector3(0,0,0));
  48. light->enableShadows(true);
  49. scene->getDefaultCamera()->setPosition(7,7,7);
  50. scene->getDefaultCamera()->lookAt(Vector3(0,0,0));
  51. }
  52. bool HelloPolycodeApp::Update() {
  53. return core->Update();
  54. }