Does any body Having this problem also ?
when using Sprite3d with simple 3d model on simple layer ( black colored )
the model shown as expected .
But when using LayerColor with Color the Sprite3d does not shown at all .
in the h the base is layerColor like this:
class HelloWorld : public cocos2d::LayerColor
this is the cpp with the LayerColor
#include "HelloWorldScene.h"
Scene* HelloWorld::createScene()
{
// 'scene' is an autorelease object
auto scene = Scene::create();
// 'layer' is an autorelease object
auto layer = HelloWorld::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if (!LayerColor::initWithColor(Color4B(0, 0, 255, 255)))
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
planRotationX = 90.0f;
planRotationY = 0.0f;
planRotationZ = 0.0f;
cameraPosition3DX = 0.0f;
cameraPosition3DY = 20.0f;
cameraPosition3DZ = 25.0f;
cameraRotation3DX = -60.0f;
cameraRotation3DY = 0.0f;
cameraRotation3DZ = 0.0f;
//create a plane
Sprite3D* _plane = Sprite3D::create("plain_yellow.c3b");
_plane->setRotation3D(Vec3(planRotationX, planRotationY, planRotationZ));
this->addChild(_plane, 10);
//create Camera
Camera* _camera = Camera::createPerspective(60, visibleSize.width / visibleSize.height, 0.1f, 200);
_camera->setCameraFlag(CameraFlag::USER1);
_camera->setPosition3D(Vec3(cameraPosition3DX, cameraPosition3DY, cameraPosition3DZ));
_camera->setRotation3D(Vec3(cameraRotation3DX, cameraRotation3DY, cameraRotation3DZ));
this->addChild(_camera, 1);
return true;
}
void HelloWorld::visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, uint32_t parentFlags)
{
Layer::visit(renderer, parentTransform, parentFlags);
_customCmd.init(_globalZOrder);
_customCmd.func = CC_CALLBACK_0(HelloWorld::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCmd);
}
void HelloWorld::onDraw()
{
}
}