public Texture2D getHeigthMapTexture(Vector2 textureCentrePosition) { // TODO: take relative texture position into account _heightFieldGenerator.GenerateHeightField(_currentFrame, _extendedHeightField); _currentFrame = (_currentFrame + 1) % _frameCycleLength; return(_extendedHeightField.textureHeightMap); }
void FixedUpdate() { currentFrame = (currentFrame + 1) % WaveParticle.FRAME_CYCLE_LENGTH; IterateWaveParticles(); ComputeObjectForces(); IterateObjects(); GenerateWaveParticles(); heightFieldGenerator.GenerateHeightField(currentFrame, extendedHeightField); needFreshMesh = true; }
void Update() { currentFrame = (currentFrame + 1) % WaveParticle.FRAME_CYCLE_LENGTH; Profiler.BeginSample("Iterate Wave Particles"); IterateWaveParticles(); Profiler.EndSample(); Profiler.BeginSample("Compute Object Forces"); ComputeObjectForces(); Profiler.EndSample(); Profiler.BeginSample("Iterate Objects"); IterateObjects(); Profiler.EndSample(); Profiler.BeginSample("Generate Wave Particles"); GenerateWaveParticles(); Profiler.EndSample(); Profiler.BeginSample("Generate Height Field"); heightFieldGenerator.GenerateHeightField(currentFrame, extendedHeightField); Profiler.EndSample(); needFreshMesh = true; //} ////// Update is called once per frame (setup the mesh for drawing the wave particle-generated waves) //void Update() //{ // Load the new vertices into the Mesh if (!_useGpuForVertices) { GenerateMeshFromHeightMap(extendedHeightField, vertices, uv, triangles, _mesh); Renderer rend = GetComponent <Renderer>(); if (rend != null) { rend.material = waterMaterial; } } else { Renderer rend = GetComponent <Renderer>(); if (rend != null) { rend.material = waterMaterial; } } waterMaterial.SetTexture(Shader.PropertyToID("_FieldTex"), extendedHeightField.textureHeightMap); }