00001 #pragma once
00002 #ifndef PHWATERCONTACT_H
00003 #define PHWATERCONTACT_H
00004
00005 #include <Base/BaseUtility.h>
00006 #include <SceneGraph/SGScene.h>
00007 #include <Collision/CDMesh.h>
00008 #include <vector>
00009
00010
00011
00012
00013 #ifdef USE_FRM
00014 #include "PHWaterResistanceMap.h"
00015 #endif
00016
00017 namespace Spr{;
00018
00019
00020
00021
00022 class CDConvex;
00023 class CDMesh;
00024
00025
00026
00027 class PHWaterContactEngine;
00028 class PHWGeometry : public UTRefCount{
00029 public:
00030 PHWGeometry();
00031 UTRef<SGFrame> frame;
00032 CDMesh* mesh;
00033 #ifdef USE_FRM
00034 PHWaterResistanceMap* frm;
00035 #endif
00036 CDGeometries conveces;
00037 void Set(SGFrame* f, CDMesh* g, PHWaterContactEngine* e);
00038 };
00039 typedef std::vector<UTRef<PHWGeometry> > PHWGeometries;
00040
00041 class PHSolid;
00042 class PHWSolid : public UTRefCount{
00043 public:
00044 UTRef<PHSolid> solid;
00045 UTRef<SGFrame> frame;
00046
00047
00048 PHWGeometries geometries;
00049 void Init(PHWaterContactEngine* e);
00050 void EnumGeometries(SGFrame*, PHWaterContactEngine* e);
00051 };
00052 typedef std::vector<UTRef<PHWSolid> > PHWSolids;
00053
00054
00055
00056
00057
00058 class PHWater;
00059 class PHWaterContactEngine : public SGBehaviorEngine{
00060 public:
00061 PHSolid* soPaddle;
00062 Vec3f paddleForceK;
00063 Vec3f paddleForceB;
00064 Vec3f paddleTorqueK;
00065 Vec3f paddleTorqueB;
00066 public:
00067 SGOBJECTDEF(PHWaterContactEngine);
00068 bool bUseFrm;
00069
00070 UTRef<PHWater> water;
00071 PHWSolids solids;
00072 #ifdef USE_FRM
00073 PHWaterResistanceMaps frms;
00074 #endif
00075
00076 std::vector<Vec3f> tris;
00077 std::vector<Vec3f> points;
00078
00079
00080 PHWaterContactEngine();
00081
00082
00083 virtual bool AddChildObject(SGObject* o, SGScene* s);
00084
00085 virtual void Loaded(SGScene* scene);
00086
00087 virtual void Init(SGScene* scene);
00088
00089 int GetPriority() const { return SGBP_WATERCONTACTENGINE; }
00090
00091 virtual void Step(SGScene* s);
00092
00093 virtual void Clear(SGScene* s);
00094
00095 virtual void LoadState(const SGBehaviorStates& states);
00096
00097 virtual void SaveState(SGBehaviorStates& states) const;
00098
00099 virtual void Render(GRRender* r, SGScene* s);
00100 };
00101
00102
00103 }
00104 #endif
00105