From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03103.html | 1389 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1389 insertions(+) create mode 100644 docs/doxygen/nel/a03103.html (limited to 'docs/doxygen/nel/a03103.html') diff --git a/docs/doxygen/nel/a03103.html b/docs/doxygen/nel/a03103.html new file mode 100644 index 00000000..88ea4947 --- /dev/null +++ b/docs/doxygen/nel/a03103.html @@ -0,0 +1,1389 @@ + + +NeL: NL3D::CPortal class Reference + + + +
+

NL3D::CPortal Class Reference

#include <portal.h> +

+


Detailed Description

+CPortal

+

Author:
Matthieu Besson

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 55 of file portal.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

bool clipPyramid (NLMISC::CVector &observer, std::vector< NLMISC::CPlane > &pyramid)
bool clipRay (const NLMISC::CVector &start, const NLMISC::CVector &end)
 return true if the portal clip the segment

 CPortal ()
CClustergetCluster (uint pos)
 return the cluster linked to the portal

std::string getName ()
uint8 getNbCluster ()
 return the number of clusters linked to the portal

const std::vector< NLMISC::CVector > & getPoly ()
void getPoly (std::vector< NLMISC::CVector > &dest) const
 get this cluster poly in local coordinates

bool isInFront (NLMISC::CVector &v)
 Return true if the vertex v is in front of the portal.

bool isOpened ()
void open (bool opened)
void resetClusterLinks ()
 set all link to clusters to NULL.

void serial (NLMISC::IStream &f)
 Serial.

bool setCluster (CCluster *cluster)
 return false if more than 2 clusters added

void setName (std::string &name)
bool setPoly (const std::vector< NLMISC::CVector > &poly)
 return false if the polygon is not convex

void setWorldMatrix (const NLMISC::CMatrix &WM)
const std::string & getOcclusionModel ()
uint getOcclusionModelId ()
const std::string & getOpenOcclusionModel ()
uint getOpenOcclusionModelId ()
void setOcclusionModel (const std::string &occlusionModel)
void setOpenOcclusionModel (const std::string &occlusionModel)

Private Attributes

CCluster_Clusters [2]
std::vector< NLMISC::CVector_LocalPoly
std::string _Name
NLMISC::TStringId _OcclusionModelId
bool _Opened
NLMISC::TStringId _OpenOcclusionModelId
std::vector< NLMISC::CVector_Poly

Friends

class CInstanceGroup
 Friend class.

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NL3D::CPortal::CPortal  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 48 of file portal.cpp. +

+References _OcclusionModelId, _Opened, and _OpenOcclusionModelId. +

+

