示例#1
0
	MapRenderer.onRender = function OnRender( tick, gl )
	{
		var fog   = MapRenderer.fog;
		fog.use   = MapPreferences.fog;
		var light = MapRenderer.light;

		var modelView, projection, normalMat;
		var x, y;

		// Clean mouse position in world
		Mouse.world.x =  -1;
		Mouse.world.y =  -1;
		Mouse.world.z =  -1;

		// Clear screen, update camera
		gl.clear( gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT );
		Camera.update( tick );

		modelView  = Camera.modelView;
		projection = Camera.projection;
		normalMat  = Camera.normalMat;

		Ground.render(gl, modelView, projection, normalMat, fog, light );
		Models.render(gl, modelView, projection, normalMat, fog, light );

		if( Altitude.intersect( modelView, projection, _pos)) {
			x = _pos[0];
			y = _pos[1];

			// Walkable
			if( (Altitude.getCellType( x, y ) & Altitude.TYPE.WALKABLE) ) {
				GridSelector.render( gl, modelView, projection, fog, x, y );
				Mouse.world.x =  x;
				Mouse.world.y =  y;
				Mouse.world.z =  Altitude.getCellHeight( x, y );
			}
		}

		EntityManager.render( gl, modelView, projection, fog );

		Water.render( gl, modelView, projection, fog, light, tick );

		// Display clouds on maps
		Sky.render( gl, modelView, projection, fog, tick );

		// Rendering effects
		Damage.render( gl, modelView, projection, fog, tick );
		//Effects.render( gl, modelView, projection, fog );

		// Play sounds
		Sounds.render( Session.Entity.position, tick );

		// Find entity over the cursor
		var entity = EntityManager.intersect( modelView, projection );
		EntityManager.setOverEntity( entity );

		// Clean up
		MemoryManager.clean(gl, tick);
	};
示例#2
0
	/**
	 * Rendering scene
	 *
	 * @param {number} tick
	 * @param {object} webgl context
	 */
	function render( tick, gl )
	{
		// Updating camera position
		mat4.identity( _modelView );
		mat4.translate( _modelView, _modelView, [ 0, -_model.box.range[1]*0.1, -_model.box.range[1]*0.5-5 ] );
		mat4.rotateX(  _modelView, _modelView, (15/180) * Math.PI );
		mat4.rotateY(  _modelView, _modelView, ((tick)/1000*360/8) / 180 * Math.PI );

		// Calculate normal mat
		mat4.toInverseMat3( _modelView, _normalMat);
		mat3.transpose( _normalMat, _normalMat);

		// Clear screen, update camera
		gl.clear( gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT );

		ModelRenderer.render(gl, _modelView, Camera.projection, _normalMat, _fog, _light );
	}