mirror of https://github.com/axmolengine/axmol.git
repaired Action BUG
This commit is contained in:
parent
e42eb950a3
commit
1a1ccda3ed
|
@ -102,6 +102,7 @@ void Light3D::onEnter()
|
|||
if (iter == lights.end())
|
||||
lights.push_back(this);
|
||||
}
|
||||
Node::onEnter();
|
||||
}
|
||||
|
||||
void Light3D::onExit()
|
||||
|
@ -114,6 +115,7 @@ void Light3D::onExit()
|
|||
if (iter != lights.end())
|
||||
lights.erase(iter);
|
||||
}
|
||||
Node::onExit();
|
||||
}
|
||||
|
||||
void Light3D::setEnabled( bool isON )
|
||||
|
|
|
@ -998,11 +998,11 @@ void GLProgram::setUniformsForBuiltins(const Mat4 &matrixMV)
|
|||
{
|
||||
CCASSERT(enabledPointLightNum < CC_MAX_POINT_LIGHT_NUM, "");
|
||||
const Color3B &col = light->getDisplayedColor();
|
||||
const Vec3 &pos = light->getPosition3D();
|
||||
Mat4 mat= light->getNodeToWorldTransform();
|
||||
sprintf(str, "CC_PointLightSource[%d].%s", enabledPointLightNum, "color");
|
||||
setUniformLocationWith3f(glGetUniformLocation(_program, str), col.r / 255.0f, col.g / 255.0f, col.b / 255.0f);
|
||||
sprintf(str, "CC_PointLightSource[%d].%s", enabledPointLightNum, "position");
|
||||
setUniformLocationWith4f(glGetUniformLocation(_program, str), pos.x, pos.y, pos.z, light->getRange());
|
||||
setUniformLocationWith4f(glGetUniformLocation(_program, str), mat.m[12], mat.m[13], mat.m[14], light->getRange());
|
||||
++enabledPointLightNum;
|
||||
}
|
||||
else
|
||||
|
@ -1010,11 +1010,11 @@ void GLProgram::setUniformsForBuiltins(const Mat4 &matrixMV)
|
|||
CCASSERT(enabledSpotLightNum < CC_MAX_SPOT_LIGHT_NUM, "");
|
||||
const Color3B &col = light->getDisplayedColor();
|
||||
const Vec3 &dir = light->getWorldDirection();
|
||||
const Vec3 &pos = light->getPosition3D();
|
||||
Mat4 mat= light->getNodeToWorldTransform();
|
||||
sprintf(str, "CC_SpotLightSource[%d].%s", enabledSpotLightNum, "color");
|
||||
setUniformLocationWith3f(glGetUniformLocation(_program, str), col.r / 255.0f, col.g / 255.0f, col.b / 255.0f);
|
||||
sprintf(str, "CC_SpotLightSource[%d].%s", enabledSpotLightNum, "position");
|
||||
setUniformLocationWith3f(glGetUniformLocation(_program, str), pos.x, pos.y, pos.z);
|
||||
setUniformLocationWith3f(glGetUniformLocation(_program, str), mat.m[12], mat.m[13], mat.m[14]);
|
||||
sprintf(str, "CC_SpotLightSource[%d].%s", enabledSpotLightNum, "direction");
|
||||
setUniformLocationWith3f(glGetUniformLocation(_program, str), dir.x, dir.y, dir.z);
|
||||
sprintf(str, "CC_SpotLightSource[%d].%s", enabledSpotLightNum, "params");
|
||||
|
|
|
@ -186,16 +186,46 @@ void LightTestDemo::addLights()
|
|||
_directionalLight = Light3D::CreateDirectionalLight(Vec3(-1.0f, -1.0f, 0.0f), Color3B(200, 200, 200));
|
||||
_directionalLight->retain();
|
||||
addChild(_directionalLight);
|
||||
_directionalLight->setCameraMask(2);
|
||||
|
||||
_pointLight = Light3D::CreatePointLight(Vec3(100.0, 100.0, 100.0), Color3B(200, 200, 200), 1000.0f);
|
||||
_pointLight = Light3D::CreatePointLight(Vec3(0.0f, 0.0f, 0.0f), Color3B(200, 200, 200), 1000.0f);
|
||||
_pointLight->retain();
|
||||
_pointLight->setEnabled(false);
|
||||
addChild(_pointLight);
|
||||
_pointLight->setCameraMask(2);
|
||||
|
||||
_spotLight = Light3D::CreateSpotLight(Vec3(-1.0f, -1.0f, 0.0f), Vec3(100.0, 100.0, 0.0f), Color3B(200, 200, 200), 0.1, 0.3, 1000.0f);
|
||||
_spotLight = Light3D::CreateSpotLight(Vec3(-1.0f, -1.0f, 0.0f), Vec3(0.0f, 0.0f, 0.0f), Color3B(200, 200, 200), 0.1, 0.3, 1000.0f);
|
||||
_spotLight->retain();
|
||||
_spotLight->setEnabled(false);
|
||||
addChild(_spotLight);
|
||||
_spotLight->setCameraMask(2);
|
||||
|
||||
{
|
||||
auto tintto1 = TintTo::create(4, 255, 0, 0);
|
||||
auto tintto2 = TintTo::create(4, 0, 255, 0);
|
||||
auto tintto3 = TintTo::create(4, 0, 0, 255);
|
||||
auto tintto4 = TintTo::create(4, 255, 255, 255);
|
||||
auto seq = Sequence::create(tintto1,tintto2, tintto3, tintto4, NULL);
|
||||
_directionalLight->runAction(RepeatForever::create(seq));
|
||||
}
|
||||
|
||||
{
|
||||
auto tintto1 = TintTo::create(4, 255, 0, 0);
|
||||
auto tintto2 = TintTo::create(4, 0, 255, 0);
|
||||
auto tintto3 = TintTo::create(4, 0, 0, 255);
|
||||
auto tintto4 = TintTo::create(4, 255, 255, 255);
|
||||
auto seq = Sequence::create(tintto1,tintto2, tintto3, tintto4, NULL);
|
||||
_pointLight->runAction(RepeatForever::create(seq));
|
||||
}
|
||||
|
||||
{
|
||||
auto tintto1 = TintTo::create(4, 255, 0, 0);
|
||||
auto tintto2 = TintTo::create(4, 0, 255, 0);
|
||||
auto tintto3 = TintTo::create(4, 0, 0, 255);
|
||||
auto tintto4 = TintTo::create(4, 255, 255, 255);
|
||||
auto seq = Sequence::create(tintto1,tintto2, tintto3, tintto4, NULL);
|
||||
_spotLight->runAction(RepeatForever::create(seq));
|
||||
}
|
||||
}
|
||||
|
||||
void LightTestDemo::update( float delta )
|
||||
|
|
Loading…
Reference in New Issue