[692] | 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-2005 The OGRE Team
|
---|
| 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 |
|
---|
| 21 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
---|
| 22 | # include <Ogre/Ogre.h>
|
---|
| 23 | #else
|
---|
| 24 | # include "Ogre.h"
|
---|
| 25 | #endif
|
---|
| 26 |
|
---|
| 27 | using namespace Ogre ;
|
---|
| 28 |
|
---|
| 29 | class WaterMesh
|
---|
| 30 | {
|
---|
| 31 | private:
|
---|
| 32 | MeshPtr mesh ;
|
---|
| 33 | SubMesh *subMesh ;
|
---|
| 34 | float *vertexBuffers[3] ; // we need 3 vertex buffers
|
---|
| 35 | int currentBuffNumber ;
|
---|
| 36 | int complexity ;
|
---|
| 37 | String meshName ;
|
---|
| 38 | int numFaces ;
|
---|
| 39 | int numVertices ;
|
---|
| 40 | Vector3* vNormals ;
|
---|
| 41 |
|
---|
| 42 | HardwareVertexBufferSharedPtr posVertexBuffer ;
|
---|
| 43 | HardwareVertexBufferSharedPtr normVertexBuffer ;
|
---|
| 44 | HardwareVertexBufferSharedPtr texcoordsVertexBuffer ;
|
---|
| 45 | HardwareIndexBufferSharedPtr indexBuffer ;
|
---|
| 46 |
|
---|
| 47 | Real lastTimeStamp ;
|
---|
| 48 | Real lastAnimationTimeStamp;
|
---|
| 49 | Real lastFrameTime ;
|
---|
| 50 |
|
---|
| 51 | void calculateFakeNormals();
|
---|
| 52 | void calculateNormals();
|
---|
| 53 | public:
|
---|
| 54 | WaterMesh(const String& meshName, Real planeSize, int complexity) ;
|
---|
| 55 |
|
---|
| 56 | virtual ~WaterMesh ();
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | /** "pushes" a mesh at position [x,y]. Note, that x,y are float, hence
|
---|
| 60 | * 4 vertices are actually pushed
|
---|
| 61 | * @note
|
---|
| 62 | * This should be replaced by push with 'radius' parameter to simulate
|
---|
| 63 | * big objects falling into water
|
---|
| 64 | */
|
---|
| 65 | void push(Real x, Real y, Real depth, bool absolute=false) ;
|
---|
| 66 |
|
---|
| 67 | /** gets height at given x and y, takes average value of the closes nodes */
|
---|
| 68 | Real getHeight(Real x, Real y);
|
---|
| 69 |
|
---|
| 70 | /** updates mesh */
|
---|
| 71 | void updateMesh(Real timeSinceLastFrame) ;
|
---|
| 72 |
|
---|
| 73 | Real PARAM_C ; // ripple speed
|
---|
| 74 | Real PARAM_D ; // distance
|
---|
| 75 | Real PARAM_U ; // viscosity
|
---|
| 76 | Real PARAM_T ; // time
|
---|
| 77 | bool useFakeNormals ;
|
---|
| 78 | } ;
|
---|
| 79 |
|
---|
| 80 | #endif
|
---|