HelloPolycodeApp.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. 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),
  23. Vector3(1.5,1.5,1.5), mesh);
  24. emitter->useScaleCurves = true;
  25. emitter->scaleCurve.addControlPoint2d(0, 0.1);
  26. emitter->scaleCurve.addControlPoint2d(0.5, 0.3);
  27. emitter->scaleCurve.addControlPoint2d(1, 0);
  28. scene->addEntity(emitter);
  29. SceneLight *light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  30. light->setPosition(3,2,3);
  31. light->setLightColor(1,0,0);
  32. scene->addLight(light);
  33. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  34. light->setPosition(-3,2,3);
  35. light->setLightColor(0,1,0);
  36. scene->addLight(light);
  37. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  38. light->setPosition(-3,2,-3);
  39. light->setLightColor(0,0,1);
  40. scene->addLight(light);
  41. light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5);
  42. light->setPosition(3,2,-3);
  43. light->setLightColor(1,0,1);
  44. scene->addLight(light);
  45. light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  46. light->setPosition(0,2,2);
  47. light->setSpotlightProperties(30,6);
  48. light->setLightColor(1,1,0);
  49. scene->addLight(light);
  50. light->lookAt(Vector3(0,0,0));
  51. light->enableShadows(true);
  52. light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4);
  53. light->setPosition(0,2,-2);
  54. light->setSpotlightProperties(30,6);
  55. light->setLightColor(0,1,1);
  56. scene->addLight(light);
  57. light->lookAt(Vector3(0,0,0));
  58. light->enableShadows(true);
  59. }
  60. bool HelloPolycodeApp::Update() {
  61. return core->Update();
  62. }