/* -*- C++ -*- * Copyright ©2004 Hugo Mills * * This software is distributed under the terms of the GNU GPL v3 * For more information on the GPL, see the file COPYING or * visit http://www.gnu.org/ * * This software is distributed without warranty */ #include "xfmap_flat.h" extern "C" PluginInfo* getmodules(int i) { if(i==0) { PluginInfo_Map* pi = new PluginInfo_Map(); pi->name = "Planar Orthographic"; pi->author = "Hugo Mills"; pi->copyright = "©2005 Hugo Mills"; pi->version = 0x10000; pi->parser = XfMap_Flat::parser; return pi; } else return NULL; } XfMap* XfMap_Flat::parser( ConfigLexer* lex, const std::string& type, const std::string& subtype ) { if(type == "planar" && subtype == "orthographic") return new XfMap_Flat(); else return NULL; } bool XfMap_Flat::f(dvec2& result, const dvec3& pos) const { if(pos[2] < 0) return false; result[0] = pos[0]; result[1] = pos[1]; return true; } bool XfMap_Flat::g(dvec3& result, const dvec2& pos) const { double rad2 = pos[0]*pos[0] + pos[1]*pos[1]; if(rad2 > 1.0) return false; result[0] = pos[0]; result[1] = pos[1]; result[2] = sqrt(1.0-rad2); return true; }