Skip to content

Commit

Permalink
removed ios AR cruft; fixed a legit bug in MOAITableViewLayer; update…
Browse files Browse the repository at this point in the history
…d remaining box2d samples
  • Loading branch information
Patrick Meehan committed Nov 30, 2018
1 parent 6d17f4a commit 9493943
Show file tree
Hide file tree
Showing 67 changed files with 30,019 additions and 1,296 deletions.
11 changes: 11 additions & 0 deletions cmake/env-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

echo "Importing local env"
## Path to your moai sdk if not in <pitohome>/sdk/moai
MOAI_SDK_HOME=~/git/moai-community/sdk/moai

## Path to the Android NDK
NDK_PATH=/android/android-ndk-r13b

## Path to Emscripten SDK
EMSDK_PATH=~/git/emsdk
27 changes: 15 additions & 12 deletions samples/box2d-contact-list/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ viewport = MOAIViewport.new ()
viewport:setSize ( width, height )
viewport:setScale (width / (width/640), height / (height/480))

layer = MOAIPartitionViewLayer.new ()
layer:setPartition( MOAIPartition.new() )
layer:setViewport ( viewport )
layer:pushRenderPass ()

function onCollide ( event )

if event == MOAIBox2DArbiter.BEGIN then
Expand All @@ -45,16 +40,20 @@ world = MOAIBox2DWorld.new ()
world:setGravity ( 0, -10 )
world:setUnitsToMeters ( .05 )
world:start ()
layer:setUnderlayTable ({ world })

debugLayer = MOAITableViewLayer.new ()
debugLayer:setViewport ( viewport )
debugLayer:setRenderTable ( world )
debugLayer:pushRenderPass ()

worldBody = world:addBody ( MOAIBox2DBody.STATIC )
fixture2 = worldBody:addRect ( -(300/2), -200, 300/2, -300)
fixture2:setFilter ( 0x02 )
fixture2:setCollisionHandler ( onCollide, MOAIBox2DArbiter.BEGIN + MOAIBox2DArbiter.END, 0x00 )

texture = MOAIGfxQuad2D.new ()
texture:setTexture ( 'moai.png' )
texture:setRect ( -25/2, -25/2, 25/2, 25/2 )
deck = MOAISpriteDeck2D.new ()
deck:setTexture ( 'moai.png' )
deck:setRect ( -25/2, -25/2, 25/2, 25/2 )

sensorBody = world:addBody ( MOAIBox2DBody.KINEMATIC )
sensorFixture = sensorBody:addCircle ( 0, -130, 40 )
Expand All @@ -71,6 +70,10 @@ thread:run ( function ()
end
end )

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

function addSprite()
local body = world:addBody ( MOAIBox2DBody.DYNAMIC )

Expand All @@ -90,8 +93,8 @@ function addSprite()
body:resetMassData ()
body:applyAngularImpulse ( 80 )

local sprite = MOAIProp.new ()
sprite:setDeck ( texture )
local sprite = MOAIGraphicsProp.new ()
sprite:setDeck ( deck )
sprite.body = body
sprite:setParent ( body )
sprite:setPartition ( layer )
Expand All @@ -107,7 +110,7 @@ end

function clickCallback ( down )
if down then
pick = layer:getPartition():propForPoint ( worldX, worldY)
pick = layer:getLayerPartition():hullForPoint ( worldX, worldY )
if pick then
mouseBody = world:addBody( MOAIBox2DBody.DYNAMIC )
mouseBody:setTransform(worldX, worldY)
Expand Down
16 changes: 9 additions & 7 deletions samples/box2d-ik-chain/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ viewport = MOAIViewport.new ()
viewport:setSize ( width, height )
viewport:setScale (width / (width/640), height / (height/480))

layer = MOAIPartitionViewLayer.new ()
layer:setPartition( MOAIPartition.new() )
layer:setViewport ( viewport )
layer:pushRenderPass ()

-- set up the world and start its simulation
world = MOAIBox2DWorld.new ()
world:setGravity ( 0, 0 )
world:setUnitsToMeters ( .05 )
world:start ()
layer:setUnderlayTable ({ world })

