K3dPolyWork.cpp

Go to the documentation of this file.
00001 
00011 /***************************************************************************
00012  *   Copyright (C) 2007 by Jan Koci   *
00013  *   honza.koci@email.cz   *
00014  *   http://kengine.sourceforge.net/tutorial/
00015  *                                                                         *
00016  *   This program is free software; you can redistribute it and/or modify  *
00017  *   it under the terms of the GNU General Public License as published by  *
00018  *   the Free Software Foundation; either version 2 of the License, or     *
00019  *   (at your option) any later version.                                   *
00020  *                                                                         *
00021  *   This program is distributed in the hope that it will be useful,       *
00022  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00023  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00024  *   GNU General Public License for more details.                          *
00025  *                                                                         *
00026  *   You should have received a copy of the GNU General Public License     *
00027  *   along with this program; if not, write to the                         *
00028  *   Free Software Foundation, Inc.,                                       *
00029  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00030  ***************************************************************************/
00031 
00032 #include "K3dPolyWork.h"
00033 
00034 K3dPolyWork::K3dPolyWork(K3dGameData *_pGameData)
00035 {
00036         m_pGameData = _pGameData;
00037         // Set this pointer to the game data
00038         m_pGameData->SetPolyWork(this);
00039 }
00040 
00041 K3dPolyWork::~K3dPolyWork()
00042 {
00043 }
00044 
00046 void K3dPolyWork::CheckPoly(K3dPolyObj *_pPoly)
00047 {
00048         cout << "void K3dPolyWork::CheckPoly(K3dPolyObj *_pPoly)" << endl;
00049         // Save poly structure to the file output
00050         stringstream strFilename;
00051         strFilename << m_pGameData->GetPath(K_PATH_APP).GetString().c_str() << m_pGameData->GetDebugPath().GetString().c_str();
00052         // Create directory debug if doesn`t exists
00053         m_pGameData->GetDir()->CreateDirectory(strFilename.str().c_str());
00054         // Create file
00055         strFilename << "K3dPolyObj_" << _pPoly->GetId() << ".k3dobj";
00056         // Save this poly to the file
00057         ofstream out(strFilename.str().c_str());
00058         cout << "strFilename = " << strFilename.str() <<  endl;
00059         m_pGameData->GetVertexWork()->CheckVertexArray(_pPoly->GetVertexArray(), &out);
00060         out << endl;
00061         out << "Num edges" << _pPoly->GetEdgeArray().size() << endl;
00062         for(int i=0; i<(int)_pPoly->GetEdgeArray().size(); i++)
00063         {
00064                 out <<  "Edge " << i << endl;
00065                 out <<  "Edge Origin X = " << _pPoly->GetEdgeArray()[i]->GetOrigin()->GetX() << endl;
00066                 out <<  "Edge Origin Y = " << _pPoly->GetEdgeArray()[i]->GetOrigin()->GetY() << endl;
00067                 out <<  "Edge Origin Z = " << _pPoly->GetEdgeArray()[i]->GetOrigin()->GetZ() << endl;
00068                 out <<  "Edge Direction X = " << _pPoly->GetEdgeArray()[i]->GetDirection()->GetX() << endl;
00069                 out <<  "Edge Direction Y = " << _pPoly->GetEdgeArray()[i]->GetDirection()->GetY() << endl;
00070                 out <<  "Edge Direction Z = " << _pPoly->GetEdgeArray()[i]->GetDirection()->GetZ() << endl;
00071         }
00072         out << endl;
00073         out << "Num planes" << _pPoly->GetPlaneArray().size() << endl;
00074         for(int i=0; i<(int)_pPoly->GetPlaneArray().size(); i++)
00075         {
00076                 out <<  "Plane " << i << endl;
00077                 out <<  "Plane position X = " << _pPoly->GetPlaneArray()[i]->GetPosition()->GetX() << endl;
00078                 out <<  "Plane position Y = " << _pPoly->GetPlaneArray()[i]->GetPosition()->GetY() << endl;
00079                 out <<  "Plane position Z = " << _pPoly->GetPlaneArray()[i]->GetPosition()->GetZ() << endl;
00080                 out <<  "Plane normal X = " << _pPoly->GetPlaneArray()[i]->GetNormal()->GetX() << endl;
00081                 out <<  "Plane normal Y = " << _pPoly->GetPlaneArray()[i]->GetNormal()->GetY() << endl;
00082                 out <<  "Plane normal Z = " << _pPoly->GetPlaneArray()[i]->GetNormal()->GetZ() << endl;
00083                 out <<  "Plane distance = " << _pPoly->GetPlaneArray()[i]->GetDistance() << endl;       
00084         }
00085         out.close();
00086 }
00087 
00090 void K3dPolyWork::VisiblePoly(K3dPolyObj *_pPoly)
00091 {
00092         cout << "void K3dPolyWork::VisiblePoly(K3dPolyObj *_pPoly)" << endl;
00093         for(int i=0; i<(int)_pPoly->GetEdgeArray().size(); i++)
00094         {
00095                 K3dLineObj *pEdge = _pPoly->GetEdgeArray()[i];
00096                 pEdge->GetIsVisible() = true;
00097         }
00098 }
00099 

Generated on Thu Aug 16 23:53:29 2007 for K3dEngine by  doxygen 1.5.0