HelloPolycodeApp.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. Mesh *mesh = new Mesh(Mesh::QUAD_MESH);
  14. // mesh->createBox(1, 1, 1);
  15. mesh->createTorus(0.3,0.2,10,10);
  16. SceneParticleEmitter *emitter = new SceneParticleEmitter(100,50,2);
  17. emitter->useScaleCurve = true;
  18. emitter->scaleCurve.addControlPoint2d(0, 0.1);
  19. emitter->scaleCurve.addControlPoint2d(0.5, 0.3);
  20. emitter->scaleCurve.addControlPoint2d(1, 0);
  21. scene->addEntity(emitter);
  22. SceneLight *light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5);
  23. light->setPosition(3,2,3);
  24. light->setLightColor(1,0,0);
  25. scene->addLight(light);
  26. light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5);
  27. light->setPosition(-3,2,3);
  28. light->setLightColor(0,1,0);
  29. scene->addLight(light);
  30. light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5);
  31. light->setPosition(-3,2,-3);
  32. light->setLightColor(0,0,1);
  33. scene->addLight(light);
  34. light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5);
  35. light->setPosition(3,2,-3);
  36. light->setLightColor(1,0,1);
  37. scene->addLight(light);
  38. light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  39. light->setPosition(0,2,2);
  40. light->setSpotlightProperties(30,6);
  41. light->setLightColor(1,1,0);
  42. scene->addLight(light);
  43. light->lookAt(Vector3(0,0,0));
  44. light->enableShadows(true);
  45. light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  46. light->setPosition(0,2,-2);
  47. light->setSpotlightProperties(30,6);
  48. light->setLightColor(0,1,1);
  49. scene->addLight(light);
  50. light->lookAt(Vector3(0,0,0));
  51. light->enableShadows(true);
  52. }
  53. HelloPolycodeApp::~HelloPolycodeApp() {
  54. }
  55. bool HelloPolycodeApp::Update() {
  56. return core->updateAndRender();
  57. }