mirror of https://github.com/axmolengine/axmol.git
Merge pull request #8831 from samuele3hu/v3_new_spine
Add lua-bindings for Light and test case and fix compile error triggered by UIHelper.cpp
This commit is contained in:
commit
61215e015f
|
@ -576,3 +576,31 @@ cc.MATRIX_STACK_TYPE =
|
|||
PROJECTION = 1,
|
||||
TEXTURE = 2,
|
||||
}
|
||||
|
||||
cc.LightType =
|
||||
{
|
||||
DIRECTIONAL = 0,
|
||||
POINT = 1,
|
||||
SPOT = 2,
|
||||
AMBIENT = 3,
|
||||
}
|
||||
|
||||
cc.LightFlag =
|
||||
{
|
||||
LIGHT0 = math.pow(2,0),
|
||||
LIGHT1 = math.pow(2,1),
|
||||
LIGHT2 = math.pow(2,2),
|
||||
LIGHT3 = math.pow(2,3),
|
||||
LIGHT4 = math.pow(2,4),
|
||||
LIGHT5 = math.pow(2,5),
|
||||
LIGHT6 = math.pow(2,6),
|
||||
LIGHT7 = math.pow(2,7),
|
||||
LIGHT8 = math.pow(2,8),
|
||||
LIGHT9 = math.pow(2,9),
|
||||
LIGHT10 = math.pow(2,10),
|
||||
LIGHT11 = math.pow(2,11),
|
||||
LIGHT12 = math.pow(2,12),
|
||||
LIGHT13 = math.pow(2,13),
|
||||
LIGHT14 = math.pow(2,14),
|
||||
LIGHT15 = math.pow(2,15),
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ std::string Helper::getSubStringOfUTF8String(const std::string& str, std::string
|
|||
return str.substr(min,max);
|
||||
}
|
||||
|
||||
void changeLayoutSystemActiveState(bool bActive)
|
||||
void Helper::changeLayoutSystemActiveState(bool bActive)
|
||||
{
|
||||
_activeLayout = bActive;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,241 @@
|
|||
local LightTest = class("LightTest",function()
|
||||
return cc.Layer:create()
|
||||
end)
|
||||
|
||||
function LightTest:ctor()
|
||||
|
||||
local function onNodeEvent(event)
|
||||
if event == "enter" then
|
||||
self:init()
|
||||
elseif event == "exit" then
|
||||
self:unscheduleUpdate()
|
||||
end
|
||||
end
|
||||
|
||||
self:registerScriptHandler(onNodeEvent)
|
||||
end
|
||||
|
||||
function LightTest:init()
|
||||
|
||||
self:addSprite()
|
||||
self:addLights()
|
||||
|
||||
local s = cc.Director:getInstance():getWinSize()
|
||||
local camera = cc.Camera:createPerspective(60, s.width/s.height, 1.0, 1000.0)
|
||||
camera:setCameraFlag(cc.CameraFlag.USER1)
|
||||
camera:setPosition3D(cc.vec3(0.0, 100, 100))
|
||||
camera:lookAt(cc.vec3(0.0, 0.0, 0.0), cc.vec3(0.0, 1.0, 0.0))
|
||||
self:addChild(camera)
|
||||
|
||||
local ttfConfig = {}
|
||||
ttfConfig.fontFilePath = "fonts/arial.ttf"
|
||||
ttfConfig.fontSize = 15
|
||||
|
||||
local ambientLightLabel = cc.Label:createWithTTF(ttfConfig,"Ambient Light ON")
|
||||
local menuItem0 = cc.MenuItemLabel:create(ambientLightLabel)
|
||||
menuItem0:registerScriptTapHandler(function (tag, sender)
|
||||
local str = nil
|
||||
local isON = not self._ambientLight:isEnabled()
|
||||
if isON then
|
||||
str = "Ambient Light ON"
|
||||
else
|
||||
str = "Ambient Light OFF"
|
||||
end
|
||||
self._ambientLight:setEnabled(isON)
|
||||
menuItem0:setString(str)
|
||||
end)
|
||||
|
||||
|
||||
local directionalLightLabel = cc.Label:createWithTTF(ttfConfig,"Directional Light OFF")
|
||||
local menuItem1 = cc.MenuItemLabel:create(directionalLightLabel)
|
||||
menuItem1:registerScriptTapHandler(function (tag, sender)
|
||||
local str = nil
|
||||
local isON = not self._directionalLight:isEnabled()
|
||||
if isON then
|
||||
str = "Directional Light ON"
|
||||
else
|
||||
str = "Directional Light OFF"
|
||||
end
|
||||
self._directionalLight:setEnabled(isON)
|
||||
menuItem1:setString(str)
|
||||
end)
|
||||
|
||||
|
||||
local pointLightLabel = cc.Label:createWithTTF(ttfConfig,"Point Light OFF")
|
||||
local menuItem2 = cc.MenuItemLabel:create(pointLightLabel)
|
||||
menuItem2:registerScriptTapHandler(function (tag, sender)
|
||||
local str = nil
|
||||
local isON = not self._pointLight:isEnabled()
|
||||
if isON then
|
||||
str = "Point Light ON"
|
||||
else
|
||||
str = "Point Light OFF"
|
||||
end
|
||||
self._pointLight:setEnabled(isON)
|
||||
menuItem2:setString(str)
|
||||
end)
|
||||
|
||||
local spotLightLabel = cc.Label:createWithTTF(ttfConfig,"Spot Light OFF")
|
||||
local menuItem3 = cc.MenuItemLabel:create(spotLightLabel)
|
||||
menuItem3:registerScriptTapHandler(function (tag, sender)
|
||||
local str = nil
|
||||
local isON = not self._spotLight:isEnabled()
|
||||
if isON then
|
||||
str = "Spot Light ON"
|
||||
else
|
||||
str = "Spot Light OFF"
|
||||
end
|
||||
self._spotLight:setEnabled(isON)
|
||||
menuItem3:setString(str)
|
||||
end)
|
||||
|
||||
|
||||
local menu = cc.Menu:create(menuItem0, menuItem1, menuItem2, menuItem3)
|
||||
menu:setPosition(cc.p(0, 0))
|
||||
menuItem0:setAnchorPoint(cc.p(0.0 ,1.0))
|
||||
menuItem0:setPosition( cc.p(VisibleRect:left().x, VisibleRect:top().y-50) )
|
||||
menuItem1:setAnchorPoint(cc.p(0.0, 1.0))
|
||||
menuItem1:setPosition( cc.p(VisibleRect:left().x, VisibleRect:top().y-100) )
|
||||
menuItem2:setAnchorPoint(cc.p(0.0, 1.0))
|
||||
menuItem2:setPosition( cc.p(VisibleRect:left().x, VisibleRect:top().y -150))
|
||||
menuItem3:setAnchorPoint(cc.p(0.0, 1.0))
|
||||
menuItem3:setPosition( cc.p(VisibleRect:left().x, VisibleRect:top().y -200))
|
||||
self:addChild(menu)
|
||||
|
||||
local angleDelta = 0.0
|
||||
local function update(delta)
|
||||
if nil ~= self._directionalLight then
|
||||
self._directionalLight:setRotation3D(cc.vec3(-45.0, -angleDelta * 57.29577951, 0.0))
|
||||
end
|
||||
|
||||
if nil ~= self._pointLight then
|
||||
self._pointLight:setPositionX(100.0 * math.cos(angleDelta + 2.0 * delta))
|
||||
self._pointLight:setPositionY(100.0)
|
||||
self._pointLight:setPositionZ(100.0 * math.sin(angleDelta + 2.0 * delta))
|
||||
end
|
||||
|
||||
if nil ~= self._spotLight then
|
||||
self._spotLight:setPositionX(100.0 * math.cos(angleDelta + 4.0 * delta))
|
||||
self._spotLight:setPositionY(100.0)
|
||||
self._spotLight:setPositionZ(100.0 * math.sin(angleDelta + 4.0 * delta))
|
||||
self._spotLight:setDirection(cc.vec3(-math.cos(angleDelta + 4.0 * delta), -1.0, -math.sin(angleDelta + 4.0 * delta)))
|
||||
end
|
||||
|
||||
angleDelta = angleDelta + delta
|
||||
end
|
||||
|
||||
self:scheduleUpdateWithPriorityLua(update,0)
|
||||
end
|
||||
|
||||
function LightTest:addSprite()
|
||||
local s = cc.Director:getInstance():getWinSize()
|
||||
|
||||
local fileName = "Sprite3DTest/orc.c3b"
|
||||
local sprite1 = cc.Sprite3D:create(fileName)
|
||||
sprite1:setRotation3D(cc.vec3(0.0, 180.0, 0.0))
|
||||
sprite1:setPosition(cc.p(0.0, 0.0))
|
||||
sprite1:setScale(2.0)
|
||||
local sp = cc.Sprite3D:create("Sprite3DTest/axe.c3b")
|
||||
sprite1:getAttachNode("Bip001 R Hand"):addChild(sp)
|
||||
local animation = cc.Animation3D:create(fileName)
|
||||
if nil ~=animation then
|
||||
local animate = cc.Animate3D:create(animation)
|
||||
sprite1:runAction(cc.RepeatForever:create(animate))
|
||||
end
|
||||
self:addChild(sprite1)
|
||||
sprite1:setCameraMask(2)
|
||||
|
||||
local fileName = "Sprite3DTest/sphere.c3b"
|
||||
local sprite2 = cc.Sprite3D:create(fileName)
|
||||
sprite2:setPosition(cc.p(30.0, 0.0))
|
||||
self:addChild(sprite2)
|
||||
sprite2:setCameraMask(2)
|
||||
|
||||
|
||||
local fileName = "Sprite3DTest/sphere.c3b"
|
||||
local sprite3 = cc.Sprite3D:create(fileName)
|
||||
sprite3:setScale(0.5)
|
||||
sprite3:setPosition(cc.p(-50.0, 0.0))
|
||||
self:addChild(sprite3)
|
||||
sprite3:setCameraMask(2)
|
||||
|
||||
local fileName = "Sprite3DTest/sphere.c3b"
|
||||
local sprite4 = cc.Sprite3D:create(fileName)
|
||||
sprite4:setScale(0.5)
|
||||
sprite4:setPosition(cc.p(-30.0, 10.0))
|
||||
self:addChild(sprite4)
|
||||
sprite4:setCameraMask(2)
|
||||
end
|
||||
|
||||
function LightTest:addLights()
|
||||
local s = cc.Director:getInstance():getWinSize()
|
||||
self._ambientLight = cc.AmbientLight:create(cc.c3b(200, 200, 200))
|
||||
self._ambientLight:setEnabled(true)
|
||||
self:addChild(self._ambientLight)
|
||||
self._ambientLight:setCameraMask(2)
|
||||
|
||||
self._directionalLight = cc.DirectionLight:create(cc.vec3(-1.0, -1.0, 0.0), cc.c3b(200, 200, 200))
|
||||
self._directionalLight:setEnabled(false)
|
||||
self:addChild(self._directionalLight)
|
||||
self._directionalLight:setCameraMask(2)
|
||||
|
||||
self._pointLight = cc.PointLight:create(cc.vec3(0.0, 0.0, 0.0), cc.c3b(200, 200, 200), 10000.0)
|
||||
self._pointLight:setEnabled(false)
|
||||
self:addChild(self._pointLight)
|
||||
self._pointLight:setCameraMask(2)
|
||||
|
||||
self._spotLight = cc.SpotLight:create(cc.vec3(-1.0, -1.0, 0.0), cc.vec3(0.0, 0.0, 0.0), cc.c3b(200, 200, 200), 0.0, 0.5, 10000.0)
|
||||
self._spotLight:setEnabled(false)
|
||||
self:addChild(self._spotLight)
|
||||
self._spotLight:setCameraMask(2)
|
||||
|
||||
local tintto1 = cc.TintTo:create(4, 0, 0, 255)
|
||||
local tintto2 = cc.TintTo:create(4, 0, 255, 0)
|
||||
local tintto3 = cc.TintTo:create(4, 255, 0, 0)
|
||||
local tintto4 = cc.TintTo:create(4, 255, 255, 255)
|
||||
local seq = cc.Sequence:create(tintto1,tintto2, tintto3, tintto4)
|
||||
self._ambientLight:runAction(cc.RepeatForever:create(seq))
|
||||
|
||||
tintto1 = cc.TintTo:create(4, 255, 0, 0)
|
||||
tintto2 = cc.TintTo:create(4, 0, 255, 0)
|
||||
tintto3 = cc.TintTo:create(4, 0, 0, 255)
|
||||
tintto4 = cc.TintTo:create(4, 255, 255, 255)
|
||||
seq = cc.Sequence:create(tintto1,tintto2, tintto3, tintto4)
|
||||
self._directionalLight:runAction(cc.RepeatForever:create(seq))
|
||||
|
||||
|
||||
tintto1 = cc.TintTo:create(4, 255, 0, 0)
|
||||
tintto2 = cc.TintTo:create(4, 0, 255, 0)
|
||||
tintto3 = cc.TintTo:create(4, 0, 0, 255)
|
||||
tintto4 = cc.TintTo:create(4, 255, 255, 255)
|
||||
seq = cc.Sequence:create(tintto2, tintto1, tintto3, tintto4)
|
||||
self._pointLight:runAction(cc.RepeatForever:create(seq))
|
||||
|
||||
tintto1 = cc.TintTo:create(4, 255, 0, 0)
|
||||
tintto2 = cc.TintTo:create(4, 0, 255, 0)
|
||||
tintto3 = cc.TintTo:create(4, 0, 0, 255)
|
||||
tintto4 = cc.TintTo:create(4, 255, 255, 255)
|
||||
seq = cc.Sequence:create(tintto3, tintto2, tintto1, tintto4)
|
||||
self._spotLight:runAction(cc.RepeatForever:create(seq))
|
||||
end
|
||||
|
||||
function LightTest.create( ... )
|
||||
local layer = LightTest.new()
|
||||
Helper.initWithLayer(layer)
|
||||
Helper.titleLabel:setString("Light Test")
|
||||
return layer
|
||||
end
|
||||
|
||||
function LightTestMain()
|
||||
cclog("LightTestMain")
|
||||
local scene = cc.Scene:create()
|
||||
|
||||
Helper.createFunctionTable =
|
||||
{
|
||||
LightTest.create,
|
||||
}
|
||||
|
||||
scene:addChild(LightTest.create(), 0)
|
||||
scene:addChild(CreateBackMenuItem())
|
||||
return scene
|
||||
end
|
|
@ -27,6 +27,7 @@ require "KeypadTest/KeypadTest"
|
|||
require "LabelTest/LabelTest"
|
||||
require "LabelTestNew/LabelTestNew"
|
||||
require "LayerTest/LayerTest"
|
||||
require "LightTest/LightTest"
|
||||
require "MenuTest/MenuTest"
|
||||
require "MotionStreakTest/MotionStreakTest"
|
||||
require "NewEventDispatcherTest/NewEventDispatcherTest"
|
||||
|
@ -99,6 +100,7 @@ local _allTests = {
|
|||
{ isSupported = true, name = "LabelTest" , create_func = LabelTest },
|
||||
{ isSupported = true, name = "LabelTestNew" , create_func = LabelTestNew },
|
||||
{ isSupported = true, name = "LayerTest" , create_func = LayerTestMain },
|
||||
{ isSupported = true, name = "LightTest" , create_func = LightTestMain },
|
||||
{ isSupported = true, name = "LuaBridgeTest" , create_func = LuaBridgeMainTest },
|
||||
{ isSupported = true, name = "MenuTest" , create_func = MenuTestMain },
|
||||
{ isSupported = true, name = "MotionStreakTest" , create_func = MotionStreakTest },
|
||||
|
|
|
@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %
|
|||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device CSLoader ClippingRectangleNode
|
||||
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device CSLoader ClippingRectangleNode .*Light$
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
|
|
Loading…
Reference in New Issue