00049 {
+00050         _Clusters[0] = _Clusters[1] = NULL;
+00051         _Opened = true;
+00052         _OcclusionModelId = CStringMapper::map("no occlusion");
+00053         _OpenOcclusionModelId = CStringMapper::map("no occlusion");
+00054 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
bool NL3D::CPortal::clipPyramid NLMISC::CVector observer,
std::vector< NLMISC::CPlane > &  pyramid
+
+ + + + + +
+   + + +

+Clip the view pyramid (all planes pass through observer point) against the portal

Returns:
false if the pyramid is completly clipped
+ +

+Definition at line 83 of file portal.cpp. +

+References _Opened, _Poly, NLMISC::CPolygon::clip(), uint, and NLMISC::CPolygon::Vertices. +

+Referenced by NL3D::CCluster::recursTraverseClip(). +

+

00084 {
+00085         if (!_Opened || _Poly.size()<3)
+00086                 return false;
+00087         // Clip portal with pyramid
+00088         CPolygon p;
+00089         p.Vertices = _Poly;
+00090         p.clip( &pyramid[1], pyramid.size()-1 );
+00091 
+00092         // Construct pyramid with clipped portal
+00093         if( p.Vertices.size() > 2 )
+00094         {
+00095                 uint i;
+00096                 // Found the right orientation
+00097                 CVector n = (p.Vertices[1]-p.Vertices[0])^(p.Vertices[2]-p.Vertices[0]);
+00098                 if( ((observer-p.Vertices[0])*n) < 0.0f )
+00099                 {
+00100                         // Invert vertices
+00101                         for( i = 0; i < (p.Vertices.size()/2); ++i )
+00102                         {
+00103                                 CVector tmp = p.Vertices[i];
+00104                                 p.Vertices[i] = p.Vertices[p.Vertices.size()-1-i];
+00105                                 p.Vertices[p.Vertices.size()-1-i] = tmp;
+00106                         }
+00107                 }
+00108                 // Make pyramid : preserve 0 and 1 plane which are near and far plane
+00109                 pyramid.resize (p.Vertices.size()+2);
+00110                 for( i = 0; i < (p.Vertices.size()); ++i )
+00111                 {
+00112                         pyramid[i+2].make( observer, p.Vertices[i], p.Vertices[(i+1)%p.Vertices.size()] );
+00113                 }
+00114                 return true;
+00115         }
+00116 
+00117         return false;
+00118 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
bool NL3D::CPortal::clipRay const NLMISC::CVector start,
const NLMISC::CVector end
+
+ + + + + +
+   + + +

+return true if the portal clip the segment +

+ +

+Definition at line 262 of file portal.cpp. +

+References _Poly, NLMISC::CPlane::d, NLMISC::CPlane::getNormal(), NLMISC::CPlane::make(), sint, and uint. +

+Referenced by NL3D::CCluster::cameraRayClip(). +

+

00263 {
+00264         if(_Poly.size()<3)
+00265                 return false;
+00266 
+00267         // Avoid precision problem, make local to poly
+00268         const   CVector         &refVert= _Poly[0];
+00269         CVector         start= startWorld - refVert;
+00270         CVector         end= endWorld - refVert;
+00271         
+00272         // compute the plane of this poly, local to polygon 
+00273         CPlane  plane;
+00274         plane.make(CVector::Null, _Poly[1] - refVert, _Poly[2] - refVert);
+00275         CVector normal = plane.getNormal();
+00276 
+00277         float   np1 = normal*end;
+00278         float   np2 = np1-normal*start;
+00279         
+00280         if (np2 == 0.0f)
+00281                 return false;
+00282         
+00283         float   lambda = (plane.d+np1)/np2;
+00284         
+00285         // Checks the intersection belongs to the segment
+00286         if (lambda < 0 || lambda > 1.0f)
+00287                 return false;
+00288         
+00289         // The intersection on the plane
+00290         CVector hit = start*lambda+end*(1.0f-lambda);
+00291         
+00292         // Do convex test on each border
+00293         sint    sign= 0;
+00294         uint    polySize= _Poly.size();
+00295         for(uint i=0;i<polySize;i++)
+00296         {
+00297                 const   CVector v0= _Poly[i] - refVert;
+00298                 const   CVector v1= _Poly[(i+1)%polySize] - refVert;
+00299                 float   d = ((v1-v0)^normal)*(hit-v0);
+00300                 if(d<0)
+00301                 {
+00302                         if(sign==1)
+00303                                 return false;
+00304                         else
+00305                                 sign=-1;
+00306                 }
+00307                 else if(d>0)
+00308                 {
+00309                         if(sign==-1)
+00310                                 return false;
+00311                         else
+00312                                 sign=1;
+00313                 }
+00314                 else
+00315                         return false;
+00316         }
+00317 
+00318         // all on same side, ok!
+00319         return true;
+00320 }
+
+

+ + + + +
+ + + + + + + + + + +
CCluster* NL3D::CPortal::getCluster uint  pos  )  [inline]
+
+ + + + + +
+   + + +

+return the cluster linked to the portal +

+ +

+Definition at line 84 of file portal.h. +

+References uint. +

+Referenced by NL3D::CCluster::cameraRayClip(), and NL3D::CCluster::recursTraverseClip(). +

+

00084 { return _Clusters[pos]; }
+
+

+ + + + +
+ + + + + + + + + + +
std::string NL3D::CPortal::getName void   )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 101 of file portal.h. +

+

00101 { return _Name; }
+
+

+ + + + +
+ + + + + + + + + +
uint8 NL3D::CPortal::getNbCluster  ) 
+
+ + + + + +
+   + + +

+return the number of clusters linked to the portal +

+ +

+Definition at line 156 of file portal.cpp. +

+References uint8. +

+

00157 {
+00158         uint8 nRet = 0;
+00159         if( _Clusters[0] != NULL )
+00160                 nRet++;
+00161         if( _Clusters[1] != NULL )
+00162                 nRet++;
+00163         return nRet;
+00164 }
+
+

+ + + + +
+ + + + + + + + + +
const std::string & NL3D::CPortal::getOcclusionModel  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 60 of file portal.cpp. +

+References _OcclusionModelId. +

+

00061 {
+00062         return CStringMapper::unmap(_OcclusionModelId);
+00063 }
+
+

+ + + + +
+ + + + + + + + + +
uint NL3D::CPortal::getOcclusionModelId  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 64 of file portal.cpp. +

+References _OcclusionModelId, and uint. +

+

00065 {
+00066         return _OcclusionModelId;
+00067 }
+
+

