armory/Sources/armory/trait/MirrorTexture.hx

25 lines
475 B
Haxe
Raw Normal View History

2016-08-29 09:56:34 +02:00
package armory.trait;
import iron.Trait;
import iron.object.MeshObject;
2016-10-12 17:52:27 +02:00
@:keep
2016-08-29 09:56:34 +02:00
class MirrorTexture extends Trait {
2016-10-15 20:19:09 +02:00
var cameraName:String;
2016-08-29 09:56:34 +02:00
2016-10-15 20:19:09 +02:00
public function new(cameraName:String) {
super();
2016-08-29 09:56:34 +02:00
2016-10-15 20:19:09 +02:00
this.cameraName = cameraName;
notifyOnInit(init);
}
2016-08-29 09:56:34 +02:00
2016-10-15 20:19:09 +02:00
function init() {
2016-08-29 09:56:34 +02:00
var image = iron.Scene.active.getCamera(cameraName).data.mirror;
var o = cast(object, iron.object.MeshObject);
o.materials[0].contexts[0].textures[0] = image; // Override diffuse texture
2016-10-15 20:19:09 +02:00
}
2016-08-29 09:56:34 +02:00
}