Skip to content

Commit e22a532

Browse files
author
Patrick Meehan
committed
updated porting notes to discuss MOAICamera consolidation; fixed ‘window’ more camera to scale Z to 0
1 parent 5b8d5a9 commit e22a532

File tree

6 files changed

+17
-57
lines changed

6 files changed

+17
-57
lines changed

docs/moai 2.0 - porting notes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Is now:
4545

4646
prop:moveLoc(x, y, z, t)
4747

48+
## MOAICamera consolidation
49+
50+
2D, 3D or ortho cameras have been consolidated into a single class: MOAICamera. To set the camera type, use MOAICamera.setType() with one of MOAICamera.CAMERA_TYPE_3D, MOAICamera.CAMERA_TYPE_ORTHO, MOAICamera.CAMERA_TYPE_WINDOW.
51+
52+
The '3D' and 'ortho' camera types are simply perspective and orthographic projects. The 'window' camera type is an ortho projection that ignores that discards the Z axis (by scaling Z to 0). This elimates depth information, but also the effect of the near/far plane settings.
53+
4854
## Partition membership
4955

5056
MOAIPartitionHull now exists independently of MOAIProp. MOAIPartitionHull inherits MOAITransform and represents membership in a partition, dimenionality (having bounds or existing boundlessly in global space), and placement (having a location and orientation in space).

samples/layer-camera/main.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ viewport = MOAIViewport.new ()
1010
viewport:setSize ( 320, 480 )
1111
viewport:setScale ( 320, 480 )
1212

13-
camera = MOAICamera2D.new ()
13+
camera = MOAICamera.new ()
1414

15-
camera:moveLoc ( 128, 0, 3 )
16-
camera:moveRot ( 180, 3 )
17-
camera:moveScl ( 1, 1, 3 )
15+
camera:moveLoc ( 128, 0, 0, 3 )
16+
camera:moveRot ( 0, 0, 180, 3 )
17+
camera:moveScl ( 1, 1, 0, 3 )
1818

1919
layer = MOAIPartitionViewLayer.new ()
2020
layer:setViewport ( viewport )
2121
layer:setCamera ( camera )
2222
layer:pushRenderPass ()
2323

24-
gfxQuad = MOAIGfxQuad2D.new ()
25-
gfxQuad:setTexture ( "moai.png" )
26-
gfxQuad:setRect ( -64, -64, 64, 64 )
24+
spriteDeck = MOAISpriteDeck2D.new ()
25+
spriteDeck:setTexture ( '../resources/moai.png' )
26+
spriteDeck:setRect ( -64, -64, 64, 64 )
2727

2828
prop = MOAIProp.new ()
29-
prop:setDeck ( gfxQuad )
29+
prop:setDeck ( spriteDeck )
3030
prop:setPartition ( layer )
3131

samples/layer-camera/moai.png

-15.8 KB
Binary file not shown.

samples/layer-camera/run.bat

Lines changed: 0 additions & 24 deletions
This file was deleted.

samples/layer-camera/run.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/moai-sim/MOAICamera.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,10 @@ ZLMatrix4x4 MOAICamera::GetProjMtx ( const MOAIViewport& viewport ) const {
412412
case CAMERA_TYPE_WINDOW:
413413
default: {
414414

415-
ZLRect rect = viewport.GetRect ();
415+
float xScale = ( 2.0f / viewport.Width ()) * viewScale.mX;
416+
float yScale = ( 2.0f / viewport.Height ()) * viewScale.mY;
416417

417-
float xScale = ( 2.0f / rect.Width ()) * viewScale.mX;
418-
float yScale = ( 2.0f / rect.Height ()) * viewScale.mY;
419-
420-
mtx.Scale ( xScale, yScale, -1.0f );
418+
mtx.Scale ( xScale, yScale, 0.0 );
421419
}
422420
}
423421
}

0 commit comments

Comments
 (0)