diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/helper-classes/RDGE/src/core/script/shadowLight.js | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/shadowLight.js')
-rw-r--r-- | js/helper-classes/RDGE/src/core/script/shadowLight.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/shadowLight.js b/js/helper-classes/RDGE/src/core/script/shadowLight.js new file mode 100644 index 00000000..80d9331a --- /dev/null +++ b/js/helper-classes/RDGE/src/core/script/shadowLight.js | |||
@@ -0,0 +1,54 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | /* | ||
8 | * shadow light - a modified camera used to describe a shadow casting light | ||
9 | */ | ||
10 | shadowLight = function() | ||
11 | { | ||
12 | // inherit from the base class | ||
13 | this.inheritedFrom = camera; | ||
14 | this.inheritedFrom(); | ||
15 | |||
16 | // matrices needed for shadow projection | ||
17 | this.invViewMatrix=mat4.identity(); | ||
18 | this.mvpMatrix=mat4.identity(); | ||
19 | |||
20 | // texture matrix | ||
21 | this.shadowMatrix=mat4.identity(); | ||
22 | this.shadowMatrix=mat4.scale(this.shadowMatrix,[0.5,0.5,0.5]); | ||
23 | this.shadowMatrix=mat4.translate(this.shadowMatrix,[0.5,0.5,0.5]); | ||
24 | |||
25 | // cached references | ||
26 | this.renderer = null; | ||
27 | this.cameraManager = null; | ||
28 | |||
29 | // shadow bias offset | ||
30 | this.shadowBias = 0.0195; | ||
31 | |||
32 | this.init = function () | ||
33 | { | ||
34 | this.renderer = g_Engine.getContext().renderer; | ||
35 | this.cameraManager = this.renderer.cameraManager(); | ||
36 | } | ||
37 | |||
38 | /* | ||
39 | * makes the light the current 'camera' | ||
40 | */ | ||
41 | this.activate = function() | ||
42 | { | ||
43 | this.cameraManager.pushCamera(this); | ||
44 | } | ||
45 | |||
46 | /* | ||
47 | * restores the camera stack | ||
48 | */ | ||
49 | this.deactivate = function() | ||
50 | { | ||
51 | this.cameraManager.popCamera(); | ||
52 | } | ||
53 | |||
54 | } | ||