pxFluid.h

Engine/source/T3D/physics/physx/pxFluid.h

More...

Classes:

Public Defines

define

Detailed Description

Public Defines

MAX_PARTICLES() 100
  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _PXFLUID_H_
 25#define _PXFLUID_H_
 26
 27#ifndef _SCENEOBJECT_H_
 28#include "scene/sceneObject.h"
 29#endif
 30#ifndef _PHYSX_H_
 31#include "T3D/physics/physx/px.h"
 32#endif
 33
 34class BaseMatInstance;
 35class PxWorld;
 36class NxScene;
 37
 38
 39class PxFluid : public SceneObject
 40{
 41   typedef SceneObject Parent;
 42
 43protected:
 44   
 45   enum NetMasks
 46   {
 47      UpdateMask     = Parent::NextFreeMask,
 48      ResetMask      = Parent::NextFreeMask << 1,
 49      NextFreeMask   = Parent::NextFreeMask << 2
 50   };
 51
 52   struct FluidParticle
 53   {
 54      NxVec3   position;
 55      NxVec3   velocity;
 56      NxReal   density;
 57      NxReal   lifetime;
 58      NxU32    id;
 59      NxVec3   collisionNormal;
 60   };
 61
 62   #define MAX_PARTICLES 100
 63
 64public:
 65
 66   PxFluid();
 67   virtual ~PxFluid();
 68
 69   DECLARE_CONOBJECT( PxFluid );      
 70
 71   // SimObject
 72   virtual bool onAdd();
 73   virtual void onRemove();
 74   static void initPersistFields();
 75   virtual void inspectPostApply();
 76
 77   // NetObject
 78   virtual U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
 79   virtual void unpackUpdate( NetConnection *conn, BitStream *stream );
 80
 81   // SceneObject
 82   virtual void setTransform( const MatrixF &mat );
 83   virtual void setScale( const VectorF &scale );
 84   virtual void prepRenderImage( SceneRenderState *state );
 85
 86   void resetParticles();
 87   void setRate( F32 rate );
 88
 89protected:
 90
 91   void renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
 92
 93   void _createFluid();
 94   void _destroyFluid();
 95
 96protected:
 97
 98   PxWorld *mWorld;
 99   NxScene *mScene;
100
101   FluidParticle *mParticles;
102   //NxParticleData *mParticleData;
103   NxFluid *mFluid;
104   U32 mParticleCount;
105   NxFluidEmitter *mEmitter;
106};
107
108#endif // _PXFLUID_H_
109