├── .gitignore ├── Library ├── 2DFilter.blend ├── Cameras.blend ├── GEKit │ ├── ambientOcclusion.glsl │ ├── basicColor.glsl │ ├── camera.py │ ├── depthOfField.glsl │ └── utils.py └── textures │ ├── barrel.new.NOR.png │ ├── barrel.oil.COL.png │ ├── barrel.oil.GLOSS.png │ ├── barrel.util.COL.png │ ├── barrel.util.GLOSS.png │ ├── barrel.wood.COL.png │ ├── barrel.wood.GLOSS.png │ ├── barrel.wood.NOR.png │ ├── barrel.wood2.COL.png │ ├── barrel.wood2.GLOSS.png │ ├── env.png │ └── envBlur.png ├── Media ├── Screen Shot 2.png ├── Screen Shot 3.png ├── Screen Shot 4.png ├── Screen Shot 6.png ├── demo1.jpg ├── demo1.psd ├── demo2.jpg ├── demo2.psd ├── demo3.jpg ├── demo3.psd ├── demo4.jpg ├── demo4.psd ├── demo5.jpg ├── demo5.psd ├── demo6.jpg ├── demo6.psd ├── documentation.jpg └── documentation.psd ├── README.md ├── Template ├── main.blend └── scripts │ └── main.py ├── Tests ├── blank.blend ├── demo1.blend └── textures │ ├── GroundBrickFlooring_01.jpg │ ├── GroundBrickFlooring_01_NRM.jpg │ ├── GroundBrickFlooring_01_SPEC.jpg │ ├── GroundBrickFlooring_01_SPEC_clean.jpg │ ├── GrungeLeaking_01_SPEC.jpg │ ├── InteriorTilesDark_03.jpg │ ├── InteriorTilesDark_03_NRM.jpg │ ├── InteriorTilesDark_03_SPEC.jpg │ ├── InteriorWoodFineDark_02.jpg │ ├── InteriorWoodFineDark_02_NRM.jpg │ ├── InteriorWoodFineDark_02_SPEC.jpg │ ├── Leather_01.jpg │ ├── Leather_01_NRM.jpg │ ├── Lightmap.png │ ├── Lightmap2.png │ ├── Lightmap3.png │ ├── WallBricks_01.jpg │ ├── WallBricks_01_NRM.jpg │ ├── WallBricks_01_SPEC.jpg │ ├── WallConcreteBare_07.jpg │ ├── WallConcreteBare_07_NRM.jpg │ ├── env.png │ ├── envBlur.png │ └── leatherSpec.jpg ├── addons ├── README.md ├── easyGame │ ├── __init__.py │ ├── asset │ │ ├── barrels.blend │ │ ├── concrete.blend │ │ ├── fx.blend │ │ └── wood.blend │ ├── easyAsset.py │ ├── easyMaterial.py │ └── helpers.py └── release │ ├── easyGame10.zip │ ├── easyGame11.zip │ └── easyGame12.zip └── build.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.blend1 2 | *.blend2 3 | __pycache__ 4 | -------------------------------------------------------------------------------- /Library/2DFilter.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/2DFilter.blend -------------------------------------------------------------------------------- /Library/Cameras.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/Cameras.blend -------------------------------------------------------------------------------- /Library/GEKit/ambientOcclusion.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | SSAO GLSL shader v1.2 3 | assembled by Martins Upitis (martinsh) (devlog-martinsh.blogspot.com) 4 | original technique is made by Arkano22 (www.gamedev.net/topic/550699-ssao-no-halo-artifacts/) 5 | 6 | */ 7 | 8 | uniform sampler2D bgl_DepthTexture; 9 | uniform sampler2D bgl_RenderedTexture; 10 | uniform float bgl_RenderedTextureWidth; 11 | uniform float bgl_RenderedTextureHeight; 12 | uniform float timer; 13 | 14 | #define PI 3.14159265 15 | 16 | float width = bgl_RenderedTextureWidth; //texture width 17 | float height = bgl_RenderedTextureHeight; //texture height 18 | 19 | vec2 texCoord = gl_TexCoord[0].st; 20 | 21 | //------------------------------------------ 22 | //general stuff 23 | 24 | //make sure that these two values are the same for your camera, otherwise distances will be wrong. 25 | 26 | float znear = 0.1; //Z-near 27 | float zfar = 100.0; //Z-far 28 | 29 | //user variables 30 | int samples = 8; //ao sample count 31 | 32 | float radius = 5.0; //ao radius 33 | float aoclamp = 0.25; //depth clamp - reduces haloing at screen edges 34 | bool noise = true; //use noise instead of pattern for sample dithering 35 | float noiseamount = 0.001; //dithering amount 36 | 37 | float diffarea = 0.4; //self-shadowing reduction 38 | float gdisplace = 0.4; //gauss bell center 39 | 40 | float lumInfluence = 0.5; //how much luminance affects occlusion 41 | 42 | //-------------------------------------------------------- 43 | 44 | vec2 rand(vec2 coord) //generating noise/pattern texture for dithering 45 | { 46 | float noiseX = ((fract(1.0-coord.s*(width/2.0))*0.25)+(fract(coord.t*(height/2.0))*0.75))*2.0-1.0; 47 | float noiseY = ((fract(1.0-coord.s*(width/2.0))*0.75)+(fract(coord.t*(height/2.0))*0.25))*2.0-1.0; 48 | 49 | if (noise) 50 | { 51 | noiseX = clamp(fract(sin(dot(coord ,vec2(20.0,46.0*timer))) * 47358.5453),0.0,1.0)*2.0-1.0; 52 | noiseY = clamp(fract(sin(dot(coord ,vec2(41.0,37.2*timer)*2.0)) * 43758.5453),0.0,1.0)*2.0-1.0; 53 | } 54 | return vec2(noiseX,noiseY)*noiseamount; 55 | } 56 | 57 | 58 | float readDepth(in vec2 coord) 59 | { 60 | if (gl_TexCoord[0].x<0.0||gl_TexCoord[0].y<0.0) return 1.0; 61 | return (2.0 * znear) / (zfar + znear - texture2D(bgl_DepthTexture, coord ).x * (zfar-znear)); 62 | } 63 | 64 | float compareDepths(in float depth1, in float depth2,inout int far) 65 | { 66 | float garea = 2.0; //gauss bell width 67 | float diff = (depth1 - depth2)*100.0; //depth difference (0-100) 68 | //reduce left bell width to avoid self-shadowing 69 | if (diff 0) 98 | { 99 | temp2 = compareDepths(readDepth(coord2),depth,far); 100 | temp += (1.0-temp)*temp2; 101 | } 102 | 103 | return temp; 104 | } 105 | 106 | void main(void) 107 | { 108 | vec2 noise = rand(texCoord); 109 | float depth = readDepth(texCoord); 110 | 111 | float w = (1.0 / width)/clamp(depth,aoclamp,1.0)+(noise.x*(1.0-noise.x)); 112 | float h = (1.0 / height)/clamp(depth,aoclamp,1.0)+(noise.y*(1.0-noise.y)); 113 | 114 | float pw; 115 | float ph; 116 | 117 | float ao; 118 | 119 | float dl = PI*(3.0-sqrt(5.0)); 120 | float dz = 1.0/float(samples); 121 | float l = 0.0; 122 | float z = 1.0 - dz/2.0; 123 | 124 | for (int i = 0; i <= samples; i ++) 125 | { 126 | float r = sqrt(1.0-z); 127 | 128 | pw = cos(l)*r; 129 | ph = sin(l)*r; 130 | ao += calAO(depth,pw*w,ph*h); 131 | z = z - dz; 132 | l = l + dl; 133 | } 134 | 135 | ao /= float(samples); 136 | ao = 1.0-ao; 137 | 138 | 139 | vec3 color = texture2D(bgl_RenderedTexture,texCoord).rgb; 140 | 141 | vec3 lumcoeff = vec3(0.299,0.587,0.114); 142 | float lum = dot(color.rgb, lumcoeff); 143 | vec3 luminance = vec3(lum, lum, lum); 144 | 145 | vec3 final = vec3(color*mix(vec3(ao),vec3(1.0),luminance*lumInfluence)); 146 | 147 | gl_FragColor = vec4(final,1.0); 148 | 149 | } -------------------------------------------------------------------------------- /Library/GEKit/basicColor.glsl: -------------------------------------------------------------------------------- 1 | 2 | uniform sampler2D bgl_DepthTexture; 3 | uniform sampler2D bgl_RenderedTexture; 4 | uniform float bgl_RenderedTextureWidth; 5 | uniform float bgl_RenderedTextureHeight; 6 | 7 | uniform float timer; 8 | uniform float brightness; 9 | uniform float contrast; 10 | uniform float saturation; 11 | uniform float gamma; 12 | uniform float noise; 13 | uniform float vignette; 14 | 15 | float vignout = 1.5; //vignetting outer border 16 | float vignin = 0.1; //vignetting inner border 17 | 18 | 19 | float width = bgl_RenderedTextureWidth; 20 | float height = bgl_RenderedTextureHeight; 21 | vec2 texCoord = gl_TexCoord[0].xy; 22 | 23 | float rand1(in vec2 coord) 24 | { 25 | float noise = (fract(sin(dot(coord ,vec2(12.9898,78.233*timer))) * 43758.5453)); 26 | return (noise-0.5); 27 | } 28 | 29 | void main(void) 30 | { 31 | vec4 color = texture2D(bgl_RenderedTexture,texCoord).rgba; 32 | 33 | // brightness 34 | color.rgb += color.rgb * brightness; 35 | 36 | // contrast 37 | color.rgb += (color.rgb-vec3(0.5,0.5,0.5)) * contrast; 38 | 39 | // color saturation 40 | 41 | // gamma 42 | color.rgb = pow(color.rgb, vec3(1.0/gamma)); 43 | 44 | // noise 45 | color.rgb += rand1(texCoord) * noise; 46 | 47 | // vignette 48 | float mask = distance(texCoord, vec2(0.5,0.5)); 49 | mask = smoothstep(vignout, vignin, mask); 50 | mask = clamp(mask,0.0,1.0); 51 | mask = mix(1.0, mask, vignette); 52 | color.rgb *= (mask); 53 | 54 | // color balance 55 | 56 | 57 | gl_FragColor = color; 58 | } 59 | -------------------------------------------------------------------------------- /Library/GEKit/camera.py: -------------------------------------------------------------------------------- 1 | #Blender Game Engine Resource Kit 2.7x 2 | #Created by Mike Pan: mikepan.com 3 | 4 | # Use mouse to look around 5 | # W,A,S,D key to walk around 6 | # E and C key to ascend and descend 7 | 8 | from bge import logic 9 | from bge import events 10 | from bge import render 11 | 12 | from . import utils 13 | 14 | def look(cont): 15 | '''Called every logic tick''' 16 | 17 | owner = cont.owner 18 | currentScene = logic.getCurrentScene() 19 | 20 | # only apply to active camera 21 | if currentScene.active_camera is not owner\ 22 | and currentScene.active_camera not in owner.children: 23 | return 24 | 25 | mouse = logic.mouse 26 | keyboard = logic.keyboard.events 27 | 28 | walkSpeed = owner['walkSpeed'] 29 | lookSensitivity = owner['lookSpeed'] 30 | RClickToLook = owner['RClickToLook'] 31 | LClickToLook = owner['LClickToLook'] 32 | lookSmoothing = utils.clamp(owner['lookSmoothing'], 0.0, 0.99) 33 | 34 | # Init code 35 | if "oldX" not in owner: 36 | # center mouse on first frame, create temp variables 37 | print('Using BGE Resource Kit - Mouselook Camera:', owner) 38 | mouse.position = (0.5,0.5) 39 | owner["oldX"] = 0.0 40 | owner["oldY"] = 0.0 41 | 42 | # loop code 43 | else: 44 | # round() is a hack to work around the drifting mouse bug 45 | x = round(0.5 - mouse.position[0], 2) 46 | y = round(0.5 - mouse.position[1], 2) 47 | 48 | # workaround for re-engaged mouse 49 | if logic.mouse.visible: 50 | x = 0 51 | y = 0 52 | 53 | # Smooth movement 54 | x = (owner['oldX']*lookSmoothing + x*(1.0-lookSmoothing)) 55 | y = (owner['oldY']*lookSmoothing + y*(1.0-lookSmoothing)) 56 | 57 | # use mouse clutching options 58 | if (RClickToLook and logic.mouse.events[events.RIGHTMOUSE] == logic.KX_INPUT_ACTIVE)\ 59 | or \ 60 | (LClickToLook and logic.mouse.events[events.LEFTMOUSE] == logic.KX_INPUT_ACTIVE)\ 61 | or not (RClickToLook or LClickToLook): 62 | 63 | # apply the camera view transforms 64 | owner.applyRotation([0, 0, x * lookSensitivity], False) 65 | owner.applyRotation([y * lookSensitivity, 0, 0], True) 66 | 67 | # Center mouse in game window 68 | mouse.position = (0.5,0.5) 69 | logic.mouse.visible = False 70 | else: 71 | # release mouse 72 | logic.mouse.visible = True 73 | 74 | # save old value for smoothing use 75 | owner['oldX'] = x 76 | owner['oldY'] = y 77 | 78 | 79 | # keyboard control 80 | if keyboard[events.WKEY]: 81 | owner.applyMovement([0,0,-walkSpeed], True) 82 | if keyboard[events.SKEY]: 83 | owner.applyMovement([0,0, walkSpeed], True) 84 | if keyboard[events.AKEY]: 85 | owner.applyMovement([-walkSpeed,0,0], True) 86 | if keyboard[events.DKEY]: 87 | owner.applyMovement([walkSpeed,0,0], True) 88 | if keyboard[events.EKEY]: 89 | owner.applyMovement([0,walkSpeed/2,0], True) 90 | if keyboard[events.CKEY]: 91 | owner.applyMovement([0,-walkSpeed/2,0], True) -------------------------------------------------------------------------------- /Library/GEKit/depthOfField.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | DoF with bokeh GLSL shader v2.4 3 | by Martins Upitis (martinsh) (devlog-martinsh.blogspot.com) 4 | 5 | ---------------------- 6 | The shader is Blender Game Engine ready, but it should be quite simple to adapt for your engine. 7 | 8 | This work is licensed under a Creative Commons Attribution 3.0 Unported License. 9 | So you are free to share, modify and adapt it for your needs, and even use it for commercial use. 10 | I would also love to hear about a project you are using it. 11 | 12 | Have fun, 13 | Martins 14 | ---------------------- 15 | 16 | */ 17 | 18 | uniform sampler2D bgl_RenderedTexture; 19 | uniform sampler2D bgl_DepthTexture; 20 | uniform float bgl_RenderedTextureWidth; 21 | uniform float bgl_RenderedTextureHeight; 22 | uniform float timer; 23 | 24 | #define PI 3.14159265 25 | 26 | float width = bgl_RenderedTextureWidth; //texture width 27 | float height = bgl_RenderedTextureHeight; //texture height 28 | 29 | vec2 texel = vec2(1.0/width,1.0/height); 30 | 31 | //settings 32 | 33 | uniform bool autoFocus; 34 | uniform float manualFocusDepth; //focal distance value in meters, but you may use autofocus option below 35 | uniform float fstop; //f-stop value 36 | uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range) 37 | 38 | 39 | /* 40 | make sure that these values are the same for your camera, otherwise distances will be wrong. 41 | */ 42 | 43 | float znear = 0.1; //camera clipping start 44 | float zfar = 100.0; //camera clipping end 45 | float focalLength = 50.0; //camera focal length 46 | 47 | //------------------------------------------ 48 | //user variables 49 | 50 | int samples = 3; //samples on the first ring 51 | int rings = 3; //ring count 52 | 53 | 54 | float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm) 55 | 56 | 57 | vec2 focus = vec2(0.5,0.5); // autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right) 58 | float maxblur = 2.0; //clamp value of max blur (0.0 = no blur,1.0 default) 59 | 60 | float threshold = 0.5; //highlight threshold; 61 | float gain = 2.0; //highlight gain; 62 | 63 | float bias = 0.5; //bokeh edge bias 64 | float fringe = 0.7; //bokeh chromatic aberration/fringing 65 | 66 | float namount = 0.0005; //dither amount 67 | 68 | bool depthblur = false; //blur the depth buffer? 69 | float dbsize = 1.25; //depthblursize 70 | 71 | /* 72 | next part is experimental 73 | not looking good with small sample and ring count 74 | looks okay starting from samples = 4, rings = 4 75 | */ 76 | 77 | bool pentagon = false; //use pentagon as bokeh shape? 78 | float feather = 0.4; //pentagon shape feather 79 | 80 | //------------------------------------------ 81 | 82 | 83 | float penta(vec2 coords) //pentagonal shape 84 | { 85 | float scale = float(rings) - 1.3; 86 | vec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0); 87 | vec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0); 88 | vec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0); 89 | vec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0); 90 | vec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0); 91 | vec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0); 92 | 93 | vec4 one = vec4( 1.0 ); 94 | 95 | vec4 P = vec4((coords),vec2(scale, scale)); 96 | 97 | vec4 dist = vec4(0.0); 98 | float inorout = -4.0; 99 | 100 | dist.x = dot( P, HS0 ); 101 | dist.y = dot( P, HS1 ); 102 | dist.z = dot( P, HS2 ); 103 | dist.w = dot( P, HS3 ); 104 | 105 | dist = smoothstep( -feather, feather, dist ); 106 | 107 | inorout += dot( dist, one ); 108 | 109 | dist.x = dot( P, HS4 ); 110 | dist.y = HS5.w - abs( P.z ); 111 | 112 | dist = smoothstep( -feather, feather, dist ); 113 | inorout += dist.x; 114 | 115 | return clamp( inorout, 0.0, 1.0 ); 116 | } 117 | 118 | float bdepth(vec2 coords) //blurring depth 119 | { 120 | float d = 0.0; 121 | float kernel[9]; 122 | vec2 offset[9]; 123 | 124 | vec2 wh = vec2(texel.x, texel.y) * dbsize; 125 | 126 | offset[0] = vec2(-wh.x,-wh.y); 127 | offset[1] = vec2( 0.0, -wh.y); 128 | offset[2] = vec2( wh.x -wh.y); 129 | 130 | offset[3] = vec2(-wh.x, 0.0); 131 | offset[4] = vec2( 0.0, 0.0); 132 | offset[5] = vec2( wh.x, 0.0); 133 | 134 | offset[6] = vec2(-wh.x, wh.y); 135 | offset[7] = vec2( 0.0, wh.y); 136 | offset[8] = vec2( wh.x, wh.y); 137 | 138 | kernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0; 139 | kernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0; 140 | kernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0; 141 | 142 | 143 | for( int i=0; i<9; i++ ) 144 | { 145 | float tmp = texture2D(bgl_DepthTexture, coords + offset[i]).r; 146 | d += tmp * kernel[i]; 147 | } 148 | 149 | return d; 150 | } 151 | 152 | 153 | vec3 color(vec2 coords,float blur) //processing the sample 154 | { 155 | vec3 col = vec3(0.0); 156 | 157 | col.r = texture2D(bgl_RenderedTexture,coords + vec2(0.0,1.0)*texel*fringe*blur).r; 158 | col.g = texture2D(bgl_RenderedTexture,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g; 159 | col.b = texture2D(bgl_RenderedTexture,coords + vec2(0.866,-0.5)*texel*fringe*blur).b; 160 | 161 | vec3 lumcoeff = vec3(0.299,0.587,0.114); 162 | float lum = dot(col.rgb, lumcoeff); 163 | float thresh = max((lum-threshold)*gain, 0.0); 164 | return col+mix(vec3(0.0),col,thresh*blur); 165 | } 166 | 167 | vec2 rand(vec2 coord) //generating noise/pattern texture for dithering 168 | { 169 | 170 | float noiseX = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233*timer))) * 43758.5453),0.0,1.0)*2.0-1.0; 171 | float noiseY = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233)*2.0*timer)) * 43758.5453),0.0,1.0)*2.0-1.0; 172 | 173 | return vec2(noiseX,noiseY); 174 | } 175 | 176 | vec3 debugFocus(vec3 col, float blur, float depth) 177 | { 178 | float edge = 0.002*depth; //distance based edge smoothing 179 | float m = clamp(smoothstep(0.0,edge,blur),0.0,1.0); 180 | float e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0); 181 | 182 | col = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6); 183 | col = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2); 184 | 185 | return col; 186 | } 187 | 188 | float linearize(float depth) 189 | { 190 | return -zfar * znear / (depth * (zfar - znear) - zfar); 191 | } 192 | 193 | void main() 194 | { 195 | //scene depth calculation 196 | 197 | float depth = linearize(texture2D(bgl_DepthTexture,gl_TexCoord[0].xy).x); 198 | 199 | if (depthblur) 200 | { 201 | depth = linearize(bdepth(gl_TexCoord[0].xy)); 202 | } 203 | 204 | //focal plane calculation 205 | 206 | float fDepth = manualFocusDepth; 207 | 208 | if (autoFocus) 209 | { 210 | fDepth = linearize(texture2D(bgl_DepthTexture,focus).x); 211 | } 212 | 213 | //dof blur factor calculation 214 | 215 | float blur = 0.0; 216 | 217 | float f = focalLength; //focal length in mm 218 | float d = fDepth*1000.0; //focal plane in mm 219 | float o = depth*1000.0; //depth in mm 220 | 221 | float a = (o*f)/(o-f); 222 | float b = (d*f)/(d-f); 223 | float c = (d-f)/(d*fstop*CoC); 224 | 225 | blur = abs(a-b)*c; 226 | 227 | 228 | blur = clamp(blur,0.0,1.0); 229 | 230 | // calculation of pattern for ditering 231 | 232 | vec2 noise = rand(gl_TexCoord[0].xy)*namount*blur; 233 | 234 | // getting blur x and y step factor 235 | 236 | float w = (1.0/width)*blur*maxblur+noise.x; 237 | float h = (1.0/height)*blur*maxblur+noise.y; 238 | 239 | // calculation of final color 240 | 241 | vec3 col = vec3(0.0); 242 | 243 | 244 | col = texture2D(bgl_RenderedTexture, gl_TexCoord[0].xy).rgb; 245 | float s = 1.0; 246 | int ringsamples; 247 | 248 | for (int i = 1; i <= rings; i += 1) 249 | { 250 | ringsamples = i * samples; 251 | 252 | for (int j = 0 ; j < ringsamples ; j += 1) 253 | { 254 | float step = PI*2.0 / float(ringsamples); 255 | float pw = (cos(float(j)*step)*float(i)); 256 | float ph = (sin(float(j)*step)*float(i)); 257 | float p = 1.0; 258 | if (pentagon) 259 | { 260 | p = penta(vec2(pw,ph)); 261 | } 262 | col += color(gl_TexCoord[0].xy + vec2(pw*w,ph*h),blur)*mix(1.0,(float(i))/(float(rings)),bias)*p; 263 | s += 1.0*mix(1.0,(float(i))/(float(rings)),bias)*p; 264 | } 265 | } 266 | col /= s; //divide by sample count 267 | 268 | 269 | if (showFocus) 270 | { 271 | col = debugFocus(col, blur, depth); 272 | } 273 | 274 | gl_FragColor.rgb = col; 275 | gl_FragColor.a = 1.0; 276 | } -------------------------------------------------------------------------------- /Library/GEKit/utils.py: -------------------------------------------------------------------------------- 1 | from bge import logic 2 | from bgl import * 3 | 4 | import os, subprocess, math, cProfile 5 | 6 | def profile(cmd, g, l): 7 | cProfile.runctx(cmd, g, l, sort=1) 8 | 9 | def clamp(var, minLimit = 0.0, maxLimit = 1.0): 10 | assert minLimit < maxLimit 11 | return max(min(var, maxLimit), minLimit) 12 | 13 | def smoothstep(x): 14 | '''returns a smoothed float given an input between 0 and 1''' 15 | return x * x * (3-2*(x)) 16 | 17 | def computeFlatS(period, b, time, offset=1): 18 | """compute the position of the object based on time using this curve: 19 | http://www.wolframalpha.com/input/?i=y%3D%281%2F%281%2Be%5E%28-10-x%29%29+%2B+1%2F%281%2Be%5E%2810-x%29%29%29""" 20 | time = (time%period)+offset 21 | time = (time-period/2)*(20/period) 22 | x = 1/(1+math.e**(-b-time))+1/(1+math.e**(b-time)) 23 | x /= 2.0 24 | x += offset/10 25 | return x 26 | 27 | def mix(a,b,factor): 28 | '''mix two number together using a factor''' 29 | if type(a) is list or type(a) is tuple: 30 | if len(a)==len(b)==2: 31 | return [a[0]*factor + b[0]*(1.0-factor), a[1]*factor + b[1]*(1.0-factor)] 32 | elif len(a)==len(b)==3: 33 | return [a[0]*factor + b[0]*(1.0-factor), a[1]*factor + b[1]*(1.0-factor), a[2]*factor + b[2]*(1.0-factor)] 34 | elif len(a)==len(b)==4: 35 | return [a[0]*factor + b[0]*(1.0-factor), a[1]*factor + b[1]*(1.0-factor), a[2]*factor + b[2]*(1.0-factor), a[3]*factor + b[3]*(1.0-factor)] 36 | else: 37 | raise Exception(ArithmeticError) 38 | else: 39 | return (a*factor + b*(1.0-factor)) 40 | 41 | 42 | -------------------------------------------------------------------------------- /Library/textures/barrel.new.NOR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/barrel.new.NOR.png -------------------------------------------------------------------------------- /Library/textures/barrel.oil.COL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/barrel.oil.COL.png -------------------------------------------------------------------------------- /Library/textures/barrel.oil.GLOSS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/barrel.oil.GLOSS.png -------------------------------------------------------------------------------- /Library/textures/barrel.util.COL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/barrel.util.COL.png -------------------------------------------------------------------------------- /Library/textures/barrel.util.GLOSS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/barrel.util.GLOSS.png -------------------------------------------------------------------------------- /Library/textures/barrel.wood.COL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/barrel.wood.COL.png -------------------------------------------------------------------------------- /Library/textures/barrel.wood.GLOSS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/barrel.wood.GLOSS.png -------------------------------------------------------------------------------- /Library/textures/barrel.wood.NOR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/barrel.wood.NOR.png -------------------------------------------------------------------------------- /Library/textures/barrel.wood2.COL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/barrel.wood2.COL.png -------------------------------------------------------------------------------- /Library/textures/barrel.wood2.GLOSS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/barrel.wood2.GLOSS.png -------------------------------------------------------------------------------- /Library/textures/env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/env.png -------------------------------------------------------------------------------- /Library/textures/envBlur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Library/textures/envBlur.png -------------------------------------------------------------------------------- /Media/Screen Shot 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/Screen Shot 2.png -------------------------------------------------------------------------------- /Media/Screen Shot 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/Screen Shot 3.png -------------------------------------------------------------------------------- /Media/Screen Shot 4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/Screen Shot 4.png -------------------------------------------------------------------------------- /Media/Screen Shot 6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/Screen Shot 6.png -------------------------------------------------------------------------------- /Media/demo1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo1.jpg -------------------------------------------------------------------------------- /Media/demo1.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo1.psd -------------------------------------------------------------------------------- /Media/demo2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo2.jpg -------------------------------------------------------------------------------- /Media/demo2.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo2.psd -------------------------------------------------------------------------------- /Media/demo3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo3.jpg -------------------------------------------------------------------------------- /Media/demo3.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo3.psd -------------------------------------------------------------------------------- /Media/demo4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo4.jpg -------------------------------------------------------------------------------- /Media/demo4.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo4.psd -------------------------------------------------------------------------------- /Media/demo5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo5.jpg -------------------------------------------------------------------------------- /Media/demo5.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo5.psd -------------------------------------------------------------------------------- /Media/demo6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo6.jpg -------------------------------------------------------------------------------- /Media/demo6.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/demo6.psd -------------------------------------------------------------------------------- /Media/documentation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/documentation.jpg -------------------------------------------------------------------------------- /Media/documentation.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Media/documentation.psd -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Blender GE Resource Kit 2 | 3 | A collection of ready-to-use components and templates for the Blender Game Engine 2.7x created (mostly) by Mike Pan. Free for Commercial and Non-commercial use. 4 | 5 | ![demo1](/Media/demo3.jpg) 6 | 7 | ![demo1](/Media/demo1.jpg) 8 | ![demo1](/Media/demo2.jpg) 9 | ![demo1](/Media/demo4.jpg) 10 | ![demo1](/Media/demo5.jpg) 11 | 12 | --- 13 | Additional contributions from: 14 | - [Martins Upitis](http://devlog-martinsh.blogspot.com) 15 | -------------------------------------------------------------------------------- /Template/main.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Template/main.blend -------------------------------------------------------------------------------- /Template/scripts/main.py: -------------------------------------------------------------------------------- 1 | from bge import logic 2 | from bge import events 3 | from bge import render 4 | 5 | def init(): 6 | '''Called at start of game''' 7 | 8 | scene = logic.getCurrentScene() 9 | scene.post_draw = [postDraw] 10 | scene.pre_draw = [preDraw] 11 | 12 | 13 | def loop(): 14 | '''Called every logic tick''' 15 | 16 | # Drop to debug console 17 | keyboard = logic.keyboard.events 18 | if keyboard[events.ACCENTGRAVEKEY] == logic.KX_SENSOR_JUST_DEACTIVATED: 19 | from pprint import pprint 20 | import code 21 | namespace = globals().copy() 22 | namespace.update(locals()) 23 | code.interact(local=namespace) 24 | 25 | 26 | def preDraw(): 27 | '''called just before drawing screen''' 28 | pass 29 | 30 | 31 | def postDraw(): 32 | '''called just after drawing screen''' 33 | pass -------------------------------------------------------------------------------- /Tests/blank.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/blank.blend -------------------------------------------------------------------------------- /Tests/demo1.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/demo1.blend -------------------------------------------------------------------------------- /Tests/textures/GroundBrickFlooring_01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/GroundBrickFlooring_01.jpg -------------------------------------------------------------------------------- /Tests/textures/GroundBrickFlooring_01_NRM.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/GroundBrickFlooring_01_NRM.jpg -------------------------------------------------------------------------------- /Tests/textures/GroundBrickFlooring_01_SPEC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/GroundBrickFlooring_01_SPEC.jpg -------------------------------------------------------------------------------- /Tests/textures/GroundBrickFlooring_01_SPEC_clean.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/GroundBrickFlooring_01_SPEC_clean.jpg -------------------------------------------------------------------------------- /Tests/textures/GrungeLeaking_01_SPEC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/GrungeLeaking_01_SPEC.jpg -------------------------------------------------------------------------------- /Tests/textures/InteriorTilesDark_03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/InteriorTilesDark_03.jpg -------------------------------------------------------------------------------- /Tests/textures/InteriorTilesDark_03_NRM.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/InteriorTilesDark_03_NRM.jpg -------------------------------------------------------------------------------- /Tests/textures/InteriorTilesDark_03_SPEC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/InteriorTilesDark_03_SPEC.jpg -------------------------------------------------------------------------------- /Tests/textures/InteriorWoodFineDark_02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/InteriorWoodFineDark_02.jpg -------------------------------------------------------------------------------- /Tests/textures/InteriorWoodFineDark_02_NRM.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/InteriorWoodFineDark_02_NRM.jpg -------------------------------------------------------------------------------- /Tests/textures/InteriorWoodFineDark_02_SPEC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/InteriorWoodFineDark_02_SPEC.jpg -------------------------------------------------------------------------------- /Tests/textures/Leather_01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/Leather_01.jpg -------------------------------------------------------------------------------- /Tests/textures/Leather_01_NRM.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/Leather_01_NRM.jpg -------------------------------------------------------------------------------- /Tests/textures/Lightmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/Lightmap.png -------------------------------------------------------------------------------- /Tests/textures/Lightmap2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/Lightmap2.png -------------------------------------------------------------------------------- /Tests/textures/Lightmap3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/Lightmap3.png -------------------------------------------------------------------------------- /Tests/textures/WallBricks_01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/WallBricks_01.jpg -------------------------------------------------------------------------------- /Tests/textures/WallBricks_01_NRM.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/WallBricks_01_NRM.jpg -------------------------------------------------------------------------------- /Tests/textures/WallBricks_01_SPEC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/WallBricks_01_SPEC.jpg -------------------------------------------------------------------------------- /Tests/textures/WallConcreteBare_07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/WallConcreteBare_07.jpg -------------------------------------------------------------------------------- /Tests/textures/WallConcreteBare_07_NRM.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/WallConcreteBare_07_NRM.jpg -------------------------------------------------------------------------------- /Tests/textures/env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/env.png -------------------------------------------------------------------------------- /Tests/textures/envBlur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/envBlur.png -------------------------------------------------------------------------------- /Tests/textures/leatherSpec.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/Tests/textures/leatherSpec.jpg -------------------------------------------------------------------------------- /addons/README.md: -------------------------------------------------------------------------------- 1 | ## Addons 2 | 3 | #### Easy Game (Beta) for Blender Game Engine 4 | 5 | Easy Game is a collection of tools that allow you to work faster and more efficiently with the Blender Game Engine. It it made up of two components: 6 | 7 | **Easy Material** 8 | 9 | Easy Material creates a physically-plausible photorealistic material template(called uber material). All you have to do is load in the appropriate textures to fill the slots. No more fiddling with materials and texture settings! The materials created by Easy Material are PBR compatible, so you know they'll look great in any lighting condition. 10 | 11 | Easy Material supports Diffuse map, Normal map, Gloss/Specular Map, Light map, and Environment Reflection Map. With the right texture packs, Easy Material can make any solid surface look spectacular! 12 | 13 | The materials created are useable in the Game Engine as well as Blender Render. Textures not included. 14 | 15 | 16 | **Easy Asset** 17 | 18 | Easy Asset helps you create common game assets such as first-person camera, day-night light cycle, and post-processing effects with just one-click. This way, you can start a project at turbo speed! 19 | 20 | The created assets as fully configurable from the Blender Properties Editor or Logic Editor. 21 | 22 | 23 | **Want More?** 24 | 25 | Easy Game is under rapid development by me (Mike Pan). I will be updating this tool often in the next few months to bring you the best BGE experience possible. Please let me know how I can improve this tool. 26 | 27 | -------------------------------------------------------------------------------- /addons/easyGame/__init__.py: -------------------------------------------------------------------------------- 1 | import bpy, imp 2 | 3 | from easyGame import easyMaterial 4 | from easyGame import easyAsset 5 | 6 | imp.reload(easyMaterial) 7 | imp.reload(easyAsset) 8 | 9 | 10 | bl_info = { 11 | "name": "Easy Game Collection", 12 | "author": "Mike Pan", 13 | "version": (1, 5), 14 | "blender": (2, 70, 0), 15 | "location": "View3D > Tool Shelf > Easy Tabs", 16 | "description": "A collection of tools that make the game-creation process easier.", 17 | "warning": "", 18 | "wiki_url": "", 19 | "category": "Game Engine" 20 | } 21 | 22 | 23 | 24 | def register(): 25 | bpy.utils.register_class(BLEasyAsset) 26 | bpy.utils.register_class(BLEasyMaterial) 27 | bpy.utils.register_class(BLEasyMaterialAdv) 28 | # bpy.utils.register_class(BLSettings) 29 | bpy.utils.register_class(BLEasyMaterialCreate) 30 | bpy.utils.register_class(BLEasyAssetCreate) 31 | 32 | 33 | def unregister(): 34 | bpy.utils.unregister_class(BLEasyAsset) 35 | bpy.utils.unregister_class(BLEasyMaterial) 36 | bpy.utils.unregister_class(BLEasyMaterialAdv) 37 | # bpy.utils.unregister_class(BLSettings) 38 | bpy.utils.unregister_class(BLEasyMaterialCreate) 39 | bpy.utils.unregister_class(BLEasyAssetCreate) 40 | 41 | 42 | 43 | ############################################################################### 44 | 45 | 46 | class GamePanel(): 47 | bl_space_type = 'VIEW_3D' 48 | bl_region_type = 'TOOLS' 49 | 50 | 51 | class BLEasyAsset(GamePanel, bpy.types.Panel): 52 | """Creates The Easy Asset Interface""" 53 | bl_label = "Create Easy Asset" 54 | bl_context = "objectmode" 55 | bl_category = "Easy Asset" 56 | 57 | def draw(self, context): 58 | layout = self.layout 59 | obj = context.object 60 | 61 | row = layout.row() 62 | row.label('Camera:') 63 | row = layout.row(align=True) 64 | row.operator("easy.assetcreate", text='FPS Camera', icon='OUTLINER_DATA_CAMERA').arg = 'camera.fps' 65 | row.operator("easy.assetcreate", text='Orbit Camera', icon='OUTLINER_DATA_CAMERA').arg = 'camera.orbit' 66 | 67 | row = layout.row() 68 | row.label('Lights:') 69 | row = layout.row(align=True) 70 | row.operator("easy.assetcreate", text='Day-Night Cycle', icon='LAMP_SUN').arg = 'light.cycle' 71 | row.operator("easy.assetcreate", text='Soft Light', icon='LAMP_HEMI').arg = 'light.soft' 72 | 73 | row = layout.row() 74 | row.label('Effects:') 75 | row = layout.column(align=True) 76 | row.operator("easy.assetcreate", text='Plane Mirror', icon='MOD_MIRROR').arg = 'fx.mirror' 77 | 78 | row.operator("easy.assetcreate", text='Particles - Smoke', icon='STICKY_UVS_DISABLE').arg = 'fx.emitterSmoke' 79 | row.operator("easy.assetcreate", text='Particles - Spark', icon='PARTICLES').arg = 'fx.emitterSpark' 80 | row.operator("easy.assetcreate", text='Particles - Snow', icon='FREEZE').arg = 'fx.emitterSnow' 81 | 82 | row.operator("easy.assetcreate", text='Post-Processing 2D Filters', icon='TEXTURE' ).arg = 'fx.2DFilter' 83 | 84 | row = layout.row() 85 | row.label('Objects:') 86 | col = layout.column(align=True) 87 | col.operator("easy.assetcreate", text='Barrel-Wood').arg = 'barrel.BarrelWood' 88 | col.operator("easy.assetcreate", text='Barrel-Wood-Faded').arg = 'barrel.BarrelWood2' 89 | col.operator("easy.assetcreate", text='Barrel-Metal-Blue').arg = 'barrel.BarrelOilBlue' 90 | col.operator("easy.assetcreate", text='Barrel-Metal-Red').arg = 'barrel.BarrelOilRed' 91 | col.operator("easy.assetcreate", text='Barrel-Metal-Red-Yellow').arg = 'barrel.BarrelOilRed2' 92 | col.operator("easy.assetcreate", text='Barrel-Metal-Galvanized').arg = 'barrel.BarrelOilGalvanized' 93 | 94 | col = layout.column(align=True) 95 | col.operator("easy.assetcreate", text='Concrete-Divider').arg = 'concrete.ConcreteDivider' 96 | col.operator("easy.assetcreate", text='Concrete-Block1').arg = 'concrete.ConcreteBlock1' 97 | col.operator("easy.assetcreate", text='Concrete-Block2').arg = 'concrete.ConcreteBlock2' 98 | col.operator("easy.assetcreate", text='Concrete-Block3').arg = 'concrete.ConcreteBlock3' 99 | 100 | col = layout.column(align=True) 101 | col.operator("easy.assetcreate", text='Wood-Pallet').arg = 'wood.Pallet' 102 | 103 | 104 | 105 | row = layout.row() 106 | 107 | # row.label('Assets:') 108 | # template_list now takes two new args. 109 | # The first one is the identifier of the registered UIList to use (if you want only the default list, 110 | # with no custom draw code, use "UI_UL_list"). 111 | # layout.template_list("UI_UL_list", "assetid", obj, "material_slots", obj, "active_material_index") 112 | 113 | 114 | class BLEasyMaterial(GamePanel, bpy.types.Panel): 115 | """Creates the EasyMaterial UI""" 116 | bl_label = "Easy Material" 117 | bl_category = "Easy Material" 118 | 119 | def draw(self, context): 120 | layout = self.layout 121 | obj = context.object 122 | 123 | # bail on wrong display mode 124 | if context.scene.game_settings.material_mode != 'GLSL': 125 | row = layout.row() 126 | row.label('EasyMaterial requires GLSL mode', icon='ERROR') 127 | row = layout.row() 128 | row.prop(context.scene.game_settings, 'material_mode', text='') 129 | return 130 | 131 | # bail on no object (We don't want to use poll because that hides the panel) 132 | if not obj: 133 | return 134 | 135 | row = layout.row() 136 | rows = len(obj.material_slots) 137 | if rows > 1: 138 | row.template_list("MATERIAL_UL_matslots", "", obj, "material_slots", obj, "active_material_index", rows=rows) 139 | 140 | # material datablock manager 141 | row = layout.row() 142 | layout.template_ID_preview(obj, "active_material", new="easy.matcreate") 143 | 144 | # material editor 145 | row = layout.row() 146 | mat = obj.material_slots[obj.active_material_index].material 147 | 148 | # bail code 149 | if not mat: 150 | return 151 | if 'uberMaterial' not in mat: 152 | row.label('Not an UberMaterial', icon='ERROR') 153 | return 154 | 155 | # edit albedo 156 | row = layout.row() 157 | row.prop(mat, 'diffuse_intensity', text='Albedo') 158 | 159 | metallicTextureSlot = None 160 | for textureSlot in mat.texture_slots: 161 | if textureSlot: 162 | # bail code 163 | if textureSlot.use_map_color_spec and textureSlot.blend_type == 'COLOR': 164 | continue 165 | 166 | tex = textureSlot.texture 167 | text = tex.name.split('.')[-1] 168 | if text.isnumeric(): 169 | text = tex.name.split('.')[-2] 170 | 171 | # move to advanced section 172 | if text == 'Emit' or text == 'Alpha': 173 | continue 174 | 175 | row = layout.row() 176 | # enable/disable texture channel 177 | split = layout.split(percentage=0.20) 178 | row = split.row() 179 | row.prop(textureSlot, 'use', text=text) 180 | 181 | # image browse control 182 | row = split.row() 183 | row.active = textureSlot.use 184 | row.template_ID(tex, "image", open="image.open") 185 | split = layout.split(percentage=0.20) 186 | 187 | # empty 188 | row = split.row() 189 | 190 | split.active = textureSlot.use 191 | # additional properties 192 | if text == 'Col': 193 | split.prop(textureSlot, 'diffuse_color_factor', text='Factor') 194 | split.prop(mat, 'diffuse_color', text='') 195 | if text == 'Nor': 196 | split.prop(textureSlot, 'normal_factor', text='Factor') 197 | if text == 'Gloss': 198 | split.prop(textureSlot, 'default_value', text='Factor') 199 | 200 | if textureSlot.texture_coords == 'UV' and tex.image: 201 | split.prop_search(textureSlot, "uv_layer", context.active_object.data, "uv_textures", text="") 202 | 203 | 204 | class BLEasyMaterialAdv(GamePanel, bpy.types.Panel): 205 | """Creates the EasyMaterial UI""" 206 | bl_label = "Advanced" 207 | bl_category = "Easy Material" 208 | 209 | @classmethod 210 | def poll(self, context): 211 | return context.active_object 212 | 213 | def draw(self, context): 214 | obj = context.object 215 | layout = self.layout 216 | 217 | # bail on wrong display mode 218 | if context.scene.game_settings.material_mode != 'GLSL': 219 | return 220 | 221 | # bail on no mat slot 222 | if not context.active_object.material_slots: 223 | return 224 | 225 | # material editor 226 | row = layout.row() 227 | mat = obj.material_slots[obj.active_material_index].material 228 | 229 | # bail code 230 | if not mat: 231 | return 232 | 233 | if 'uberMaterial' not in mat: 234 | # row.label('Not an UberMaterial', icon='ERROR') 235 | return 236 | 237 | row.prop(mat, 'use_transparency', 'Transparent') 238 | if mat.use_transparency: 239 | game = mat.game_settings 240 | row.prop(game, 'alpha_blend', text='Blending') 241 | 242 | for textureSlot in mat.texture_slots: 243 | if textureSlot: 244 | 245 | # bail code 246 | if textureSlot.use_map_color_spec and textureSlot.blend_type == 'COLOR': 247 | row.prop(textureSlot, 'use', text='Metallic (Use color from Gloss map as Spec Color)') 248 | continue 249 | 250 | row = layout.row() 251 | tex = textureSlot.texture 252 | text = tex.name.split('.')[-1] 253 | if text.isnumeric(): 254 | text = tex.name.split('.')[-2] 255 | 256 | if text != 'Emit' and text!= 'Alpha': 257 | continue 258 | 259 | # enable/disable texture channel 260 | split = layout.split(percentage=0.20) 261 | split.prop(textureSlot, 'use', text=text) 262 | 263 | # image browse control 264 | split.template_ID(tex, "image", open="image.open") 265 | split = layout.split(percentage=0.20) 266 | 267 | # empty 268 | row = split.row() 269 | 270 | # additional properties 271 | if text == 'Emit': 272 | split.prop(textureSlot, 'emit_factor', text='Factor') 273 | 274 | if textureSlot.texture_coords == 'UV' and tex.image: 275 | split.prop_search(textureSlot, "uv_layer", context.active_object.data, "uv_textures", text="") 276 | 277 | 278 | 279 | class BLEasyMaterialCreate(bpy.types.Operator): 280 | """Create an übershader""" 281 | bl_label = "New UberMaterial" 282 | bl_idname = 'easy.matcreate' 283 | bl_options = {'REGISTER', 'UNDO'} 284 | 285 | MatName = bpy.props.StringProperty(name='Material Name', default='uber') 286 | 287 | def execute(self, context): 288 | error = easyMaterial.sanityCheck(context) 289 | if not error: 290 | mat = easyMaterial.createMaterial(context, self.MatName) 291 | easyMaterial.assignMaterial(context, mat) 292 | return {'FINISHED'} 293 | else: 294 | self.report({'ERROR'}, error) 295 | return {'CANCELLED'} 296 | 297 | 298 | class BLEasyAssetCreate(bpy.types.Operator): 299 | """Create an asset""" 300 | bl_label = "New Asset" 301 | bl_idname = 'easy.assetcreate' 302 | bl_options = {'REGISTER', 'UNDO'} 303 | 304 | arg = bpy.props.StringProperty(options={'HIDDEN'}) 305 | 306 | def execute(self, context): 307 | 308 | objType, option = self.arg.split('.') 309 | 310 | # cleanup before we start 311 | bpy.ops.object.select_all(action='DESELECT') 312 | 313 | if objType == 'camera': 314 | obj = easyAsset.createCamera(option) 315 | elif objType == 'light': 316 | obj = easyAsset.createLight(option) 317 | elif objType == 'fx': 318 | obj = easyAsset.createFX(option) 319 | elif objType == 'barrel': 320 | obj = easyAsset.createBarrel(option) 321 | elif objType == 'concrete': 322 | obj = easyAsset.createConcrete(option) 323 | elif objType == 'wood': 324 | obj = easyAsset.createWood(option) 325 | else: 326 | obj = 'Sorry, not implemented yet.' 327 | 328 | if not obj: 329 | self.report({'ERROR'}, 'Error Importing this model.') 330 | return {'CANCELLED'} 331 | else: 332 | obj.select = True 333 | bpy.context.scene.objects.active = obj 334 | return {'FINISHED'} 335 | 336 | 337 | -------------------------------------------------------------------------------- /addons/easyGame/asset/barrels.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/addons/easyGame/asset/barrels.blend -------------------------------------------------------------------------------- /addons/easyGame/asset/concrete.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/addons/easyGame/asset/concrete.blend -------------------------------------------------------------------------------- /addons/easyGame/asset/fx.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/addons/easyGame/asset/fx.blend -------------------------------------------------------------------------------- /addons/easyGame/asset/wood.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/addons/easyGame/asset/wood.blend -------------------------------------------------------------------------------- /addons/easyGame/easyAsset.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | 3 | from math import * 4 | import os 5 | 6 | 7 | def createCamera(option): 8 | ops = bpy.ops 9 | 10 | if option == 'fps': 11 | obj = checkExists('GECamera.FPS') 12 | if obj: return obj 13 | ops.object.camera_add(rotation=(pi/2, 0, 0)) 14 | if option == 'orbit': 15 | obj = checkExists('GECamera.Pivot') 16 | if obj: return obj 17 | ops.object.empty_add(type='SPHERE') 18 | 19 | obj = bpy.context.active_object 20 | 21 | # mouse look 22 | sensors, actuators = makeLogicBrick(obj, 'ALWAYS', 'LOGIC_AND', 'MOUSE') 23 | actuators[0].mode = 'LOOK' 24 | 25 | if option == 'fps': 26 | # walk 27 | sensors, actuators = makeLogicBrick(obj, ('KEYBOARD', 'KEYBOARD'), 'LOGIC_OR', 'MOTION') 28 | sensors[0].key = 'UP_ARROW' 29 | sensors[1].key = 'W' 30 | actuators[0].name = 'Forward' 31 | actuators[0].offset_location[2] = -0.2 32 | 33 | sensors, actuators = makeLogicBrick(obj, ('KEYBOARD', 'KEYBOARD'), 'LOGIC_OR', 'MOTION') 34 | sensors[0].key = 'DOWN_ARROW' 35 | sensors[1].key = 'S' 36 | actuators[0].name = 'Back' 37 | actuators[0].offset_location[2] = 0.2 38 | 39 | sensors, actuators = makeLogicBrick(obj, ('KEYBOARD', 'KEYBOARD'), 'LOGIC_OR', 'MOTION') 40 | sensors[0].key = 'LEFT_ARROW' 41 | sensors[1].key = 'A' 42 | actuators[0].name = 'Left' 43 | actuators[0].offset_location[0] = -0.2 44 | 45 | sensors, actuators = makeLogicBrick(obj, ('KEYBOARD', 'KEYBOARD'), 'LOGIC_OR', 'MOTION') 46 | sensors[0].key = 'RIGHT_ARROW' 47 | sensors[1].key = 'D' 48 | actuators[0].name = 'Right' 49 | actuators[0].offset_location[0] = 0.2 50 | 51 | obj.name = 'GECamera.FPS' 52 | 53 | return obj 54 | 55 | if option == 'orbit': 56 | # add camera and parent 57 | parentObj = obj 58 | ops.object.camera_add(rotation=(pi/2, 0,0), location=(0,0,0)) 59 | ops.transform.translate(value=(0,-10,0)) 60 | childObj = bpy.context.active_object 61 | childObj.parent = parentObj 62 | childObj.select = True 63 | parentObj.select = True 64 | childObj.name = 'GECamera.Orbit' 65 | parentObj.name = 'GECamera.Pivot' 66 | 67 | return parentObj 68 | 69 | 70 | 71 | def createLight(option): 72 | 73 | if option == 'cycle': 74 | obj = checkExists('GECycle.Target') 75 | if obj: return obj 76 | obj = checkExists('GECycle.Sun') 77 | if obj: return obj 78 | obj = checkExists('GECycle.Fill') 79 | if obj: return obj 80 | 81 | obj = loadAsset('fx.blend', ('GECycle.Target', 'GECycle.Sun', 'GECycle.Fill')) 82 | 83 | if option == 'soft': 84 | obj = checkExists('GESoftLight') 85 | if obj: return obj 86 | 87 | obj = loadAsset('fx.blend', ['GESoftLight.0', 'GESoftLight.1', 'GESoftLight.2', 'GESoftLight.3', 'GESoftLight.4']) 88 | 89 | return obj 90 | 91 | 92 | def createFX(option): 93 | if option == '2DFilter': 94 | obj = checkExists('2DFilter') 95 | if obj: return obj 96 | 97 | if option.startswith('emitter'): 98 | obj = loadAsset('fx.blend', [option]) 99 | option = option.replace('emitter', 'particle') 100 | objParticle = loadAsset('fx.blend', [option]) 101 | 102 | 103 | layers = 20*[False] 104 | layers[19] = True 105 | objParticle.layers = layers 106 | return obj 107 | 108 | obj = loadAsset('fx.blend', [option]) 109 | return obj 110 | 111 | 112 | def createBarrel(option): 113 | obj = checkExists(option) 114 | if obj: return obj 115 | obj = loadAsset('barrels.blend', [option]) 116 | return obj 117 | 118 | 119 | def createConcrete(option): 120 | obj = checkExists(option) 121 | if obj: return obj 122 | obj = loadAsset('concrete.blend', [option]) 123 | return obj 124 | 125 | def createWood(option): 126 | obj = checkExists(option) 127 | if obj: return obj 128 | obj = loadAsset('wood.blend', [option]) 129 | return obj 130 | 131 | 132 | def checkExists(name): 133 | for obj in bpy.context.scene.objects: 134 | if name in obj.name: 135 | return obj 136 | return False 137 | 138 | 139 | def loadAsset(filename, objList): 140 | 141 | scriptPath = os.path.realpath(__file__) 142 | assetPath = os.path.join(os.path.dirname(scriptPath), 'asset', filename) 143 | 144 | try: 145 | with bpy.data.libraries.load(assetPath) as (data_from, data_to): 146 | data_to.objects = [name for name in data_from.objects if name in objList] 147 | except: 148 | return 'Asset file not found' 149 | 150 | retObj = None 151 | for obj in data_to.objects: 152 | bpy.context.scene.objects.link(obj) 153 | retObj = obj 154 | 155 | return retObj 156 | 157 | 158 | def makeLogicBrick(obj, s, c, a, pulse=True): 159 | logic = bpy.ops.logic 160 | sensorsList = [] 161 | actuatorsList = [] 162 | 163 | # create controller first 164 | logic.controller_add(type=c) 165 | controller = obj.game.controllers[-1] 166 | 167 | # add sensors 168 | if type(s) is str: s = [s] 169 | for i in s: 170 | logic.sensor_add(type=i) 171 | sensor = obj.game.sensors[-1] 172 | sensor.use_pulse_true_level = pulse 173 | sensor.link(controller) 174 | sensorsList.append(sensor) 175 | 176 | # add actuators 177 | if type(a) is str: a = [a] 178 | for i in a: 179 | logic.actuator_add(type=i) 180 | actuator = obj.game.actuators[-1] 181 | actuator.link(controller) 182 | actuatorsList.append(actuator) 183 | 184 | return sensorsList, actuatorsList 185 | -------------------------------------------------------------------------------- /addons/easyGame/easyMaterial.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | 3 | def createMaterial(context, name): 4 | mat = bpy.data.materials.new(name) 5 | 6 | # Diffuse with fresnel simulation 7 | mat.use_diffuse_ramp = True 8 | mat.diffuse_ramp_input = 'NORMAL' 9 | mat.diffuse_ramp_blend = 'MULTIPLY' 10 | mat.diffuse_ramp_factor = 0.4 11 | mat.diffuse_ramp.elements[0].color = [1,1,1,1] 12 | mat.diffuse_ramp.elements[1].color = [0,0,0,1] 13 | mat.diffuse_ramp.elements[0].position = 0.0 14 | mat.diffuse_ramp.elements[1].position = 1.0 15 | 16 | # alternative diffuse 17 | # mat.diffuse_shader = 'MINNAERT' 18 | # mat.darkness = 1.5 19 | 20 | mat.alpha = 0.0 21 | 22 | # specular 23 | mat.specular_shader = 'BLINN' 24 | mat.specular_intensity = 0.0 25 | mat.specular_hardness = 1 26 | mat.specular_ior = 10.0 27 | 28 | # color map 29 | tex = bpy.data.textures.new(name+'.Col', type = 'IMAGE') 30 | tex.use_alpha = False 31 | mtex = mat.texture_slots.add() 32 | mtex.texture = tex 33 | mtex.texture_coords = 'UV' 34 | mtex.uv_layer = 'UVMap' 35 | mtex.use_map_color_diffuse = True 36 | 37 | # normal map 38 | tex = bpy.data.textures.new(name+'.Nor', type = 'IMAGE') 39 | tex.use_alpha = False 40 | tex.use_normal_map = True 41 | mtex = mat.texture_slots.add() 42 | mtex.texture = tex 43 | mtex.texture_coords = 'UV' 44 | mtex.uv_layer = 'UVMap' 45 | mtex.use_map_normal = True 46 | mtex.use_map_color_diffuse = False 47 | 48 | # alpha map 49 | tex = bpy.data.textures.new(name+'.Alpha', type = 'IMAGE') 50 | mtex = mat.texture_slots.add() 51 | mtex.texture = tex 52 | mtex.texture_coords = 'UV' 53 | mtex.uv_layer = 'UVMap' 54 | mtex.use_map_color_diffuse = False 55 | mtex.use_map_alpha = True 56 | mtex.use = False 57 | 58 | 59 | # emit map 60 | tex = bpy.data.textures.new(name+'.Emit', type = 'IMAGE') 61 | tex.use_alpha = False 62 | mtex = mat.texture_slots.add() 63 | mtex.texture = tex 64 | mtex.texture_coords = 'UV' 65 | mtex.uv_layer = 'UVMap' 66 | mtex.use_map_color_diffuse = False 67 | mtex.use_map_emit = True 68 | mtex.use = False 69 | 70 | # light map 71 | tex = bpy.data.textures.new(name+'.AO', type = 'IMAGE') 72 | tex.use_alpha = False 73 | mtex = mat.texture_slots.add() 74 | mtex.texture = tex 75 | mtex.texture_coords = 'UV' 76 | mtex.uv_layer = 'Lightmap' 77 | mtex.blend_type = 'MULTIPLY' 78 | mtex.use_map_color_spec = True 79 | 80 | # spec map (gloss map with color) 81 | specTexture = bpy.data.textures.new(name+'.Gloss', type = 'IMAGE') 82 | specTexture.use_alpha = False 83 | mtex = mat.texture_slots.add() 84 | mtex.texture = specTexture 85 | mtex.texture_coords = 'UV' 86 | mtex.uv_layer = 'UVMap' 87 | mtex.use_map_color_diffuse = False 88 | mtex.use_map_color_spec = True 89 | mtex.blend_type = 'COLOR' 90 | mtex.use = False 91 | 92 | # gloss map (gloss map grayscale) 93 | mtex = mat.texture_slots.add() 94 | mtex.texture = specTexture 95 | mtex.texture_coords = 'UV' 96 | mtex.uv_layer = 'UVMap' 97 | mtex.use_map_color_diffuse = False 98 | mtex.use_map_specular = True 99 | mtex.specular_factor = 2.0 100 | mtex.use_map_hardness = True 101 | mtex.hardness_factor = 2.0 102 | mtex.use_rgb_to_intensity = True 103 | mtex.use_stencil = True 104 | mtex.default_value = 1.0 105 | mtex.color = [1,1,1] 106 | 107 | # reflection map 108 | tex = bpy.data.textures.new(name+'.Env', type = 'IMAGE') 109 | tex.use_alpha = False 110 | mtex = mat.texture_slots.add() 111 | mtex.texture = tex 112 | mtex.texture_coords = 'REFLECTION' 113 | mtex.diffuse_color_factor = 0.75 114 | mtex.blend_type = 'MULTIPLY' 115 | 116 | # set identity 117 | mat['uberMaterial'] = True 118 | return mat 119 | 120 | 121 | def assignMaterial(context, mat): 122 | ''' assign material to all selected objects, overriding all mat slots''' 123 | for obj in context.selected_objects: 124 | obj.data.materials.clear() 125 | obj.data.materials.append(mat) 126 | 127 | 128 | def sanityCheck(context): 129 | ''' returns error if selected objects has usable materials''' 130 | for obj in context.selected_objects: 131 | if obj.type != 'MESH': 132 | return 'Object is not a mesh, Aborted' 133 | for mat in obj.data.materials: 134 | if mat: 135 | return False 136 | return 'Object already has materials, Aborted.' 137 | return False 138 | 139 | -------------------------------------------------------------------------------- /addons/easyGame/helpers.py: -------------------------------------------------------------------------------- 1 | import math 2 | import bisect 3 | import random 4 | 5 | def mix(a,b,factor): 6 | '''mix two number together using a factor''' 7 | if type(a) is list or type(a) is tuple: 8 | if len(a)==len(b)==2: 9 | return [a[0]*factor + b[0]*(1.0-factor), a[1]*factor + b[1]*(1.0-factor)] 10 | elif len(a)==len(b)==3: 11 | return [a[0]*factor + b[0]*(1.0-factor), a[1]*factor + b[1]*(1.0-factor), a[2]*factor + b[2]*(1.0-factor)] 12 | elif len(a)==len(b)==4: 13 | return [a[0]*factor + b[0]*(1.0-factor), a[1]*factor + b[1]*(1.0-factor), a[2]*factor + b[2]*(1.0-factor), a[3]*factor + b[3]*(1.0-factor)] 14 | else: 15 | raise Exception(ArithmeticError) 16 | else: 17 | return (a*factor + b*(1.0-factor)) 18 | 19 | 20 | def checkValue(var, minV, maxV): 21 | if not minV <= var <= maxV: 22 | print('Warning:', var, 'is outside of the expected range for', var, ':', minV, '-' , maxV) 23 | 24 | 25 | def smoothstep(x): 26 | '''returns a smoothed float given an input between 0 and 1''' 27 | return x * x * (3-2*(x)) 28 | 29 | 30 | def computeDistance(a, b): 31 | if len(a)==len(b)==2: 32 | return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2) 33 | elif len(a)==len(b)==3: 34 | return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2 + (a[2]-b[2])**2) 35 | elif len(a)==len(b)==4: 36 | return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2 + (a[2]-b[2])**2 + (a[3]-b[3])**2) 37 | else: 38 | raise Exception(ArithmeticError) 39 | 40 | -------------------------------------------------------------------------------- /addons/release/easyGame10.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/addons/release/easyGame10.zip -------------------------------------------------------------------------------- /addons/release/easyGame11.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/addons/release/easyGame11.zip -------------------------------------------------------------------------------- /addons/release/easyGame12.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepan/BlenderGEResourceKit/8ac68b3a288f443d9a96d2e9d856e876f7b4ff14/addons/release/easyGame12.zip -------------------------------------------------------------------------------- /build.py: -------------------------------------------------------------------------------- 1 | # Run with Python3 2 | 3 | import argparse 4 | import sys 5 | import os 6 | import shutil 7 | import time 8 | 9 | ignored = shutil.ignore_patterns('__pycache__', '.git', '*.blend1', '*.blend2') 10 | 11 | 12 | def copyFiles(useZip): 13 | startTime = time.time() 14 | pwd = os.path.dirname(os.path.realpath(__file__)) 15 | print('Working directory: %s' % pwd) 16 | 17 | print('Creating release folder', end='...') 18 | sys.stdout.flush() 19 | try: 20 | os.makedirs('BGERsourceKit') 21 | print('Done') 22 | except Exception as E: 23 | print('Error', E) 24 | return 25 | 26 | print('Copying Files to release', end='...') 27 | sys.stdout.flush() 28 | shutil.copytree('Library', 'BGERsourceKit/Library', ignore=ignored) 29 | shutil.copytree('StarterTemplate', 'BGERsourceKit/GEStarterTemplate', ignore=ignored) 30 | 31 | 32 | name = time.strftime('%Y%m%d') 33 | 34 | if useZip: 35 | print('Zipping', end='...') 36 | sys.stdout.flush() 37 | shutil.make_archive(name, 'zip', 'BGERsourceKit') 38 | 39 | elapsedTime = time.time() - startTime 40 | print('Completed in %d seconds' % elapsedTime) 41 | 42 | 43 | # ------------------------------------------------------------------------------- 44 | 45 | if __name__ == '__main__': 46 | 47 | parser = argparse.ArgumentParser(description='Help build BGE Resource Kit from source') 48 | parser.add_argument('--zip', '-z', default=False, help='Compress release into one archive') 49 | args = parser.parse_args() 50 | 51 | useZip = args.zip 52 | 53 | copyFiles(useZip) 54 | --------------------------------------------------------------------------------