00001
00002
00003 #include "SGFMeshModelFactory.h"
00004
00005 #include "Light.h"
00006 #include "SGFMeshModel.h"
00007 #include "World.h"
00008
00009 #include <vector>
00010
00011
00012 namespace pge {
00013 namespace sgfmeshmodelfactory {
00014
00015
00016
00017
00018
00019
00020 SGFMeshModel* createSGFMeshModel(const std::string &filename, Vector3f bottomCenter, float scaleFactor) {
00021 SGFFile file(filename);
00022 SGFMeshModel *model = new SGFMeshModel(&file, bottomCenter, scaleFactor, NULL);
00023
00024 return model;
00025 }
00026
00027
00028
00029
00030
00031
00032
00033 SGFMeshModel* createSGFMeshModelWithLights(const std::string &filename, Vector3f bottomCenter,
00034 float scaleFactor, World *world) {
00035
00036 std::vector<SGFFile::SGFLight>::iterator it;
00037
00038
00039 SGFFile file(filename);
00040 SGFMeshModel *model = new SGFMeshModel(&file, bottomCenter, scaleFactor, NULL);
00041
00042
00043 for(it = file.getLights()->begin(); it != file.getLights()->end(); it++) {
00044 SGFFile::SGFLight light = *it;
00045 Light *worldLight = new Light();
00046
00047
00048
00049 light.m_position = light.m_position + model->getBottomCenterDifference();
00050
00051
00052 SGFFile::sgfLightToLight(&light, worldLight, Vector4f(0.1f, 0.1f, 0.1f, 1.0f),
00053 Vector4f(0.1f, 0.1f, 0.1f, 1.0f));
00054
00055 world->addLight(worldLight);
00056
00057 }
00058
00059 return model;
00060 }
00061 };
00062 };