Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

polyplan.h

00001 /*
00002     Copyright (C) 1998 by Jorrit Tyberghein
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library 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 GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_POLYPLANE_H__
00020 #define __CS_POLYPLANE_H__
00021 
00022 #include "csgeom/math3d.h"
00023 #include "csgeom/transfrm.h"
00024 
00030 class csPolyPlane
00031 {
00033   friend class csPolygon2D;
00035   friend class csPolyTexture;
00036 
00037 private:
00039   csPlane3 plane_obj;
00041   csPlane3 plane_wor;
00043   csPlane3 plane_cam;
00045   int ref_count;
00046 
00048   virtual ~csPolyPlane ();
00049 
00050 public:
00052   csPolyPlane ();
00053 
00055   void IncRef () { ref_count++; }
00057   void DecRef () { if (!--ref_count) delete this; }
00058 
00065   void ObjectToWorld (
00066         const csReversibleTransform& obj,
00067         const csVector3& vertex1);
00068 
00075   void WorldToCamera (
00076         const csReversibleTransform& t,
00077         const csVector3& vertex1);
00078 
00083   float SquaredDistance (csVector3& v) const
00084   {
00085     float d = plane_wor.Distance (v);
00086     return d*d;
00087   }
00088 
00094   bool NearlyEqual (csPolyPlane* plane) const
00095   {
00096     return csMath3::PlanesEqual (plane_wor, plane->plane_wor);
00097   }
00098 
00103   void ClosestPoint (csVector3& v, csVector3& isect) const;
00104 
00112   bool IntersectSegment (const csVector3& start, const csVector3& end,
00113                           csVector3& isect, float* pr) const;
00114 
00118   csPlane3& GetObjectPlane () { return plane_obj; }
00119 
00123   const csPlane3& GetObjectPlane () const { return plane_obj; }
00124 
00128   csPlane3& GetWorldPlane () { return plane_wor; }
00129 
00133   const csPlane3& GetWorldPlane () const { return plane_wor; }
00134 
00138   csPlane3& GetCameraPlane () { return plane_cam; }
00139 
00143   const csPlane3& GetCameraPlane () const { return plane_cam; }
00144 
00148   void GetObjectNormal (float* p_A, float* p_B, float* p_C, float* p_D) const;
00149 
00153   void GetWorldNormal (float* p_A, float* p_B, float* p_C, float* p_D) const;
00154 
00158   void GetCameraNormal (float* p_A, float* p_B, float* p_C, float* p_D) const;
00159 };
00160 
00161 #endif // __CS_POLYPLANE_H__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000