⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bumpmapgenerator.as

📁 Papervision3d的源码
💻 AS
字号:
package org.papervision3d.materials.utils
{
	import flash.display.BitmapData;
	import flash.filters.ConvolutionFilter;
	import flash.geom.Point;

	public class BumpmapGenerator
	{
		public static function generateBumpmapFrom(bitmapData : BitmapData) : BitmapData
		{
			var tempMap : BitmapData;
			var p : Point = new Point();
			var convolve : ConvolutionFilter = new ConvolutionFilter();
			convolve.matrixX = 3;
			convolve.matrixY = 3;
			convolve.divisor = 1;
			convolve.bias = 127;
			
			var outputData : BitmapData = new BitmapData(bitmapData.width, bitmapData.height, false, 0x000080);
			
			convolve.matrix = new Array(0, 0, 0, -1, 0, 1, 0, 0, 0);
			tempMap = bitmapData.clone();
			tempMap.applyFilter(bitmapData, tempMap.rect, p, convolve);
			outputData.copyChannel(tempMap, tempMap.rect, p, 1, 1);
			convolve.matrix = new Array(0, -1, 0, 0, 0, 0, 0, 1, 0);
			tempMap = bitmapData.clone();
			tempMap.applyFilter(bitmapData, tempMap.rect, p, convolve);
			outputData.copyChannel(tempMap, tempMap.rect, p, 1, 2);
		
			tempMap.dispose();
			return outputData;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -