InvertCamera

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
m (Text replace - "</javascript>" to "</syntaxhighlight>")
 
Line 27: Line 27:
  
 
@script RequireComponent (Camera)
 
@script RequireComponent (Camera)
</javascript>
+
</syntaxhighlight>

Latest revision as of 20:52, 10 January 2012

Author: (Joachim Ante)

[edit] Description

This script inverts the view of the camera. So everything rendered by the camera is flipped. This will help you to implement a rear mirror camera.

[edit] Usage

Attach the script to a camera.

[edit] JavaScript - InvertCamera.js

// EXAMPLE WITH CAMERA UPSIDEDOWN
function OnPreCull () {
	camera.ResetWorldToCameraMatrix ();
	camera.ResetProjectionMatrix ();
	camera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale(Vector3 (1, -1, 1));
}
 
function OnPreRender () {
	GL.SetRevertBackfacing (true);
}
 
function OnPostRender () {
	GL.SetRevertBackfacing (false);
}
 
@script RequireComponent (Camera)
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox