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

ExNihiloNameSpace.cpp

Go to the documentation of this file.
00001 /*
00002  * ExNihilo 3D Engine
00003  * 
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * Please read AUTHORS file !!!
00019  * 
00020  * $Id: ExNihiloNameSpace.cpp,v 1.5 2002/10/15 09:17:20 data Exp $
00021  *
00022  */
00023 
00024 #include "ExNihiloNameSpace.h"
00025 
00026 void ExNihilo::InitBasicObjectList(void)
00027 {
00028         float i;        
00029         glNewList(GRILLE,GL_COMPILE);
00030         glDisable(GL_LIGHTING);
00031         glBegin(GL_LINES);
00032                 glColor3f(1.0f,0.0f,0.0f);
00033                 for ( i=-100;i<101;i+=2)
00034                 {       
00035                         glVertex3f(0.0f,      i, 100.0f);
00036                         glVertex3f(0.0f,      i,-100.0f);
00037                         glVertex3f(0.0f, 100.0f,      i);
00038                         glVertex3f(0.0f,-100.0f,      i);
00039                 }
00040                 glColor3f(0.0,1.0f,0.0f);
00041                 
00042                 for ( i=-100;i<101;i+=2)
00043                 {
00044                         glVertex3f( 100.0f,     i,0.0f);
00045                         glVertex3f(-100.0f,     i,0.0f);
00046                         glVertex3f(     i, 100.0f,0.0f);
00047                         glVertex3f(     i,-100.0f,0.0f);
00048                 }
00049                 glColor3f(0.0,0.0f,1.0f);
00050                 for (i=-100;i<101;i+=2)
00051                 {
00052                         glVertex3f( 100.0f,0.0f,      i);
00053                         glVertex3f(-100.0f,0.0f,      i);
00054                         glVertex3f(      i,0.0f, 100.0f);
00055                         glVertex3f(      i,0.0f,-100.0f);
00056                 }
00057         glEnd();
00058         glEnable(GL_LIGHTING);
00059         glEndList();
00060 
00061 
00062 }
00063 
00064 void ExNihilo::RenderBitmapString(float x, float y, void *font,std::string string)
00065 {
00066         const char *c;
00067         glRasterPos2f(x, y);
00068         for (c=string.data(); *c != '\0'; c++)
00069         {
00070            glutBitmapCharacter(font, *c);
00071         }
00072 }
00073 
00074 void ExNihilo::EnterOrthoMode(void)
00075 {
00076         glMatrixMode(GL_PROJECTION);                                            
00077         glPushMatrix();                                                                 
00078         glLoadIdentity();
00079         glOrtho( 0,glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT),0,0,1);       
00080         glMatrixMode(GL_MODELVIEW);                                                             
00081         glLoadIdentity();                                                                               
00082 }
00083 
00084 void ExNihilo::LeaveOrthoMode(void)     
00085 {
00086         glMatrixMode( GL_PROJECTION );                                                  
00087         glPopMatrix();                                                                                  
00088         glMatrixMode( GL_MODELVIEW );                                                   
00089 }
00090 
00091 void ExNihilo::WriteToScreen(float x,float y,std::string String)
00092 {
00093         ExNihilo::EnterOrthoMode();
00094         ExNihilo::RenderBitmapString(x,y,(void *)GLUT_BITMAP_HELVETICA_12,String);
00095         ExNihilo::LeaveOrthoMode();
00096 }
00097 
00098 std::string ExNihilo::ExtracValueFromSring(std::string buffstring,std::string start,std::string end)
00099 {
00100         char buffer[255];
00101         memset(buffer,0,255);
00102         try{buffstring.copy(buffer,buffstring.find(end,buffstring.find(start)+start.size())-buffstring.find(start)-start.size(),buffstring.find(start)+start.size());}
00103         catch(...){throw ExCExpStringNotFound();}
00104         return buffer;
00105 }
00106 
00107 int ExNihilo::ExtractIntValueFromSring(std::string buffstring,std::string start,std::string end)
00108 {
00109         char buffer[255];
00110         memset(buffer,0,255);
00111         try{buffstring.copy(buffer,buffstring.find(end,buffstring.find(start)+start.size())-buffstring.find(start)-start.size(),buffstring.find(start)+start.size());}
00112         catch(...){throw ExCExpStringNotFound();}
00113         return atoi(buffer);
00114 }
00115 
00116 float ExNihilo::ExtractFloatValueFromSring(std::string buffstring,std::string start,std::string end)
00117 {
00118         char buffer[255];
00119         memset(buffer,0,255);
00120         try{buffstring.copy(buffer,buffstring.find(end,buffstring.find(start)+start.size())-buffstring.find(start)-start.size(),buffstring.find(start)+start.size());}
00121         catch(...){throw ExCExpStringNotFound();}
00122         return atof(buffer);
00123 }
00124 
00125 std::string ExNihilo::ExtracStringValueFromFile(std::string FileName, std::string start,std::string end)
00126 {
00127         char buffer[255],b[256];memset(buffer,0,255);
00128         std::ifstream fin;
00129         std::string buffstring;
00130         fin.open(FileName.data(),std::ios::in);
00131         if(fin.is_open())
00132         {
00133                 try
00134                 {
00135                         do
00136                         {
00137                                 memset(b,0,255);
00138                                 fin.getline(b,256,'\n');
00139                                 buffstring=buffstring+b;
00140                         }while(!fin.eof());
00141                         fin.close();
00142                 }catch(...){throw ExCExpFileReadError();}
00143         }else throw   ExCExpFileNotFound();
00144         buffstring.copy(buffer,buffstring.find(end,buffstring.find(start)+start.size())-buffstring.find(start)-start.size(),buffstring.find(start)+start.size());
00145         return buffer;
00146 }
00147 
00148 int ExNihilo::ExtractIntValueFromFile(std::string FileName, std::string start,std::string end)
00149 {
00150         return atoi(ExNihilo::ExtracStringValueFromFile(FileName,start,end).data());
00151 }
00152 
00153 float ExNihilo::ExtractFloatValueFromFile(std::string FileName, std::string start,std::string end)
00154 {
00155         return atof(ExNihilo::ExtracStringValueFromFile(FileName,start,end).data());
00156 }
00157 
00158 int ExNihilo::ExtracStringCommandFromString(std::string FileName,std::string command,std::string &TargetString)
00159 {
00160         return 1;
00161 }
00162 
00163 int ExNihilo::ExtracStringCommandFromFile(std::string FileName,std::string command,std::string &TargetString)
00164 {
00165         char buffer[255],b[256];memset(buffer,0,255);
00166         std::ifstream fin;
00167         std::string buffstring;
00168         fin.open(FileName.data(),std::ios::in);
00169         if(fin.is_open())
00170         {
00171                 try
00172                 {
00173                         do
00174                         {
00175                                 memset(b,0,255);
00176                                 fin.getline(b,256,'\n');
00177                                 buffstring=buffstring+b;
00178                         }while(!fin.eof());
00179                         fin.close();
00180                 }catch(...){throw ExCExpFileReadError();}
00181         }else throw   ExCExpFileNotFound();
00182 //      buffstring.copy(buffer,buffstring.find(end,buffstring.find(start)+start.size())-buffstring.find(start)-start.size(),buffstring.find(start)+start.size());
00183         TargetString=buffer;
00184         return 1;
00185 }

Generated on Tue Dec 10 18:20:08 2002 for ExNihilo by doxygen1.3-rc1