mirror of https://github.com/axmolengine/axmol.git
commit
e5dd91029a
|
@ -93,12 +93,13 @@ BillBorad* BillBorad::create()
|
|||
void BillBorad::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
auto camera = Camera::getVisitingCamera();
|
||||
if (memcmp(_preViewMat.m, camera->getViewMatrix().m, sizeof(float) * 16) != 0)
|
||||
const Mat4 &viewMat = camera->getViewMatrix();
|
||||
if (memcmp(_preViewMat.m, viewMat.m, sizeof(float) * 16) != 0)
|
||||
{
|
||||
Mat4 viewInverseMat = camera->getInverseViewMatrix();
|
||||
viewInverseMat.m[12] = viewInverseMat.m[13] = viewInverseMat.m[14] = 0;
|
||||
Mat4 modelViewMat = camera->getViewMatrix() * transform;
|
||||
_preViewMat = camera->getViewMatrix();
|
||||
Mat4 modelViewMat = viewMat * transform;
|
||||
_preViewMat = viewMat;
|
||||
_zDepthInView = -modelViewMat.m[14];
|
||||
_mv = viewInverseMat;
|
||||
}
|
||||
|
|
|
@ -456,7 +456,7 @@ void Renderer::render()
|
|||
|
||||
//Process render commands
|
||||
//draw transparent objects here, do not batch for transparent objects
|
||||
if (_transparentRenderGroups.size())
|
||||
if (0 < _transparentRenderGroups.size())
|
||||
{
|
||||
_transparentRenderGroups.sort();
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
|
|
@ -1538,7 +1538,6 @@ BillBoardTest::BillBoardTest()
|
|||
auto layer3D=Layer::create();
|
||||
addChild(layer3D,0);
|
||||
_layerBillBorad=layer3D;
|
||||
DrawNode3D* line =DrawNode3D::create();
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
if (_camera == nullptr)
|
||||
{
|
||||
|
@ -1551,8 +1550,8 @@ BillBoardTest::BillBoardTest()
|
|||
{
|
||||
std::string fileName = "Sprite3DTest/orc.c3b";
|
||||
auto sprite = Sprite3D::create(fileName);
|
||||
sprite->setScale(3);
|
||||
sprite->setRotation3D(Vec3(0,180,0));
|
||||
sprite->setScale(2.0f);
|
||||
_layerBillBorad->addChild(sprite);
|
||||
//test attach
|
||||
auto sp = Sprite3D::create("Sprite3DTest/axe.c3b");
|
||||
|
@ -1564,6 +1563,43 @@ BillBoardTest::BillBoardTest()
|
|||
sprite->runAction(RepeatForever::create(animate));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::string fileName = "Sprite3DTest/orc.c3b";
|
||||
auto sprite = Sprite3D::create(fileName);
|
||||
sprite->setRotation3D(Vec3(0,180,0));
|
||||
sprite->setPosition3D(Vec3(100.0f, 0.0f, 0.0f));
|
||||
sprite->setScale(2.0f);
|
||||
_layerBillBorad->addChild(sprite);
|
||||
//test attach
|
||||
auto sp = Sprite3D::create("Sprite3DTest/axe.c3b");
|
||||
sprite->getAttachNode("Bip001 R Hand")->addChild(sp);
|
||||
auto animation = Animation3D::create(fileName);
|
||||
if (animation)
|
||||
{
|
||||
auto animate = Animate3D::create(animation);
|
||||
sprite->runAction(RepeatForever::create(animate));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::string fileName = "Sprite3DTest/orc.c3b";
|
||||
auto sprite = Sprite3D::create(fileName);
|
||||
sprite->setRotation3D(Vec3(0,180,0));
|
||||
sprite->setPosition3D(Vec3(-100.0f, 0.0f, 0.0f));
|
||||
sprite->setScale(2.0f);
|
||||
_layerBillBorad->addChild(sprite);
|
||||
//test attach
|
||||
auto sp = Sprite3D::create("Sprite3DTest/axe.c3b");
|
||||
sprite->getAttachNode("Bip001 R Hand")->addChild(sp);
|
||||
auto animation = Animation3D::create(fileName);
|
||||
if (animation)
|
||||
{
|
||||
auto animate = Animate3D::create(animation);
|
||||
sprite->runAction(RepeatForever::create(animate));
|
||||
}
|
||||
}
|
||||
|
||||
addNewBillBoradWithCoords(Vec3(20,5,0));
|
||||
addNewBillBoradWithCoords(Vec3(60,5,0));
|
||||
addNewBillBoradWithCoords(Vec3(100,5,0));
|
||||
|
@ -1577,20 +1613,6 @@ BillBoardTest::BillBoardTest()
|
|||
_camera->setPosition3D(Vec3(0, 130, 230));
|
||||
_camera->lookAt(Vec3(0,0,100), Vec3(0,1,0));
|
||||
|
||||
//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);
|
||||
auto label1 = Label::createWithTTF(ttfConfig,"rotate+");
|
||||
auto menuItem1 = MenuItemLabel::create(label1, CC_CALLBACK_1(BillBoardTest::rotateCameraCallback,this,10));
|
||||
|
|
Loading…
Reference in New Issue