Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

plane.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++ -*-
00002    
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2003 Koblenz University
00006    $Id: plane.cpp,v 1.2 2003/05/19 21:32:39 fruit Exp $
00007 
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; version 2 of the License.
00011   
00012    This program 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
00015    GNU General Public License for more details.
00016  
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 #include "plane.h"
00022 
00023 using namespace salt;
00024 
00025 EPlaneSide Plane::ClassifyBox(const AABB3& bb) const
00026 {
00027     Vector3f posFarPt;
00028     Vector3f negFarPt;
00029 
00030     if(normal.x()>0)    // right
00031         if(normal.y()>0)    // right, top
00032             if(normal.z()>0)    // right, top, front
00033             {
00034                 posFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.maxVec.z()); 
00035                 negFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.minVec.z()); 
00036             }
00037             else    // right, top, back
00038             {
00039                 posFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.minVec.z()); 
00040                 negFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.maxVec.z()); 
00041             }
00042         else    // right, bottom
00043             if(normal.z()>0)    // right, bottom, front
00044             {
00045                 posFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.maxVec.z()); 
00046                 negFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.minVec.z()); 
00047             }
00048             else    // right, bottom, back
00049             {
00050                 posFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.minVec.z()); 
00051                 negFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.maxVec.z()); 
00052             }
00053     else
00054         if(normal.y()>0)    // left, top
00055             if(normal.z()>0)    // left, top, front
00056             {
00057                 posFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.maxVec.z()); 
00058                 negFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.minVec.z()); 
00059             }
00060             else    // left, top, back
00061             {
00062                 posFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.minVec.z()); 
00063                 negFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.maxVec.z()); 
00064             }
00065         else    // left, bottom
00066             if(normal.z()>0)    // left, bottom, front
00067             {
00068                 posFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.maxVec.z()); 
00069                 negFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.minVec.z()); 
00070             }
00071             else    // left, bottom, back
00072             {
00073                 posFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.minVec.z()); 
00074                 negFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.maxVec.z()); 
00075             }
00076 
00077     // BOX IS "OUTSIDE"
00078     if (GetOrientation(negFarPt, 0.0f)==PLANESIDE_FRONT) return PLANESIDE_FRONT;
00079 
00080     // BOX IS "INSIDE"
00081     if (GetOrientation(posFarPt, 0.0f)==PLANESIDE_BACK) return PLANESIDE_BACK;
00082 
00083     return PLANESIDE_SPLIT;
00084 }
00085 
00086 void Plane::Normalize()
00087 {
00088     float l=normal.Length();
00089     float iLen = 1.0f/l;
00090     normal.x()*=iLen;
00091     normal.y()*=iLen;
00092     normal.z()*=iLen;
00093     d*=iLen;
00094 }

Generated on Thu Apr 6 15:25:39 2006 for rcssserver3d by  doxygen 1.4.4