Skip to content

Commit

Permalink
updated porting notes to discuss MOAICamera consolidation; fixed ‘win…
Browse files Browse the repository at this point in the history
…dow’ more camera to scale Z to 0
  • Loading branch information
Patrick Meehan committed Dec 6, 2018
1 parent 5b8d5a9 commit e22a532
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 57 deletions.
6 changes: 6 additions & 0 deletions docs/moai 2.0 - porting notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ Is now:

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

## MOAICamera consolidation

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.

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.

## Partition membership

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).
Expand Down
16 changes: 8 additions & 8 deletions samples/layer-camera/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ viewport = MOAIViewport.new ()
viewport:setSize ( 320, 480 )
viewport:setScale ( 320, 480 )

camera = MOAICamera2D.new ()
camera = MOAICamera.new ()

camera:moveLoc ( 128, 0, 3 )
camera:moveRot ( 180, 3 )
camera:moveScl ( 1, 1, 3 )
camera:moveLoc ( 128, 0, 0, 3 )
camera:moveRot ( 0, 0, 180, 3 )
camera:moveScl ( 1, 1, 0, 3 )

layer = MOAIPartitionViewLayer.new ()
layer:setViewport ( viewport )
layer:setCamera ( camera )
layer:pushRenderPass ()

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

prop = MOAIProp.new ()
prop:setDeck ( gfxQuad )
prop:setDeck ( spriteDeck )
prop:setPartition ( layer )

Binary file removed samples/layer-camera/moai.png
Binary file not shown.
24 changes: 0 additions & 24 deletions samples/layer-camera/run.bat

This file was deleted.

20 changes: 0 additions & 20 deletions samples/layer-camera/run.sh

This file was deleted.

8 changes: 3 additions & 5 deletions src/moai-sim/MOAICamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,10 @@ ZLMatrix4x4 MOAICamera::GetProjMtx ( const MOAIViewport& viewport ) const {
case CAMERA_TYPE_WINDOW:
default: {

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

float xScale = ( 2.0f / rect.Width ()) * viewScale.mX;
float yScale = ( 2.0f / rect.Height ()) * viewScale.mY;

mtx.Scale ( xScale, yScale, -1.0f );
mtx.Scale ( xScale, yScale, 0.0 );
}
}
}
Expand Down

0 comments on commit e22a532

Please sign in to comment.