forked from LeenkxTeam/Leenkx_Examples
update
This commit is contained in:
44
render_splitscreen/Sources/lnx/SplitScreen.hx
Normal file
44
render_splitscreen/Sources/lnx/SplitScreen.hx
Normal file
@ -0,0 +1,44 @@
|
||||
package lnx;
|
||||
|
||||
import iron.Scene;
|
||||
import iron.object.CameraObject;
|
||||
import leenkx.renderpath.RenderPathCreator;
|
||||
|
||||
class SplitScreen extends iron.Trait {
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
notifyOnInit(function() {
|
||||
|
||||
var drawMeshes = RenderPathCreator.drawMeshes;
|
||||
|
||||
// Single viewport size
|
||||
var w = Std.int(iron.App.w() / 2);
|
||||
var h = iron.App.h();
|
||||
|
||||
// Retrieve cameras
|
||||
var cam1:CameraObject = cast Scene.active.getChild("Camera");
|
||||
var cam2:CameraObject = cast Scene.active.getChild("Camera.001");
|
||||
cam1.buildProjection(w / h);
|
||||
cam2.buildProjection(w / h);
|
||||
|
||||
// Override draw method to draw split screen
|
||||
RenderPathCreator.drawMeshes = function() {
|
||||
|
||||
var g = RenderPathCreator.path.currentG;
|
||||
|
||||
// Left viewport
|
||||
RenderPathCreator.setTargetMeshes();
|
||||
Scene.active.camera = cam1;
|
||||
g.viewport(0, 0, w, h);
|
||||
drawMeshes();
|
||||
|
||||
// Right viewport
|
||||
RenderPathCreator.setTargetMeshes();
|
||||
Scene.active.camera = cam2;
|
||||
g.viewport(w, 0, w, h);
|
||||
drawMeshes();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
BIN
render_splitscreen/render_splitscreen.blend
Normal file
BIN
render_splitscreen/render_splitscreen.blend
Normal file
Binary file not shown.
Reference in New Issue
Block a user