mirror of https://github.com/axmolengine/axmol.git
Added testing Model Number
This commit is contained in:
parent
71d722854c
commit
34070677ad
|
@ -1165,6 +1165,9 @@
|
||||||
<ClCompile Include="..\editor-support\cocosbuilder\CCSpriteLoader.cpp">
|
<ClCompile Include="..\editor-support\cocosbuilder\CCSpriteLoader.cpp">
|
||||||
<Filter>cocosbuilder\Source Files</Filter>
|
<Filter>cocosbuilder\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\3d\CCBillBoard.cpp">
|
||||||
|
<Filter>3d</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
||||||
|
@ -2290,6 +2293,9 @@
|
||||||
<ClInclude Include="..\editor-support\cocosbuilder\CocosBuilder.h">
|
<ClInclude Include="..\editor-support\cocosbuilder\CocosBuilder.h">
|
||||||
<Filter>cocosbuilder\Header Files</Filter>
|
<Filter>cocosbuilder\Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\3d\CCBillBoard.h">
|
||||||
|
<Filter>3d</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\math\Mat4.inl">
|
<None Include="..\math\Mat4.inl">
|
||||||
|
|
|
@ -33,12 +33,20 @@
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
BillBorad::BillBorad()
|
BillBorad::BillBorad()
|
||||||
|
: _zDepthInView(0.0f)
|
||||||
|
//, _vertexBuffer(nullptr)
|
||||||
|
//, _indexBuffer(nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BillBorad::~BillBorad()
|
BillBorad::~BillBorad()
|
||||||
{
|
{
|
||||||
|
//if (_vertexBuffer)
|
||||||
|
// _vertexBuffer->release();
|
||||||
|
|
||||||
|
//if (_indexBuffer)
|
||||||
|
// _indexBuffer->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
BillBorad* BillBorad::createWithTexture(Texture2D *texture)
|
BillBorad* BillBorad::createWithTexture(Texture2D *texture)
|
||||||
|
@ -46,7 +54,7 @@ BillBorad* BillBorad::createWithTexture(Texture2D *texture)
|
||||||
BillBorad *billborad = new (std::nothrow) BillBorad();
|
BillBorad *billborad = new (std::nothrow) BillBorad();
|
||||||
if (billborad && billborad->initWithTexture(texture))
|
if (billborad && billborad->initWithTexture(texture))
|
||||||
{
|
{
|
||||||
billborad->genRenderInformation();
|
//billborad->genRenderInformation();
|
||||||
billborad->autorelease();
|
billborad->autorelease();
|
||||||
return billborad;
|
return billborad;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +68,7 @@ BillBorad* BillBorad::create(const std::string& filename)
|
||||||
BillBorad *billborad = new (std::nothrow) BillBorad();
|
BillBorad *billborad = new (std::nothrow) BillBorad();
|
||||||
if (billborad && billborad->initWithFile(filename))
|
if (billborad && billborad->initWithFile(filename))
|
||||||
{
|
{
|
||||||
billborad->genRenderInformation();
|
//billborad->genRenderInformation();
|
||||||
billborad->autorelease();
|
billborad->autorelease();
|
||||||
return billborad;
|
return billborad;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +81,7 @@ BillBorad* BillBorad::create(const std::string& filename, const Rect& rect)
|
||||||
BillBorad *billborad = new (std::nothrow) BillBorad();
|
BillBorad *billborad = new (std::nothrow) BillBorad();
|
||||||
if (billborad && billborad->initWithFile(filename, rect))
|
if (billborad && billborad->initWithFile(filename, rect))
|
||||||
{
|
{
|
||||||
billborad->genRenderInformation();
|
//billborad->genRenderInformation();
|
||||||
billborad->autorelease();
|
billborad->autorelease();
|
||||||
return billborad;
|
return billborad;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +94,7 @@ BillBorad* BillBorad::create()
|
||||||
BillBorad *billborad = new (std::nothrow) BillBorad();
|
BillBorad *billborad = new (std::nothrow) BillBorad();
|
||||||
if (billborad && billborad->init())
|
if (billborad && billborad->init())
|
||||||
{
|
{
|
||||||
billborad->genRenderInformation();
|
//billborad->genRenderInformation();
|
||||||
billborad->autorelease();
|
billborad->autorelease();
|
||||||
return billborad;
|
return billborad;
|
||||||
}
|
}
|
||||||
|
@ -97,38 +105,44 @@ BillBorad* BillBorad::create()
|
||||||
void BillBorad::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
void BillBorad::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||||
{
|
{
|
||||||
auto camera = Camera::getVisitingCamera();
|
auto camera = Camera::getVisitingCamera();
|
||||||
Mat4 viewInverseMat = camera->getInverseViewMatrix();
|
if (memcmp(_preViewMat.m, camera->getViewMatrix().m, sizeof(float) * 16) != 0)
|
||||||
viewInverseMat.m[12] = viewInverseMat.m[13] = viewInverseMat.m[14] = 0;
|
{
|
||||||
|
Mat4 viewInverseMat = camera->getInverseViewMatrix();
|
||||||
Mat4 transMat = transform;
|
viewInverseMat.m[12] = viewInverseMat.m[13] = viewInverseMat.m[14] = 0;
|
||||||
transMat *= viewInverseMat;
|
Mat4 modelViewMat = camera->getViewMatrix() * transform;
|
||||||
|
_preViewMat = camera->getViewMatrix();
|
||||||
|
_zDepthInView = -modelViewMat.m[14];
|
||||||
|
_mv = viewInverseMat;
|
||||||
|
}
|
||||||
//// Don't do calculate the culling if the transform was not updated
|
//// Don't do calculate the culling if the transform was not updated
|
||||||
//_insideBounds = (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transMat, _contentSize) : _insideBounds;
|
//_insideBounds = (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transMat, _contentSize) : _insideBounds;
|
||||||
|
|
||||||
//if(_insideBounds)
|
//if(_insideBounds)
|
||||||
{
|
{
|
||||||
Mat4 modelViewMat = camera->getViewMatrix() * transMat;
|
_quadCommand.init(_zDepthInView, _texture->getName(), getGLProgramState(), _blendFunc, &_quad, 1, transform * _mv);
|
||||||
_quadCommand.init(-modelViewMat.m[14], _texture->getName(), getGLProgramState(), _blendFunc, &_quad, 1, transMat);
|
//_meshCommand.init(-modelViewMat.m[14], _texture->getName(), getGLProgramState(), _blendFunc, _vertexBuffer->getVBO(), _indexBuffer->getVBO(), GL_TRIANGLES, GL_UNSIGNED_SHORT, _indexBuffer->getIndexNumber(), transMat);
|
||||||
_meshCommand.init(-modelViewMat.m[14], _texture->getName(), getGLProgramState(), _blendFunc, _vertexBuffer->getVBO(), _indexBuffer->getVBO(), GL_TRIANGLES, GL_UNSIGNED_SHORT, _indexBuffer->getIndexNumber(), transMat);
|
renderer->addTransparentCommand(&_quadCommand);
|
||||||
renderer->addTransparentCommand(&_meshCommand);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BillBorad::genRenderInformation()
|
//void BillBorad::genRenderInformation()
|
||||||
{
|
//{
|
||||||
_vertexBuffer = VertexBuffer::create(sizeof(_quad), 1);
|
// _vertexBuffer = VertexBuffer::create(sizeof(_quad), 1);
|
||||||
_vertexBuffer->updateVertices((void*)&_quad, 1, 0);
|
// _vertexBuffer->updateVertices((void*)&_quad, 1, 0);
|
||||||
|
// _vertexBuffer->retain();
|
||||||
std::vector<unsigned short> indices;
|
//
|
||||||
indices.push_back(0);indices.push_back(1);indices.push_back(2);
|
// std::vector<unsigned short> indices;
|
||||||
indices.push_back(3);indices.push_back(2);indices.push_back(1);
|
// indices.push_back(0);indices.push_back(1);indices.push_back(2);
|
||||||
_indexBuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_SHORT_16, indices.size());
|
// indices.push_back(3);indices.push_back(2);indices.push_back(1);
|
||||||
_indexBuffer->updateIndices((void*)&indices, (int)indices.size(), 0);
|
// _indexBuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_SHORT_16, indices.size());
|
||||||
|
// _indexBuffer->updateIndices((void*)&indices[0], (int)indices.size(), 0);
|
||||||
#define kQuadSize sizeof(_quad.bl)
|
// _indexBuffer->retain();
|
||||||
getGLProgramState()->setVertexAttribPointer(GLProgram::ATTRIBUTE_NAME_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices));
|
//
|
||||||
getGLProgramState()->setVertexAttribPointer(GLProgram::ATTRIBUTE_NAME_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors));
|
//#define kQuadSize sizeof(_quad.bl)
|
||||||
getGLProgramState()->setVertexAttribPointer(GLProgram::ATTRIBUTE_NAME_TEX_COORD, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords));
|
// setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||||
}
|
// getGLProgramState()->setVertexAttribPointer(GLProgram::ATTRIBUTE_NAME_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices));
|
||||||
|
// getGLProgramState()->setVertexAttribPointer(GLProgram::ATTRIBUTE_NAME_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors));
|
||||||
|
// getGLProgramState()->setVertexAttribPointer(GLProgram::ATTRIBUTE_NAME_TEX_COORD, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords));
|
||||||
|
//}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
class VertexBuffer;
|
//class VertexBuffer;
|
||||||
class IndexBuffer;
|
//class IndexBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inherit from Sprite, achieve BillBorad.
|
* Inherit from Sprite, achieve BillBorad.
|
||||||
|
@ -90,13 +90,16 @@ CC_CONSTRUCTOR_ACCESS:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void genRenderInformation();
|
//void genRenderInformation();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
MeshCommand _meshCommand;
|
// MeshCommand _meshCommand;
|
||||||
VertexBuffer *_vertexBuffer;
|
// VertexBuffer *_vertexBuffer;
|
||||||
IndexBuffer *_indexBuffer;
|
// IndexBuffer *_indexBuffer;
|
||||||
|
Mat4 _preViewMat;
|
||||||
|
Mat4 _mv;
|
||||||
|
float _zDepthInView;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(BillBorad);
|
CC_DISALLOW_COPY_AND_ASSIGN(BillBorad);
|
||||||
|
|
|
@ -1530,9 +1530,7 @@ void Sprite3DMirrorTest::addNewSpriteWithCoords(Vec2 p)
|
||||||
}
|
}
|
||||||
|
|
||||||
BillBoardTest::BillBoardTest()
|
BillBoardTest::BillBoardTest()
|
||||||
: _billborad(nullptr)
|
: _camera(nullptr)
|
||||||
, _billboradAni(nullptr)
|
|
||||||
, _camera(nullptr)
|
|
||||||
{
|
{
|
||||||
auto listener = EventListenerTouchAllAtOnce::create();
|
auto listener = EventListenerTouchAllAtOnce::create();
|
||||||
listener->onTouchesMoved = CC_CALLBACK_2(BillBoardTest::onTouchesMoved, this);
|
listener->onTouchesMoved = CC_CALLBACK_2(BillBoardTest::onTouchesMoved, this);
|
||||||
|
@ -1549,24 +1547,33 @@ BillBoardTest::BillBoardTest()
|
||||||
_layerBillBorad->addChild(_camera);
|
_layerBillBorad->addChild(_camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
addNewBillBoradWithCoords(Vec3(20,5,0));
|
|
||||||
addNewAniBillBoradWithCoords(Vec3(-20,0,0));
|
|
||||||
_camera->setPosition3D(Vec3(0, 130, 130));
|
|
||||||
_camera->lookAt(Vec3(0,0,0), Vec3(0,1,0));
|
|
||||||
|
|
||||||
for( int j =-20; j<=20 ;j++)
|
addNewBillBoradWithCoords(Vec3(20,5,0));
|
||||||
{
|
addNewBillBoradWithCoords(Vec3(60,5,0));
|
||||||
line->drawLine(Vec3(-100, 0, 5*j),Vec3(100,0,5*j),Color4F(0,1,0,1));
|
addNewBillBoradWithCoords(Vec3(100,5,0));
|
||||||
}
|
addNewBillBoradWithCoords(Vec3(140,5,0));
|
||||||
//draw z
|
addNewBillBoradWithCoords(Vec3(180,5,0));
|
||||||
for( int j =-20; j<=20 ;j++)
|
addNewAniBillBoradWithCoords(Vec3(-20,0,0));
|
||||||
{
|
addNewAniBillBoradWithCoords(Vec3(-60,0,0));
|
||||||
line->drawLine(Vec3(5*j, 0, -100),Vec3(5*j,0,100),Color4F(0,1,0,1));
|
addNewAniBillBoradWithCoords(Vec3(-100,0,0));
|
||||||
}
|
addNewAniBillBoradWithCoords(Vec3(-140,0,0));
|
||||||
//draw y
|
addNewAniBillBoradWithCoords(Vec3(-180,0,0));
|
||||||
//line->drawLine(Vec3(0, -50, 0),Vec3(0,0,0),Color4F(0,0.5,0,1));
|
_camera->setPosition3D(Vec3(0, 130, 330));
|
||||||
//line->drawLine(Vec3(0, 0, 0),Vec3(0,50,0),Color4F(0,1,0,1));
|
_camera->lookAt(Vec3(0,0,200), Vec3(0,1,0));
|
||||||
_layerBillBorad->addChild(line);
|
|
||||||
|
//for( int j =-20; j<=20 ;j++)
|
||||||
|
//{
|
||||||
|
// line->drawLine(Vec3(-100, 0, 5*j),Vec3(100,0,5*j),Color4F(0,1,0,1));
|
||||||
|
//}
|
||||||
|
////draw z
|
||||||
|
//for( int j =-20; j<=20 ;j++)
|
||||||
|
//{
|
||||||
|
// line->drawLine(Vec3(5*j, 0, -100),Vec3(5*j,0,100),Color4F(0,1,0,1));
|
||||||
|
//}
|
||||||
|
////draw y
|
||||||
|
////line->drawLine(Vec3(0, -50, 0),Vec3(0,0,0),Color4F(0,0.5,0,1));
|
||||||
|
////line->drawLine(Vec3(0, 0, 0),Vec3(0,50,0),Color4F(0,1,0,1));
|
||||||
|
//_layerBillBorad->addChild(line);
|
||||||
|
|
||||||
TTFConfig ttfConfig("fonts/arial.ttf", 20);
|
TTFConfig ttfConfig("fonts/arial.ttf", 20);
|
||||||
auto label1 = Label::createWithTTF(ttfConfig,"rotate+");
|
auto label1 = Label::createWithTTF(ttfConfig,"rotate+");
|
||||||
|
@ -1597,177 +1604,42 @@ std::string BillBoardTest::subtitle() const
|
||||||
}
|
}
|
||||||
void BillBoardTest::addNewBillBoradWithCoords(Vec3 p)
|
void BillBoardTest::addNewBillBoradWithCoords(Vec3 p)
|
||||||
{
|
{
|
||||||
|
std::string imgs[3] = {"Images/Icon.png", "Images/r2.png"};
|
||||||
for (unsigned int i = 0; i < 100; ++i)
|
for (unsigned int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
auto billborad = BillBorad::create("Images/Icon.png");
|
auto billborad = BillBorad::create(imgs[(unsigned int)(CCRANDOM_0_1() * 1 + 0.5)]);
|
||||||
billborad->setScale(CCRANDOM_0_1() * 5.0f);
|
billborad->setScale(0.5f);
|
||||||
_layerBillBorad->addChild(billborad);
|
_layerBillBorad->addChild(billborad);
|
||||||
billborad->setPosition3D(Vec3(p.x + CCRANDOM_MINUS1_1() * 200, p.y + CCRANDOM_MINUS1_1() * 200, p.z + CCRANDOM_MINUS1_1() * 200));
|
billborad->setPosition3D(Vec3(p.x, p.y, 30 * i));
|
||||||
billborad->setBlendFunc(cocos2d::BlendFunc::ALPHA_PREMULTIPLIED);
|
billborad->setBlendFunc(cocos2d::BlendFunc::ALPHA_NON_PREMULTIPLIED);
|
||||||
billborad->setOpacity(CCRANDOM_0_1() * 255);
|
billborad->setOpacity(CCRANDOM_0_1() * 128 + 128);
|
||||||
}
|
}
|
||||||
//_billborad = BillBorad::create("Images/Icon.png");
|
|
||||||
//_billborad->setScale(0.5f);
|
|
||||||
//_layerBillBorad->addChild(_billborad,10);
|
|
||||||
//_billborad->setPosition(Vec2( p.x,p.y ));
|
|
||||||
//_billborad->setBlendFunc(cocos2d::BlendFunc::ALPHA_PREMULTIPLIED);
|
|
||||||
//_billborad->setOpacity(200);
|
|
||||||
|
|
||||||
//auto billborad1 = BillBorad::create("Images/Icon.png");
|
|
||||||
//billborad1->setScale(0.5f);
|
|
||||||
//_layerBillBorad->addChild(billborad1,10);
|
|
||||||
//billborad1->setPosition3D(Vec3(p.x,p.y,p.z - 130));
|
|
||||||
//billborad1->setBlendFunc(cocos2d::BlendFunc::ALPHA_PREMULTIPLIED);
|
|
||||||
//billborad1->setOpacity(200);
|
|
||||||
|
|
||||||
//auto billborad2 = BillBorad::create("Images/Icon.png");
|
|
||||||
//billborad2->setScale(0.5f);
|
|
||||||
//_layerBillBorad->addChild(billborad2,10);
|
|
||||||
//billborad2->setPosition3D(Vec3(p.x,p.y,p.z + 50));
|
|
||||||
//billborad2->setBlendFunc(cocos2d::BlendFunc::ALPHA_PREMULTIPLIED);
|
|
||||||
//billborad2->setOpacity(200);
|
|
||||||
|
|
||||||
//auto billborad3 = BillBorad::create("Images/Icon.png");
|
|
||||||
//billborad3->setScale(0.5f);
|
|
||||||
//_layerBillBorad->addChild(billborad3,10);
|
|
||||||
//billborad3->setPosition3D(Vec3(p.x,p.y,p.z + 90));
|
|
||||||
//billborad3->setBlendFunc(cocos2d::BlendFunc::ALPHA_PREMULTIPLIED);
|
|
||||||
//billborad3->setOpacity(200);
|
|
||||||
|
|
||||||
//auto billborad4 = BillBorad::create("Images/Icon.png");
|
|
||||||
//billborad4->setScale(0.5f);
|
|
||||||
//_layerBillBorad->addChild(billborad4,10);
|
|
||||||
//billborad4->setPosition3D(Vec3(p.x,p.y,p.z - 60));
|
|
||||||
//billborad4->setBlendFunc(cocos2d::BlendFunc::ALPHA_PREMULTIPLIED);
|
|
||||||
//billborad4->setOpacity(200);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void BillBoardTest::addNewAniBillBoradWithCoords(Vec3 p)
|
void BillBoardTest::addNewAniBillBoradWithCoords(Vec3 p)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < 100; ++i)
|
for (unsigned int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
auto billboradAni = BillBorad::create("Images/grossini.png");
|
auto billboradAni = BillBorad::create("Images/grossini.png");
|
||||||
billboradAni->setScale(CCRANDOM_0_1() * 5.0f);
|
billboradAni->setScale(0.5f);
|
||||||
billboradAni->setPosition3D(Vec3(p.x + CCRANDOM_MINUS1_1() * 200, p.y + CCRANDOM_MINUS1_1() * 200, p.z + CCRANDOM_MINUS1_1() * 200));
|
billboradAni->setPosition3D(Vec3(p.x, p.y, 30 * i));
|
||||||
_layerBillBorad->addChild(billboradAni);
|
_layerBillBorad->addChild(billboradAni);
|
||||||
|
|
||||||
auto animation = Animation::create();
|
auto animation = Animation::create();
|
||||||
for( int i=1;i<15;i++)
|
for( int i=1;i<15;i++)
|
||||||
{
|
{
|
||||||
char szName1[100] = {0};
|
char szName1[100] = {0};
|
||||||
sprintf(szName1, "Images/grossini_dance_%02d.png", i);
|
sprintf(szName1, "Images/grossini_dance_%02d.png", i);
|
||||||
animation->addSpriteFrameWithFile(szName1);
|
animation->addSpriteFrameWithFile(szName1);
|
||||||
}
|
}
|
||||||
// should last 2.8 seconds. And there are 14 frames.
|
// should last 2.8 seconds. And there are 14 frames.
|
||||||
animation->setDelayPerUnit(2.8f / 14.0f);
|
animation->setDelayPerUnit(2.8f / 14.0f);
|
||||||
animation->setRestoreOriginalFrame(true);
|
animation->setRestoreOriginalFrame(true);
|
||||||
|
|
||||||
auto action = Animate::create(animation);
|
auto action = Animate::create(animation);
|
||||||
billboradAni->runAction(RepeatForever::create(action));
|
billboradAni->runAction(RepeatForever::create(action));
|
||||||
billboradAni->setOpacity(CCRANDOM_0_1() * 255);
|
billboradAni->setBlendFunc(cocos2d::BlendFunc::ALPHA_NON_PREMULTIPLIED);
|
||||||
}
|
billboradAni->setOpacity(CCRANDOM_0_1() * 128 + 128);
|
||||||
|
}
|
||||||
//auto billboradAni1 = BillBorad::create("Images/grossini.png");
|
|
||||||
//billboradAni1->setScale(0.5f);
|
|
||||||
//billboradAni1->setPosition3D(Vec3(p.x, p.y, p.z - 130));
|
|
||||||
//_layerBillBorad->addChild(billboradAni1,10);
|
|
||||||
//
|
|
||||||
//auto animation1 = Animation::create();
|
|
||||||
//for( int i=1;i<15;i++)
|
|
||||||
//{
|
|
||||||
// char szName1[100] = {0};
|
|
||||||
// sprintf(szName1, "Images/grossini_dance_%02d.png", i);
|
|
||||||
// animation1->addSpriteFrameWithFile(szName1);
|
|
||||||
//}
|
|
||||||
//// should last 2.8 seconds. And there are 14 frames.
|
|
||||||
//animation1->setDelayPerUnit(2.8f / 14.0f);
|
|
||||||
//animation1->setRestoreOriginalFrame(true);
|
|
||||||
|
|
||||||
//auto action1 = Animate::create(animation1);
|
|
||||||
//billboradAni1->runAction(RepeatForever::create(action1));
|
|
||||||
//billboradAni1->setOpacity(alpha);
|
|
||||||
|
|
||||||
//auto billboradAni2 = BillBorad::create("Images/grossini.png");
|
|
||||||
//billboradAni2->setScale(0.5f);
|
|
||||||
//billboradAni2->setPosition3D(Vec3(p.x, p.y, p.z - 60));
|
|
||||||
//_layerBillBorad->addChild(billboradAni2,10);
|
|
||||||
//
|
|
||||||
//auto animation2 = Animation::create();
|
|
||||||
//for( int i=1;i<15;i++)
|
|
||||||
//{
|
|
||||||
// char szName2[100] = {0};
|
|
||||||
// sprintf(szName2, "Images/grossini_dance_%02d.png", i);
|
|
||||||
// animation2->addSpriteFrameWithFile(szName2);
|
|
||||||
//}
|
|
||||||
//// should last 2.8 seconds. And there are 14 frames.
|
|
||||||
//animation2->setDelayPerUnit(2.8f / 14.0f);
|
|
||||||
//animation2->setRestoreOriginalFrame(true);
|
|
||||||
|
|
||||||
//auto action2 = Animate::create(animation2);
|
|
||||||
//billboradAni2->runAction(RepeatForever::create(action2));
|
|
||||||
//billboradAni2->setOpacity(alpha);
|
|
||||||
|
|
||||||
//_billboradAni = BillBorad::create("Images/grossini.png");
|
|
||||||
//_billboradAni->setScale(0.5f);
|
|
||||||
//_billboradAni->setPosition3D( p );
|
|
||||||
//_layerBillBorad->addChild(_billboradAni,10);
|
|
||||||
//
|
|
||||||
//auto animation = Animation::create();
|
|
||||||
//for( int i=1;i<15;i++)
|
|
||||||
//{
|
|
||||||
// char szName[100] = {0};
|
|
||||||
// sprintf(szName, "Images/grossini_dance_%02d.png", i);
|
|
||||||
// animation->addSpriteFrameWithFile(szName);
|
|
||||||
//}
|
|
||||||
//// should last 2.8 seconds. And there are 14 frames.
|
|
||||||
//animation->setDelayPerUnit(2.8f / 14.0f);
|
|
||||||
//animation->setRestoreOriginalFrame(true);
|
|
||||||
|
|
||||||
//auto action = Animate::create(animation);
|
|
||||||
//_billboradAni->runAction(RepeatForever::create(action));
|
|
||||||
//_billboradAni->setOpacity(alpha);
|
|
||||||
|
|
||||||
//auto billboradAni3 = BillBorad::create("Images/grossini.png");
|
|
||||||
//billboradAni3->setScale(0.5f);
|
|
||||||
//billboradAni3->setPosition3D(Vec3(p.x, p.y, p.z + 50));
|
|
||||||
//_layerBillBorad->addChild(billboradAni3,10);
|
|
||||||
//
|
|
||||||
//auto animation3 = Animation::create();
|
|
||||||
//for( int i=1;i<15;i++)
|
|
||||||
//{
|
|
||||||
// char szName3[100] = {0};
|
|
||||||
// sprintf(szName3, "Images/grossini_dance_%02d.png", i);
|
|
||||||
// animation3->addSpriteFrameWithFile(szName3);
|
|
||||||
//}
|
|
||||||
//// should last 2.8 seconds. And there are 14 frames.
|
|
||||||
//animation3->setDelayPerUnit(2.8f / 14.0f);
|
|
||||||
//animation3->setRestoreOriginalFrame(true);
|
|
||||||
|
|
||||||
//auto action3 = Animate::create(animation3);
|
|
||||||
//billboradAni3->runAction(RepeatForever::create(action3));
|
|
||||||
//billboradAni3->setOpacity(alpha);
|
|
||||||
|
|
||||||
//auto billboradAni4 = BillBorad::create("Images/grossini.png");
|
|
||||||
//billboradAni4->setScale(0.5f);
|
|
||||||
//billboradAni4->setPosition3D(Vec3(p.x, p.y, p.z + 90));
|
|
||||||
//_layerBillBorad->addChild(billboradAni4,10);
|
|
||||||
//
|
|
||||||
//auto animation4 = Animation::create();
|
|
||||||
//for( int i=1;i<15;i++)
|
|
||||||
//{
|
|
||||||
// char szName4[100] = {0};
|
|
||||||
// sprintf(szName4, "Images/grossini_dance_%02d.png", i);
|
|
||||||
// animation4->addSpriteFrameWithFile(szName4);
|
|
||||||
//}
|
|
||||||
//// should last 2.8 seconds. And there are 14 frames.
|
|
||||||
//animation4->setDelayPerUnit(2.8f / 14.0f);
|
|
||||||
//animation4->setRestoreOriginalFrame(true);
|
|
||||||
|
|
||||||
//auto action4 = Animate::create(animation4);
|
|
||||||
//billboradAni4->runAction(RepeatForever::create(action4));
|
|
||||||
//billboradAni4->setOpacity(alpha);
|
|
||||||
}
|
}
|
||||||
void BillBoardTest::update(float dt)
|
void BillBoardTest::update(float dt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -344,8 +344,6 @@ public:
|
||||||
void onTouchesMoved(const std::vector<Touch*>& touches, Event* event);
|
void onTouchesMoved(const std::vector<Touch*>& touches, Event* event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BillBorad* _billborad;
|
|
||||||
BillBorad* _billboradAni;
|
|
||||||
Camera* _camera;
|
Camera* _camera;
|
||||||
Layer* _layerBillBorad;
|
Layer* _layerBillBorad;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue