Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

/Users/blackie/Documents/myRepository/phobosengine-vc2005/phobosengine/phobosengine/SGFMeshModelFactory.cpp

Go to the documentation of this file.
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                                 // Load model and create meshmodel.
00039                                 SGFFile file(filename);
00040                                 SGFMeshModel *model = new SGFMeshModel(&file, bottomCenter, scaleFactor, NULL);
00041 
00042                                 // Add the lights to the world.
00043                                 for(it = file.getLights()->begin(); it != file.getLights()->end(); it++) {
00044                                         SGFFile::SGFLight light = *it;
00045                                         Light *worldLight = new Light();
00046 
00047                                         // The bottomcenter is set, so calculate the difference to the light
00048                                         // position.
00049                                         light.m_position = light.m_position + model->getBottomCenterDifference();
00050 
00051                                         // TODO: Ambient and specular values!
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 };

Generated on Mon Oct 16 12:08:11 2006 for Phobosengine by doxygen 1.3.4