00001
00002
00003
00004
00005 #include <vector>
00006 #include "Log.h"
00007 #include "Point.h"
00008 #include "Model.h"
00009 #include "BuildingList.h"
00010
00011 class Building {
00012 public:
00013 Building(Model *modelIn, Point *pointIn, float rotationIn);
00014 ~Building();
00015
00016 void Dump();
00017
00018 void Draw();
00019
00020 void AddToPoint(float x, float y, float z);
00021 private:
00022 Model *m_model;
00023 Point *m_point;
00024 float m_rotation;
00025 };
00026
00027 Building::Building(Model *modelIn, Point *pointIn, float rotationIn) {
00028 m_model = modelIn;
00029 m_point = pointIn;
00030 m_rotation = rotationIn;
00031 }
00032
00033 Building::~Building() {
00034 delete m_point;
00035 }
00036
00037 void Building::Draw() {
00038 glPushMatrix();
00039 m_point->Translatef();
00040 glRotatef(m_rotation, 0, 1, 0);
00041 glRotatef(90, 0, 0, 1);
00042 m_model->draw();
00043 glPopMatrix();
00044 }
00045
00046 void Building::Dump() {
00047 Log::s_log->Message("Building");
00048 Log::s_log->Message("Rot: %f", m_rotation);
00049 m_point->Dump();
00050 }
00051
00052 void Building::AddToPoint(float x, float y, float z) {
00053 m_point->m_x += x;
00054 m_point->m_y += y;
00055 m_point->m_z += z;
00056 }
00057
00058
00059
00060
00061 BuildingList::BuildingList() {
00062
00063 }
00064
00065 BuildingList::~BuildingList() {
00066 unsigned int i;
00067
00068 for (i = 0; i < m_list.size(); i++) {
00069 delete m_list[i];
00070 m_list[i] = NULL;
00071 }
00072 m_list.clear();
00073 }
00074
00075 void BuildingList::Add(Model *modelIn, Point *pointIn, float rotationIn) {
00076 Building *temp;
00077
00078 temp = new Building(modelIn, pointIn, rotationIn);
00079 m_list.push_back(temp);
00080 }
00081
00082 void BuildingList::AddCityLocation(float x, float y, float z) {
00083 unsigned int i;
00084
00085 for (i = 0; i < m_list.size(); i++) {
00086 m_list[i]->AddToPoint(x, y, z);
00087 }
00088 }
00089
00090 void BuildingList::Dump() {
00091 unsigned int i;
00092
00093 Log::s_log->Message("Building list");
00094 for (i = 0; i < m_list.size(); i++) {
00095 m_list[i]->Dump();
00096 }
00097 Log::s_log->Message("");
00098 }
00099
00100 void BuildingList::Draw() {
00101 unsigned int i;
00102
00103 for (i = 0; i < m_list.size(); i++) {
00104 m_list[i]->Draw();
00105 }
00106 }