debugLayer = MOAITableViewLayer.new ()
debugLayer:setViewport ( viewport )
debugLayer:setRenderTable ( world )
debugLayer:pushRenderPass ()

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

local chain = {}

Expand Down Expand Up @@ -96,7 +98,7 @@ end
function clickCallback ( down )

if down then
pick = layer:getPartition ():propForPoint ( worldX, worldY )
pick = layer:getLayerPartition ():hullForPoint ( worldX, worldY )
if pick then
mouseBody = world:addBody ( MOAIBox2DBody.STATIC )
mouseBody:setTransform ( worldX, worldY )
Expand Down
27 changes: 15 additions & 12 deletions samples/box2d-motorjoint/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ viewport = MOAIViewport.new ()
viewport:setSize ( width, height )
viewport:setScale (width / (width/640), height / (height/480))

layer = MOAIPartitionViewLayer.new ()
layer:setPartition( MOAIPartition.new() )
layer:setViewport ( viewport )
layer:pushRenderPass ()

-- set up the world and start its simulation
world = MOAIBox2DWorld.new ()
world:setUnitsToMeters(0.05)
layer:setUnderlayTable ({ world })

debugLayer = MOAITableViewLayer.new ()
debugLayer:setViewport ( viewport )
debugLayer:setRenderTable ( world )
debugLayer:pushRenderPass ()

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

worldBody = world:addBody ( MOAIBox2DBody.STATIC )

texture = MOAIGfxQuad2D.new ()
texture:setTexture ( 'moai.png' )
texture:setRect ( -25/2, -25/2, 25/2, 25/2 )
deck = MOAISpriteDeck2D.new ()
deck:setTexture ( 'moai.png' )
deck:setRect ( -25/2, -25/2, 25/2, 25/2 )

function addSprite()
local body = world:addBody ( MOAIBox2DBody.DYNAMIC )
Expand All @@ -39,10 +42,10 @@ function addSprite()
local fixture = body:addPolygon ( poly )
fixture:setDensity ( 0.1 )
fixture:setFriction ( 0.6 )
body:resetMassData ()
body:resetMassData ()

local sprite = MOAIProp.new ()
sprite:setDeck ( texture )
local sprite = MOAIGraphicsProp.new ()
sprite:setDeck ( deck )
sprite.body = body
sprite:setParent ( body )
sprite:setPartition ( layer )
Expand Down
3 changes: 1 addition & 2 deletions samples/box2d-squishy-swine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ TO USE THE SAMPLE

Right click to add pigs. If the pigs hit either wall they will become muddy. Muddy pigs will stick to the floor and to other pigs. Press 's' on the keyboard to toggle visibility of the pig sprites.


ABOUT THE PIG

We don't know where the cute pig graphic used in this demo came from or who owns it. It it from the internet, but we can't seem to find it again.
Expand All @@ -11,4 +10,4 @@ This pig graphic is *not* licensed as part of Moai and is not owned by Zipline g

If you own this pig graphic and want us to remove it, please let us know and we will do so.

If do not own this pig graphics then use it at your own risk as it is not covered by the Moai CPAL.
If you do not own this pig graphics then use it at your own risk as it is not covered by the Moai CPAL.
34 changes: 19 additions & 15 deletions samples/box2d-squishy-swine/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ function createTexturePackerDeckRaw ( filename )
end

