1 | /* |
---|
2 | ----------------------------------------------------------------------------- |
---|
3 | This source file is part of OGRE |
---|
4 | (Object-oriented Graphics Rendering Engine) |
---|
5 | For the latest info, see http://www.ogre3d.org/ |
---|
6 | |
---|
7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | You may use this sample code for anything you like, it is not covered by the |
---|
11 | LGPL like the rest of the engine. |
---|
12 | ----------------------------------------------------------------------------- |
---|
13 | */ |
---|
14 | |
---|
15 | |
---|
16 | #ifndef _WATER_MESH_H_ |
---|
17 | #define _WATER_MESH_H_ |
---|
18 | |
---|
19 | #include "OgrePlatform.h" |
---|
20 | #include "Ogre.h" |
---|
21 | |
---|
22 | using namespace Ogre ; |
---|
23 | |
---|
24 | class WaterMesh |
---|
25 | { |
---|
26 | private: |
---|
27 | MeshPtr mesh ; |
---|
28 | SubMesh *subMesh ; |
---|
29 | float *vertexBuffers[3] ; // we need 3 vertex buffers |
---|
30 | int currentBuffNumber ; |
---|
31 | int complexity ; |
---|
32 | String meshName ; |
---|
33 | int numFaces ; |
---|
34 | int numVertices ; |
---|
35 | Vector3* vNormals ; |
---|
36 | |
---|
37 | HardwareVertexBufferSharedPtr posVertexBuffer ; |
---|
38 | HardwareVertexBufferSharedPtr normVertexBuffer ; |
---|
39 | HardwareVertexBufferSharedPtr texcoordsVertexBuffer ; |
---|
40 | HardwareIndexBufferSharedPtr indexBuffer ; |
---|
41 | |
---|
42 | Real lastTimeStamp ; |
---|
43 | Real lastAnimationTimeStamp; |
---|
44 | Real lastFrameTime ; |
---|
45 | |
---|
46 | void calculateFakeNormals(); |
---|
47 | void calculateNormals(); |
---|
48 | public: |
---|
49 | WaterMesh(const String& meshName, Real planeSize, int complexity) ; |
---|
50 | |
---|
51 | virtual ~WaterMesh (); |
---|
52 | |
---|
53 | |
---|
54 | /** "pushes" a mesh at position [x,y]. Note, that x,y are float, hence |
---|
55 | * 4 vertices are actually pushed |
---|
56 | * @note |
---|
57 | * This should be replaced by push with 'radius' parameter to simulate |
---|
58 | * big objects falling into water |
---|
59 | */ |
---|
60 | void push(Real x, Real y, Real depth, bool absolute=false) ; |
---|
61 | |
---|
62 | /** gets height at given x and y, takes average value of the closes nodes */ |
---|
63 | Real getHeight(Real x, Real y); |
---|
64 | |
---|
65 | /** updates mesh */ |
---|
66 | void updateMesh(Real timeSinceLastFrame) ; |
---|
67 | |
---|
68 | Real PARAM_C ; // ripple speed |
---|
69 | Real PARAM_D ; // distance |
---|
70 | Real PARAM_U ; // viscosity |
---|
71 | Real PARAM_T ; // time |
---|
72 | bool useFakeNormals ; |
---|
73 | } ; |
---|
74 | |
---|
75 | #endif |
---|