Example #1
0
	// ************************************************************************ //
	// Constructor
	// ************************************************************************ //	

	/**
	 * 
	 */
	private void createPatches( int numX, int numY, int size, OceanParams settings )
	{
		for(int x = 0; x < numX; x++)
		{
			for(int y = 0; y < numY; y++)
			{
				GameObject patch = new GameObject( "OceanPatch_ " + x + "_" + y );
				
				patch.AddComponent<MeshFilter>();
				patch.AddComponent<MeshRenderer>();
				
				// ------------------- //
				
				patch.GetComponent<MeshFilter>().mesh 	= this.mesh;
				patch.renderer.material 				= this.material;
				
				// ------------------- //
				
				Vector3 tranform = new Vector3();
				tranform.x = x * settings.L - numX * settings.L/2;
				tranform.z = y * settings.L - numY * settings.L/2;
				
				patch.transform.Translate( tranform );
				
				// ------------------- //
				
				this.oceanPatches[x,y] = patch;
			}
		}
	}
Example #2
0
	// ************************************************************************ //
	// Constructor
	// ************************************************************************ //	
	
	/**
	 * 
	 */
	public OceanGrid( int numX, int numY, int size, OceanParams settings ) 
	{		
		this.oceanPatches = new GameObject[ numX, numY ];

		this.mesh 			= this.createMesh( size );

		this.material 		= settings.material != null ? settings.material : new Material( Shader.Find("Ocean/Ocean") );

		// ------------ //

		this.createPatches( numX, numY, size, settings );
		this.updatePositions( size, settings );
	}
	// ************************************************************************ //
	// Constructor
	// ************************************************************************ //	
	
	public OceanDispertion( OceanParams settings ) 
	{		
		this.settings = settings;
	}
Example #4
0
	/**
	 * 
	 */
	private void updatePositions( int size, OceanParams settings )
	{
		this.positions = new Vector2[ size * size ];

		// ----------- //

		Vector3[] vertices = this.mesh.vertices;

		for( int n = 0; n < size; n++ ) 
		{
			for( int m = 0; m < size; m++ ) 
			{
				int index = n * size + m;

				float x = n * settings.L / settings.N;
				float y = m * settings.L / settings.N;

				vertices[index].x = x;
				vertices[index].z = y;

				this.positions[index] = new Vector2( x, y ); 
			}
		}

		this.mesh.vertices = vertices;
		this.mesh.RecalculateBounds();
	}
	// ************************************************************************ //
	// Constructor
	// ************************************************************************ //	
	
	/**
	 * 
	 */
	public OceanSpectrum( OceanParams settings ) 
	{		
		this.settings = settings;
	}