+ + + + +
+ + + + + + + + + +
const std::string & NL3D::CPortal::getOpenOcclusionModel  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 72 of file portal.cpp. +

+References _OpenOcclusionModelId. +

+

00073 {
+00074         return CStringMapper::unmap(_OpenOcclusionModelId);
+00075 }
+
+

+ + + + +
+ + + + + + + + + +
uint NL3D::CPortal::getOpenOcclusionModelId  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 76 of file portal.cpp. +

+References _OpenOcclusionModelId, and uint. +

+

00077 {
+00078         return _OpenOcclusionModelId;
+00079 }
+
+

+ + + + +
+ + + + + + + + + +
const std::vector<NLMISC::CVector>& NL3D::CPortal::getPoly  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 91 of file portal.h. +

+References _LocalPoly. +

+

00091 {return _LocalPoly;}
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPortal::getPoly std::vector< NLMISC::CVector > &  dest  )  const
+
+ + + + + +
+   + + +

+get this cluster poly in local coordinates +

+ +

+Definition at line 209 of file portal.cpp. +

+References _LocalPoly. +

+

00210 {
+00211         dest = _LocalPoly;
+00212 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CPortal::isInFront NLMISC::CVector v  ) 
+
+ + + + + +
+   + + +

+Return true if the vertex v is in front of the portal. +

+ +

+Definition at line 121 of file portal.cpp. +

+References _Poly, and v. +

+Referenced by NL3D::CCluster::recursTraverseClip(). +

+

00122 {
+00123         if( _Poly.size()<3 )
+00124                 return false;
+00125         CVector v1 = _Poly[1] - _Poly[0];
+00126         CVector v2 = _Poly[2] - _Poly[0];
+00127         CVector n = v1^v2;
+00128         CVector pv = v - _Poly[0];
+00129         return ((n*pv) > 0.0f);
+00130 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CPortal::isOpened  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 104 of file portal.h. +

+References _Opened. +

+

00104 { return _Opened; }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPortal::open bool  opened  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 103 of file portal.h. +

+References _Opened. +

+

00103 { _Opened = opened; }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPortal::resetClusterLinks  ) 
+
+ + + + + +
+   + + +

+set all link to clusters to NULL. +

+Accessors --------- +

+Definition at line 134 of file portal.cpp. +

+

00135 {
+00136         _Clusters[0] = _Clusters[1] = NULL;
+00137 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPortal::serial NLMISC::IStream f  ) 
+
+ + + + + +
+   + + +

+Serial. +

+ +

+Definition at line 216 of file portal.cpp. +

+References _LocalPoly, _OcclusionModelId, _OpenOcclusionModelId, _Poly, NLMISC::IStream::isReading(), NLMISC::IStream::serial(), NLMISC::IStream::serialCont(), and NLMISC::IStream::serialVersion(). +

+

00217 {
+00218         int version = f.serialVersion (1);
+00219 
+00220         f.serialCont (_LocalPoly);
+00221         if (f.isReading())
+00222                 _Poly = _LocalPoly;
+00223         f.serial (_Name);
+00224 
+00225         if (version >= 1)
+00226         {
+00227                 if (f.isReading())
+00228                 {
+00229                         std::string occName;
+00230                         f.serial(occName);
+00231                         if (occName.empty())
+00232                                 occName = "no occlusion";
+00233                         _OcclusionModelId = CStringMapper::map(occName);
+00234 
+00235                         f.serial(occName);
+00236                         if (occName.empty())
+00237                                 occName = "no occlusion";
+00238                         _OpenOcclusionModelId = CStringMapper::map(occName);
+00239                 }
+00240                 else
+00241                 {
+00242                         std::string occName = CStringMapper::unmap(_OcclusionModelId);
+00243                         if (occName == "no occlusion")
+00244                                 occName = "";
+00245                         f.serial(occName);
+00246                         occName = CStringMapper::unmap(_OpenOcclusionModelId);
+00247                         if (occName == "no occlusion")
+00248                                 occName = "";
+00249                         f.serial(occName);
+00250                 }
+00251         }
+00252 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CPortal::setCluster CCluster cluster  ) 
+
+ + + + + +
+   + + +

+return false if more than 2 clusters added +

+ +

+Definition at line 140 of file portal.cpp. +

+

