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/ps__mesh_8h-source.html | 486 +++++++++++++++++++++++++++++++ 1 file changed, 486 insertions(+) create mode 100644 docs/doxygen/nel/ps__mesh_8h-source.html (limited to 'docs/doxygen/nel/ps__mesh_8h-source.html') diff --git a/docs/doxygen/nel/ps__mesh_8h-source.html b/docs/doxygen/nel/ps__mesh_8h-source.html new file mode 100644 index 00000000..59a31781 --- /dev/null +++ b/docs/doxygen/nel/ps__mesh_8h-source.html @@ -0,0 +1,486 @@ + + + + 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  
+

ps_mesh.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000, 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_PS_MESH_H
+00027 #define NL_PS_MESH_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "nel/misc/class_registry.h"
+00031 #include "3d/ps_particle_basic.h"
+00032 #include "3d/ps_attrib.h"
+00033 #include "3d/ps_plane_basis.h"
+00034 #include "3d/vertex_buffer.h"
+00035 #include "3d/material.h"
+00036 #include "3d/primitive_block.h"
+00037 #include "3d/shape.h"
+00038 
+00039 
+00040 
+00041 #include <string>
+00042 #include <vector>
+00043 #include <queue>
+00044 
+00045 namespace NLMISC
+00046 {
+00047         class IStream;
+00048         struct EStream;
+00049 }
+00050 
+00051 
+00052 namespace NL3D {
+00053 
+00054 
+00055 class CPSLocated;
+00056 class CTransformShape;
+00057 class CShapeBank;
+00058 class CMesh;
+00059 
+00060 
+00061 
+00062 const uint ConstraintMeshMaxNumVerts                    = 512; // the maximum number of vertices for a constraint mesh
+00063 const uint ConstraintMeshBufSize                                = 64;  // number of meshs to be processed at once...
+00064 const uint ConstraintMeshMaxNumPrerotatedModels = 32;  // maximum number of meshs that can be prerotated
+00065 
+00072 class CPSMesh : public  CPSParticle,
+00073                             public CPSSizedParticle,
+00074                                 public CPSRotated3DPlaneParticle,
+00075                                 public CPSRotated2DParticle,
+00076                                 public CPSShapeParticle
+00077 {
+00078 public:
+00080         CPSMesh(const std::string &shape = "") : _Invalidated(false)
+00081         {
+00082                 _Shape = shape;
+00083                 _Name = std::string("Mesh");
+00084         }
+00085 
+00087         void setShape(const std::string &shape) { _Shape = shape; }
+00088 
+00090         std::string getShape(void) const { return _Shape; }
+00091 
+00093         virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
+00094 
+00095         virtual ~CPSMesh();
+00096 
+00097         NLMISC_DECLARE_CLASS(CPSMesh);
+00098 
+00099 
+00104         void invalidate() 
+00105         { 
+00106                 _Invalidated = true; 
+00107                 _Instances.clear();
+00108         }
+00109 
+00111         virtual bool hasTransparentFaces(void);
+00112 
+00114         virtual bool hasOpaqueFaces(void);
+00115 
+00117         virtual uint32 getMaxNumFaces(void) const;
+00118 
+00119 protected:
+00122         virtual void newElement(CPSLocated *emitterLocated, uint32 emitterIndex);
+00123         
+00128         virtual void deleteElement(uint32 index);
+00129 
+00130         virtual void step(TPSProcessPass pass, TAnimationTime ellapsedTime, TAnimationTime realEt);
+00131 
+00133         virtual void updatePos();
+00134 
+00138         virtual void resize(uint32 size);       
+00139 
+00140         //CSmartPtr<IShape> _Shape;
+00141 
+00142         std::string _Shape;
+00143 
+00144         // a container for mesh instances
+00145         typedef CPSAttrib<CTransformShape *> TInstanceCont;
+00146 
+00147         TInstanceCont _Instances;
+00148 
+00149         // this is set to true when the transformed shape have to be recerated
+00150 
+00151         bool _Invalidated;
+00152 
+00153         virtual CPSLocated *getSizeOwner(void) { return _Owner; }
+00154         virtual CPSLocated *getAngle2DOwner(void) { return _Owner; }
+00155         virtual CPSLocated *getPlaneBasisOwner(void) { return _Owner; }
+00156 }; 
+00157 
+00158 
+00163 class CPSConstraintMesh : public CPSParticle,
+00164                                                   public CPSSizedParticle,
+00165                                                   public CPSRotated3DPlaneParticle,
+00166                                                   public CPSHintParticleRotateTheSame,
+00167                                                   public CPSShapeParticle,
+00168                                                   public CPSColoredParticle
+00169 {
+00170 public: 
+00172         CPSConstraintMesh();
+00173 
+00174         virtual ~CPSConstraintMesh();
+00175 
+00179         void                            setShape(const std::string &meshFileName);
+00180 
+00182         std::string                     getShape(void) const;
+00183 
+00184 
+00185 
+00195         void                                            setShapes(const std::string *shapesNames, uint numShapes);
+00196 
+00197 
+00199         void                                            setShape(uint index, const std::string &shapeName);
+00200 
+00202         const std::string          &getShape(uint index) const;
+00203 
+00205         uint                                            getNumShapes() const;
+00206 
+00210         void                                            getShapesNames(std::string *shapesNames) const;
+00211 
+00213         void                                            setMorphValue(float value);
+00214 
+00216         float                                           getMorphValue() const;
+00217 
+00219         void                                            setMorphScheme(CPSAttribMaker<float> *scheme);
+00220 
+00222         CPSAttribMaker<float>           *getMorphScheme();
+00223 
+00225         const CPSAttribMaker<float>     *getMorphScheme() const;
+00226           
+00227 
+00228         
+00229         
+00230 
+00241         void                            hintRotateTheSame(uint32 nbConfiguration,
+00242                                                                                   float minAngularVelocity = NLMISC::Pi,
+00243                                                                                   float maxAngularVelocity = NLMISC::Pi
+00244                                                                                  );
+00245 
+00250         void                            disableHintRotateTheSame(void)
+00251         {
+00252                 hintRotateTheSame(0);
+00253         }
+00254 
+00260         uint32                          checkHintRotateTheSame(float &min, float &max) const
+00261         {
+00262                 min = _MinAngularVelocity;
+00263                 max = _MaxAngularVelocity;
+00264                 return _PrecompBasis.size(); 
+00265         }
+00266 
+00267 
+00269         virtual void            serial(NLMISC::IStream &f) throw(NLMISC::EStream);
+00270 
+00271         
+00272         NLMISC_DECLARE_CLASS(CPSConstraintMesh);
+00273         
+00275         virtual bool            hasTransparentFaces(void);
+00276 
+00278         virtual bool            hasOpaqueFaces(void);
+00279 
+00281         virtual uint32          getMaxNumFaces(void) const;
+00282 
+00283 
+00289         void                            forceStageModulationByColor(uint stage, bool force);
+00290         
+00292         bool                            isStageModulationForced(uint stage) const;
+00293 
+00295         void                            forceVertexColorLighting(bool force = true) { _VertexColorLightingForced = force; }
+00296 
+00298         bool                            isVertexColorLightingForced() const { return _VertexColorLightingForced; }
+00299 
+00301         static  void            initPrerotVB();
+00302 
+00303         //\name Texture animation
+00305 
+00306                 enum TTexAnimType { NoAnim = 0, GlobalAnim, /*Local, */ Last};
+00307 
+00309                 void    setTexAnimType(TTexAnimType type);
+00310 
+00312                 TTexAnimType getTexAnimType() const;
+00314 
+00315                 //\name Global texture animation. Calls to these method are only valid if texture animation is global.
+00317 
+00318                         struct CGlobalTexAnim
+00319                         {
+00320                                 NLMISC::CVector2f TransSpeed; /* = (0, 0) */
+00321                                 NLMISC::CVector2f TransAccel; /* = (0, 0) */
+00322                                 NLMISC::CVector2f ScaleStart; /* = (1, 1) */
+00323                                 NLMISC::CVector2f ScaleSpeed; /* = (0, 0) */
+00324                                 NLMISC::CVector2f ScaleAccel; /* = (0, 0) */
+00325                                 float                     WRotSpeed;  /* = 0 */
+00326                                 float                     WRotAccel;  /* = 0 */
+00327                                 CGlobalTexAnim();
+00328                                 void    serial(NLMISC::IStream &f) throw(NLMISC::EStream);
+00330                                 void    buildMatrix(TAnimationTime &date, NLMISC::CMatrix &dest);
+00331                         };
+00332 
+00334                         void                    setGlobalTexAnim(uint stage, const CGlobalTexAnim &properties);
+00335 
+00337                         const CGlobalTexAnim &getGlobalTexAnim(uint stage) const;
+00338 
+00340                         void  forceGlobalAnimTimeResetOnNewElement(bool force = true) { _ReinitGlobalAnimTimeOnNewElement = force; }
+00341                         bool  isGlobalAnimTimeResetOnNewElementForced()  const { return _ReinitGlobalAnimTimeOnNewElement != 0; }
+00342 
+00344 
+00345         
+00346 
+00347 protected:
+00348         friend class CPSConstraintMeshHelper;
+00349         // inherited from CPSColoredParticle
+00350         virtual CPSLocated *getColorOwner(void) { return _Owner; }
+00351 
+00352         // inherited from CPSColoredParticle
+00353         virtual void updateMatAndVbForColor(void);
+00354 
+00357         virtual void            newElement(CPSLocated *emitterLocated, uint32 emitterIndex);
+00358         
+00361         virtual void            deleteElement(uint32 index);
+00362 
+00363         virtual void step(TPSProcessPass pass, TAnimationTime ellapsedTime, TAnimationTime realEt);
+00367         void            draw(bool opaque, TAnimationTime ellapsedTime);
+00368 
+00370         void                            drawPreRotatedMeshs(bool opaque, TAnimationTime ellapsedTime);
+00371         
+00372 
+00374         void                            releaseShapes();
+00375 
+00376 
+00383         void    computeColors(CVertexBuffer &outVB, const CVertexBuffer &inVB, uint startIndex, uint toProcess, uint32 srcStep);
+00384 
+00388         virtual void            resize(uint32 size);    
+00389         
+00393         bool                            update(void);
+00394 
+00396         CVertexBuffer       &makePrerotatedVb(const CVertexBuffer &inVB, TAnimationTime ellapsedTime);
+00397         
+00401         struct CRdrPass
+00402         {
+00403                 CMaterial                       Mat;
+00404                 CMaterial                       SourceMat;
+00405                 CPrimitiveBlock         Pb;             
+00406         };
+00407 
+00409         typedef std::vector<CRdrPass> TRdrPassSet;
+00410 
+00412         struct CMeshDisplay
+00413         {
+00414                 TRdrPassSet   RdrPasses;
+00415                 CVertexBuffer VB;
+00416         };
+00417         
+00418         void restoreMaterials();
+00419 
+00421         void    CPSConstraintMesh::setupRenderPasses(float date, TRdrPassSet &rdrPasses, bool opaque);
+00422 
+00424         void                            doRenderPasses(IDriver *driver, uint numObj, TRdrPassSet &rdrPasses, bool opaque);      
+00425 
+00426         
+00427         typedef NLMISC::CSmartPtr<IShape>                 PShape;
+00428         typedef std::vector<std::string>                  TShapeNameVect;
+00429         typedef std::vector<PShape>                               TShapeVect;   
+00430 
+00431         // name of the shapes
+00432         TShapeNameVect _MeshShapeFileName;
+00433         TShapeVect         _Shapes;
+00434 
+00435         // caches the number of faces (for load balacing)
+00436         uint _NumFaces;
+00437 
+00438         // the shape bank containing the shape
+00439         CShapeBank  *_ModelBank;        
+00440 
+00441         
+00445         class CMeshDisplayShare
+00446         {
+00447                 public:
+00449                         CMeshDisplayShare(uint maxNumMD) : _MaxNumMD(maxNumMD) {}
+00450 
+00452                         ~CMeshDisplayShare();
+00453 
+00457                         CMeshDisplay &getMeshDisplay(IShape *shape, uint32 format);
+00458                         
+00459                 protected:
+00460                         uint     _MaxNumMD;
+00461                         typedef  NLMISC::CSmartPtr<IShape> PShape;
+00462                         struct CKey
+00463                         {
+00464                                 ~CKey();
+00465                                 PShape Shape;
+00466                                 uint32 Format;
+00467                                 bool operator == (const CKey &key) const { return Shape == key.Shape && Format == key.Format; }
+00468                                 bool operator != (const CKey &key) const { return ! (*this == key); }
+00469                                 bool operator <  (const CKey &key) const { return Shape < key.Shape || (Shape == key.Shape && Format < key.Format); }
+00470                         };                              
+00471                         typedef std::map<CKey, CMeshDisplay *> TMDMap; // vb  sorted by their formats
+00472                         typedef std::queue<CKey> TMDQueue; // vb sorted by creation date
+00473                         TMDQueue MDQueue;
+00474                         TMDMap   MDMap;
+00476                         static void buildRdrPassSet(TRdrPassSet &dest, const IShape *src);
+00478                         static void buildVB(uint32 destFormat, CVertexBuffer &dest, const IShape *src); 
+00479         };
+00480 
+00481         friend class CMeshDisplayShare;
+00482 
+00483         
+00485         static CMeshDisplayShare                _MeshDisplayShare;      
+00486 
+00488         static CVertexBuffer                    _PreRotatedMeshVB;                        // mesh has no normals
+00489         static CVertexBuffer                    _PreRotatedMeshVBWithNormal;  // mesh has normals
+00490 
+00491         
+00492         // we must store them for serialization
+00493         float _MinAngularVelocity;
+00494         float _MaxAngularVelocity;
+00495 
+00496 
+00497         // use for rotation of precomputed meshs
+00498         struct CPlaneBasisPair
+00499         {               
+00500                 CPlaneBasis Basis;
+00501                 CVector         Axis; // an axis for rotation
+00502                 float           AngularVelocity; // an angular velocity
+00503         };
+00504 
+00506         std::vector< CPlaneBasisPair > _PrecompBasis;
+00507 
+00509         std::vector<uint32> _IndexInPrecompBasis;
+00510 
+00512         void fillIndexesInPrecompBasis(void);
+00513         
+00514         // release the model shape (dtor, or before loading)
+00515         void clean(void);
+00516 
+00517         virtual CPSLocated *getSizeOwner(void) { return _Owner; }       
+00518         virtual CPSLocated *getPlaneBasisOwner(void) { return _Owner; }
+00519 
+00521         uint8   _ModulatedStages;
+00522 
+00523         // A new mesh has been set, so we must reconstruct it when needed       
+00524         uint8   _Touched : 1;   
+00525         // flags that indicate wether the object has transparent faces. When the 'touch' flag is set, it is undefined, until the next update() call.
+00526         uint8   _HasTransparentFaces : 1;
+00527         // flags that indicate wether the object has opaques faces. When the 'touch' flag is set, it is undefined, until the next update() call.
+00528         uint8   _HasOpaqueFaces : 1;
+00529         uint8   _VertexColorLightingForced : 1;
+00530         uint8   _GlobalAnimationEnabled : 1;
+00531         uint8   _ReinitGlobalAnimTimeOnNewElement : 1;
+00532 
+00533         
+00535         struct CGlobalTexAnims
+00536         {
+00537                 CGlobalTexAnim          Anims[IDRV_MAT_MAXTEXTURES];            
+00538                 void    serial(NLMISC::IStream &f) throw(NLMISC::EStream);              
+00539         };
+00540 
+00541         typedef std::auto_ptr<CGlobalTexAnims> PGlobalTexAnims;
+00542         PGlobalTexAnims                                            _GlobalTexAnims;
+00543         float                                                              _GlobalAnimDate;
+00544 
+00545 
+00547 
+00548                 float                                   _MorphValue;
+00549                 CPSAttribMaker<float>   *_MorphScheme;
+00551 private:
+00552         CPSConstraintMesh(const CPSConstraintMesh &) { nlassert(0); /* not supported */ }
+00553         CPSConstraintMesh &operator = (const CPSConstraintMesh &other) { nlassert(0); return *this; /* not supported */ }
+00554 }; 
+00555 
+00556 
+00557 
+00558 } // NL3D
+00559 
+00560 
+00561 #endif // NL_PS_MESH_H
+00562 
+00563 /* End of ps_mesh.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1