root/as3/FLARToolKit/trunk/libs/Papervision3D/src/org/papervision3d/materials/utils/BumpmapGenerator.as

リビジョン 3288, 1.1 kB (コミッタ: rokubou, コミット時期: 3 年 前)

Add Papervison3D.

Line 
1 package org.papervision3d.materials.utils
2 {
3         import flash.display.BitmapData;
4         import flash.filters.ConvolutionFilter;
5         import flash.geom.Point;
6
7         public class BumpmapGenerator
8         {
9                 public static function generateBumpmapFrom(bitmapData : BitmapData) : BitmapData
10                 {
11                         var tempMap : BitmapData;
12                         var p : Point = new Point();
13                         var convolve : ConvolutionFilter = new ConvolutionFilter();
14                         convolve.matrixX = 3;
15                         convolve.matrixY = 3;
16                         convolve.divisor = 1;
17                         convolve.bias = 127;
18                        
19                         var outputData : BitmapData = new BitmapData(bitmapData.width, bitmapData.height, false, 0x000080);
20                        
21                         convolve.matrix = new Array(0, 0, 0, -1, 0, 1, 0, 0, 0);
22                         tempMap = bitmapData.clone();
23                         tempMap.applyFilter(bitmapData, tempMap.rect, p, convolve);
24                         outputData.copyChannel(tempMap, tempMap.rect, p, 1, 1);
25                         convolve.matrix = new Array(0, -1, 0, 0, 0, 0, 0, 1, 0);
26                         tempMap = bitmapData.clone();
27                         tempMap.applyFilter(bitmapData, tempMap.rect, p, convolve);
28                         outputData.copyChannel(tempMap, tempMap.rect, p, 1, 2);
29                
30                         tempMap.dispose();
31                         return outputData;
32                 }
33         }
34 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。