Difference between revisions of "Viewport"

From GiderosMobile
 
(18 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Supported platforms:''' <br/>
+
<!-- GIDEROSOBJ:Viewport -->
 +
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
 
'''Available since:''' Gideros 2016.04<br/>
 
'''Available since:''' Gideros 2016.04<br/>
 +
'''Inherits from:''' [[Sprite]]<br/>
 +
 
=== Description ===
 
=== Description ===
<translate>A Viewport sprite allows to display another view of a tree hierarchy already on stage. Sprites can't have two parents, but thanks to Viewport you can display the same Sprite twice on the stage. Useful for split screen games, mini maps and so on.</translate>
+
A Viewport sprite allows to display another view of a tree hierarchy already on stage. Sprites can't have two parents, but thanks to Viewport you can display the same Sprite twice on the stage.
=== Examples ===
+
 
'''Displaying same Bitmap in multiple views'''<br/>
+
Useful for split screen games, mini maps and so on.
<source lang="lua">-- content we want to display in multiple views
+
 
 +
=== Example ===
 +
'''Displaying same Bitmap in multiple views'''
 +
<syntaxhighlight lang="lua">
 +
-- content we want to display in multiple views
 
local content = Bitmap.new(Texture.new("ball.png"))
 
local content = Bitmap.new(Texture.new("ball.png"))
  
Line 13: Line 20:
 
view1:setClip(0,0,300,300)
 
view1:setClip(0,0,300,300)
 
view1:setContent(content)
 
view1:setContent(content)
 
 
-- add some transformations, just to see the difference
 
-- add some transformations, just to see the difference
 
view1:setTransform(Matrix.new(1.7320507764816, -1.0000001192093, 1.0000001192093, 1.7320507764816, 50, 50))
 
view1:setTransform(Matrix.new(1.7320507764816, -1.0000001192093, 1.0000001192093, 1.7320507764816, 50, 50))
 
 
-- add view to stage
 
-- add view to stage
 
stage:addChild(view1)
 
stage:addChild(view1)
 
  
 
-- now setup view 2 as a 200x200 window
 
-- now setup view 2 as a 200x200 window
Line 26: Line 30:
 
view2:setPosition(0,300) -- lower down the screen
 
view2:setPosition(0,300) -- lower down the screen
 
view2:setContent(content)
 
view2:setContent(content)
 
 
-- add some transformations, just to see the difference
 
-- add some transformations, just to see the difference
 
view2:setTransform(Matrix.new(0.32139378786087, -0.38302224874496, 0.38302224874496, 0.32139378786087, 30, 30))
 
view2:setTransform(Matrix.new(0.32139378786087, -0.38302224874496, 0.38302224874496, 0.32139378786087, 30, 30))
 +
-- add view to stage
 +
stage:addChild(view2)
 +
</syntaxhighlight>
  
-- add view to stage
 
stage:addChild(view2)</source>
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== Methods ===
 
=== Methods ===
[[Viewport:lookAngles]] ''<translate></translate>''<br/>
+
[[Viewport.new]] ''creates a new viewport''<br/><!--GIDEROSMTD:Viewport.new() creates a new viewport-->
[[Viewport:lookAt]] ''<translate></translate>''<br/>
+
[[Viewport:lookAngles]] ''sets up the viewport look angle transform matrix (eye position, pitch, yaw and roll angles)''<br/><!--GIDEROSMTD:Viewport:lookAngles(eyex,eyey,eyez,pitch,yaw,roll) sets up the viewport look angle transform matrix-->
[[Viewport:setContent]] ''<translate></translate>''<br/>
+
[[Viewport:lookAt]] ''sets up the viewport look at transform matrix (eye, target position and up direction)''<br/><!--GIDEROSMTD:Viewport:lookAt(eyex,eyey,eyez,targetx,targety,targetz,upx,upy,upz) sets up the viewport look at transform matrix-->
[[Viewport:setProjection]] ''<translate>Specify a projection matrix to use when displaying the content. </translate>''<br/>
+
[[Viewport:setClip]] ''sets the viewport size''<br/><!--GIDEROSMTD:Viewport:setClip(x,y,width,height) sets the viewport size-->
[[Viewport:setTransform]] ''<translate></translate>''<br/>
+
[[Viewport:setContent]] ''sets the viewport content (sprite)''<br/><!--GIDEROSMTD:Viewport:setContent(content) sets the viewport content (sprite)-->
 +
[[Viewport:setProjection]] ''specifies a projection matrix to use when displaying the content''<br/><!--GIDEROSMTD:Viewport:setProjection(matrix) specifies a projection matrix to use when displaying the content-->
 +
[[Viewport:setTarget]] ''sets a rt as target''<br/><!--GIDEROSMTD:Viewport:setTarget(rt) sets a rt as target-->
 +
[[Viewport:setTransform]] ''sets the content transform matrix before it being displayed''<br/><!--GIDEROSMTD:Viewport:setTransform(transform) sets the content transform matrix before it being displayed-->
 +
 
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== Events ===
 
=== Events ===
 
=== Constants ===
 
=== Constants ===
 
|}
 
|}
 +
 +
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 00:13, 21 February 2024

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2016.04
Inherits from: Sprite

Description

A Viewport sprite allows to display another view of a tree hierarchy already on stage. Sprites can't have two parents, but thanks to Viewport you can display the same Sprite twice on the stage.

Useful for split screen games, mini maps and so on.

Example

Displaying same Bitmap in multiple views

-- content we want to display in multiple views
local content = Bitmap.new(Texture.new("ball.png"))

-- now setup view 1 as a 300x300 window
view1=Viewport.new()
view1:setClip(0,0,300,300)
view1:setContent(content)
-- add some transformations, just to see the difference
view1:setTransform(Matrix.new(1.7320507764816, -1.0000001192093, 1.0000001192093, 1.7320507764816, 50, 50))
-- add view to stage
stage:addChild(view1)

-- now setup view 2 as a 200x200 window
view2=Viewport.new()
view2:setClip(0,0,200,200)
view2:setPosition(0,300) -- lower down the screen
view2:setContent(content)
-- add some transformations, just to see the difference
view2:setTransform(Matrix.new(0.32139378786087, -0.38302224874496, 0.38302224874496, 0.32139378786087, 30, 30))
-- add view to stage
stage:addChild(view2)

Methods

Viewport.new creates a new viewport
Viewport:lookAngles sets up the viewport look angle transform matrix (eye position, pitch, yaw and roll angles)
Viewport:lookAt sets up the viewport look at transform matrix (eye, target position and up direction)
Viewport:setClip sets the viewport size
Viewport:setContent sets the viewport content (sprite)
Viewport:setProjection specifies a projection matrix to use when displaying the content
Viewport:setTarget sets a rt as target
Viewport:setTransform sets the content transform matrix before it being displayed

Events

Constants