HelloPolycodeApp.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "HelloPolycodeApp.h"
  2. HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {
  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. scene->getDefaultCamera()->setPosition(7,7,7);
  12. scene->getDefaultCamera()->lookAt(Vector3(0,0,0));
  13. SceneParticleEmitter *emitter = new SceneParticleEmitter(100,10,3);
  14. emitter->useScaleCurve = true;
  15. emitter->scaleCurve.addControlPoint2d(0, 0.1);
  16. emitter->scaleCurve.addControlPoint2d(0.5, 0.3);
  17. emitter->scaleCurve.addControlPoint2d(1, 0);
  18. scene->addEntity(emitter);
  19. SceneLight *light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5);
  20. light->setPosition(3,2,3);
  21. light->setLightColor(1,0,0);
  22. scene->addLight(light);
  23. light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5);
  24. light->setPosition(-3,2,3);
  25. light->setLightColor(0,1,0);
  26. scene->addLight(light);
  27. light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5);
  28. light->setPosition(-3,2,-3);
  29. light->setLightColor(0,0,1);
  30. scene->addLight(light);
  31. light = new SceneLight(SceneLight::POINT_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 = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  42. light->setPosition(0,2,-2);
  43. light->setSpotlightProperties(30,6);
  44. light->setLightColor(0,1,1);
  45. scene->addLight(light);
  46. light->lookAt(Vector3(0,0,0));
  47. }
  48. HelloPolycodeApp::~HelloPolycodeApp() {
  49. }
  50. bool HelloPolycodeApp::Update() {
  51. return core->updateAndRender();
  52. }