2
0

HelloPolycodeApp.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "HelloPolycodeApp.h"
  2. HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {
  3. #ifdef __APPLE__
  4. core = new CocoaCore(view, 640,480,false,false,0,0,90);
  5. #else
  6. core = new SDLCore(view, 640,480,false,false,0,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. scene->getDefaultCamera()->setPosition(7,7,7);
  16. scene->getDefaultCamera()->lookAt(Vector3(0,0,0));
  17. SceneParticleEmitter *emitter = new SceneParticleEmitter("TestParticle", scene,
  18. Particle::BILLBOARD_PARTICLE, ParticleEmitter::CONTINUOUS_EMITTER, 4, 200,
  19. Vector3(0.0,1.0,0.0), Vector3(0.0,0.0,0.0), Vector3(0.3, 0.0, 0.3),
  20. Vector3(1.5,1.5,1.5));
  21. emitter->useScaleCurves = true;
  22. emitter->scaleCurve.addControlPoint2d(0, 0.1);
  23. emitter->scaleCurve.addControlPoint2d(0.5, 0.3);
  24. emitter->scaleCurve.addControlPoint2d(1, 0);
  25. scene->addEntity(emitter);
  26. SceneLight *light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  27. light->setPosition(3,2,3);
  28. light->setLightColor(1,0,0);
  29. scene->addLight(light);
  30. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  31. light->setPosition(-3,2,3);
  32. light->setLightColor(0,1,0);
  33. scene->addLight(light);
  34. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  35. light->setPosition(-3,2,-3);
  36. light->setLightColor(0,0,1);
  37. scene->addLight(light);
  38. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  39. light->setPosition(3,2,-3);
  40. light->setLightColor(1,0,1);
  41. scene->addLight(light);
  42. light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  43. light->setPosition(0,2,2);
  44. light->setSpotlightProperties(30,6);
  45. light->setLightColor(1,1,0);
  46. scene->addLight(light);
  47. light->lookAt(Vector3(0,0,0));
  48. light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  49. light->setPosition(0,2,-2);
  50. light->setSpotlightProperties(30,6);
  51. light->setLightColor(0,1,1);
  52. scene->addLight(light);
  53. light->lookAt(Vector3(0,0,0));
  54. }
  55. bool HelloPolycodeApp::Update() {
  56. return core->Update();
  57. }