K3dDraw.cpp

Go to the documentation of this file.
00001 
00012 /***************************************************************************
00013  *   Copyright (C) 2007 by Jan Koci   *
00014  *   honza.koci@email.cz   *
00015  *   http://kengine.sourceforge.net/tutorial/
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  *   This program is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00025  *   GNU General Public License for more details.                          *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU General Public License     *
00028  *   along with this program; if not, write to the                         *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00031  ***************************************************************************/
00032 
00033 #include "K3dDraw.h"
00034 
00035 K3dDraw::K3dDraw(K3dGameData *_pGameData):
00036         K3dDrawTriangle(_pGameData),
00037         K3dDrawLine(_pGameData),
00038         K3dDrawSphere(_pGameData),
00039         K3dDrawPlane(_pGameData),
00040         K3dDrawVertex(_pGameData)
00041 {
00042         m_pGameData = _pGameData;
00043 }
00044 
00045 K3dDraw::~K3dDraw()
00046 {
00047 }
00048 
00049 void K3dDraw::BuildTriangleArray()
00050 {
00051         cout << "void K3dDraw::BuildTriangleArray()" << endl;
00052         // Get number of triangles from global data
00053         int iNum = m_pGameData->GetTriangleObjSP().GetNum();
00054         // Set number of draw triangles
00055         m_pGameData->NumDrawTriangles() = iNum;
00056         
00057         // Go through number of triangles
00058         for(int i =0; i<iNum; i++)
00059         {
00060                 // Get triangle from global data
00061                 K3dTriangleObj *pTriangle = m_pGameData->GetTriangleObjSP().Get(i);
00062                 // Create new triangle
00063                 TRenderTriangle tRenderTriangle;// = new TRenderTriangle;
00064                 // Go through triangle vertices
00065                 for(int j=0; j<3; j++)
00066                 {
00067                         // Go through all vectors
00068                         for(int k=0; k<3; k++)
00069                         {
00070                                 tRenderTriangle.atVertex[j].afVector[k] = pTriangle->GetVertex(j)[0][k];
00071                                 tRenderTriangle.atNormal[j].afVector[k] = pTriangle->GetNormal()[0][k];
00072                                 
00073                         }
00074                 }
00075                 AddTriangle(tRenderTriangle);
00076         }
00077         InitTriangleArray();
00078 }
00079 

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