00141 {
+00142         if( _Clusters[0] == NULL )
+00143         {
+00144                 _Clusters[0] = cluster;
+00145                 return true;
+00146         }
+00147         if( _Clusters[1] == NULL )
+00148         {
+00149                 _Clusters[1] = cluster;
+00150                 return true;
+00151         }
+00152         return false;
+00153 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPortal::setName std::string &  name  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 99 of file portal.h. +

+

00099 { _Name = name; }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPortal::setOcclusionModel const std::string &  occlusionModel  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 56 of file portal.cpp. +

+References _OcclusionModelId. +

+

00057 {
+00058         _OcclusionModelId = CStringMapper::map(occlusionModel);
+00059 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPortal::setOpenOcclusionModel const std::string &  occlusionModel  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 68 of file portal.cpp. +

+References _OpenOcclusionModelId. +

+

00069 {
+00070         _OpenOcclusionModelId = CStringMapper::map(occlusionModel);
+00071 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CPortal::setPoly const std::vector< NLMISC::CVector > &  poly  ) 
+
+ + + + + +
+   + + +

+return false if the polygon is not convex +

+ +

+

Todo:
check if the polygon has the good orientation
+ +

+Definition at line 167 of file portal.cpp. +

+References _LocalPoly, _Poly, NLMISC::CPlane::make(), NLMISC::CPlane::normalize(), PORTALPRECISION, and uint. +

+

00168 {
+00169         uint i;
+00170 
+00171         if( poly.size() < 3 )
+00172                 return false;
+00173 
+00174         // Check if the polygon is a plane
+00175         CPlane p;
+00176         p.make( poly[0], poly[1], poly[2] );
+00177         p.normalize();
+00178         float dist;
+00179         for( i = 0; i < (poly.size()-3); ++i )
+00180         {
+00181                 dist = fabsf(p*poly[i+3]);
+00182                 if( dist > PORTALPRECISION )
+00183                         return false;
+00184         }
+00185 
+00186         // Check if the polygon is convex
+00188         /*
+00189         CPlane p2;
+00190         for( i = 0; i < (poly.size()-1); ++i )
+00191         {
+00192                 p2.make( poly[i], poly[i+1], poly[i]+p.getNormal() );
+00193                 for( j = 0; j < poly.size(); ++j )
+00194                 if( (j != i) && (j != i+1) )
+00195                 {
+00196                         if( p2*poly[j] < 0.0f )
+00197                                 return false;
+00198                 }
+00199         }*/
+00200 
+00201         // Set the value
+00202         _LocalPoly = poly;
+00203         _Poly = poly;
+00204 
+00205         return true;
+00206 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPortal::setWorldMatrix const NLMISC::CMatrix WM  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 255 of file portal.cpp. +

+References _LocalPoly, _Poly, NLMISC::CMatrix::mulPoint(), and uint32. +

+Referenced by NL3D::CInstanceGroup::addToSceneWhenAllShapesLoaded(), and NL3D::CCluster::traverseHrc(). +

+

00256 {
+00257         for (uint32 i = 0; i < _LocalPoly.size(); ++i)
+00258                 _Poly[i] = WM.mulPoint(_LocalPoly[i]);
+00259 }
+
+


Friends And Related Function Documentation

+

+ + + + +
+ + +
friend class CInstanceGroup [friend] +
+
+ + + + + +
+   + + +

+Friend class. +

+ +

+Definition at line 136 of file portal.h.

+


Field Documentation

+

+ + + + +
+ + +
CCluster* NL3D::CPortal::_Clusters[2] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 121 of file portal.h.

+

+ + + + +
+ + +
std::vector<NLMISC::CVector> NL3D::CPortal::_LocalPoly [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 126 of file portal.h. +

+Referenced by getPoly(), serial(), setPoly(), and setWorldMatrix().

+

+ + + + +
+ + +
std::string NL3D::CPortal::_Name [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 123 of file portal.h.

+

+ + + + +
+ + +
NLMISC::TStringId NL3D::CPortal::_OcclusionModelId [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 131 of file portal.h. +

+Referenced by CPortal(), getOcclusionModel(), getOcclusionModelId(), serial(), and setOcclusionModel().

+

+ + + + +
+ + +
bool NL3D::CPortal::_Opened [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 124 of file portal.h. +

+Referenced by clipPyramid(), CPortal(), isOpened(), and open().

+

+ + + + +
+ + +
NLMISC::TStringId NL3D::CPortal::_OpenOcclusionModelId [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 132 of file portal.h. +

+Referenced by CPortal(), getOpenOcclusionModel(), getOpenOcclusionModelId(), serial(), and setOpenOcclusionModel().

+

+ + + + +
+ + +
std::vector<NLMISC::CVector> NL3D::CPortal::_Poly [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 127 of file portal.h. +

+Referenced by clipPyramid(), clipRay(), isInFront(), serial(), setPoly(), and setWorldMatrix().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 07:03:00 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1