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/mrm__internal_8h-source.html | 386 ++++++++++++++++++++++++++ 1 file changed, 386 insertions(+) create mode 100644 docs/doxygen/nel/mrm__internal_8h-source.html (limited to 'docs/doxygen/nel/mrm__internal_8h-source.html') diff --git a/docs/doxygen/nel/mrm__internal_8h-source.html b/docs/doxygen/nel/mrm__internal_8h-source.html new file mode 100644 index 00000000..393be5b7 --- /dev/null +++ b/docs/doxygen/nel/mrm__internal_8h-source.html @@ -0,0 +1,386 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

mrm_internal.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2001 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #ifndef NL_MRM_INTERNAL_H
+00027 #define NL_MRM_INTERNAL_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "3d/mrm_mesh.h"
+00031 
+00032 
+00033 namespace NL3D
+00034 {
+00035 
+00036 // ***************************************************************************
+00037 struct CLinearEquation
+00038 {
+00039         struct Element
+00040         {
+00041                 uint32  index;
+00042                 float   factor;
+00043 
+00044                 Element(uint32 i, float f)
+00045                 {
+00046                         index = i;
+00047                         factor = f;
+00048                 }
+00049         };
+00050 
+00051         std::vector<Element> Elts;
+00052 
+00053         void init(uint32 ii)
+00054         {
+00055                 clear();
+00056                 Elts.push_back (Element(ii, 1.0f));
+00057         }
+00058 
+00059         // this = this + eq * factor
+00060         void add(CLinearEquation& eq, float factor)
+00061         {
+00062                 Element tmp(0, 0.0f);
+00063 
+00064                 for (uint32 i = 0; i < eq.Elts.size(); ++i)
+00065                 {
+00066                         tmp.index = eq.Elts[i].index;
+00067                         tmp.factor = factor * eq.Elts[i].factor;
+00068                         Elts.push_back (tmp);
+00069                 }
+00070         }
+00071 
+00072         // this = this * factor
+00073         void mul (float factor)
+00074         {
+00075                 for (uint32 i = 0; i < Elts.size(); ++i)
+00076                         Elts[i].factor *= factor;
+00077         }
+00078 
+00079         void clear()
+00080         {
+00081                 NLMISC::contReset (Elts);
+00082         }
+00083 };
+00084 
+00085 // ***************************************************************************
+00092 struct  CMRMVertex
+00093 {
+00094 public:
+00095         // Original / Dest position.
+00096         CVector                                 Current,Original;
+00097         std::vector<CVector>    BSCurrent;
+00098         // For Skinning.
+00099         CMesh::CSkinWeight              CurrentSW, OriginalSW;
+00100         std::vector<sint>               SharedFaces;
+00101         sint                                    CollapsedTo;
+00102         // Final index in the coarser mesh.
+00103         sint                                    CoarserIndex;
+00104 
+00105         // The link to the current meshInterface vertex.
+00106         CMesh::CInterfaceLink   InterfaceLink;
+00107 
+00108 public:
+00109         CMRMVertex() {CollapsedTo=-1;}
+00110 };
+00111 
+00112 
+00113 // ***************************************************************************
+00120 struct  CMRMAttribute
+00121 {
+00122 public:
+00123         CVectorH                Current,Original;
+00124         std::vector<CVectorH>           BSCurrent;
+00125         sint                    CollapsedTo;            // -2 <=> "must interpolate from Current to Original".
+00126         // Final index in the coarser mesh.
+00127         sint                    CoarserIndex;
+00128 
+00129 public:
+00130         // temporary data in construction:
+00131         sint                    InterpolatedFace;
+00132         sint                    NbSharedFaces;
+00133         bool                    Shared;
+00134         // A wedge is said "shared" if after edge is collapsed, he lost corners.
+00135         // If NbSharedFaces==0, this wedge has been entirely destroyed.
+00136 
+00137 public:
+00138         CMRMAttribute() {CollapsedTo=-1;}
+00139 };
+00140 
+00141 
+00142 // ***************************************************************************
+00149 struct  CMRMEdge
+00150 {
+00151         sint    v0,v1;
+00152         CMRMEdge() {}
+00153         CMRMEdge(sint a, sint b) {v0= a; v1=b;}
+00154         bool operator==(const CMRMEdge &o) const
+00155         {
+00156                 // Order means nothing  ( (v0,v1) == (v1,v0) ).... Kick it.
+00157                 return (v0==o.v0 && v1==o.v1) || (v0==o.v1 && v1==o.v0);
+00158         }
+00159         bool operator<(const CMRMEdge &o) const
+00160         {
+00161                 // Order means nothing  ( (v0,v1) == (v1,v0) ).... Kick it.
+00162                 sint max0= std::max(v0,v1);
+00163                 sint min0= std::min(v0,v1);
+00164                 sint max1= std::max(o.v0,o.v1);
+00165                 sint min1= std::min(o.v0,o.v1);
+00166                 if(max0!=max1)
+00167                         return max0<max1;
+00168                 else
+00169                         return min0<min1;
+00170         }
+00171 };
+00172 
+00173 
+00174 // ***************************************************************************
+00175 struct  CMRMFaceBuild;
+00182 struct  CMRMEdgeFace : public CMRMEdge
+00183 {
+00184         CMRMFaceBuild           *Face;
+00185         CMRMEdgeFace();
+00186         CMRMEdgeFace(sint a, sint b, CMRMFaceBuild *f) 
+00187         {
+00188                 v0=a; v1=b;
+00189                 Face= f;
+00190         }
+00191         CMRMEdgeFace(const CMRMEdge &e, CMRMFaceBuild *f) : CMRMEdge(e)
+00192         {
+00193                 Face= f;
+00194         }
+00195 
+00196 };
+00197 
+00198 
+00199 // ***************************************************************************
+00206 typedef std::multimap<float, CMRMEdgeFace>      TEdgeMap;
+00207 typedef TEdgeMap::iterator                                      ItEdgeMap;
+00208 
+00209 
+00210 // ***************************************************************************
+00217 struct  CMRMFaceBuild : public CMRMFace
+00218 {
+00219 public:
+00220         // temporary data in construction:
+00221         // The interpolated attrbute of the face.
+00222         CVectorH                InterpolatedAttribute;
+00223         std::vector<CVectorH>   BSInterpolated;
+00224 
+00225         // Is this face deleted in the current MRM collapse?
+00226         bool                    Deleted;
+00227         // The iterator of the edges in the EdgeCollapse list.
+00228         ItEdgeMap               It0, It1, It2;
+00229         // The mirror value of iterator: are they valid???
+00230         bool                    ValidIt0, ValidIt1, ValidIt2;
+00231 
+00232 
+00233 public:
+00234         CMRMFaceBuild()
+00235         {
+00236                 Deleted=false;
+00237                 ValidIt0= ValidIt1= ValidIt2= false;
+00238         }
+00239         CMRMFaceBuild &operator=(const CMRMFace &f)
+00240         {
+00241                 (CMRMFace &)(*this)=f;
+00242                 return *this;
+00243         }
+00244 
+00245         // Edges.
+00246         //=======
+00247         sint    getAssociatedEdge(const CMRMEdge &edge) const
+00248         {
+00249                 sint v0= edge.v0;
+00250                 sint v1= edge.v1;
+00251                 if(Corner[0].Vertex==v0 && Corner[1].Vertex==v1)        return 0;
+00252                 if(Corner[0].Vertex==v1 && Corner[1].Vertex==v0)        return 0;
+00253                 if(Corner[1].Vertex==v0 && Corner[2].Vertex==v1)        return 1;
+00254                 if(Corner[1].Vertex==v1 && Corner[2].Vertex==v0)        return 1;
+00255                 if(Corner[0].Vertex==v0 && Corner[2].Vertex==v1)        return 2;
+00256                 if(Corner[0].Vertex==v1 && Corner[2].Vertex==v0)        return 2;
+00257                 return -1;
+00258         }
+00259         bool    hasEdge(const CMRMEdge &edge) const
+00260         {
+00261                 return getAssociatedEdge(edge)!=-1;
+00262         }
+00263         CMRMEdge        getEdge(sint eId) const
+00264         {
+00265                 if(eId==0) return CMRMEdge(Corner[0].Vertex, Corner[1].Vertex);
+00266                 if(eId==1) return CMRMEdge(Corner[1].Vertex, Corner[2].Vertex);
+00267                 if(eId==2) return CMRMEdge(Corner[2].Vertex, Corner[0].Vertex);
+00268                 nlstop;
+00269                 return CMRMEdge(-1,-1);
+00270         }
+00271         void    invalidAllIts(TEdgeMap &edgeMap)
+00272         {
+00273                 ValidIt0= ValidIt1= ValidIt2= false;
+00274                 It0= edgeMap.end();
+00275                 It1= edgeMap.end();
+00276                 It2= edgeMap.end();
+00277         }
+00278         void    invalidEdgeIt(const CMRMEdge &e, TEdgeMap &edgeMap)
+00279         {
+00280                 if(e== getEdge(0))
+00281                         It0= edgeMap.end(), ValidIt0= false;
+00282                 else if(e== getEdge(1))
+00283                         It1= edgeMap.end(), ValidIt1= false;
+00284                 else if(e== getEdge(2))
+00285                         It2= edgeMap.end(), ValidIt2= false;
+00286                 else nlstop;
+00287         }
+00288         bool    validEdgeIt(const CMRMEdge &e)
+00289         {
+00290                 if(e== getEdge(0)) return ValidIt0;
+00291                 if(e== getEdge(1)) return ValidIt1;
+00292                 if(e== getEdge(2)) return ValidIt2;
+00293                 nlstop;
+00294                 return false;
+00295         }
+00296 
+00297         // Vertices.
+00298         //==========
+00299         bool    hasVertex(sint  numvertex)
+00300         {
+00301                 return Corner[0].Vertex==numvertex || Corner[1].Vertex==numvertex || Corner[2].Vertex==numvertex;
+00302         }
+00303 
+00304         
+00305         // Wedges.
+00306         //==========
+00307         bool    hasWedge(sint attribId, sint numwedge)
+00308         {
+00309                 return Corner[0].Attributes[attribId]==numwedge ||
+00310                         Corner[1].Attributes[attribId]==numwedge ||
+00311                         Corner[2].Attributes[attribId]==numwedge;
+00312         }
+00313         sint    getAssociatedWedge(sint attribId, sint numvertex)
+00314         {
+00315                 if(Corner[0].Vertex==numvertex) return Corner[0].Attributes[attribId];
+00316                 if(Corner[1].Vertex==numvertex) return Corner[1].Attributes[attribId];
+00317                 if(Corner[2].Vertex==numvertex) return Corner[2].Attributes[attribId];
+00318                 return -1;
+00319         }
+00320 };
+00321 
+00322 
+00323 // ***************************************************************************
+00327 class   CMRMSewingMesh
+00328 {
+00329         struct  CLod
+00330         {
+00331                 // A list of edge that must be collapsed for this Lod. NB: sorted from first to collapse to last to collapse
+00332                 std::vector<CMRMEdge>   EdgeToCollapse;
+00333         };
+00334 
+00335         // A list of Lods.
+00336         std::vector<CLod>       _Lods;
+00337 
+00338 public:
+00339 
+00342         void    build(const CMesh::CInterface &meshInt, uint nWantedLods, uint divisor);
+00343 
+00347         sint    mustCollapseEdge(uint lod, const CMRMEdge &edge, uint &vertToCollapse) const;
+00348 
+00350         sint    getNumCollapseEdge(uint lod) const;
+00351 
+00352 };
+00353 
+00354 
+00355 
+00356 
+00357 } // NL3D
+00358 
+00359 
+00360 #endif // NL_MRM_INTERNAL_H
+00361 
+00362 /* End of mrm_internal.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1