Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FaceCollisionModel.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: FaceCollisionModel.cpp,v 1.2 2002/01/17 18:57:37 tksuoran Exp $
00022 */
00023 
00024 
00025 #include "Teddy/Models/Face.h"
00026 #if defined( TEDDY_INCLUDE_COLDET )
00027 # include "Teddy/ColDet/ColDet.h"
00028 #endif
00029 
00030 
00031 namespace Teddy  {
00032 namespace Models {
00033 
00034 
00039 #if defined( TEDDY_INCLUDE_COLDET )
00040 /*virtual*/ int Face::addToCollisionModel( Teddy::ColDet::CollisionModel3D *collision_model ){
00041     int tris = 0;
00042     list<Vertex*>::const_iterator v_it = vertices.begin();
00043 
00044     Vector a  = (*v_it)->getVertex(); v_it++; if( v_it == vertices.end() ) return 0;
00045     Vector b  = (*v_it)->getVertex(); v_it++;
00046     while( v_it != vertices.end() ){
00047         Vector c = (*v_it)->getVertex();
00048         FloatVector fa = a;
00049         FloatVector fb = b;
00050         FloatVector fc = c;
00051         collision_model->addTriangle( fa, fb, fc );
00052         a  = b;
00053         b  = c;
00054         tris++;
00055         v_it++;
00056     }
00057     return tris;
00058 }
00059 #endif
00060 
00061 
00062 };  //  namespace Models
00063 };  //  namespace Teddy
00064