NavMeshAreaFactory.cpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #include "NavMeshAreaFactory.hpp"
00023 #include "NavMeshArea.hpp"
00024 #include "NavMesh.hpp"
00025 #include "sim/zone/ZoneAreaComponent.hpp"
00026 #include "util/type/ByteArray.hpp"
00027 
00028 using namespace se_core;
00029 
00030 namespace se_basic {
00031 
00032     NavMeshAreaFactory
00033     ::NavMeshAreaFactory(String* name, coor_tile_t w, coor_tile_t h, se_core::ByteArray* data)
00034             : AreaFactory(name), data_(data), width_(w), height_(h) {
00035         navMesh_ = new const NavMesh(data->get());
00036     }
00037 
00038 
00039     NavMeshAreaFactory
00040     ::~NavMeshAreaFactory() {
00041         delete navMesh_;
00042         delete data_;
00043     }
00044 
00045 
00046     Composite* NavMeshAreaFactory
00047     ::create(String* name, int pageX, int pageY, int pageZ, int gridId) const {
00048         Composite* c = new Composite(this, name->copyValue());
00049         NavMeshArea* a = new NavMeshArea(c, 0, width_, height_, navMesh_);
00050         createComponents(c);
00051         createGenericComponents(c);
00052 
00053         ZoneAreaComponent::Ptr aZone(*c);
00054         aZone->page().set(pageX, pageY, pageZ, gridId);
00055         PosComponent::Ptr aPos(*c);
00056         aPos->nextPos().localCoor().x_ = CoorT::fromTile(pageX * a->width());
00057         aPos->nextPos().localCoor().z_ = CoorT::fromTile(pageZ * a->height());
00058         aPos->nextPos().world_.setViewPoint(aPos->nextPos().local_);
00059         aPos->flip();
00060 
00061         return c;
00062     }
00063 
00064     void NavMeshAreaFactory
00065     ::release(Composite* c) const {
00066         //LogWarning(c->name());
00067         delete c->component(se_core::sct_BLOB);
00068         delete c;
00069     }
00070 }

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:02 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo