HelloPolycodeApp.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "HelloPolycodeApp.h"
  2. HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {
  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. scene->getDefaultCamera()->setPosition(7,7,7);
  16. scene->getDefaultCamera()->lookAt(Vector3(0,0,0));
  17. Mesh *mesh = new Mesh(Mesh::QUAD_MESH);
  18. // mesh->createBox(1, 1, 1);
  19. mesh->createTorus(0.3,0.2,10,10);
  20. SceneParticleEmitter *emitter = new SceneParticleEmitter("Default", scene,
  21. Particle::MESH_PARTICLE, ParticleEmitter::CONTINUOUS_EMITTER, 4, 100,
  22. Vector3(0.0,1.0,0.0), Vector3(0.0,0.0,0.0), Vector3(0.3, 0.0, 0.3), mesh);
  23. emitter->useScaleCurves = true;
  24. emitter->scaleCurve.addControlPoint2d(0, 0.1);
  25. emitter->scaleCurve.addControlPoint2d(0.5, 0.3);
  26. emitter->scaleCurve.addControlPoint2d(1, 0);
  27. scene->addEntity(emitter);
  28. SceneLight *light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  29. light->setPosition(3,2,3);
  30. light->setLightColor(1,0,0);
  31. scene->addLight(light);
  32. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  33. light->setPosition(-3,2,3);
  34. light->setLightColor(0,1,0);
  35. scene->addLight(light);
  36. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  37. light->setPosition(-3,2,-3);
  38. light->setLightColor(0,0,1);
  39. scene->addLight(light);
  40. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  41. light->setPosition(3,2,-3);
  42. light->setLightColor(1,0,1);
  43. scene->addLight(light);
  44. light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  45. light->setPosition(0,2,2);
  46. light->setSpotlightProperties(30,6);
  47. light->setLightColor(1,1,0);
  48. scene->addLight(light);
  49. light->lookAt(Vector3(0,0,0));
  50. light->enableShadows(true);
  51. light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  52. light->setPosition(0,2,-2);
  53. light->setSpotlightProperties(30,6);
  54. light->setLightColor(0,1,1);
  55. scene->addLight(light);
  56. light->lookAt(Vector3(0,0,0));
  57. light->enableShadows(true);
  58. }
  59. bool HelloPolycodeApp::Update() {
  60. return core->Update();
  61. }