[SOLVED] Cocos2d-x v3.7 beta0 3d cube with simple material +texture doesn't shown

i created simple scaled cube in blender applied material + texture to the model .
and loaded it into cocos2d-x code.
and all i see is White color cube .
the blender version 2.7.4 , exporting to FBX 7.4
here is the export config selected all faces of the cube

also attching the c3t/c3b and texture file file : converted.zip (127.5 KB)

the code for loading the model

bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

	auto floor = cocos2d::Sprite3D::create("models/converted/floor.c3b");
	floor->setScale(5);
	floor->setNormalizedPosition(Vec2(.5f, .3f));
	floor->setPositionZ(40);
	floor->setRotation3D(Vec3(0, 180, 0));
	floor->setGlobalZOrder(-1);

	this->addChild(floor);


	cocos2d::Camera *_camera = Camera::createPerspective(60, visibleSize.width / visibleSize.height, 10, 1000);
	_camera->setPosition3D(Vec3(0.0f, 50.0f, 100.0f));
	_camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f));
	_camera->setCameraFlag(CameraFlag::USER1);
	this->addChild(_camera);
    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png",
                                           "CloseSelected.png",
                                           CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
    
	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                                origin.y + closeItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    auto menu = Menu::create(closeItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);

     
    
    return true;
}

im getting warning after auto floor = cocos2d::Sprite3D::create(“models/converted/floor.c3b”); line

cocos2d: warning: Attribute not found: a_normal

what does it means ?
Also Question : say i didn’t export the model well or the loading code doesn’t find the texture or the texture format
can i see some-kind of log print that gives me hint about what is wrong ??

I answering to my self here …
if you export model + texture from blender you must apply UVMapping to the model.
this fixed my problem.
by the way i think its good idea to write it in the manual, i didn’t found it in the docs : http://www.cocos2d-x.org/programmersguide/9/#3d-file-formats

1 Like

Hey could you explain that to me?
Would be very cool as I had the same problem

part of the textures procedure you must apply UV coordinates to the model

1 Like