HelloPolycodeApp.cpp 2.0 KB

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