diff --git a/docs/moai 2.0 - porting notes.md b/docs/moai 2.0 - porting notes.md index 05472051c8..5fca9c8f4d 100644 --- a/docs/moai 2.0 - porting notes.md +++ b/docs/moai 2.0 - porting notes.md @@ -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). diff --git a/samples/layer-camera/main.lua b/samples/layer-camera/main.lua index 6696dc4f87..9c3823ecc3 100644 --- a/samples/layer-camera/main.lua +++ b/samples/layer-camera/main.lua @@ -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 ) diff --git a/samples/layer-camera/moai.png b/samples/layer-camera/moai.png deleted file mode 100644 index 8a9974bd65..0000000000 Binary files a/samples/layer-camera/moai.png and /dev/null differ diff --git a/samples/layer-camera/run.bat b/samples/layer-camera/run.bat deleted file mode 100644 index d5fad5e750..0000000000 --- a/samples/layer-camera/run.bat +++ /dev/null @@ -1,24 +0,0 @@ -::----------------------------------------------------------------:: -:: Copyright (c) 2010-2017 Zipline Games, Inc. -:: All Rights Reserved. -:: http://getmoai.com -::----------------------------------------------------------------:: - -@echo off - -:: verify paths -if not exist "%MOAI_BIN%\moai.exe" ( - echo. - echo -------------------------------------------------------------------------------- - echo ERROR: The MOAI_BIN environment variable either doesn't exist or it's pointing - echo to an invalid path. Please point it at a folder containing moai.exe. - echo -------------------------------------------------------------------------------- - echo. - goto end -) - -:: run moai -"%MOAI_BIN%\moai" "main.lua" - -:end -pause \ No newline at end of file diff --git a/samples/layer-camera/run.sh b/samples/layer-camera/run.sh deleted file mode 100755 index 612def2f86..0000000000 --- a/samples/layer-camera/run.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -#-------------------------------------------------------------------------------------- -# Copyright (c) 2010-2013 Zipline Games, Inc. -# All Rights Reserved. -# http://getmoai.com -#-------------------------------------------------------------------------------------- - -cd `dirname $0` - -# Verify paths -if [ ! -f "$MOAI_BIN/moai" ]; then - echo "---------------------------------------------------------------------------" - echo "Error: The MOAI_BIN environment variable doesn't exist or its pointing to an" - echo "invalid path. Please point it at a folder containing moai executable" - echo "---------------------------------------------------------------------------" - exit 1 -fi - -# Run moai -$MOAI_BIN/moai main.lua diff --git a/src/moai-sim/MOAICamera.cpp b/src/moai-sim/MOAICamera.cpp index b763bece8f..2b6545c04a 100644 --- a/src/moai-sim/MOAICamera.cpp +++ b/src/moai-sim/MOAICamera.cpp @@ -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 ); } } }