2010-10-28 02:51:25 +02:00
|
|
|
// ==============================================================
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
//
|
2011-12-14 08:40:48 +01:00
|
|
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
2010-10-28 02:51:25 +02:00
|
|
|
//
|
|
|
|
// You can redistribute this code and/or modify it under
|
|
|
|
// the terms of the GNU General Public License as published
|
|
|
|
// by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#include "object_type.h"
|
|
|
|
|
|
|
|
#include "renderer.h"
|
|
|
|
#include "leak_dumper.h"
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class ObjectType
|
|
|
|
// =====================================================
|
|
|
|
|
2010-10-30 06:05:48 +02:00
|
|
|
void ObjectType::init(int modelCount, int objectClass, bool walkable, int height) {
|
2011-06-22 22:26:39 +02:00
|
|
|
// modeltypes.reserve(modelCount);
|
2010-10-28 02:51:25 +02:00
|
|
|
this->objectClass= objectClass;
|
|
|
|
this->walkable= walkable;
|
2010-10-30 06:05:48 +02:00
|
|
|
this->height = height;
|
2010-10-28 02:51:25 +02:00
|
|
|
}
|
|
|
|
|
2011-03-02 00:36:33 +01:00
|
|
|
ObjectType::~ObjectType(){
|
2011-06-22 22:26:39 +02:00
|
|
|
while(!(modeltypes.empty())){
|
|
|
|
delete modeltypes.back();
|
|
|
|
modeltypes.pop_back();
|
|
|
|
//Logger::getInstance().add("ObjectType", true);
|
2011-03-02 00:36:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-22 22:26:39 +02:00
|
|
|
TilesetModelType* ObjectType::loadModel(const string &path, std::map<string,vector<pair<string, string> > > *loadedFileList,
|
2011-05-05 21:21:50 +02:00
|
|
|
string parentLoader) {
|
2013-12-05 16:17:41 +01:00
|
|
|
Model *model= Renderer::getInstance().newModel(rsGame, path, false, loadedFileList, &parentLoader);
|
2010-10-28 02:51:25 +02:00
|
|
|
color= Vec3f(0.f);
|
2011-09-27 07:29:57 +02:00
|
|
|
if(model && model->getMeshCount()>0 && model->getMesh(0)->getTexture(0) != NULL) {
|
2010-11-09 10:06:52 +01:00
|
|
|
const Pixmap2D *p= model->getMesh(0)->getTexture(0)->getPixmapConst();
|
2010-10-28 02:51:25 +02:00
|
|
|
color= p->getPixel3f(p->getW()/2, p->getH()/2);
|
|
|
|
}
|
2011-06-22 22:26:39 +02:00
|
|
|
TilesetModelType *modelType=new TilesetModelType();
|
|
|
|
modelType->setModel(model);
|
|
|
|
modeltypes.push_back(modelType);
|
|
|
|
return modelType;
|
2010-10-28 02:51:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ObjectType::deletePixels() {
|
2013-11-19 07:14:06 +01:00
|
|
|
for(int i = 0; i < (int)modeltypes.size(); ++i) {
|
2011-06-22 22:26:39 +02:00
|
|
|
TilesetModelType *model = modeltypes[i];
|
|
|
|
if(model->getModel() != NULL) {
|
|
|
|
model->getModel()->deletePixels();
|
2010-10-28 02:51:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}}//end namespace
|