-- Construct the deck
local deck = MOAIGfxQuadDeck2D.new ()
local deck = MOAISpriteDeck2D.new ()
deck:setTexture ( tex )
deck:reserve ( #frames )
deck:reserveQuads ( #frames )
deck:reserveUVQuads ( #frames )
local names = {}
for i, frame in ipairs ( frames ) do
local q = frame.uvQuad
Expand Down Expand Up @@ -135,7 +136,7 @@ local function positionSprite ( sprite, x, y, head, points )
local angle = vecAngle ( headAxisX, headAxisY, 0, 1 )

angle = ( headAxisX < 0 ) and angle or -angle
sprite:setRot ( angle )
sprite:setRot ( 0, 0, angle )

local sideAxisX, sideAxisY = headAxisY, -headAxisX

Expand Down Expand Up @@ -176,12 +177,7 @@ MOAISim.openWindow ( "test", width ,height )

viewport = MOAIViewport.new ()
viewport:setSize ( width, height )
viewport:setScale (width / (width/640), height / (height/480))

layer = MOAIPartitionViewLayer.new ()
layer:setPartition( MOAIPartition.new() )
layer:setViewport ( viewport )
layer:pushRenderPass ()
viewport:setScale ( width / ( width / 640 ), height / ( height / 480 ))

allPigs = {}
pigs = 0
Expand All @@ -192,9 +188,9 @@ stickyFloorQueue = {}
function onPigCollide ( event, thisFixture, thatFixture, arbiter )

if thatFixture.pig and ( thatFixture.sticky or thisFixture.sticky ) then
table.insert ( stickyQueue, { body1 = thisFixture:getBody (), body2 = thatFixture:getBody (), type = "pig" } )
table.insert ( stickyQueue, { body1 = thisFixture:getBody (), body2 = thatFixture:getBody (), type = "pig" })
elseif thatFixture.floor and thisFixture.sticky then
table.insert ( stickyQueue, { body1 = thisFixture:getBody (), body2 = thatFixture:getBody (), type = "floor" } )
table.insert ( stickyQueue, { body1 = thisFixture:getBody (), body2 = thatFixture:getBody (), type = "floor" })
thisFixture:setSensor ( true )
elseif thisFixture.pig and thatFixture.mud then

Expand All @@ -215,7 +211,15 @@ world:setIterations ( ITERATIONS, ITERATIONS )
world:start ()

world:setDebugDrawFlags ( MOAIBox2DWorld.DEBUG_DRAW_SHAPES + MOAIBox2DWorld.DEBUG_DRAW_JOINTS + MOAIBox2DWorld.DEBUG_DRAW_PAIRS )
layer:setUnderlayTable ({ world })

debugLayer = MOAITableViewLayer.new ()
debugLayer:setViewport ( viewport )
debugLayer:setRenderTable ( world )
debugLayer:pushRenderPass ()

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

worldBody = world:addBody ( MOAIBox2DBody.STATIC )
fixture2 = worldBody:addRect ( -(800/2), -200, 800/2, -300)
Expand Down Expand Up @@ -408,7 +412,7 @@ end

function clickCallback ( down )
if down then
pick = layer:getPartition():propForPoint ( worldX, worldY)
pick = layer:getLayerPartition():hullForPoint ( worldX, worldY)
if pick then
mouseBody = world:addBody( MOAIBox2DBody.DYNAMIC )
mouseBody:setTransform(worldX, worldY)
Expand Down Expand Up @@ -464,7 +468,7 @@ else
)
end

scaleThread = MOAIThread.new ()
scaleThread = MOAICoroutine.new ()
scaleThread:run ( function ()
repeat
coroutine.yield ()
Expand All @@ -475,7 +479,7 @@ scaleThread:run ( function ()
until false
end )

stickyThread = MOAIThread.new ()
stickyThread = MOAICoroutine.new ()
stickyThread:run ( function ()

repeat
Expand Down
6 changes: 3 additions & 3 deletions samples/box2d/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ world:setGravity ( 0, -10 )
world:setUnitsToMeters ( .05 )
world:start ()

debugLayer = MOAITableLayer.new ()
debugLayer = MOAITableViewLayer.new ()
debugLayer:setViewport ( viewport )
debugLayer:pushRenderPass ()
debugLayer:setRenderTable ( world )
debugLayer:pushRenderPass ()

worldBody = world:addBody ( MOAIBox2DBody.STATIC )
fixture2 = worldBody:addRect ( -( 300 / 2 ), -200, 300 / 2, -300 )
fixture2:setFilter ( 0x02 )
fixture2:setCollisionHandler ( onCollide, MOAIBox2DArbiter.BEGIN + MOAIBox2DArbiter.END, 0x00 )

layer = MOAIPartitionLayer.new ()
layer = MOAIPartitionViewLayer.new ()
layer:setViewport ( viewport )
layer:pushRenderPass ()

Expand Down
2 changes: 1 addition & 1 deletion samples/debugCamera/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ partition:setLevel ( 3, 96, 96, 12 )
layer = MOAIPartitionViewLayer.new ()
layer:setViewport ( viewport )
layer:setCamera ( camera )
layer:setPartition ( partition )
layer:setLayerPartition ( partition )
layer:pushRenderPass ()

spriteDeck = MOAISpriteDeck2D.new ()
Expand Down
4 changes: 3 additions & 1 deletion samples/debugLines-partition/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

MOAISim.openWindow ( "test", 320, 480 )

print ( 'NO DEBUG LINES HERE' )

MOAIDebugLinesMgr.setStyle ( MOAIProp.DEBUG_DRAW_PARTITION_CELLS, 2, 1, 1, 1 )
MOAIDebugLinesMgr.setStyle ( MOAIProp.DEBUG_DRAW_PARTITION_PADDED_CELLS, 1, 0.5, 0.5, 0.5 )
MOAIDebugLinesMgr.setStyle ( MOAIProp.DEBUG_DRAW_WORLD_BOUNDS, 4, 1, 0, 1 )
Expand All @@ -22,7 +24,7 @@ partition:setLevel ( 3, 96, 96, 12 )

layer = MOAIPartitionViewLayer.new ()
layer:setViewport ( viewport )
layer:setPartition ( partition )
layer:setLayerPartition ( partition )
layer:pushRenderPass ()

spriteDeck = MOAISpriteDeck2D.new ()
Expand Down
2 changes: 1 addition & 1 deletion samples/input-picking3D/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ viewport:setScale ( SCREEN_WIDTH, SCREEN_HEIGHT )
layer:setViewport ( viewport )

partition = MOAIPartition.new ()
layer:setPartition ( partition )
layer:setLayerPartition ( partition )

function addCube ( x, y, z, name )
local prop = makeCube ( 32 )
Expand Down
1 change: 0 additions & 1 deletion src/moai-box2d/MOAIBox2DWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,6 @@ void MOAIBox2DWorld::MOAIDrawable_Draw ( int subPrimID ) {
MOAIGfxState& gfxState = MOAIGfxMgr::Get ().mGfxState;

gfxState.SetMtx ( MOAIGfxState::MODEL_TO_WORLD_MTX );
gfxState.SetVertexTransform ( MOAIGfxState::WORLD_TO_CLIP_MTX );

this->mDebugDraw->mScale = 1.0f / this->mUnitsToMeters;
this->mWorld->DrawDebugData ();
Expand Down
3 changes: 1 addition & 2 deletions src/moai-sim/MOAITableViewLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ void MOAITableViewLayer::SerializeOut ( MOAILuaState& state, MOAISerializer& ser

//----------------------------------------------------------------//
void MOAITableViewLayer::MOAIDrawable_Draw ( int subPrimID ) {
UNUSED ( subPrimID );

MOAIViewLayer_Draw ();
this->MOAIViewLayer::MOAIDrawable_Draw ( subPrimID );
}

//----------------------------------------------------------------//
Expand Down
2 changes: 1 addition & 1 deletion xcode/ios/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<string>[email protected]</string>
</array>
<key>CFBundleIdentifier</key>
<string>com.moaisdk.samples</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
10 changes: 5 additions & 5 deletions xcode/ios/lua/main.lua → xcode/ios/lua/anim-basic/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
-- http://getmoai.com
----------------------------------------------------------------

VIEW_WIDTH, VIEW_HEIGHT = MOAIGfxMgr.getViewSize ()
MOAISim.openWindow ( "test", 320, 480 )

viewport = MOAIViewport.new ()
viewport:setSize ( VIEW_WIDTH, VIEW_HEIGHT )
viewport:setScale ( 320, 320 * ( VIEW_HEIGHT / VIEW_WIDTH ))
viewport:setSize ( 320, 480 )
viewport:setScale ( 320, 480 )

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

prop = MOAIProp.new ()
prop:setDeck ( 'moai.png' )
prop:setDeck ( '../resources/moai.png' )
prop:setPartition ( layer )
prop:moveRot ( 0, 0, 360, 5 )

prop = MOAIProp.new ()
prop:setDeck ( 'test.png' )
prop:setDeck ( '../resources/test.png' )
prop:setColor ( 1, 1, 1, 0 )
prop:setScl ( 2, 2, 1 )
prop:setPartition ( layer )
Expand Down
Loading

0 comments on commit 9493943

Please sign in to comment.